Skip to content
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

vtk unstructureddata (vtu file) file type can be loaded? #693

Open
zhangcl-163 opened this issue Nov 16, 2022 · 5 comments
Open

vtk unstructureddata (vtu file) file type can be loaded? #693

zhangcl-163 opened this issue Nov 16, 2022 · 5 comments

Comments

@zhangcl-163
Copy link

since vtk.js -itk, unstructureddata file (vtu) can be loaded.
in itk-wasm, does it support vtu file type to be loaded?
or it is supported in seperate itk-wasm io module?

any suggestions are appreciated!

@thewtex
Copy link
Member

thewtex commented Nov 23, 2022

Hi @zhangcl-163 ,

vtu is not planned in the current future as far as I am aware; however, .vtk unstructured data is planned around December.

@jord1e
Copy link

jord1e commented Aug 7, 2024

Hey Matt, did UNSTRUCTURED_DATA get implemented?

My models are working fine with itk.js but itk-wasm is crashing without any usefull error codes so this might be the problem

I don't think I need it, but maybe it would help people in the future

For now I am just doing an extra postprocessing step of converting to XML PolyData:

import vtk

# Step 1: Read the unstructured grid data
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName("x.vtk")
reader.Update()

# Step 2: Convert the unstructured grid to polydata
geometryFilter = vtk.vtkGeometryFilter()
geometryFilter.SetInputData(reader.GetOutput())
geometryFilter.Update()

# Step 3: Write the polydata to a new VTK file
polydata = geometryFilter.GetOutput()
writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName("x.vtk")
writer.SetInputData(polydata)
writer.Write()

Than using the https://kitware.github.io/vtk-js/examples/XMLPolyDataWriter.html
But it did take some time to figure out that that is possible :)

@thewtex
Copy link
Member

thewtex commented Aug 7, 2024

@jord1e thanks for sharing the workaround!

I currently do not have plans to add VTU support, but contributions are welcome.

@jord1e
Copy link

jord1e commented Aug 8, 2024

Thank you for the update!

The workaround is working perfectly, and I am getting WAY better performance as compared to using the vtk.js IO/Legacy vtkITKPolyDataReader/ITKPolyDataReader + itk.js+ setReadPolyDataArrayBufferFromITK

Hoping Google guides people to it ;)

@thewtex
Copy link
Member

thewtex commented Oct 29, 2024

xref: #1261

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

No branches or pull requests

3 participants