ENH: ignore empty zones in paraview reader

This commit is contained in:
Mark Olesen
2010-03-19 18:57:09 +01:00
parent db34c43ab0
commit 01f8538e27
2 changed files with 42 additions and 13 deletions

View File

@ -356,8 +356,15 @@ class vtkPV3Foam
//- Zone info //- Zone info
void updateInfoZones(vtkDataArraySelection*); void updateInfoZones(vtkDataArraySelection*);
//- Read zone names for zoneType from file //- Get non-empty zone names for zoneType from file
wordList readZoneNames(const word& zoneType); wordList getZoneNames(const word& zoneType) const;
//- Get non-empty zone names from mesh info
template<class ZoneType>
wordList getZoneNames
(
const ZoneMesh<ZoneType, polyMesh>&
) const;
//- Add objects of Type to paraview array selection //- Add objects of Type to paraview array selection
template<class Type> template<class Type>

View File

@ -82,9 +82,31 @@ public:
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) template<class ZoneType>
Foam::wordList Foam::vtkPV3Foam::getZoneNames
(
const ZoneMesh<ZoneType, polyMesh>& zmesh
) const
{ {
wordList zoneNames; wordList names(zmesh.size());
label nZone = 0;
forAll(zmesh, zoneI)
{
if (zmesh[zoneI].size())
{
names[nZone++] = zmesh[zoneI].name();
}
}
names.setSize(nZone);
return names;
}
Foam::wordList Foam::vtkPV3Foam::getZoneNames(const word& zoneType) const
{
wordList names;
// mesh not loaded - read from file // mesh not loaded - read from file
IOobject ioObj IOobject ioObj
@ -107,14 +129,14 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
{ {
zonesEntries zones(ioObj); zonesEntries zones(ioObj);
zoneNames.setSize(zones.size()); names.setSize(zones.size());
forAll(zones, zoneI) forAll(zones, zoneI)
{ {
zoneNames[zoneI] = zones[zoneI].keyword(); names[zoneI] = zones[zoneI].keyword();
} }
} }
return zoneNames; return names;
} }
@ -312,11 +334,11 @@ void Foam::vtkPV3Foam::updateInfoZones
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_) if (meshPtr_)
{ {
namesLst = meshPtr_->cellZones().names(); namesLst = getZoneNames(meshPtr_->cellZones());
} }
else else
{ {
namesLst = readZoneNames("cellZones"); namesLst = getZoneNames("cellZones");
} }
arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays()); arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays());
@ -335,11 +357,11 @@ void Foam::vtkPV3Foam::updateInfoZones
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_) if (meshPtr_)
{ {
namesLst = meshPtr_->faceZones().names(); namesLst = getZoneNames(meshPtr_->faceZones());
} }
else else
{ {
namesLst = readZoneNames("faceZones"); namesLst = getZoneNames("faceZones");
} }
arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays()); arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays());
@ -358,11 +380,11 @@ void Foam::vtkPV3Foam::updateInfoZones
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_) if (meshPtr_)
{ {
namesLst = meshPtr_->pointZones().names(); namesLst = getZoneNames(meshPtr_->pointZones());
} }
else else
{ {
namesLst = readZoneNames("pointZones"); namesLst = getZoneNames("pointZones");
} }
arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays()); arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays());