如何删除vtk中的演员?
how to delete an actor in vtk?
例如,
如果我有一个立方体
(这部分代码来自vtk python例子)
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()
如何删除这个立方体演员并添加另一个?
(这必须按顺序完成)
你试过了吗
ren.RemoveActor(cubeActor);
?
然后,您只需添加另一个演员
ren.AddActor(anotherActor);
例如, 如果我有一个立方体
(这部分代码来自vtk python例子)
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()
如何删除这个立方体演员并添加另一个? (这必须按顺序完成)
你试过了吗
ren.RemoveActor(cubeActor);
?
然后,您只需添加另一个演员
ren.AddActor(anotherActor);