Hello, I’d like to obtain the border of a polydata triangulated surface as a polyline.
With the following code (where tri_surf is the triangulated surface polydata), I get all the edges on the border, but they are not ordered, so I cannot build a proper closed polyline representing the border of the surface from these scattered edges.
Hello, thanks for quick answer! It looks like vtkStripper is what I need, however the order of the lines in the polyline is still messed up. In this example, what I expect as border is in yellow and the polyline I get is in one.
I guess that the reason is that the cell called here is a polyline, generated by vtkStripper, that combines all the single lines in the correct order.
However, if the surface is composed of two disconnected parts, I get two polylines, and in this case I am still not able to add all the points properly, and I end up with just the border of the first part.
I thought I can append the points from the second cell (or more cells) like this
for i in range(border_polyline.GetNumberOfCells()-1):
border_polyline.GetPoints().AppendPoints(border_strips.GetOutput().GetCell(i+1).GetPoints())
But for some reason I don’t understand it does not work. It appears it replaces the points of the first part with those of the second one.
That’s why I was experimenting with the code above, that works in case of single-part surfaces, but yields just the border of the first part in case of multiple parts.
For this reason I was trying to add also the other parts.
Hello, now it works. Basically I am building the polygons that correspond to borders, using points in the order with which they appear in the polyline cells issued by vtkStripper.
In this way I get proper borders even in case of multi-part surfaces.
This was just what I was looking for, I spent over an hour trying to write an algorithm that reordered the points but realized this must already be an anticipated/desired output structure