43 vtkInformationVector **inputVector,
44 vtkInformationVector *outputVector) {
52 connectivityFilter->SetInputData(vtkDataSet::GetData(inputVector[0]));
53 connectivityFilter->SetExtractionModeToAllRegions();
54 connectivityFilter->ColorRegionsOn();
55 connectivityFilter->Update();
57 size_t const nRegions = connectivityFilter->GetNumberOfExtractedRegions();
59 this->
printErr(
"Unable to compute connected components.");
64 "Computing connected components (" + std::to_string(nRegions) +
")", 1,
68 this->
printMsg(
"Computing component sizes", 0, 0, threadNumber,
71 auto output = vtkDataSet::GetData(outputVector);
72 output->ShallowCopy(connectivityFilter->GetOutput());
74 size_t const nVertices = output->GetNumberOfPoints();
75 size_t const nCells = output->GetNumberOfCells();
78 output->GetPointData()->GetArray(
"RegionId"));
80 output->GetCellData()->GetArray(
"RegionId"));
82 if(!vertexIds || !cellIds) {
83 this->
printErr(
"Unable to retrieve vertex and cell Identifiers.");
91 std::vector<double> regionIdToVertexCountMap(nRegions, 0);
92#ifdef TTK_ENABLE_OPENMP
93#pragma omp parallel for num_threads(threadNumber)
95 for(
size_t i = 0; i < nVertices; i++) {
96 auto regionId = vertexIds[i];
98#ifdef TTK_ENABLE_OPENMP
99#pragma omp atomic update
101 regionIdToVertexCountMap[regionId]++;
105 std::vector<double> regionIdToCellCountMap(nRegions, 0);
106#ifdef TTK_ENABLE_OPENMP
107#pragma omp parallel for num_threads(threadNumber)
109 for(
size_t i = 0; i < nCells; i++) {
110 auto regionId = cellIds[i];
112#ifdef TTK_ENABLE_OPENMP
113#pragma omp atomic update
115 regionIdToCellCountMap[regionId]++;
121 vertexNumbers->SetNumberOfComponents(1);
122 vertexNumbers->SetNumberOfTuples(nVertices);
123 vertexNumbers->SetName(
"VertexNumber");
126#ifdef TTK_ENABLE_OPENMP
127#pragma omp parallel for num_threads(threadNumber)
129 for(
size_t i = 0; i < nVertices; i++) {
130 vertexNumbersData[i] = regionIdToVertexCountMap[vertexIds[i]];
133 output->GetPointData()->AddArray(vertexNumbers);
139 cellNumbers->SetNumberOfComponents(1);
140 cellNumbers->SetNumberOfTuples(nCells);
141 cellNumbers->SetName(
"CellNumber");
144#ifdef TTK_ENABLE_OPENMP
145#pragma omp parallel for num_threads(threadNumber)
147 for(
size_t i = 0; i < nCells; i++) {
148 cellNumbersData[i] = regionIdToCellCountMap[cellIds[i]];
151 output->GetCellData()->AddArray(cellNumbers);
155 "Computing component sizes", 1, t.
getElapsedTime(), threadNumber);
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)