refactoring

This commit is contained in:
Giovanni Fattori
2026-01-06 00:14:34 +01:00
parent f15b6f8086
commit bd6568d8dd
6 changed files with 1703 additions and 1032 deletions
+13 -1
View File
@@ -154,6 +154,18 @@ MarkerList LocalizationService::localize(
if (!labeled)
return result;
// VTK has changed over time whether "RegionId" is stored on cells or points.
// For stable per-region extraction we want it on *cells*.
vtkPolyData* labeledForThreshold = labeled;
vtkNew<vtkPointDataToCellData> p2c;
if (!labeled->GetCellData()->GetArray("RegionId") && labeled->GetPointData()->GetArray("RegionId"))
{
p2c->SetInputData(labeled);
p2c->PassPointDataOn();
p2c->Update();
labeledForThreshold = vtkPolyData::SafeDownCast(p2c->GetOutput());
}
const int nRegions = connectivity->GetNumberOfExtractedRegions();
if (nRegions <= 0)
return result;
@@ -168,7 +180,7 @@ MarkerList LocalizationService::localize(
onProgress(100.0 * static_cast<double>(regionId + 1) / static_cast<double>(nRegions));
vtkNew<vtkThreshold> th;
th->SetInputData(labeled);
th->SetInputData(labeledForThreshold);
th->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "RegionId");
th->SetLowerThreshold(regionId);
th->SetUpperThreshold(regionId);