[vtkusers] vtkClipPolyData: problem computing output bounds

Audrius Stundzia adv_biologic at hotmail.com
Mon Dec 4 11:22:45 EST 2000


Dear vtk users,

I've run into a puzzling problem using vtkClipPolyData.
My input is a vtkPolyData surface which I left-right bisect using vtkPlane 
and vtkClipPolyData. The number of triangles
for each side is about half of the whole surface, as expected.

Here's the problem: computing and getting the bounds for the left and right 
bisected surfaces returns the bounds of the input whole surface for each of 
the left and right bisected surfaces, which is clearly
wrong.

To make this concrete. If the bounds of the input surface were

(XMin, XMax) = (-1, 1)
(YMin, YMax) = (-1, 1)
(ZMin, ZMax) = (-1, 1)

Then for the left surface I'd expect

(XMin, XMax) = (-1, 0)
(YMin, YMax) = (-1, 1)
(ZMin, ZMax) = (-1, 1)

and the right surface

(XMin, XMax) = ( 0, 1)
(YMin, YMax) = (-1, 1)
(ZMin, ZMax) = (-1, 1)

Instead I get the original values for both sides.

Sample code is included below. Any insight would be most appreciated.

Regards,

Audrius Stundzia

   vtkPlane *leftRightBisectPlane

   leftRightBisectPlane = vtkPlane::New();
   leftRightBisectPlane->SetOrigin( 0.0
                                  , 0.0
                                  , 0.0 );
   leftRightBisectPlane->SetNormal( 1.0
                                  , 0.0
                                  , 0.0 );

   vtkClipPolyData *leftRightClipPolyData;

   leftRightClipPolyData = vtkClipPolyData::New();
   leftRightClipPolyData->SetInput( myPolyData );
   leftRightClipPolyData->SetClipFunction( leftRightBisectPlane );
   leftRightClipPolyData->CreateDefaultLocator();
   leftRightClipPolyData->GenerateClippedOutputOn();
   leftRightClipPolyData->SetValue( 0.0);
   leftRightClipPolyData->Update();

   vtkPolyData *rightSurfacePolyData;
   vtkPolyData *leftSurfacePolyData;

   rightSurfacePolyData = leftRightClipPolyData->GetOutput();
   leftSurfacePolyData  = leftRightClipPolyData->GetClippedOutput();

   cout << "nRightSurfaceTriangles: "
        << rightSurfacePolyData->GetNumberOfPolys() << endl;
   cout << "nLeftSurfaceTriangles: "
        << leftSurfacePolyData->GetNumberOfPolys() << endl;

   float rightBounds[_3DBounds];
   float leftBounds[_3DBounds];

   rightSurfacePolyData->ComputeBounds();
   rightSurfacePolyData->GetBounds( rightBounds);

   leftSurfacePolyData->ComputeBounds();
   leftSurfacePolyData->GetBounds( leftBounds);

   cout << "Left bounds: " << endl
        << leftBounds[XMin] << " " << leftBounds[XMax] << endl
        << leftBounds[YMin] << " " << leftBounds[YMax] << endl
        << leftBounds[ZMin] << " " << leftBounds[ZMax] << endl;

   cout << "Right bounds: " << endl
        << rightBounds[XMin] << " " << rightBounds[XMax] << endl
        << rightBounds[YMin] << " " << rightBounds[YMax] << endl
        << rightBounds[ZMin] << " " << rightBounds[ZMax] << endl;


_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com





More information about the vtkusers mailing list