基本的代码如下,
import vtk
cylinder = vtk.vtkCylinderSource()
cylinder.SetRadius(3.0)
cylinder.SetHeight(10.0)
cylinder.SetResolution(50)
boundsFilter = vtk.vtkOutlineFilter()
boundsFilter.SetInputConnection(cylinder.GetOutputPort())
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(cylinder.GetOutputPort())
mapper.SetInputConnection(boundsFilter.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(0.0, 0.7, 0.0)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor)
renderer.SetBackground(.2, .3, .4)
renderWindow.Render()
renderWindowInteractor.Start()
还不是太熟悉,只能绘制一个东西,
mapper.SetInputConnection(cylinder.GetOutputPort())
mapper.SetInputConnection(boundsFilter.GetOutputPort())
这两句调整位置,只有后面的一句有效;有时间继续;