VTK renderiza em IPython Notebook

Esta função pega um objeto vtkRenderer e exibe a saída diretamente no IPython Notebook

def vtk_show(renderer, w=100, h=100):
"""
Takes vtkRenderer instance and returns an IPython Image with the rendering.

"""

renderWindow
= vtkRenderWindow()
renderWindow
.SetOffScreenRendering(1)
renderWindow
.AddRenderer(renderer)
renderWindow
.SetSize(w, h)
renderWindow
.Render()

windowToImageFilter
= vtkWindowToImageFilter()
windowToImageFilter
.SetInput(renderWindow)
windowToImageFilter
.Update()

writer
= vtkPNGWriter()
writer
.SetWriteToMemory(1)
writer
.SetInputConnection(windowToImageFilter.GetOutputPort())
writer
.Write()
data
= str(buffer(writer.GetResult()))

from IPython.display import Image
return Image(data)

Leia o artigo: ( http://pyscience.wordpress.com/2014/09/03/ipython-notebook-vtk/ )