The vtkPolyDataEdgeConnectivityFilter
works fine, it is crashing because it needs polygons, not just lines.
Here is a solution in vedo, (uncomment reverse()
to have it clockwise):
from vedo import *
m = Mesh("poly1.vtk").clean().triangulate()
ms = m.split(must_share_edge=True) # return a list of meshes
s1 = ms[0].boundaries().join_segments()[0]#.reverse()
print("First polyline", s1.points())
show(ms, s1, s1.labels2d(), axes=1)
First polyline
[[ 1562187.9 -5830366. 2038637.4]
[ 1764714.6 -5772294. 2038637.4]
[ 1965086. -5707191.5 2038637.4]
[ 2163063.2 -5635136. 2038637.4]
[ 2358410.5 -5556212.5 2038637.4]
[ 2331017.8 -5491532.5 2235859.8]
[ 2137944.8 -5569539. 2235859.8]
[ 1942269.2 -5640759. 2235859.8]
[ 1744224.8 -5705107.5 2235859.8]
[ 1544058. -5762504.5 2235859.8]]
pip install -U git+https://github.com/marcomusy/vedo.git