Memory issue corrected using Scott Meyer's "swap trick" to trim excess capacity

This commit is contained in:
Nader Salman 2009-06-02 10:51:06 +00:00
parent 31afd00f94
commit ceb1dd1014
2 changed files with 15 additions and 5 deletions

View File

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

View File

@ -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, "