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.

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.