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);