[vtkusers] converting output of vtkContourFilter from line segments to closed loop polyline

Marc Cotran marc at cotran.ca
Thu Jun 22 18:30:04 EDT 2006

David C Thompson wrote:
> On Thu, 2006-06-22 at 15:30 -0600, Richard Strelitz wrote:
>> I want to use contours (and isosurfaces) as discrete objects.  For 
>> example, while vtkContourFilter generates a multitude of 2-point line 
>> segment cells, I want to string together those pieces belonging to the 
>> same contour to be shown as an N-point polyline.  Absent special cases 
>> (hitting the boundary, duplicate points, etc.) the problem is 
>> straightforward.  ...
>> Is there a method or class that I have overlooked?  Wouldn't this be a 
>> nice thing to have?
>> Suggestions, comments, hints and even flames, welcome.
> Hint: VTK/Graphics/vtkStripper does what you want. Note that it won't
> create polylines with more than 100,000 segments (by fiat).
> 	David
I tried this once using vtkStripper and found that it often gave 
multiple strips for polylines that could be described as a single strip. 
I also found that sometimes a strip went in one direction, while a 
connecting strip went the other. I tried cleaning the points first, 
which helped a little, but I ended up getting frustrated and giving up.

For my project, I was *not* starting with the output of a 
vtkContourFilter, but rather the output of a vtkCutter (cutting through 
a polydata mesh with an implicit plane). While I assume the results 
would be the same, you may have more luck with vtkContourFilter. If not, 
I fear you may have to implement the algo you proposed.


More information about the vtkusers mailing list