Mapping an in memory triangular mesh to an equivalent VTK object in python
Firstly, thanks for the great package.
I'm working in python with VTK. I have a triangular mesh object defined in memory, which is described by two arrays:
- the mesh vertices as an Nx3 list/array of floating point values (x, y, z).
- a mesh triangle array as an Mx3 list/array of integers that index into the first vertex array. So there are M triangles in the mesh, composed from N vertex points. I also have an array of triangle normal vectors if needed.
I would like to read the data from my own object and instance the mesh in an equivalent VTK object for visualisation and further computations. I have seen numerous examples that work with various mesh format importers, like the STL reader for example. So I'm assuming an appropriate object exists somewhere but I just haven't found it yet. The vtkPolyDataMapper() object looks close to what I'm looking for, I've often seen it in code like this:
reader = vtk.vtkSTLReader() reader.SetFileName(filename) mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(reader.GetOutputPort())
Can you suggest an appropriate class for me to try working with? Or maybe refer me to a tutorial / example somewhere?