I choose some points in a polydata. With these points, I want to create a spline (closed) on the surface of the polydata in order to clip it in two parts.
How can I do to create that spline? I have seen vtkOrientedGlyphContourRepresentation but it find the shortest path and it is not on the surface.
Any help would be appreciated.
this is just an attempt … i create a closed spline from a bunch of random points on a sphere then create a “ribbon” surface and cut through the sphere with that.
The blue part is the result. It is not perfect because also a different part of the sphere mesh is selected…
from vtkplotter import * import numpy as np s = Sphere().alpha(0.2).lw(0.1) sc = s.coordinates() pts = np.array([sc, sc, sc, sc, sc]) ptsm = spline(pts, smooth=0).coordinates() pts0 = ptsm-[.3,0,0] pts1 = ptsm+[.3,0,0] rb = Ribbon(pts0, pts1).bc('green') scut = s.clone().c('blue').alpha(0.5).cutWithMesh(rb) show(s, scut, Points(pts), Line(ptsm), rb, axes=1, bg='w')
You can use the points as loop input in a vtkSelectPolyData filter, enable generation of selection scalars, and get the enclosed surface patch using vtkClipPolyData.
Thanks for the answer. But it does not resolve my problem. There are some polydata where the vtkSelectPolyData filter can not follow the edge.
Yes, edge following may fail if you don’t provide dense enough point list or the surface has holes. However, if the surface mesh is well behaved and you sample your mesh with appropriate spacing then it works.
Hi Bassirou FAYE,
could you solve this problem? how?
You can use the VTK filters described above but if you want to convenient GUI to extract a surface patch using a closed curve then you can use the recently added Dynamic modeler module in 3D Slicer.
Hi Andras Lasso,
thanks for your reply. I need to use Python, also VTK. I use SelectPollyDataFilter but “There are some pollydata where the vtkSelectPollyData filter can not follow the edge”. How I can cut pollydata with a contour widget without SelectPollyDataFilter? or How to use vtkSelectPollyData for pollydataes are not sample?