[vtkusers] x-y-z coordinates from vtkPolyData from vtkContourFilter

Luke hazelnusse at gmail.com
Thu Dec 1 22:20:57 EST 2011


Hello,
  I'm contouring an implicit function using vtkSampleFunction and
vtkContourFilter.  I generate one isosurface, and my goal is to
evaluate a function (R^3: --> R) at each x-y-z coordinate on the
isosurface.  My understanding is that I can use the GetOutput() method
of vtkContourFilter to obtain a pointer to the vtkPolyData.  From
here, I'm not quite sure how to get the vertex data, which I would
like to pass to my function.

I tried the following

  vtkPolyData *pd = contours->GetOutput();
  std::cout << "verts: " << pd->GetNumberOfVerts() << std::endl
            << "lines: " <<  pd->GetNumberOfLines() << std::endl
            << "polys: " <<  pd->GetNumberOfPolys() << std::endl
            << "strips: " <<  pd->GetNumberOfStrips() << std::endl
            << "cells: " <<  pd->GetNumberOfCells() << std::endl;

for a quadric, just to get a feel for what is in the data.  The
resulting output was:

verts: 0
lines: 0
polys: 7484
strips: 0
cells: 7484

Looking into the vtkPolyData documentation about what exactly the
GetNumberOfPolys() method returns, I got a bit confused. vtkPolyData
can represent "vertices, lines, polygons, and triangle strips", or
more specifically "The actual cell types (vtkCellType.h) supported by
vtkPolyData are: vtkVertex, vtkPolyVertex, vtkLine, vtkPolyLine,
vtkTriangle, vtkQuad, vtkPolygon, and vtkTriangleStrip".

So I'm guessing the cells in this vtkPolyData instance are either of
type vtkPolyVertex, vtkPolyLine, or vtkPolygon?  How do I know for
sure and how can I get the x-y-z coordinates of each point on the
isosurface?

I imagine that once I figure this out, I can subclass
vtkPolyDataAlgorithm and connect the output of the contour filter to
my subclass and have it perform the the calculation on each vertex and
then this would make my algorithm fit into the pipeline model of VTK.

Also, the number of verts, lines, polys, strips, and cells was all
zero unless I put the above code after calling the Render() method of
vtkRenderWindow.

Any help would be greatly appreciated.

Thanks,
~Luke

-- 
"Those who would give up essential liberty to purchase a little
temporary safety deserve neither liberty nor safety."

-- Benjamin Franklin, Historical Review of Pennsylvania, 1759



More information about the vtkusers mailing list