From 8551bfd36be167f1b199f70ff3f507c83d5cec9f Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 19 May 2010 16:33:48 +0100 Subject: [PATCH] BUG: PV3FoamReader : patch names was addressing outside of zoneCentres array. --- .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 1a01cb65640..a73b46621ed 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -651,7 +651,7 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) labelList nZones(pbMesh.size(), 0); // Per global zone number the average face centre position - DynamicList<point> zoneCentre(pbMesh.size()); + List<DynamicList<point> > zoneCentre(pbMesh.size()); // Loop through all patches to determine zones, and centre of each zone @@ -693,31 +693,28 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) labelList zoneNFaces(pZones.nZones(), 0); - // Save start of information for current patch - label patchStart = zoneCentre.size(); - // Create storage for additional zone centres forAll(zoneNFaces, zoneI) { - zoneCentre.append(vector::zero); + zoneCentre[patchI].append(vector::zero); } // Do averaging per individual zone forAll(pp, faceI) { label zoneI = pZones[faceI]; - zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points()); + zoneCentre[patchI][zoneI] += pp[faceI].centre(pp.points()); zoneNFaces[zoneI]++; } - for (label i=0; i<nZones[patchI]; i++) + forAll(zoneCentre[patchI], zoneI) { - zoneCentre[patchStart + i] /= zoneNFaces[i]; + zoneCentre[patchI][zoneI] /= zoneNFaces[zoneI]; } } - // Count number of zones we're actually going to display. This is truncated - // to a max per patch + // Count number of zones we're actually going to display. + // This is truncated to a max per patch const label MAXPATCHZONES = 20; @@ -728,13 +725,9 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) displayZoneI += min(MAXPATCHZONES, nZones[patchI]); } - - zoneCentre.shrink(); - if (debug) { - Info<< "patch zone centres = " << zoneCentre << nl - << "displayed zone centres = " << displayZoneI << nl + Info<< "displayed zone centres = " << displayZoneI << nl << "zones per patch = " << nZones << endl; } @@ -749,13 +742,12 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) // Actor index displayZoneI = 0; - // Index in zone centres - label globalZoneI = 0; - forAll(pbMesh, patchI) { const polyPatch& pp = pbMesh[patchI]; + label globalZoneI = 0; + // Only selected patches will have a non-zero number of zones label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]); label increment = 1; @@ -769,7 +761,7 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) if (debug) { Info<< "patch name = " << pp.name() << nl - << "anchor = " << zoneCentre[globalZoneI] << nl + << "anchor = " << zoneCentre[patchI][globalZoneI] << nl << "globalZoneI = " << globalZoneI << endl; } @@ -792,9 +784,9 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) txt->GetPositionCoordinate()->SetValue ( - zoneCentre[globalZoneI].x(), - zoneCentre[globalZoneI].y(), - zoneCentre[globalZoneI].z() + zoneCentre[patchI][globalZoneI].x(), + zoneCentre[patchI][globalZoneI].y(), + zoneCentre[patchI][globalZoneI].z() ); // Add text to each renderer -- GitLab