From dacb2ffa045aa992e9a606fc81098729757814d9 Mon Sep 17 00:00:00 2001 From: papush! Date: Wed, 16 Mar 2022 13:00:49 +0100 Subject: [PATCH] iterate over surface points directly in the relaxation --- src/relaxation_filter.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/relaxation_filter.cc b/src/relaxation_filter.cc index 9ab596c..19bdf8f 100644 --- a/src/relaxation_filter.cc +++ b/src/relaxation_filter.cc @@ -25,16 +25,18 @@ vtkTypeBool RelaxationFilter::RequestData( newPoints->DeepCopy(output->GetPoints()); vtkNew neighborCells; vtkNew cellPoints; + vtkIdTypeArray *surfacePoints = vtkIdTypeArray::SafeDownCast( + output->GetFieldData()->GetArray("surface_points")); vtkIntArray *isSurface = vtkIntArray::SafeDownCast( output->GetPointData()->GetArray("isSurface")); std::set neighbors; output->BuildLinks(); double avg[3]; - for (vtkIdType i = 0; i < output->GetNumberOfPoints(); i++) { - if (!isSurface->GetValue(i)) continue; + for (vtkIdType i = 0; i < surfacePoints->GetNumberOfValues(); i++) { + vtkIdType id = surfacePoints->GetValue(i); - output->GetPointCells(i, neighborCells); + output->GetPointCells(id, neighborCells); if (neighborCells->GetNumberOfIds() != 0) { @@ -52,10 +54,7 @@ vtkTypeBool RelaxationFilter::RequestData( } cellPoints->Reset(); } - - if (neighbors.find(i) != neighbors.end()) { - neighbors.erase(neighbors.find(i)); - } + neighbors.erase(neighbors.find(id)); if (neighbors.size() != 0) { avg[0] = 0; avg[1] = 0; avg[2] = 0; for (const vtkIdType &j : neighbors) { @@ -64,7 +63,7 @@ vtkTypeBool RelaxationFilter::RequestData( vtkMath::Add(point, avg, avg); } vtkMath::MultiplyScalar(avg, 1. / neighbors.size()); - newPoints->SetPoint(i, avg); + newPoints->SetPoint(id, avg); } } neighborCells->Reset();