pyvtk 分块渲染
import vtk
# 创建一些模拟数据
source = vtk.vtkRandomHills()
source.SetAmplitude(0.25)
source.SetNumberOfHills(20)
# 分割数据
plane = vtk.vtkPlane()
plane.SetOrigin(0, 0, 0)
plane.SetNormal(0, 0, 1)
clip = vtk.vtkClipPolyData()
clip.SetInputConnection(source.GetOutputPort())
clip.SetClipFunction(plane)
clip.SetValue(0)
# 创建一个映射器和渲染器
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(clip.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(0, 0, 0)
# 创建一个窗口并添加渲染器
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
# 创建一个窗口管理器
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# 开始渲染
renWin.Render()
iren.Start()