From 79aa6a755ae30d64eb2ce64d1059646d57331b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Mar 2020 18:47:46 +0100 Subject: [PATCH] Enable passing a mesh as output --- .../oriented_bounding_box.h | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h b/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h index 0ebf2b207cb..619412f142f 100644 --- a/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h +++ b/Optimal_bounding_box/include/CGAL/Optimal_bounding_box/oriented_bounding_box.h @@ -140,9 +140,9 @@ void compute_best_transformation(const PointRange& points, } // Following two functions are overloads to dispatch depending on return type -template +template void construct_oriented_bounding_box(const PointRange& points, - typename Traits::Aff_transformation_3& transformation, + CGAL::Aff_transformation_3& transformation, CGAL::Random& rng, const Traits& traits) { @@ -150,11 +150,14 @@ void construct_oriented_bounding_box(const PointRange& points, compute_best_transformation(points, transformation, inverse_transformation, rng, traits); } -template +template void construct_oriented_bounding_box(const PointRange& points, - std::array& obb_points, + Array& obb_points, CGAL::Random& rng, - const Traits& traits) + const Traits& traits, + typename boost::enable_if< + typename boost::has_range_iterator + >::type* = 0) { typename Traits::Aff_transformation_3 transformation, inverse_transformation; compute_best_transformation(points, transformation, inverse_transformation, rng, traits); @@ -162,6 +165,25 @@ void construct_oriented_bounding_box(const PointRange& points, construct_oriented_bounding_box(points, transformation, inverse_transformation, obb_points, traits); } +template +void construct_oriented_bounding_box(const PointRange& points, + PolygonMesh& pm, + CGAL::Random& rng, + const Traits& traits, + typename boost::disable_if< + typename boost::has_range_iterator + >::type* = 0) +{ + typename Traits::Aff_transformation_3 transformation, inverse_transformation; + compute_best_transformation(points, transformation, inverse_transformation, rng, traits); + + std::array obb_points; + construct_oriented_bounding_box(points, transformation, inverse_transformation, obb_points, traits); + + CGAL::make_hexahedron(obb_points[0], obb_points[1], obb_points[2], obb_points[3], + obb_points[4], obb_points[5], obb_points[6], obb_points[7], pm); +} + // Entry point, decide whether to compute the CH_3 or not template void construct_oriented_bounding_box(const PointRange& points, @@ -237,7 +259,8 @@ void construct_oriented_bounding_box(const PointRange& points, /// \tparam PointRange a model of `Range`. The value type may not be equal to the type `%Point_3` of the traits class /// if a point map is provided via named parameters (see below) to access points. /// \tparam Output either the type `Aff_transformation_3` of the traits class, -/// or `std::array` with `Point` being equivalent to the type `%Point_3` of the traits class +/// or `std::array` with `Point` being equivalent to the type `%Point_3` of the traits class, +/// or a model of `MutableFaceGraph` /// \tparam NamedParameters a sequence of \ref obb_namedparameters "Named Parameters" /// /// \param points the input range @@ -327,7 +350,8 @@ void oriented_bounding_box(const PointRange& points, /// /// \tparam PolygonMesh a model of `VertexListGraph` /// \tparam Output either the type `Aff_transformation_3` of the traits class, -/// or `std::array` with `Point` being equivalent to the type `%Point_3` of the traits class +/// or `std::array` with `Point` being equivalent to the type `%Point_3` of the traits class, +/// or a model of `MutableFaceGraph` /// \tparam NamedParameters a sequence of \ref obb_namedparameters "Named Parameters" /// /// \param pmesh the input mesh @@ -384,7 +408,7 @@ void oriented_bounding_box(const PolygonMesh& pmesh, /// Convenience overloads ///////////////////////////////////////////////////////////////////////////////////////////////// -template +template void oriented_bounding_box(const Input& in, Output& out) { return oriented_bounding_box(in, out, CGAL::parameters::all_default());