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])
)
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