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

David Doria daviddoria at gmail.com
Fri Dec 2 06:44:10 EST 2011


> 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?

Or vtkTriangle or vtkQuad, like you mentioned. Just everything except
vtkVertex and vtkLine and vtk*Strip, I believe.

> How do I know for sure?

You can try to cast the cells to different types. Or, you can use
polydata->GetCellType() and compare the value returned to this list:
http://www.vtk.org/doc/nightly/html/vtkCellType_8h_source.html

> and how can I get the x-y-z coordinates of each point on the isosurface?

I think you're just looking for

vtkPoints* points = contourFilter->GetOutput()->GetPoints();

> 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.

I don't believe there is any need for that in this case.

> 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.

To actually run the filter, you need contourFilter->Update() (since
you have the filter connected to the renderer, calling Render()
updates everything "upstream", including the contourFilter.

David



More information about the vtkusers mailing list