VTK/Examples/Python/GeometricObjects/Display/Cube

From KitwarePublic
< VTK‎ | Examples‎ | Python
Jump to navigationJump to search

Display a cube

Cube.py

import vtk

# create a rendering window and renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)

# create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

# create cube
cube = vtk.vtkCubeSource()

# mapper
cubeMapper = vtk.vtkPolyDataMapper()
cubeMapper.SetInput(cube.GetOutput())

# actor
cubeActor = vtk.vtkActor()
cubeActor.SetMapper(cubeMapper)

# assign actor to the renderer
ren.AddActor(cubeActor)

# enable user interface interactor
iren.Initialize()
renWin.Render()
iren.Start()