赞
踩
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;
}
2. 正确的做法是后街一个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; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。