tetgen icon indicating copy to clipboard operation
tetgen copied to clipboard

Exception while writing VTK file

Open MichaelHillier opened this issue 4 years ago • 2 comments

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

MichaelHillier avatar Jun 30 '20 21:06 MichaelHillier

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.

akaszynski avatar Jun 30 '20 21:06 akaszynski

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!

MichaelHillier avatar Jul 01 '20 14:07 MichaelHillier