Creating implicitfunction with vtkImplicitModeller and vtkImplicitVolume

Hey all,

I’m pretty new to VTK so I’m trying to wrap my head around a few things. I’ve gotten pretty far but now I’m stuck here. I’d like to clip an isosurface with a specific mesh. I’ve been attempting to do it as shown below,- and though it asks for vtkImageData and it is being provided with the vtkImplicitModeller,- it says it is missing volume or points. I’m not sure if I’m going about this wrong because I’m missing a step,- or what I’m doing isn’t achievable by these means.

    reader = vtk.vtkSTLReader()
    reader.SetFileName("box.stl")
    reader.Update()

    reader2 = vtk.vtkPolyDataReader()
    reader2.SetFileName("LineSet.vtk")
    reader2.Update()

    imp = vtk.vtkImplicitModeller()
    imp.SetInputConnection(reader.GetOutputPort())
    imp.SetSampleDimensions(110, 110, 110)
    imp.SetAdjustBounds(True)
    imp.SetAdjustDistance(5.0)
    imp.SetOutputScalarTypeToUnsignedChar()
    imp.SetModelBounds(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0)

    imp2 = vtk.vtkImplicitModeller()
    imp2.SetInputConnection(reader2.GetOutputPort())
    imp2.SetSampleDimensions(200, 200, 200)
    imp2.SetAdjustBounds(True)
    imp2.SetAdjustDistance(5.0)
    imp2.SetOutputScalarTypeToUnsignedChar()
    imp2.SetModelBounds(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0)

    contour2 = vtk.vtkContourFilter()
    contour2.SetInputConnection(imp2.GetOutputPort())
    contour2.SetValue(0, 0.3)
    contour2.ComputeNormalsOn()

    #Infinite loop, no volume or no points error
    test_im = vtk.vtkImplicitVolume()
    test_im.SetVolume(imp.GetOutput())

    clipping = vtk.vtkClipDataSet()
    clipping.SetClipFunction(test_im.GetOutput())
    clipping.SetInputData(contour2)

Any help or a push in the right direction for whatever means to clip/boolean/cut/etc. a generated isosurface from lines with a specific mesh…Would be greatly appreciated.

So, ImplicitModeller seems to only create surface information.
I wanted to clip some data that I created by a mesh,- this can be done before sending to the implicitmodeller by running the polydata through the implicitpolydatadistance filter and using that as the function. There is likely a better way but it works relatively fast for what I’m doing.

    distance = vtk.vtkImplicitPolyDataDistance()
    distance.SetInput(reader.GetOutput())
...

 print("clipping Start")
    clipper = vtk.vtkClipPolyData()
    clipper.SetInputConnection(LatticeStructure.GetOutputPort())
    clipper.SetClipFunction(distance)
    clipper.SetValue(0)
    clipper.InsideOutOn()
    clipper.Update()