plane_index_map is not optional!

update doc + cleaner static assert
This commit is contained in:
Sébastien Loriot 2022-01-07 14:03:41 +01:00
parent 8d4e63bbe9
commit c8b0c157cc
4 changed files with 23 additions and 19 deletions

View File

@ -356,17 +356,24 @@ const T& choose_parameter(const T& t)
return 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; return true;
} }
template <class T> template <class T>
constexpr bool is_default_parameter(const T&) bool is_default_parameter(const T&)
{ {
return false; return false;
} }
template <class NP, class TAG>
constexpr bool is_default_parameter_static()
{
return std::is_same< typename internal_np::Get_param<typename NP::base, TAG>::type,
internal_np::Param_not_found> ::value;
}
} // end of parameters namespace } // end of parameters namespace
#ifndef CGAL_NO_DEPRECATED_CODE #ifndef CGAL_NO_DEPRECATED_CODE

View File

@ -406,7 +406,6 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits<Graph>::fa
{ {
typedef Constant_property_map<std::size_t, int> DummyPlaneIndexMap; typedef Constant_property_map<std::size_t, int> DummyPlaneIndexMap;
public: public:
typedef DummyPlaneIndexMap NoMap;
typedef typename internal_np::Lookup_named_param_def < typedef typename internal_np::Lookup_named_param_def <
internal_np::plane_index_t, internal_np::plane_index_t,
NamedParameters, NamedParameters,

View File

@ -165,7 +165,7 @@ public:
\param points input point range \param points input point range
\param planes input plane range. \param planes input plane range.
\param epsilon size parameter. \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 \cgalNamedParamsBegin
\cgalParamNBegin{point_map} \cgalParamNBegin{point_map}
@ -185,7 +185,7 @@ public:
\cgalParamDescription{a property map associating the index of a point in the input range \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)} 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} \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 \cgalParamNEnd
\cgalParamNBegin{plane_map} \cgalParamNBegin{plane_map}
@ -204,11 +204,11 @@ public:
*/ */
template <typename PointRange, template <typename PointRange,
typename PlaneRange, typename PlaneRange,
typename NamedParameters = parameters::Default_named_parameters> typename NamedParameters>
Point_set_with_structure (const PointRange& points, Point_set_with_structure (const PointRange& points,
const PlaneRange& planes, const PlaneRange& planes,
double epsilon, double epsilon,
const NamedParameters& np = parameters::use_default_values()) const NamedParameters& np)
{ {
init (points, planes, epsilon, np); init (points, planes, epsilon, np);
} }
@ -225,6 +225,7 @@ public:
{ {
using parameters::choose_parameter; using parameters::choose_parameter;
using parameters::get_parameter; using parameters::get_parameter;
using parameters::is_default_parameter_static;
// basic geometric types // basic geometric types
typedef Point_set_processing_3_np_helper<PointRange, NamedParameters> NP_helper; typedef Point_set_processing_3_np_helper<PointRange, NamedParameters> NP_helper;
@ -234,8 +235,7 @@ public:
typedef typename Point_set_processing_3::GetPlaneIndexMap<NamedParameters>::type PlaneIndexMap; typedef typename Point_set_processing_3::GetPlaneIndexMap<NamedParameters>::type PlaneIndexMap;
CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map");
CGAL_static_assertion_msg(!(boost::is_same<PlaneIndexMap, CGAL_static_assertion_msg((!is_default_parameter_static<NamedParameters, internal_np::plane_index_t>()),
typename Point_set_processing_3::GetPlaneIndexMap<NamedParameters>::NoMap>::value),
"Error: no plane index map"); "Error: no plane index map");
PointMap point_map = NP_helper::get_const_point_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np);

View File

@ -292,13 +292,13 @@ namespace Planes {
using parameters::get_parameter; using parameters::get_parameter;
using parameters::choose_parameter; using parameters::choose_parameter;
using parameters::is_default_parameter_static;
using PlaneIndexMap = typename CGAL::Point_set_processing_3:: using PlaneIndexMap = typename CGAL::Point_set_processing_3::
GetPlaneIndexMap<NamedParameters>::type; GetPlaneIndexMap<NamedParameters>::type;
CGAL_static_assertion_msg( CGAL_static_assertion_msg((!is_default_parameter_static<NamedParameters, internal_np::plane_index_t>()),
!(boost::is_same<PlaneIndexMap, "Error: no plane index map");
typename CGAL::Point_set_processing_3::GetPlaneIndexMap<NamedParameters>::NoMap>::value),
"Error: no index map found!");
const PlaneIndexMap index_map = const PlaneIndexMap index_map =
choose_parameter(get_parameter(np, internal_np::plane_index_map), PlaneIndexMap()); choose_parameter(get_parameter(np, internal_np::plane_index_map), PlaneIndexMap());
@ -376,9 +376,7 @@ namespace Planes {
for more details for more details
\param np \param np
an optional sequence of \ref bgl_namedparameters "Named Parameters" a sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below:
among the ones listed below; this parameter can be omitted,
the default values are then used
\cgalNamedParamsBegin \cgalNamedParamsBegin
\cgalParamNBegin{plane_map} \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 in the `points` range to the index of a plane in the `planes` range (-1 if
point is not assigned to a plane)} point is not assigned to a plane)}
\cgalParamType{a model of `ReadablePropertyMap` with `std::size_t` as key type and `int` as value type} \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 \cgalParamNEnd
\cgalParamNBegin{maximum_angle} \cgalParamNBegin{maximum_angle}
\cgalParamDescription{maximum allowed angle in degrees between plane normals used \cgalParamDescription{maximum allowed angle in degrees between plane normals used
@ -440,11 +438,11 @@ namespace Planes {
template< template<
typename PlaneRange, typename PlaneRange,
typename PointRange, typename PointRange,
typename NamedParameters = parameters::Default_named_parameters> typename NamedParameters>
void regularize_planes( void regularize_planes(
PlaneRange& planes, PlaneRange& planes,
const PointRange& points, const PointRange& points,
const NamedParameters& np = parameters::use_default_values()) { const NamedParameters& np) {
using parameters::get_parameter; using parameters::get_parameter;
using parameters::choose_parameter; using parameters::choose_parameter;