BUG: PV3FoamReader : patch names was addressing outside of zoneCentres array.

This commit is contained in:
mattijs
2010-05-19 16:33:48 +01:00
parent 8c94ccd392
commit 8551bfd36b

View File

@ -651,7 +651,7 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
labelList nZones(pbMesh.size(), 0); labelList nZones(pbMesh.size(), 0);
// Per global zone number the average face centre position // 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 // 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); labelList zoneNFaces(pZones.nZones(), 0);
// Save start of information for current patch
label patchStart = zoneCentre.size();
// Create storage for additional zone centres // Create storage for additional zone centres
forAll(zoneNFaces, zoneI) forAll(zoneNFaces, zoneI)
{ {
zoneCentre.append(vector::zero); zoneCentre[patchI].append(vector::zero);
} }
// Do averaging per individual zone // Do averaging per individual zone
forAll(pp, faceI) forAll(pp, faceI)
{ {
label zoneI = pZones[faceI]; label zoneI = pZones[faceI];
zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points()); zoneCentre[patchI][zoneI] += pp[faceI].centre(pp.points());
zoneNFaces[zoneI]++; 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 // Count number of zones we're actually going to display.
// to a max per patch // This is truncated to a max per patch
const label MAXPATCHZONES = 20; const label MAXPATCHZONES = 20;
@ -728,13 +725,9 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
displayZoneI += min(MAXPATCHZONES, nZones[patchI]); displayZoneI += min(MAXPATCHZONES, nZones[patchI]);
} }
zoneCentre.shrink();
if (debug) if (debug)
{ {
Info<< "patch zone centres = " << zoneCentre << nl Info<< "displayed zone centres = " << displayZoneI << nl
<< "displayed zone centres = " << displayZoneI << nl
<< "zones per patch = " << nZones << endl; << "zones per patch = " << nZones << endl;
} }
@ -749,13 +742,12 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
// Actor index // Actor index
displayZoneI = 0; displayZoneI = 0;
// Index in zone centres
label globalZoneI = 0;
forAll(pbMesh, patchI) forAll(pbMesh, patchI)
{ {
const polyPatch& pp = pbMesh[patchI]; const polyPatch& pp = pbMesh[patchI];
label globalZoneI = 0;
// Only selected patches will have a non-zero number of zones // Only selected patches will have a non-zero number of zones
label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]); label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]);
label increment = 1; label increment = 1;
@ -769,7 +761,7 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
if (debug) if (debug)
{ {
Info<< "patch name = " << pp.name() << nl Info<< "patch name = " << pp.name() << nl
<< "anchor = " << zoneCentre[globalZoneI] << nl << "anchor = " << zoneCentre[patchI][globalZoneI] << nl
<< "globalZoneI = " << globalZoneI << endl; << "globalZoneI = " << globalZoneI << endl;
} }
@ -792,9 +784,9 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show)
txt->GetPositionCoordinate()->SetValue txt->GetPositionCoordinate()->SetValue
( (
zoneCentre[globalZoneI].x(), zoneCentre[patchI][globalZoneI].x(),
zoneCentre[globalZoneI].y(), zoneCentre[patchI][globalZoneI].y(),
zoneCentre[globalZoneI].z() zoneCentre[patchI][globalZoneI].z()
); );
// Add text to each renderer // Add text to each renderer