diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Point_inside_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Point_inside_polyhedron_plugin.cpp index 96364990da4..0829e2810f0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Point_inside_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Point_inside_polyhedron_plugin.cpp @@ -142,39 +142,27 @@ public Q_SLOTS: QString("Constructing with %1 items is done in %2 sec.").arg(inside_smesh_testers.size()).arg(timer.time())); timer.reset(); - std::size_t nb_query = 0, nb_selected = 0;// for print message - for(std::vector::iterator point_set_it = point_sets.begin(); - point_set_it != point_sets.end(); ++point_set_it) - { - Point_set* point_set = *point_set_it; - for (std::size_t pt = 0; - pt < point_set->size() - point_set->nb_selected_points(); - ++ pt, ++ nb_query) - { - bool selected = false; - Point_set::iterator point_it = point_set->begin() + pt; - if(! selected){ - // now the same for the smeshs - point_it = point_set->begin() + pt; - for (std::size_t i = 0; i < inside_smesh_testers.size(); ++i) + std::size_t nb_selected = 0; + for (Point_set* point_set : point_sets) + point_set->set_first_selected + (std::partition + (point_set->begin(), point_set->end(), + [&](const Point_set::Index& idx) -> bool + { + for (const Point_inside_smesh* tester : inside_smesh_testers) { - CGAL::Bounded_side res = (*inside_smesh_testers[i])(point_set->point(*point_it)); - - if( (inside && res == CGAL::ON_BOUNDED_SIDE) || - (on_boundary && res == CGAL::ON_BOUNDARY) || - (outside && res == CGAL::ON_UNBOUNDED_SIDE) ) - { - point_set->select(*point_it); ++nb_selected; - -- pt; // Selection replaces current point with unselected one - selected = true; - break;//loop on i - } + CGAL::Bounded_side res = (*tester)(point_set->point(idx)); + if ( (inside && res == CGAL::ON_BOUNDED_SIDE) || + (on_boundary && res == CGAL::ON_BOUNDARY) || + (outside && res == CGAL::ON_UNBOUNDED_SIDE) ) + { + ++ nb_selected; + return false; + } } - } - } // loop on points in point_set - }// loop on selected point sets + return true; + })); - print_message(QString("Querying with %1 points is done in %2 sec.").arg(nb_query).arg(timer.time())); print_message(QString("%1 points are selected. All Done!").arg(nb_selected)); // delete testers