From 226ef2dc0a202eddb845755184d61e8b222cb2f8 Mon Sep 17 00:00:00 2001 From: papush! Date: Thu, 24 Mar 2022 13:48:18 +0100 Subject: [PATCH] remove dupes from surfacePoints list --- src/surface_points_filter.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/surface_points_filter.cc b/src/surface_points_filter.cc index 7d1358b..6b73428 100644 --- a/src/surface_points_filter.cc +++ b/src/surface_points_filter.cc @@ -10,6 +10,8 @@ #include #include +#include + vtkStandardNewMacro(SurfacePointsFilter); @@ -46,6 +48,7 @@ vtkTypeBool SurfacePointsFilter::RequestData( vtkNew neighborCells; vtkNew facePoints; + std::set surfacePointsSet; auto *it = input->NewCellIterator(); for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) { vtkIdList *cellPointIds = it->GetPointIds(); @@ -60,15 +63,19 @@ vtkTypeBool SurfacePointsFilter::RequestData( neighborCells); facePoints->Reset(); if (neighborCells->GetNumberOfIds() == 0) { - surfacePoints->InsertNextValue(idA); - surfacePoints->InsertNextValue(idB); - surfacePoints->InsertNextValue(idC); + surfacePointsSet.insert(idA); + surfacePointsSet.insert(idB); + surfacePointsSet.insert(idC); isSurface->SetValue(idA, 1); isSurface->SetValue(idB, 1); isSurface->SetValue(idC, 1); } } } + surfacePoints->Allocate(surfacePointsSet.size()); + for (const vtkIdType &id : surfacePointsSet) { + surfacePoints->InsertNextValue(id); + } output->GetPointData()->SetScalars(isSurface); output->GetFieldData()->AddArray(surfacePoints);