有没有办法使用 vtk 从切割平面的 3D 坐标和相关数据(可以是倾斜的)获取 2D 图像?
这是我的代码片段,它读取结构化网格并设置剖切面:
self._reader = vtk.vtkXMLStructuredGridReader()
self._reader.SetFileName(filename)
self._reader.Update()
self._reader.GetOutput().GetPointData().SetActiveScalars("Intensity")
plane = vtk.vtkPlane()
plane.SetOrigin(self._reader.GetOutput().GetCenter())
plane.SetNormal(0, 0, 1)
planeCut = vtk.vtkCutter()
planeCut.SetInput(self._reader.GetOutput())
planeCut.SetCutFunction(plane)
# THIS GIVES THE 3D COORDINATES OF THE POINTS OF THE CUT PLANE
print planeCut.GetOutput().GetPoints()
# THIS GIVES THE DATA ASSOCIATED WITH EACH OF THE POINTS
planeCut.GetOutput().GetPointData().GetAttribute(0)
cutMapper = vtk.vtkPolyDataMapper()
cutMapper.SetInputConnection(planeCut.GetOutputPort())
cutMapper.SetLookupTable(table)
cutMapper.SetScalarRange(0,100)
cutActor = vtk.vtkActor()
cutActor.SetMapper(cutMapper)
self._renderer.AddActor(cutActor)
self._iren.Render()
非常感谢您的帮助
埃里克