My problem seems simple but I can't find an algorithm that will do that for me for any 3D complex surface.
I have a really complex shape 3D surface and a closed curve on it defined by some points (see picture below, that black curve is the closed curve). My purpose is to detach that bulge from the rest of the surface based on that closed curve. In fact, if I find a way to distinguish between the points that are on the side of that closed curve on the bulge from the rest of the points, that would be suffice for me. Any idea how to do that? I couldn't find anything in VTK. So, I appreciate any suggestion or recommendation.
Update:
The closest thing, which I was able to find is vtkImplicitSelectionLoop
class in VTK library. I used it this way:
from vtk import *
def vtkPolyDataReader(filename):
reader = vtkXMLPolyDataReader()
reader.SetFileName(filename)
reader.Update()
pd = reader.GetOutput()
return pd
def vtkPolyDataWriter(filename,pd):
writer = vtkXMLPolyDataWriter()
writer.SetFileName(filename)
writer.SetInputData(pd)
writer.Write()
model = vtkPolyDataReader('model.vtp')
neck_curve = vtkPolyDataReader('neck_curve.vtp')
selectionPoints = neck_curve.GetPoints()
loop = vtkImplicitSelectionLoop()
loop.SetLoop(selectionPoints)
clippedOutput = vtkClipPolyData()
clippedOutput.SetClipFunction(loop)
clippedOutput.SetInputData(model)
clippedOutput.SetInsideOut(True)
clippedOutput.Update()
vtkPolyDataWriter('sac.vtp',clippedOutput.GetOutput())
Basically, I create an implicit function based on my closed curve (i.e. loop) and then I just clip it. But the result is far from satisfactory and it is somewhat confusing:
The red regions are the regions that are picked as within the closed curve by using vtkImplicitSelectionLoop
, which are obviously not the thing that I'm expected here. Any idea?