VTK-裁剪分割-不规则闭合圈选裁剪-vtkSelectPolyData类python

import vtk
colors = vtk.vtkNamedColors()

sphereSource = vtk.vtkSphereSource()
sphereSource.SetPhiResolution(10)
sphereSource.SetThetaResolution(10)
sphereSource.Update()

selectionPoints = vtk.vtkPoints()
selectionPoints.InsertPoint(0, 0, 0, 0)
selectionPoints.InsertPoint(1, 0.25, 0, 0)
selectionPoints.InsertPoint(2, 0.25, 0.25, 0)
selectionPoints.InsertPoint(3, 0, 0.25, 0)
selectionPoints.InsertPoint(4, 0.125, 0.125, 0)

loop = vtk.vtkImplicitSelectionLoop()
loop.SetLoop(selectionPoints)

clip = vtk.vtkClipPolyData()
clip.SetInputConnection(sphereSource.GetOutputPort());
clip.SetClipFunction(loop);
clip.SetValue(0.0);

clipMapper = vtk.vtkPolyDataMapper()
clipMapper.SetInputConnection(clip.GetOutputPort())
clipMapper.ScalarVisibilityOff()

backProp = vtk.vtkProperty()
backProp.SetColor(colors.GetColor3d("Tomato"))


clipActor = vtk.vtkLODActor()
clipActor.SetMapper(clipMapper);
clipActor.SetBackfaceProperty(backProp);
clipActor.GetProperty().SetColor(colors.GetColor3d("Banana"));
renderer = vtk.vtkRenderer()
renderWindow= vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
interactor=vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow);

renderer.AddActor(clipActor);
renderer.SetBackground(colors.GetColor3d("SlateGray"));
renderWindow.SetSize(500, 500);
renderWindow.SetWindowName("ImplicitSelectionLoop");
renderWindow.Render();
interactor.Start();

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值