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+Qt+Cmake+VS的环境搭建
qt·vtk·cmake
noravinsc3 个月前
vtk.vtkXMLUnstructuredGridReader() 读取很耗内存
python·vtk
stay hungry foolish4 个月前
PCL + Qt + Ribbon 风格(窗口自由组合) demo展示
c++·后端·spring cloud·ribbon·vtk·pcl
noravinsc4 个月前
paraview将raw数据转为vtk
python·vtk·raw
coco_1998_24 个月前
Ubuntu22.04 搭建 PCL 环境(VTK源码安装),PCL测试代码
linux·vtk·点云·pcl
hfmeet5 个月前
使用C++调用VTK库实现三维显示示例
c++·microsoft·vtk·三维显示
恋恋西风5 个月前
PolygonalSurfaceContourLineInterpolator 多边形交互器
vtk
leaf_csdn6 个月前
VTK9.2.0+QT5.14.0绘制三维显示背景
开发语言·qt·vtk
信必诺6 个月前
VTK —— 二、教程七 - 对点云进行操作(按下r键切换选取或观察模式)(附完整源码)
c++·vtk·点云