Hello,
I have a question about vtkPolyDataConnectivityFilter with SetExtractionModeToSpecifiedRegions . It does it well if I only get one region with label 0 or 1. But if I already specified one, the other returns both labels.
vtkSmartPointer<vtkPolyDataConnectivityFilter>
GetConnectedComponents(vtkSmartPointer<vtkPolyData> pol) {
vtkNew<vtkPolyDataConnectivityFilter> result;
result->SetInputData(pol);
result->SetExtractionModeToAllRegions();
result->Modified();
result->Update();
return result;
}
vtkSmartPointer<vtkPolyDataConnectivityFilter> components_alongX =
GetConnectedComponents(polydata);
if (components_alongX->GetNumberOfExtractedRegions() == 2) {
components_alongX->SetExtractionModeToSpecifiedRegions();
components_alongX->AddSpecifiedRegion(0);
components_alongX->Update();
cout << "Number of cells : " << components_alongX->GetOutput()-
>GetNumberOfCells() << "\n";
components_alongX->SetExtractionModeToSpecifiedRegions();
components_alongX->AddSpecifiedRegion(1);
components_alongX->Update();
cout << "Number of cells : " << components_alongX->GetOutput()-
>GetNumberOfCells() << "\n";
}
I have also tried like this. But it was still worse I got both components in both labels
components_alongX->InitializeSpecifiedRegionList();
components_alongX->AddSpecifiedRegion(1); //select the region to extract here
components_alongX->Update();
Someone had the same problem?. I am using vtk 8. Thanks !!