感觉与C++程序对应关系很好,不过运行速度好像要比C++的应用程序慢。
import vtk
import time
cone = vtk.vtkConeSource()
cone.SetHeight( 3.0 )
cone.SetRadius( 1.0 )
cone.SetResolution( 10 )
coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInputConnection( cone.GetOutputPort() )
coneActor = vtk.vtkActor()
coneActor.SetMapper( coneMapper )
ren1= vtk.vtkRenderer()
ren1.AddActor( coneActor )
ren1.SetBackground( 0.1, 0.2, 0.4 )
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer( ren1 )
renWin.SetSize( 300, 300 )
for i in range(0,360):
time.sleep(0.08)
renWin.Render()
ren1.GetActiveCamera().Azimuth( i )
运行代码后显示的是一个旋转的圆锥体。