From 0e2225d5c5b486b1a4e779271d38e2f886f2f404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 25 Oct 2021 10:42:33 +0200 Subject: [PATCH 1/2] Allow polygon soups to use std::array points in PM_to_PS --- .../polygon_mesh_to_polygon_soup.h | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h index e9c0f6ce302..99dcbcf4cd3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h @@ -26,8 +26,32 @@ #include #include +#include + namespace CGAL { namespace Polygon_mesh_processing { +namespace internal { + +template +struct PM_to_PS_point_converter +{ + PS_Point operator()(const PM_Point& p) const + { + CGAL_static_assertion((std::is_convertible::value)); + return PS_Point(p); + } +}; + +template +struct PM_to_PS_point_converter > +{ + std::array operator()(const PM_Point& p) const + { + return { p[0], p[1], p[2] }; + } +}; + +} // namespace internal /// \ingroup PMP_repairing_grp /// @@ -84,20 +108,24 @@ void polygon_mesh_to_polygon_soup(const PolygonMesh& mesh, typedef typename GetVertexPointMap::const_type VPM; VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(vertex_point, mesh)); + typedef typename boost::property_traits::value_type PM_Point; typedef CGAL::dynamic_vertex_property_t Vertex_index; typedef typename boost::property_map::const_type VIM; VIM vim = get(Vertex_index(), mesh); + typedef typename boost::range_value::type PS_Point; typedef typename boost::range_value::type Polygon; + internal::PM_to_PS_point_converter converter; + std::size_t index = points.size(); // so that multiple meshes can be put into the same soup CGAL::internal::reserve(points, points.size() + vertices(mesh).size()); CGAL::internal::reserve(polygons, polygons.size() + faces(mesh).size()); for(const vertex_descriptor v : vertices(mesh)) { - points.emplace_back(get(vpm, v)); + points.push_back(converter(get(vpm, v))); put(vim, v, index++); } From 00cd63f209e9cf46d25310ed9f37937a887787b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 25 Oct 2021 10:50:47 +0200 Subject: [PATCH 2/2] Add some includes for completeness --- .../CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h index 99dcbcf4cd3..96f71d89eaf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include +#include namespace CGAL { namespace Polygon_mesh_processing {