[vtkusers] vtkVoxelContoursToSurfaceFilter's limitations, alternatives?

kent williams nkwmailinglists at gmail.com
Tue Feb 3 10:02:41 EST 2009


NOTE: I posted this yesterday and never saw it show up on the vtkusers
list. If you're on the VTK users mailing list and you do see it show
up, please hit me back with a private E-Mail.


In the documentation for vtkVoxelContourToSurfaceFilter:

   * The contours are input as vtkPolyData, with the contours being
polys in the vtkPolyData.
   * The contours lie on XY planes - each contour has a constant Z
   * The contours are ordered in the polys of the vtkPolyData such
that all contours on the first (lowest) XY plane are first, then
continuing in order of increasing Z value.
   * The X, Y and Z coordinates are all integer values.
   * The desired sampling of the contour data is 1x1x1 - Aspect can
be used to control the aspect ratio in the output polygonal dataset.

This means that if you have, as I do, a collection of contours created
with vtkContourWidget, to use this filter I'll have to do the
following.

1. Create a new vtkPolyData.
2. Add each contour polygon to the PolyData in sort order, lowest Z to
highest z.  Also, round/truncate all values to integers.
3. use vtkVoxelContourToSurfaceFilter to generate the surface.
4. Before adding to view, transform to identity frame*

My questions: Is this an accurate summary of what needs to happen? Is
there some huge performance benefit to this filter over other options?

*the hardest thing to get one's head around with the vtkContourWidget
is that the points it reports are (according to the documentation) in
"world coordinates", but in fact they are permuted, based on the
viewing plane.

This led me to write the function below, which I can use to permute
points back into world coordinates, when I'm using the vtkINRIA3D
'vtkViewImage2D class for display and visualization. vtkViewImage2D
helpfully will tell you the Z axis for a given view.

inline void
GetAxesIndices(vtkViewImage *viewImage,
              int &xAxis,
              int &yAxis,
              int &zAxis,
              bool &negY)
{
 vtkViewImage2D *viewImage2D(vtkViewImage2D::SafeDownCast(viewImage));
 negY = false;
 zAxis = viewImage2D->GetOrthogonalAxis(viewImage2D->GetOrientation());
 switch(zAxis)
   {
   case 0:
     xAxis = 1;
     yAxis = 2;
     break;
   case 1:
     xAxis = 0;
     yAxis = 2;
     break;
   case 2:
     xAxis = 0;
     yAxis = 1;
     negY = true;
     break;
   default:
     std::cerr << "Unknown axis " << zAxis << std::endl << std::flush;
     throw;
   }
}



More information about the vtkusers mailing list