操作
要将一组(无限)平面(用法线,点或平面方程表示)的边界绑定/剪切/切割到边界框/体积。
尝试
# `planes_data` (a Pandas dataframe containing centroid and normal vector for each plane)
planes = vtk.vtkPlaneCollection()
for centroid, normal in zip(planes_data.centroid.tolist(), planes_data.normal_vector.tolist()):
plane=vtk.vtkPlane()
plane.SetOrigin(centroid[0],centroid[1],centroid[2])
plane.SetNormal(normal[0],normal[1],normal[2])
planes.AddItem(plane)
# `bounds` is an array (2*3) containing min_XYZ and max_XYZ
bounding_box = vtk.vtkPlanesIntersection()
bounding_box.SetBounds(bounds[0,0],bounds[1,0],bounds[0,1],bounds[1,1],bounds[0,1],bounds[1,1])
clipper = vtk.vtkClipPolyData()
clipper.SetInputConnection(planes_vtk)
clipper.SetClipFunction(bounding_box)
clipper.GenerateClippedOutputOn()
# but apparently clipper requires different InputConnection
问题
我认为该功能可能是Python VTK中的功能,但是由于仅以示例(https://lorensen.github.io/VTKExamples/site/Python/)进行了说明,因此我无法弄清楚如何正确执行此操作。