diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h index 3c3f37cfa5c..e69402c73fe 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h @@ -20,9 +20,15 @@ #include #include #include +#include +#include #include +#include +#include +#include + namespace CGAL::Polygon_mesh_processing { template ::const_type>(parameters::get_parameter(np, internal_np::point_map)); - using Point_3 = typename boost::property_traits::value_type; - using PointRange_const_iterator = typename PointRange::const_iterator; - using PointRange_value_type = typename std::iterator_traits::value_type; - auto to_point =[pm](const PointRange_value_type& v) { return get(pm, v); }; + using std::cbegin; + using std::cend; + using std::size; - std::vector unique_points(boost::make_transform_iterator(points.begin(), to_point), - boost::make_transform_iterator(points.end(), to_point)); + using Default_pm = typename GetPointMap::const_type; + auto pm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::point_map)); + using Point_3 = CGAL::cpp20::remove_cvref_t; + + //let's be a bit more permissive and allow duplicated vertices + auto to_point =[pm](const auto& v) { return get(pm, v); }; + auto first = boost::make_transform_iterator(cbegin(points), to_point); + auto last = boost::make_transform_iterator(cend(points), to_point); + + std::vector unique_points(first, last); merge_duplicate_points_in_polygon_soup(unique_points, polygons); - bool is_pure_triangles = std::all_of(polygons.begin(), polygons.end(), - [](const auto&f) { return f.size() == 3; }); + bool is_pure_triangles = std::all_of(CGAL_MAYBE_EXEC_POLICY(ConcurrencyTag) + cbegin(polygons), cend(polygons), + [](const auto&f) { return size(f) == 3; }); if(is_pure_triangles) { // if the polygon soup is pure triangles, @@ -55,15 +67,13 @@ bool does_polygon_soup_self_intersect(const PointRange& points, } // otherwise, we need to triangulate the polygons beforehand - using Polygon = CGAL::cpp20::remove_cvref_t; - using Id = typename std::iterator_traits::value_type; - auto to_std_vector = [](const Polygon& poly) - { - return std::vector(poly.begin(), poly.end()); - }; + using Id = CGAL::cpp20::remove_cvref_t; + using New_polygon_type = std::vector; - std::vector> triangles(boost::make_transform_iterator(polygons.begin(), to_std_vector), - boost::make_transform_iterator(polygons.end(), to_std_vector)); + auto to_std_vector = [](const auto& poly) { return New_polygon_type{cbegin(poly), cend(poly)}; }; + + std::vector triangles(boost::make_transform_iterator(cbegin(polygons), to_std_vector), + boost::make_transform_iterator(cend(polygons), to_std_vector)); bool OK = triangulate_polygons(points, triangles, np); if (!OK) return false;