Commit 0c310e5c authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: ignore empty zones in paraview reader

parent c4a2dee7
......@@ -356,8 +356,15 @@ class vtkPV3Foam
//- Zone info
void updateInfoZones(vtkDataArraySelection*);
//- Read zone names for zoneType from file
wordList readZoneNames(const word& zoneType);
//- Get non-empty zone names for zoneType from file
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
template<class Type>
......
......@@ -82,9 +82,31 @@ public:
// * * * * * * * * * * * * * 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 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 zoneNames;
wordList names;
// mesh not loaded - read from file
IOobject ioObj
......@@ -107,14 +129,14 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType)
{
zonesEntries zones(ioObj);
zoneNames.setSize(zones.size());
names.setSize(zones.size());
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_)
{
namesLst = meshPtr_->cellZones().names();
namesLst = getZoneNames(meshPtr_->cellZones());
}
else
{
namesLst = readZoneNames("cellZones");
namesLst = getZoneNames("cellZones");
}
arrayRangeCellZones_.reset(arraySelection->GetNumberOfArrays());
......@@ -335,11 +357,11 @@ void Foam::vtkPV3Foam::updateInfoZones
// ~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{
namesLst = meshPtr_->faceZones().names();
namesLst = getZoneNames(meshPtr_->faceZones());
}
else
{
namesLst = readZoneNames("faceZones");
namesLst = getZoneNames("faceZones");
}
arrayRangeFaceZones_.reset(arraySelection->GetNumberOfArrays());
......@@ -358,11 +380,11 @@ void Foam::vtkPV3Foam::updateInfoZones
// ~~~~~~~~~~~~~~~~~~~~~~
if (meshPtr_)
{
namesLst = meshPtr_->pointZones().names();
namesLst = getZoneNames(meshPtr_->pointZones());
}
else
{
namesLst = readZoneNames("pointZones");
namesLst = getZoneNames("pointZones");
}
arrayRangePointZones_.reset(arraySelection->GetNumberOfArrays());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment