-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update shapeworks.sw2vtkMesh to export mesh vertices, edges, and polys rather than read/write to disk #825
Comments
Update for sw.Image:
These helper functions will be soon demonstrated in our notebook tutorials. These helper functions can be included in shapeworks init.py using pyvista to render volumes does not reflect image physical coordinates converting to itk/vtk images should also consider header information for subsequent visualization. I will provide more updates on sw.Mesh later. |
For sw.Mesh, we need access to mesh vertices and faces to construct itkMesh and vtkPolyData in python. |
pyvista wrap function can wrap vtkPolyData and trimesh (python) objects. If we can get the vertices and faces as arrays from sw.Mesh, we can construct vtkPolydata in python and use pv.wrap for visualization. |
Please, update notebooks to replace sw2vtk sw2itk helper functions. |
This may simply not be possible from c++, but these helpers should be in the pymodule. |
@jadie1 @iyerkrithika21 please address this issue as you resolve #1173 and #865. |
I don't think we need toItk anymore since we are not going to use itkwidgets. |
@archanasri is this still an issue? |
In order to construct the mesh after obtaining the two arrays, we need to import vtk or import trimesh. Is this something we want to do? |
Agreed. And we essentially already have these functions in our module (we can add sw2itk if we want, but since our "resolution" to so many itk issues is to simply not include it, this would go against that). Implementing them on the C++ side--they already are, just not provided as part of our module--would provide no benefit. |
So should we just leave sw2vtk as it is? It currently writes out the sw mesh and loads the same mesh using pyvista.read |
This works fine, but should probably not use the disk. I don't think resolving this is necessary for 6.1, and possibly not at all, though similarly to #903, sharing memory will be more efficient than copying. |
These functions exist in shapeworks python module as #903 will automatically improve performance (note: this should be used as a test and performance comparison for that issue). |
I no longer agree with myself about renaming:
This now works efficiently and even the internal data pointer in the wrapped image points directly back to the image. |
@cchriste It looks like this issue can be closed. Do you want to discuss this offline? |
From our discussion yesterday, the best way to convert a shapeworks.Mesh to a vtkImage (wrapped by pyvista) will be to retrieve the vertices, faces, [and any fields], using the example here: https://docs.pyvista.org/examples/00-load/create-poly.html#sphx-glr-examples-00-load-create-poly-py All of these can be fetched without copying similar to Images. The quantity of data is significant and unlikely to be re-allocated with every filter. Therefore sharing without copying should also increase efficiency. |
Similar to shapeworks.Image, we want to convert a shapeworks mesh to itk or vtk data structure to be visualized by itkwidgets, which supports both itk:Mesh and vtk::PolyData
This also will be very handy when visualizing multiple samples in a grid view using pyvista.
For now, a workaround would be saving the mesh/image and re-reading it for visualization.
The text was updated successfully, but these errors were encountered: