How to save renderer output (vtk python) in format that is compatible on web side(vtk.js)

i want all the processing on python vtk side and send the resulting file on vtk.js side on webGL that only rendered the results.

i want to save renderer output in any file format , that can be used on the other end side (vtk.js) just to render the results. kindly provide sugessions

code

renderer = vtk.vtkRenderer()
volume, mask = setup_volume(renderer, LiverVolume_FILE), setup_mask(renderer, LiverMask_FILE)
#volume_image_prop = setup_projection(volume, renderer)
#volume_slicer_props = setup_slicer(renderer, volume)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
renWin.SetSize(900, 900)

You should use vtkJSONSceneExporter from Python and HttpSceneLoader in vtk.js.

You can see its integration into ParaView and Glance.

1 Like

Thankyou soo much it worked :slight_smile:

1 Like

code used in python vtk to export
exporter=vtk.vtkJSONSceneExporter()
exporter.SetFileName(“3Dscene”)
exporter.SetInput(renWin)
exporter.SetActiveRenderer(renderer);
exporter.Write()

as a result of vtkjsonsceneexporter i got index.json and 3 folder files (folders contain index.json file and a data folder contains some float and int file ) , i am not able to understand these , when i load these filles in paraview it gives error. can you please explain
files

ParaView (Qt application) does not know how to read those files. But if you zip it and rename it to something-you-like.vtkjs, Glance should be able to read it.

Thankyou it worked on glance , want to know one thing as i am new to vtk.js as when i used HttpSceneLoader on js side using webpack i am following the basic cone example (Starting a vtk.js project from scratch | vtk.js) and adding my own things in it, but it gives the error , you know how to sort this out.

This is my index.js in src folder.

this is my index.html in dist folder

ERROR by running npm run command

If you read the documentation you pointed out, you will notice that the imports are not the same.

vtk.js/Sources/*
vs
@kitware/vtk.js/*

1 Like

thankyou :slight_smile: