Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.23k stars 371 forks source link

Loading unstructured grid data VTU #1670

Closed MHadavand closed 3 years ago

MHadavand commented 3 years ago

I am not sure if this is an issue or lack of my knowledge about the API. I need to load vtu files (unstructured grids) but I cannot find a proper IO API for that. STL and VTP is pretty straightforward though.

Does it mean that vtu is not supported?

Thanks,

jourdain commented 3 years ago

vtu is for 3D cells, vtk.js does not support those cells and mainly focus on rendering which means that you need to run a GeometryFilter to extract the skin into a polydata for the rendering. Itk.js does have such reader that will do the conversion for vtk.js. But if your goal is to clip/slice/contour your data, that is still not the solution.

MHadavand commented 3 years ago

Thanks for the reply!

MHadavand commented 3 years ago

One quick question, is there an API from paraview glance that I can use and integrate to an application that uses VTKJS? It is important to be able to process unstructured grids for earth science models. I can convert them to uniform grid and export VTI volumes but would prefer to have the option to handle VTU.

Thanks

jourdain commented 3 years ago

VTK/ParaView Web or WebAssembly could be the way to go as well.

jourdain commented 3 years ago

ParaViewGlance is mainly vtk.js and mostly focus on providing a GUI to it.

MHadavand commented 3 years ago

Thanks! The reason I thought about ParaviewGlance is that I can upload a vtu file and it gets loaded correctly so I thought there should be an API to process VTU file format.

jourdain commented 3 years ago

Glance integrate itk.js that is why.

MHadavand commented 3 years ago

That makes sense and as you mentioned, I cannot slice or clip the imported VTU file in glance.

MHadavand commented 3 years ago

Unstructured grid are not currently supported by VTK-JS.

bernland commented 2 years ago

vtu is for 3D cells, vtk.js does not support those cells and mainly focus on rendering which means that you need to run a GeometryFilter to extract the skin into a polydata for the rendering. Itk.js does have such reader that will do the conversion for vtk.js. But if your goal is to clip/slice/contour your data, that is still not the solution.

I'm interested in clipping/slicing data. From what I understand, HttpDataSetReader works with VTK.js only. So is HttpSceneLoader what I need? How can I export a scene from a C++ VTK app such that I can open/load it in VTK.js?

jourdain commented 2 years ago

Once on the JS side, you won't be able to clip it as the transformation to vtkPolyData already happened.

You can see that such export is available within ParaView. The technology underneath is indeed HttpSceneLoader and on the VTK/C++ side, the code is here.

bernland commented 2 years ago

Thank you! In other words, VTK.js does not support 3D objects, but only vtkPolyData? In other words, clipping/slicing will need to happen in the C++ VTK app by passing mouse events from VTK.js to that app?

jourdain commented 2 years ago

vtk.js will handle the display part of your data processing. But the processing will need to happen on a server or via some VTK/wasm magic.

jourdain commented 2 years ago

You can find some cool examples doing that with a server using trame in plain VTK.

bernland commented 2 years ago

The examples all work based on vtkJSONRenderWindowExporter (C++) and HttpSceneLoader (VTK.js)?

jourdain commented 2 years ago

The example provided use a different serialization method to enable incremental changes and caching rather than a standalone/single state. But some of the core components are the same. The vtk.js side use the SynchronizableRenderWindow.