From c8b0c157ccda8d39b1c26cdd1eefe95001181cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 7 Jan 2022 14:03:41 +0100 Subject: [PATCH] plane_index_map is not optional! update doc + cleaner static assert --- .../boost/graph/Named_function_parameters.h | 11 +++++++++-- .../CGAL/boost/graph/named_params_helper.h | 1 - .../include/CGAL/structure_point_set.h | 12 ++++++------ .../Shape_regularization/regularize_planes.h | 18 ++++++++---------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Named_function_parameters.h b/BGL/include/CGAL/boost/graph/Named_function_parameters.h index 4fcc2da2b09..735bf07c517 100644 --- a/BGL/include/CGAL/boost/graph/Named_function_parameters.h +++ b/BGL/include/CGAL/boost/graph/Named_function_parameters.h @@ -356,17 +356,24 @@ const T& choose_parameter(const T& t) return t; } -constexpr bool inline is_default_parameter(const internal_np::Param_not_found&) +bool inline is_default_parameter(const internal_np::Param_not_found&) { return true; } template -constexpr bool is_default_parameter(const T&) +bool is_default_parameter(const T&) { return false; } +template +constexpr bool is_default_parameter_static() +{ + return std::is_same< typename internal_np::Get_param::type, + internal_np::Param_not_found> ::value; +} + } // end of parameters namespace #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index e3515a9ba1b..03f3a7e982a 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -406,7 +406,6 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::fa { typedef Constant_property_map DummyPlaneIndexMap; public: - typedef DummyPlaneIndexMap NoMap; typedef typename internal_np::Lookup_named_param_def < internal_np::plane_index_t, NamedParameters, diff --git a/Point_set_processing_3/include/CGAL/structure_point_set.h b/Point_set_processing_3/include/CGAL/structure_point_set.h index 66b219f539f..0bf6873665f 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -165,7 +165,7 @@ public: \param points input point range \param planes input plane range. \param epsilon size parameter. - \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + \param np a sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below: \cgalNamedParamsBegin \cgalParamNBegin{point_map} @@ -185,7 +185,7 @@ public: \cgalParamDescription{a property map associating the index of a point in the input range to the index of plane (`-1` if the point is not assigned to a plane)} \cgalParamType{a class model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type} - \cgalParamDefault{unused} + \cgalParamDefault{There is no default, this parameters is mandatory} \cgalParamNEnd \cgalParamNBegin{plane_map} @@ -204,11 +204,11 @@ public: */ template + typename NamedParameters> Point_set_with_structure (const PointRange& points, const PlaneRange& planes, double epsilon, - const NamedParameters& np = parameters::use_default_values()) + const NamedParameters& np) { init (points, planes, epsilon, np); } @@ -225,6 +225,7 @@ public: { using parameters::choose_parameter; using parameters::get_parameter; + using parameters::is_default_parameter_static; // basic geometric types typedef Point_set_processing_3_np_helper NP_helper; @@ -234,8 +235,7 @@ public: typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); - CGAL_static_assertion_msg(!(boost::is_same::NoMap>::value), + CGAL_static_assertion_msg((!is_default_parameter_static()), "Error: no plane index map"); PointMap point_map = NP_helper::get_const_point_map(points, np); diff --git a/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h b/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h index 732835141a2..f78aee2b2ec 100644 --- a/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h +++ b/Shape_regularization/include/CGAL/Shape_regularization/regularize_planes.h @@ -292,13 +292,13 @@ namespace Planes { using parameters::get_parameter; using parameters::choose_parameter; + using parameters::is_default_parameter_static; using PlaneIndexMap = typename CGAL::Point_set_processing_3:: GetPlaneIndexMap::type; - CGAL_static_assertion_msg( - !(boost::is_same::NoMap>::value), - "Error: no index map found!"); + CGAL_static_assertion_msg((!is_default_parameter_static()), + "Error: no plane index map"); + const PlaneIndexMap index_map = choose_parameter(get_parameter(np, internal_np::plane_index_map), PlaneIndexMap()); @@ -376,9 +376,7 @@ namespace Planes { for more details \param np - an optional sequence of \ref bgl_namedparameters "Named Parameters" - among the ones listed below; this parameter can be omitted, - the default values are then used + a sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below: \cgalNamedParamsBegin \cgalParamNBegin{plane_map} @@ -396,7 +394,7 @@ namespace Planes { in the `points` range to the index of a plane in the `planes` range (-1 if point is not assigned to a plane)} \cgalParamType{a model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type} - \cgalParamDefault{`PlaneIndexMap()`} + \cgalParamDefault{There is no default, this parameters is mandatory} \cgalParamNEnd \cgalParamNBegin{maximum_angle} \cgalParamDescription{maximum allowed angle in degrees between plane normals used @@ -440,11 +438,11 @@ namespace Planes { template< typename PlaneRange, typename PointRange, - typename NamedParameters = parameters::Default_named_parameters> + typename NamedParameters> void regularize_planes( PlaneRange& planes, const PointRange& points, - const NamedParameters& np = parameters::use_default_values()) { + const NamedParameters& np) { using parameters::get_parameter; using parameters::choose_parameter;