# Mesh an implicit function (python lambda)

**URL:** https://discourse.vtk.org/t/mesh-an-implicit-function-python-lambda/3838
**Category:** Support
**Created:** [July 23, 2020, 11:42am UTC](https://discourse.vtk.org/t/mesh-an-implicit-function-python-lambda/3838 "2020-07-23T11:42:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![T4mmi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/t4mmi/32/1237_2.png) [@T4mmi](https://discourse.vtk.org/u/T4mmi)
#### Post date: [July 23, 2020, 11:42am UTC](https://discourse.vtk.org/t/mesh-an-implicit-function-python-lambda/3838/1 "2020-07-23T11:42:35Z")

</div>

Hi all,

I’m looking for a VTK way to mesh any custom implicit function (as a python lambda with a signature of type `List[float[3]] -> float`)

From what I read `vtkSampleFunction` \> `vtkMarchingCubes` seems the way to go but I could not manage to derivate `vtkImplicitFunction` through the Python interface, nor find any example (even C++ meshing a `float(*)(double x[3])`)

😕

```auto
from vtk import vtkImplicitFunction

class vtkImplicitFunctor(vtkImplicitFunction):

    def __init__ (self, functor: "List[float[3]] -> float", gradient: "List[float[3]] -> List[float[3]]"):
        self.FunctionValue = functor
        self.FunctionGradient = gradient
        
    def EvaluateFunction(self, point: "List[float[3]]") -> float:
        return self.FunctionValue(point)
    
    def EvaluateGradient(self,point: "List[float[3]]") -> "List[float[3]]":
        return self.FunctionGradient(point)

vtkImplicitFunctor(functor=lambda x,y,z: z, gradient=lambda x,y,z: [0,0,1])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-02f59cfea173> in <module>
----> 1 vtkImplicitFunctor(functor=lambda x,y,z: z, gradient=lambda x,y,z: [0,0,1])

TypeError: this is an abstract class and cannot be instantiated

```

---

<div class="post-metadata">

### Author: ![Cos0](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/ea5d25/32.png) [@Cos0](https://discourse.vtk.org/u/Cos0)
#### Post date: [April 12, 2024, 6:07am UTC](https://discourse.vtk.org/t/mesh-an-implicit-function-python-lambda/3838/2 "2024-04-12T06:07:29Z")

</div>

Same question again, man, it’s really tough.
