From 01f8538e27ecf18ff80c0030f62bcdebe765d7d0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 19 Mar 2010 18:57:09 +0100 Subject: [PATCH] ENH: ignore empty zones in paraview reader --- .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H | 11 ++++- .../vtkPV3Foam/vtkPV3FoamUpdateInfo.C | 44 ++++++++++++++----- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 577edfc310..9febbad6f8 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -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 + wordList getZoneNames + ( + const ZoneMesh& + ) const; //- Add objects of Type to paraview array selection template diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index f83be3ee15..bdac311fcd 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -82,9 +82,31 @@ public: // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) +template +Foam::wordList Foam::vtkPV3Foam::getZoneNames +( + const ZoneMesh& 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 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());