Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Optimize the vtk_loader module #28

Open
banesullivan opened this issue Oct 13, 2019 · 1 comment
Open

Optimize the vtk_loader module #28

banesullivan opened this issue Oct 13, 2019 · 1 comment

Comments

@banesullivan
Copy link
Contributor

There are quite a lot of for-loops in the vtk_loader module which would get really slow on bigger VTK datasets. This library can handle NumPy arrays, correct?

Perhaps we should reimplement that whole module to only leverage PyVista instead of VTK to access those data arrays in a much faster implementation. PyVista has accessors to the VTK arrays over a direct interface in memory (i.e. no Python for-loops) but everything comes as a NumPy array. The get_ugrid_triangles would simply be replaced by grid.extract_geometry().faces and the get_ugrid_tetrahedrons() would be replaced with a triangulate() filter and grabbing the .cells array from the PyVista mesh.

As for the get_ugrid_data method... this seems a bit convoluted. PyVista can give you all the point/cell data as a dictionary: keys are the name of the arrays and values are numpy arrays of the data values (length corresponds to the number of points or cells and 2nd dimension is the number of components) (F-ordered).

Also, you could just use PyVista to load any VTK dataset or file format supported by PyVista/VTK and not have to worry about all the type checking in load_vtk. This would also add a lot more supported file formats to this library.

@martinRenou
Copy link
Owner

If PyVista can make this VTK loading logic faster and simpler, then it is a big yes for me! I am really not an expert in the VTK library so any help is very much appreciated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants