ValueError: VTKVolume pane does not support objects of type 'vtkVolume'

HI,

I’m tyring to construct Panel from a PyVista volume. I’m using a bokeh server.

I read the documentation : https://panel.holoviz.org/reference/panes/VTKVolume.html .
And it says :

The VTKVolume pane renders 3d volumetric data defined on regular grids. It may be constructed from a 3D NumPy array or a vtkVolume .

Which is exalty what I’m trying to do. Here is how I do it :slight_smile:

plotter = pv.Plotter()
vol = plotter.add_volume(vol_datas)
vtkpan = pn.pane.VTKVolume(vol, sizing_mode='stretch_both', orientation_widget=True)
row = pn.Row(vtkpan.controls(jslink=True), vtkpan)

And this gives me an error ValueError: VTKVolume pane does not support objects of type 'vtkVolume'.

Few additionals information :

  • I do not have this problem if I use add_mesh from PyVista (but obviously the rendering will not be the same).
  • If I call plotter.show() I have the correct volume displayed.

How can I display add_volume from PyVista in a Panel?

Hello, actually there is an error in the documentation, VTKVolume pane can be construct from 3D numpy array or vtkImageData, not vtkVolume.
However I think we should support it so an issue on the tracker would be welcome

Thx

else you can use this workaround

vtkpan = pn.pane.VTKVolume(vol.GetMapper().GetInputDataObject(0,0), sizing_mode='stretch_both', orientation_widget=True)

but in this case you could pass directly you vol_datas object to the VTKVolume panel

Thank you for your answer.

Currently this is what I do as a workaround
vtkpan = pn.pane.VTKVolume(vol_datas) but the displayed result isn’t identical as what I see on PyVista that’s why I was hoping I could have the same results.

Don’t expect to have same results as pyvista using VTKVolume.
To have closest results as pyvista you have to use pn.panel(plotter.ren_win) but you will loose al fonctionnalities of VTKVolume pane (slice, opacity controller…)

Don’t expect to have same results as pyvista using VTKVolume.
To have closest results as pyvista you have to use pn.panel(plotter.ren_win)

Thanks for your input ! I’ll try that