VTK vtkClipClosedSurface 针对 vtkPolyData surface 数据 裁剪闭合曲面形成闭合多边形数据

Part1: 简介

使用 vtkClipPolyData裁切后,切口是开放的,有时我们需要切口封闭,可以使用  vtkClipClosedSurface 切割完成的面会进行自动封闭;

vtkClipPolyData: vtk 鼠标截取数据 使用 vtkClipPolyData 裁剪删除选中的矩形区域_恋恋西风的博客-CSDN博客_vtkclippolydata

  vtkClipClosedSurface 将使用一组剪裁平面剪裁闭合的多边形曲面。它将通过在剪切输入数据的地方创建新的多边形面来生成新的闭合曲面。

Part2:

如:vtkClipPolyData

 vtkClipClosedSurface 裁切

下面使用三个面,裁切一个球的结果 ; 可以有多个面裁切

            vtkNew<vtkPlaneCollection> planes;
            planes->AddItem(clippingPlane);

            vtkNew<vtkClipClosedSurface> clipper;
       
            clipper->SetClippingPlanes(planes);

Part3: code

vtkSmartPointer<vtkPlane> clippingPlane = vtkSmartPointer<vtkPlane>::New();

	/*Clipping Plane Widget*/
	vtkSmartPointer<vtkPlaneWidget> m_pPlaneWidget = vtkSmartPointer<vtkPlaneWidget>::New();
	m_pPlaneWidget->SetInteractor(renderWindowInteractor);//与交互器关联
	m_pPlaneWidget->SetInputData(triangleFilter->GetOutput());//设置数据集,用于初始化平面,可以不设置
	m_pPlaneWidget->SetResolution(50);//即:设置网格数
	m_pPlaneWidget->GetPlaneProperty()->SetColor(.2, .8, 0.1);//设置颜色
	m_pPlaneWidget->GetPlaneProperty()->SetOpacity(0.5);//设置透明度
	m_pPlaneWidget->GetHandleProperty()->SetColor(0, .4, .7);//设置平面顶点颜色
	m_pPlaneWidget->GetHandleProperty()->SetLineWidth(1.5);//设置平面线宽
	m_pPlaneWidget->NormalToZAxisOn();//初始法线方向平行于Z轴
	m_pPlaneWidget->SetRepresentationToWireframe();//平面显示为网格属性
	m_pPlaneWidget->SetCenter(actor->GetCenter());//设置平面坐标
	m_pPlaneWidget->SetPlaceFactor(1.0);
	m_pPlaneWidget->PlaceWidget();//放置平面
	m_pPlaneWidget->On();//显示平面

    m_pPlaneWidget->GetPlane(clippingPlane);

    			vtkNew<vtkPlaneCollection> planes;
			planes->AddItem(clippingPlane);

			vtkNew<vtkClipClosedSurface> clipper;
			clipper->SetInputData(this->Data);
			clipper->SetClippingPlanes(planes);
			//clipper->SetActivePlaneId(2);
			clipper->SetScalarModeToColors();
			clipper->SetClipColor(colors->GetColor3d("Banana").GetData());
			clipper->SetBaseColor(colors->GetColor3d("Tomato").GetData());
			clipper->SetActivePlaneColor(colors->GetColor3d("SandyBrown").GetData());
			clipper->Update();

			this->Data->DeepCopy(clipper->GetOutput());

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

恋恋西风

up up up

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值