# Creating implicitfunction with vtkImplicitModeller and vtkImplicitVolume

**URL:** https://discourse.vtk.org/t/creating-implicitfunction-with-vtkimplicitmodeller-and-vtkimplicitvolume/6994
**Category:** Support
**Created:** [October 27, 2021, 5:37pm UTC](https://discourse.vtk.org/t/creating-implicitfunction-with-vtkimplicitmodeller-and-vtkimplicitvolume/6994 "2021-10-27T17:37:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AustinPeppel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/austinpeppel/32/4782_2.png) [@AustinPeppel](https://discourse.vtk.org/u/AustinPeppel)
#### Post date: [October 27, 2021, 5:37pm UTC](https://discourse.vtk.org/t/creating-implicitfunction-with-vtkimplicitmodeller-and-vtkimplicitvolume/6994/1 "2021-10-27T17:37:31Z")

</div>

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.

```auto
    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.

---

<div class="post-metadata">

### Author: ![AustinPeppel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/austinpeppel/32/4782_2.png) [@AustinPeppel](https://discourse.vtk.org/u/AustinPeppel)
#### Post date: [November 5, 2021, 12:37pm UTC](https://discourse.vtk.org/t/creating-implicitfunction-with-vtkimplicitmodeller-and-vtkimplicitvolume/6994/2 "2021-11-05T12:37:32Z")

</div>

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.

```auto
    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()

```
