diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_cleaning_plugin.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_cleaning_plugin.cpp index 9d49bc8f116..eaf567abc91 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_cleaning_plugin.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_cleaning_plugin.cpp @@ -80,6 +80,9 @@ void Point_set_demo_cleaning_plugin::on_actionOutlierRemoval_triggered() removed_percentage), points->end()); + // Scott Meyer's "swap trick" to trim excess capacity + Point_set(points).swap(points); + points->invalidate_bounds(); if (areOriented) points->unoriented_points_begin() = points->end(); diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_normal_estimation_plugin.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_normal_estimation_plugin.cpp index f7821c71e37..53bf4b5d832 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_normal_estimation_plugin.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_demo/Point_set_demo_normal_estimation_plugin.cpp @@ -122,11 +122,18 @@ void Point_set_demo_normal_estimation_plugin::on_actionNormalEstimation_triggere // mst_orient_normals() requires an iterator over points // + property maps to access each point's index, position and normal. - CGAL::mst_orient_normals(points->begin(), points->end(), - CGAL::make_dereference_property_map(points->begin()), - CGAL::make_normal_vector_property_map(points->begin()), - CGAL::make_index_property_map(*points), - dialog.orientationNbNeighbors()); + Point_set::iterator unoriented_points_begin = + CGAL::mst_orient_normals(points->begin(), points->end(), + CGAL::make_dereference_property_map(points->begin()), + CGAL::make_normal_vector_property_map(points->begin()), + CGAL::make_index_property_map(*points), + dialog.orientationNbNeighbors()); + + // Delete points with unoriented normals + points.erase(unoriented_points_begin, points.end()); + + // Optional: Scott Meyer's "swap trick" to trim excess capacity + Point_set(points).swap(points); long memory = CGAL::Memory_sizer().virtual_size(); std::cerr << "done: " << task_timer.time() << " seconds, "