Closed akaszynski closed 3 years ago
First off, great work with this library/package!
I'd like to improve the performance when wrapping pyvista meshes, so I've proposed the following method:
PolyMesh.from_pyvista(pvmesh)
It can actually wrap any VTK/pyvista object and does it quickly as it utializes a bunch of pyvista's fast methods for getting data from VTK.
pyvista
For example:
pvmesh = examples.download_nefertiti() def old(pvmesh): ugrid = pvmesh.cast_to_unstructured_grid() return PolyMesh.from_vtk(ugrid) def new(pvmesh): return PolyMesh.from_pyvista(pvmesh)
New approach is about 20x faster (and will be even faster with https://github.com/pyvista/pyvista/pull/1228):
>>> %timeit old(pvmesh) 2.28 s ± 20.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) >>> %timeit new(pvmesh) 117 ms ± 3.62 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Also, makes examples a bit cleaner:
Amazing! Thanks a ton :)
Wrap PyVista Meshes Directly
First off, great work with this library/package!
I'd like to improve the performance when wrapping pyvista meshes, so I've proposed the following method:
It can actually wrap any VTK/pyvista object and does it quickly as it utializes a bunch of
pyvista
's fast methods for getting data from VTK.For example:
New approach is about 20x faster (and will be even faster with https://github.com/pyvista/pyvista/pull/1228):
Also, makes examples a bit cleaner: