vtkConnectivityFilter提取连通区域中的问题

  1. 直接使用vtkConnectivityFilter提取连通区域,渲染上没问题,但是打印出polydata中的点数,发现跟原始数据是一致的。

     for (int i = 0; i < numRegions; ++i)
     {
     	vtkSmartPointer<vtkConnectivityFilter> connectivityFilter = vtkSmartPointer<vtkConnectivityFilter>::New();
     	connectivityFilter->SetInputData(polyData);
     	connectivityFilter->SetExtractionModeToSpecifiedRegions();
     	connectivityFilter->InitializeSpecifiedRegionList();
     	connectivityFilter->AddSpecifiedRegion(i);
     	connectivityFilter->Update();
     	cout << connectivityFilter->GetOutput()->GetNumberOfPoints() << endl;
     }
    
  1. 正确的做法是后街一个vtkCleanPolyData过滤器

     for (int i = 0; i < numRegions; ++i)
    {
    	vtkSmartPointer<vtkConnectivityFilter> connectivityFilter = vtkSmartPointer<vtkConnectivityFilter>::New();
    	connectivityFilter->SetInputData(polyData);
    	connectivityFilter->SetExtractionModeToSpecifiedRegions();
    	connectivityFilter->InitializeSpecifiedRegionList();
    	connectivityFilter->AddSpecifiedRegion(i);
    	connectivityFilter->Update();
    	
    	// 使用vtkCleanPolyData删除孤立点
    	vtkSmartPointer<vtkCleanPolyData> cleanPolyData = vtkSmartPointer<vtkCleanPolyData>::New();
    	cleanPolyData->SetInputData(connectivityFilter->GetOutput());
    	cleanPolyData->Update();
    	
    	cout << cleanPolyData->GetOutput()->GetNumberOfPoints() << endl;
    }
    
相关推荐
无所谓จุ๊บ2 天前
VTK知识学习(10)- 渲染引擎
学习·vtk
无所谓จุ๊บ9 天前
VTK知识学习(6)-使用颜色
学习·vtk
巴普蒂斯塔3 个月前
VTK+Qt+Cmake+VS的环境搭建
qt·vtk·cmake
noravinsc3 个月前
vtk.vtkXMLUnstructuredGridReader() 读取很耗内存
python·vtk
stay hungry foolish4 个月前
PCL + Qt + Ribbon 风格(窗口自由组合) demo展示
c++·后端·spring cloud·ribbon·vtk·pcl
noravinsc5 个月前
paraview将raw数据转为vtk
python·vtk·raw
coco_1998_25 个月前
Ubuntu22.04 搭建 PCL 环境(VTK源码安装),PCL测试代码
linux·vtk·点云·pcl
hfmeet5 个月前
使用C++调用VTK库实现三维显示示例
c++·microsoft·vtk·三维显示
恋恋西风6 个月前
PolygonalSurfaceContourLineInterpolator 多边形交互器
vtk