- Notifications
You must be signed in to change notification settings - Fork13
🔗 minimalist ipywidget to interface with any Python vtkRenderWindow
License
Kitware/ipyvtklink
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
An ipywidget for vtkRenderWindow (formerlyipyvtk-simple)
This is an early prototype of creating a Jupyter interface to VTK. This toolkitis a proof of concept and a more polished tool will be available asipyvtk in the future.
The code here was implemented from the work done byAndras Lassounder an MIT License (seethe source).
The goal is to enable this widget to work with any server sidevtkRenderWindowThis render window could be fromVTK Python,ParaView, orPyVista.
Please note thatvtk is not listed as a requirement for this package tosimplify its installation in virtual environments where VTK may be built fromsource or bundled with ParaView and we do not want to install the wheels fromPyPI.
For use with PyVista, simply install withpip orconda:
pip install ipyvtklinkor
conda install -c conda-forge ipyvtklinkA Docker image is prebuilt and hosted in the ipyvtklink repository's packages.
To run in Docker:
docker pull ghcr.io/kitware/ipyvtklink:latestdocker run -p 8888:8888 ghcr.io/kitware/ipyvtklink:latestand open thevtk.ipynb notebook.
Additionally, this can be used with ParaView. An example is given inparaview.ipynb which can be run via:
docker pull ghcr.io/kitware/ipyvtklink-paraview:latestdocker run -p 8878:8878 ghcr.io/kitware/ipyvtklink-paraview:latestYou may have to build jupyter lab extensions for this to work in Lab. This isknown to work well in Notebook.
PyVista has fully implemented downstream support foripyvtklink. SeePyVista's Documentation
See thepyvista.ipynb for an original proof of concept.
The widget here can be used with VTK. Here is a minimal example showing howto pass anyvtkRenderWindow to theViewInteractiveWidget:
importvtkfromipyvtklink.viewerimportViewInteractiveWidget# Create some datacylinder=vtk.vtkCylinderSource()cylinder.SetResolution(8)mapper=vtk.vtkPolyDataMapper()mapper.SetInputConnection(cylinder.GetOutputPort())actor=vtk.vtkActor()actor.SetMapper(mapper)# Set up render windowren=vtk.vtkRenderer()ren_win=vtk.vtkRenderWindow()ren_win.SetOffScreenRendering(1)ren_win.SetSize(600,600)ren_win.AddRenderer(ren)iren=vtk.vtkRenderWindowInteractor()iren.SetRenderWindow(ren_win)style=vtk.vtkInteractorStyleTrackballCamera()iren.SetInteractorStyle(style)# Add actor to sceneren.AddActor(actor)ren.ResetCamera()# DisplayViewInteractiveWidget(ren_win)
See instructions above for running ParaView in a Docker container.
importparaview.simpleaspvsfromipyvtklink.viewerimportViewInteractiveWidget# Create data on the pipelinewavelet=pvs.Wavelet()contour=pvs.Contour(Input=wavelet)contour.ContourBy= ['POINTS','RTData']contour.Isosurfaces= [63,143,170,197,276]# Set the data as visiblepvs.Show(contour)# Fetch the view and render the sceneview=pvs.GetActiveView()pvs.Render(view)# Fetch the RenderWindowren_win=view.GetClientSideObject().GetRenderWindow()# Display the RenderWindow with the widgetViewInteractiveWidget(ren_win)
About
🔗 minimalist ipywidget to interface with any Python vtkRenderWindow
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.



