Kitware / vtk-js

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

How to load a .vtk file in vtk.js #668

Closed nicolasmaurotorres closed 6 years ago

nicolasmaurotorres commented 6 years ago

Hi, im doing my thesis and i need to render files locally and remotelly

Im trying to do the local rendering to visualize a .vtk file from my pc to the browser with vtk.js using this examples https://kitware.github.io/vtk-js/examples/STLReader.html using the handleFile of the example and the rendering part of this one https://kitware.github.io/vtk-js/examples/PolyDataReader.html but is not working

This is the file im using to render (125MB) https://drive.google.com/file/d/1IbcaAZcK7ysc5noGb5cuo6unvq7Q0zbq/view

I already did the remote render and works like a charm, i used this tutorial https://kitware.github.io/paraviewweb/docs/multi_user_setup.html

what im doing wrong?

thanks in advance!

nicolasmaurotorres commented 6 years ago

Update i tryed this code import vtkPolyDataReader from 'vtk.js/Sources/IO/Legacy/PolyDataReader'; ... _this.reader = vtkPolyDataReader.newInstance(); _this.reader.setUrl("/src/js/imagen_procesada.vtk").then(() => { const polydata = _this.reader.getOutputData(0); const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance(); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); _this.actor.setMapper(_this.mapper); _this.mapper.setInputData(polydata); renderer.addActor(_this.actor); resetCamera(); render(); }); and the console of chrome throws "Dataset of type UNSTRUCTURED_GRID not supported"

Maybe is not the component i need to render properly?

jourdain commented 6 years ago

You will need to extract the surface of your unstructured grid in order to render it into vtk.js. The preferred format for it would be vtp.

nicolasmaurotorres commented 6 years ago

@jourdain thanks for answer so fast, very appreciate

this solution does not works for me because i need to render the inside of the 3D model of the vein, is not enough only the surface

what about paraviewweb? there is something in there to render all the 3D model locally?

jourdain commented 6 years ago

this solution does not works for me because i need to render the inside of the 3D model of the vein, is not enough only the surface

Just so you know, that is exactly what VTK is doing.

What you are probably missing is that you are running a filter to contour/clip?

You can use ParaViewWeb and do local rendering with vtk.js. The extract surface will be done automatically for you in a transparent manner.