pyvista / tetgen

A Python interface to the C++ TetGen library to generate tetrahedral meshes of any 3D polyhedral domains
http://tetgen.pyvista.org
Other
226 stars 33 forks source link

Exception while writing VTK file #17

Open MichaelHillier opened 4 years ago

MichaelHillier commented 4 years ago

Hello there,

I've created a tetrahedral mesh using the tetgen API successfully and able to visualize using pyvista. However, when I try to write a VTK file i get the exception "'UnstructuredGrid' object has no attribute 'write'". I've tried both the legacy format .vtk and xml format .vtu. Below is my code:

tgen = tetgen.TetGen(v, f)
nodes, elems = tgen.tetrahedralize(quality=True, minratio=1.414, mindihedral=16, varvolume=1, nobound=1, vtkview=1)
tgen.write('data/test.vtk')

TetGen's method write() called above uses a grid object (an UnstructuredGrid):

self.grid.write(filename, binary)

but it doesn't have a method called write().

Am I doing something wrong when I generate the mesh (via. tetrahedralize())?

Thanks

Mike

akaszynski commented 4 years ago

Looks like I should be using save instead of write. If you're feeling up to it you can submit a PR for this. Otherwise, I can but it might take a few days as I'm a bit swamped.

MichaelHillier commented 4 years ago

I can confirm that using self.grid.save(filename, binary) works. No worries that you can't get to it right away with the fix, I understand - am also swamped!