[vtkusers] Bug / Infinite Loop in vtkBandedPolyDataContourFilter

Charles Boivin okeovtk at gmail.com
Tue Aug 23 18:05:30 EDT 2005


Hello all,

I have stumbled upon a bug in vtkBandedPolyDataContourFilter. It only
happens *sometimes* (and I don't know *why* just yet), but I now have
a case where I can make the class go into an infinite loop every time
I use it.

BTW, I am using VTK 4.4.

I've been able to track down the exact place where this happens by
adding some debug code to the class. Here is a snippet of what I added
mixed with the existing code...

...
      //Find the first intersection points in the polygons starting
      //from this vertex and build a polygon.
      vtkDebugMacro(<< "Step 1");
      numPointsToAdd = 1;
      for ( mR=idx, intersectionPoint=0; !intersectionPoint; )
        {
        numPointsToAdd++;
        mR = (mR + 1) % numFullPts;
        if ( isContourValue[mR] ) intersectionPoint = 1;
        }
      vtkDebugMacro(<< "Step 2");
      for ( mL=idx, intersectionPoint=0; !intersectionPoint; )
        {
        numPointsToAdd++;
        mL = (mL + numFullPts - 1) % numFullPts;
        if ( isContourValue[mL] && s[mL] != s[idx] ) intersectionPoint = 1;
		vtkDebugMacro(<< "Inside step 2 -- numPointsToAdd: " << numPointsToAdd);
        }
      vtkDebugMacro(<< "Step 3");
      for ( numPolyPoints=0, i=0; i<numPointsToAdd; i++)
        {
        newPolygon[numPolyPoints++] = fullPoly[(mL+i)%numFullPts];
        }
	  vtkDebugMacro(<< "Inserting cell");
      cellId = this->InsertCell(newPolys,numPolyPoints,newPolygon,
                                cellId,s[idx],newScalars);
...

And here is an excerpt from the debug file..

...
Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 540
vtkBandedPolyDataContourFilter (0E9EE608): Creating new polygons


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 602
vtkBandedPolyDataContourFilter (0E9EE608): Found this starting vertex: 2


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 613
vtkBandedPolyDataContourFilter (0E9EE608): Step 1


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 621
vtkBandedPolyDataContourFilter (0E9EE608): Step 2


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 3


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 4


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 5


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 6


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 7


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 8


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 9


Debug: In \Vtk44\src\Graphics\vtkBandedPolyDataContourFilter.cxx, line 627
vtkBandedPolyDataContourFilter (0E9EE608): Inside step 2 -- numPointsToAdd: 10

... and this goes on forever. When I stopped it, numPointsToAdd was
close to a million.

Is this something that has been documented before and could have been
fixed in the CVS version? If not, is there anything else I can provide
to help the VTK gurus track down this bug better?

Thanks in advance for the replies,

Charles Boivin



More information about the vtkusers mailing list