In [84]:
%gui qt
import vtk
from vtkviewer import SimpleVtkViewer
#help(vtk.vtkRectilinearGridReader())
In [85]:
# do not forget to call "Update()" at the end of the reader
rectGridReader = vtk.vtkRectilinearGridReader()
rectGridReader.SetFileName("data/jet4_0.500.vtk")
rectGridReader.Update()
In [86]:
rectGridOutline = vtk.vtkRectilinearGridOutlineFilter()
rectGridOutline.SetInputData(rectGridReader.GetOutput())
In [87]:
rectGridOutlineMapper = vtk.vtkPolyDataMapper()
rectGridOutlineMapper.SetInputConnection(rectGridOutline.GetOutputPort())
In [88]:
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(rectGridOutlineMapper)
outlineActor.GetProperty().SetColor(0, 0, 0)
In [89]:
#Option 1: Default vtk render window
renderer = vtk.vtkRenderer()
renderer.SetBackground(0.5, 0.5, 0.5)
renderer.AddActor(outlineActor)
renderer.ResetCamera()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.SetSize(500, 500)
renderWindow.Render()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renderWindow)
iren.Start()
In [83]:
#Option 2: Using the vtk-viewer for Jupyter to interactively modify the pipeline
vtkSimpleWin = SimpleVtkViewer()
vtkSimpleWin.resize(1000,800)
vtkSimpleWin.hide_axes()
vtkSimpleWin.add_actor(outlineActor)
vtkSimpleWin.add_actor(gridGeomActor)
vtkSimpleWin.ren.SetBackground(0.5, 0.5, 0.5)
vtkSimpleWin.ren.ResetCamera()
__Trick:__ The autocomplete functionality in Jupyter is available by pressing the Tab
button.