VTK-js API to load .VTK file for volume rendering

Hello,

I am interested in the vtk-js library, and would like to learn more about it. Before I investigate more on it’s various applications, I want to know if the library has APIs to load .vtk file.

I found some examples, and they can only load .vti, .vtp and .vtkjs files.

*.vtk files are VTK legacy format which can encapsulate any kind of vtkDataSets.

We currently have partial support for vtkPolyData inside *.vtk file.

But the key aspect with vtk.js is that we mainly focus on PolyData or ImageData for the rendering aspect. Therefore what should drive your reflexion is what to aim to do with vtk.js, not really what it can read at a given point in time.

So I guess my question to you would be: “What are you looking to do with vtk.js?”

Thank you for your reply. Yes, .vtk is a legacy format. Previously we used C++ VTK library to do volume rendering. Now we want to use vtk-js library to develop web application that also needs to do volume rendering. We are currently evaluate the libraries and tools to see if they can meet our needs. We have some data from CT scan that are saved in .vtk format.

We found some examples like: https://kitware.github.io/vtk-js-datasets/apps/VolumeViewer.html?fileURL=/vtk-js-datasets/data/vti/LIDC2.vti
From there you can drag any .vti file, and it will get a rendering from the vtk-js application. It would help our evaluation if we can drag and place a .vtk file and get the rendering result.

1 Like

Currently vtkImageData for *.vtk is not supported but for your use case that only have one field, it would be very easy and quick to add that reader.

Thanks. Do you mean it is easy to modify the library? I look forward to it.

I mean it is easy to add/write that specific legacy reader code for image data.

Actually itk.js may already have a version of that reader wrapped in WebAssembly which might work directly work inside ParaView Glance.
You can always use that path rather than creating a 100% JS reader for that file format.

@Sebastien_Jourdain is correct – you can use the vtk.js ITKImageReader to read in a volume in VTK legacy file format (binary or ascii) via itk.js.

As a side note, it is now also possible to read it a vtk.js PolyData from a binary or ascii .vtk polydata or unstructured grid file via VTK C++ WebAssembly / itk.js with the vtk.js ITKPolyDataReader.

Thanks so much. I’ll search to see if I can find some sample code.

Hi @Sebastien_Jourdain

can vtk.js properly read legacy vtk files under version 5.1 ?
I was successfully using vtkPolyDataReader with version 4.2 but it is not working anymore now that I have to deal with version 5.1 files.

Thank you for your answer.

Raphael

The legacy format was added at the very beginning of vtk.js with very bare functionalities. I would suggest creating an issue Add support for reading Legacy VTK format of version 5.1 with maybe a sample dummy file (small) just to validate.

I’m not expecting that too much work is required to make it work again.

Thank you for your quick answer. I’ve submitted an issue.

1 Like

I could not find any examples to work with ITKPolyDataReader
except this one
https://discourse.itk.org/t/how-to-use-readimagedicomfileseries-on-a-zipfile/3277/8

This is not working as the same way as other VTK-JS readers are.
Hopefully, VTK-JS will add some examples on how to use these classes

  • vtkITKPolyDataReader
  • vtkITKImageReader