From e99f4428303c82b66a5e93979991081e45c40588 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 25 Oct 2022 11:59:59 +0200 Subject: [PATCH 01/13] NP_helper::has_normal_map should not always return true look for a normal_map in the point set, and in the named parameters # Conflicts: # BGL/include/CGAL/boost/graph/named_params_helper.h # Point_set_processing_3/include/CGAL/jet_estimate_normals.h --- .../CGAL/boost/graph/named_params_helper.h | 6 +++--- Point_set_3/include/CGAL/Point_set_3.h | 16 +++++++++++----- .../include/CGAL/IO/read_off_points.h | 7 +++---- .../include/CGAL/IO/read_ply_points.h | 9 +++------ .../include/CGAL/IO/read_xyz_points.h | 7 +++---- .../include/CGAL/IO/write_off_points.h | 2 +- .../include/CGAL/IO/write_ply_points.h | 2 +- .../include/CGAL/IO/write_xyz_points.h | 2 +- .../include/CGAL/bilateral_smooth_point_set.h | 2 +- .../include/CGAL/edge_aware_upsample_point_set.h | 2 +- .../include/CGAL/jet_estimate_normals.h | 2 +- .../include/CGAL/mst_orient_normals.h | 2 +- .../include/CGAL/pca_estimate_normals.h | 2 +- .../include/CGAL/scanline_orient_normals.h | 2 +- .../include/CGAL/structure_point_set.h | 2 +- .../include/CGAL/vcm_estimate_normals.h | 2 +- 16 files changed, 34 insertions(+), 33 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 4399e555143..e80cae78072 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -336,10 +336,10 @@ struct Point_set_processing_3_np_helper return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map() + static constexpr bool has_normal_map(const PointRange&, const NamedParameters&) { - return !boost::is_same< typename internal_np::Get_param::type, - internal_np::Param_not_found> ::value; + using CGAL::parameters::is_default_parameter; + return !(is_default_parameter::value); } }; diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 74b731a0d31..66f86d0ed04 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -219,11 +219,9 @@ public: added. If `false` (default value), the normal map can still be added later on (see `add_normal_map()`). */ - Point_set_3 (bool with_normal_map = false) : m_base() + Point_set_3 () : m_base() { clear(); - if (with_normal_map) - add_normal_map(); } /*! @@ -1341,11 +1339,17 @@ struct Point_set_processing_3_np_helper, NamedParamet static const Normal_map get_normal_map(const Point_set_3& ps, const NamedParameters& np) { + CGAL_assertion_code( + if (!(parameters::is_default_parameter::value))) + CGAL_assertion(!!ps.normal_map()); return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map), ps.normal_map()); } static Normal_map get_normal_map(Point_set_3& ps, const NamedParameters& np) { + CGAL_assertion_code( + if (!(parameters::is_default_parameter::value))) + CGAL_assertion(!!ps.normal_map()); return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map), ps.normal_map()); } @@ -1354,9 +1358,11 @@ struct Point_set_processing_3_np_helper, NamedParamet return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map() + static constexpr bool has_normal_map(const Point_set_3& ps, const NamedParameters& np) { - return true; + using CGAL::parameters::is_default_parameter; + const bool np_has_normals = !(is_default_parameter::value); + return np_has_normals || !!ps.normal_map(); } }; diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index 783fd20c1fc..7ef015cc018 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -98,8 +98,8 @@ bool read_OFF(std::istream& is, typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - bool has_normals = NP_helper::has_normal_map(); - + //the default value for normal map, if not provided in the np, + // is a dummy Constant_property_map PointMap point_map = NP_helper::get_point_map(np); NormalMap normal_map = NP_helper::get_normal_map(np); @@ -183,8 +183,7 @@ bool read_OFF(std::istream& is, Enriched_point pwn; put(point_map, pwn, point); // point_map[&pwn] = point - if (has_normals) - put(normal_map, pwn, normal); // normal_map[&pwn] = normal + put(normal_map, pwn, normal); // normal_map[&pwn] = normal *output++ = pwn; ++pointsRead; diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index 1a0f7ed547b..5a38b4fd034 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -258,17 +258,14 @@ bool read_PLY(std::istream& is, typedef typename NP_helper::Point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(); - + //the default value for normal map, if not provided in the np, + // is a dummy Constant_property_map PointMap point_map = NP_helper::get_point_map(np); NormalMap normal_map = NP_helper::get_normal_map(np); - if(has_normals) - return read_PLY_with_properties(is, output, + return read_PLY_with_properties(is, output, make_ply_point_reader(point_map), make_ply_normal_reader(normal_map)); - // else - return read_PLY_with_properties(is, output, make_ply_point_reader(point_map)); } /** diff --git a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h index 793c7e2e85f..d2a7f178992 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h @@ -90,8 +90,8 @@ bool read_XYZ(std::istream& is, typedef typename NP_helper::Normal_map NormalMap; typedef typename NP_helper::Geom_traits Kernel; - bool has_normals = NP_helper::has_normal_map(); - + //the default value for normal map, if not provided in the np, + // is a dummy Constant_property_map PointMap point_map = NP_helper::get_point_map(np); NormalMap normal_map = NP_helper::get_normal_map(np); @@ -156,8 +156,7 @@ bool read_XYZ(std::istream& is, Enriched_point pwn; put(point_map, pwn, point); // point_map[pwn] = point - if (has_normals) - put(normal_map, pwn, normal); // normal_map[pwn] = normal + put(normal_map, pwn, normal); // normal_map[pwn] = normal *output++ = pwn; continue; diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index f89ca2a28c0..2fb38456379 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -46,7 +46,7 @@ bool write_OFF_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - const bool has_normals = !(is_default_parameter::value); + bool has_normals = NP_helper::has_normal_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index 38b361ff779..d151871a541 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -201,7 +201,7 @@ bool write_PLY(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(); + bool has_normals = NP_helper::has_normal_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index 73610c9545f..b98ebb247df 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -47,7 +47,7 @@ bool write_XYZ_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(); + bool has_normals = NP_helper::has_normal_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index 86fa5d23b19..5c1d2d7cf25 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -278,7 +278,7 @@ bilateral_smooth_point_set( typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Vector_3 Vector_3; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); typedef typename Kernel::FT FT; diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 507418d45b8..7bcb43eaf8f 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -367,7 +367,7 @@ edge_aware_upsample_point_set( typedef typename NP_helper::Geom_traits Kernel; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index da74d6e93ee..092c479c53d 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -196,7 +196,7 @@ jet_estimate_normals( typedef typename Kernel::FT FT; typedef typename GetSvdTraits::type SvdTraits; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); CGAL_static_assertion_msg(!(boost::is_same::NoTraits>::value), "Error: no SVD traits"); diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index 909dc37a63d..18be66609e5 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -631,7 +631,7 @@ mst_orient_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetIsConstrainedMap::type ConstrainedMap; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 8447ae952ff..9c4f5cde3e6 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -168,7 +168,7 @@ pca_estimate_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h index 02f956f2416..272ce021158 100644 --- a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h @@ -478,7 +478,7 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np = pa ::type; using Fallback_scanline_ID = Boolean_tag::value>; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); 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 f0a9fc34c86..5930d4b08f0 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -234,7 +234,7 @@ public: typedef typename Point_set_processing_3::GetPlaneMap::type PlaneMap; typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); CGAL_static_assertion_msg((!is_default_parameter::value), "Error: no plane index map"); diff --git a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h index 5b69f3ef0f9..de0c26d68f6 100644 --- a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h @@ -321,7 +321,7 @@ vcm_estimate_normals_internal (PointRange& points, typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); From 0ee5493f02101f802f400dabff6feee3a024fe52 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 25 Oct 2022 12:53:39 +0200 Subject: [PATCH 02/13] revert unintended change --- Point_set_3/include/CGAL/Point_set_3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 66f86d0ed04..dbf00b0182b 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -219,9 +219,11 @@ public: added. If `false` (default value), the normal map can still be added later on (see `add_normal_map()`). */ - Point_set_3 () : m_base() + Point_set_3 (bool with_normal_map = false) : m_base() { clear(); + if (with_normal_map) + add_normal_map(); } /*! From dcf0ea09b32204bd6bc17c5f69c699bb60658536 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Nov 2022 14:12:52 +0100 Subject: [PATCH 03/13] create normal_map when not already created before usage --- Point_set_3/include/CGAL/Point_set_3.h | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index dbf00b0182b..a02ea9509bd 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -465,8 +465,8 @@ public: \note Properties of the added point other than its normal vector are initialized to their default value. - \note A normal property must have been added to the point set - before using this method. + \note If not already added, a normal property is automatically + added to the point set when using this method. \note If a reallocation happens, all iterators, pointers and references related to the container are invalidated. Otherwise, @@ -479,8 +479,7 @@ public: iterator insert (const Point& p, const Vector& n) { iterator out = insert (p); - CGAL_assertion(has_normal_map()); - m_normals[size()-1] = n; + normal_map()[size()-1] = n; return out; } @@ -550,17 +549,17 @@ public: /*! \brief returns a reference to the normal corresponding to `index`. - \note The normal property must have been added to the point set - before calling this method (see `add_normal_map()`). + \note If not already added, a normal property is automatically + added to the point set (see `add_normal_map()`). */ - Vector& normal (const Index& index) { return m_normals[index]; } + Vector& normal (const Index& index) { return normal_map()[index]; } /*! \brief returns a constant reference to the normal corresponding to `index`. - \note The normal property must have been added to the point set - before calling this method (see `add_normal_map()`). + \note If not already added, a normal property is automatically + added to the point set (see `add_normal_map()`). */ - const Vector& normal (const Index& index) const { return m_normals[index]; } + const Vector& normal (const Index& index) const { return normal_map()[index]; } /// @} @@ -869,11 +868,14 @@ public: /*! \brief returns the property map of the normal property. - \note The normal property must have been added to the point set - before calling this method (see `add_normal_map()`). + \note If the normal property has not been added yet to the point set + before calling this method, the property map is automatically added + with `add_normal_map()`. */ Vector_map normal_map () { + if (!m_normals) + add_normal_map(); return m_normals; } /*! @@ -982,7 +984,7 @@ public: inline parameters() const { return CGAL::parameters::point_map (m_points). - normal_map (m_normals). + normal_map (normal_map()). geom_traits (typename Kernel_traits::Kernel()); } @@ -1036,7 +1038,7 @@ public: */ Vector_range normals () const { - return this->range (m_normals); + return this->range (normal_map()); } /// @} From 9ed334bcf9c0178205c0099159aa2364eb6f2294 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Nov 2022 14:27:09 +0100 Subject: [PATCH 04/13] now normal_map is always valid since it is created before it's used, when not available --- Point_set_3/include/CGAL/Point_set_3.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index a02ea9509bd..55d2f5bfa5a 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -1343,17 +1343,11 @@ struct Point_set_processing_3_np_helper, NamedParamet static const Normal_map get_normal_map(const Point_set_3& ps, const NamedParameters& np) { - CGAL_assertion_code( - if (!(parameters::is_default_parameter::value))) - CGAL_assertion(!!ps.normal_map()); return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map), ps.normal_map()); } static Normal_map get_normal_map(Point_set_3& ps, const NamedParameters& np) { - CGAL_assertion_code( - if (!(parameters::is_default_parameter::value))) - CGAL_assertion(!!ps.normal_map()); return parameters::choose_parameter(parameters::get_parameter(np, internal_np::normal_map), ps.normal_map()); } @@ -1362,11 +1356,9 @@ struct Point_set_processing_3_np_helper, NamedParamet return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map(const Point_set_3& ps, const NamedParameters& np) + static constexpr bool has_normal_map(const Point_set_3&, const NamedParameters&) { - using CGAL::parameters::is_default_parameter; - const bool np_has_normals = !(is_default_parameter::value); - return np_has_normals || !!ps.normal_map(); + return true;//either available in np, or in point set } }; From 1a226ed87705c4ae0cabc664dc74020ede52e8ca Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Mon, 7 Nov 2022 10:41:22 +0100 Subject: [PATCH 05/13] Restore [revious API --- BGL/include/CGAL/boost/graph/named_params_helper.h | 2 +- Point_set_3/include/CGAL/Point_set_3.h | 2 +- Point_set_processing_3/include/CGAL/IO/write_off_points.h | 2 +- Point_set_processing_3/include/CGAL/IO/write_ply_points.h | 2 +- Point_set_processing_3/include/CGAL/IO/write_xyz_points.h | 2 +- .../include/CGAL/bilateral_smooth_point_set.h | 2 +- .../include/CGAL/edge_aware_upsample_point_set.h | 2 +- Point_set_processing_3/include/CGAL/jet_estimate_normals.h | 2 +- Point_set_processing_3/include/CGAL/mst_orient_normals.h | 2 +- Point_set_processing_3/include/CGAL/pca_estimate_normals.h | 2 +- Point_set_processing_3/include/CGAL/scanline_orient_normals.h | 2 +- Point_set_processing_3/include/CGAL/structure_point_set.h | 2 +- Point_set_processing_3/include/CGAL/vcm_estimate_normals.h | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index e80cae78072..948de5dded6 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -336,7 +336,7 @@ struct Point_set_processing_3_np_helper return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map(const PointRange&, const NamedParameters&) + static constexpr bool has_normal_map() { using CGAL::parameters::is_default_parameter; return !(is_default_parameter::value); diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 55d2f5bfa5a..6ca6be884d5 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -1356,7 +1356,7 @@ struct Point_set_processing_3_np_helper, NamedParamet return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map(const Point_set_3&, const NamedParameters&) + static constexpr bool has_normal_map() { return true;//either available in np, or in point set } diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index 2fb38456379..a3435090bb8 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -46,7 +46,7 @@ bool write_OFF_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(points, np); + bool has_normals = NP_helper::has_normal_map(); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index d151871a541..faad40b8f9a 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -201,7 +201,7 @@ bool write_PLY(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(points, np); + bool has_normals = NP_helper::has_normal_map(np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index b98ebb247df..73610c9545f 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -47,7 +47,7 @@ bool write_XYZ_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(points, np); + bool has_normals = NP_helper::has_normal_map(); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index 5c1d2d7cf25..91147a5a6e5 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -278,7 +278,7 @@ bilateral_smooth_point_set( typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Vector_3 Vector_3; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); typedef typename Kernel::FT FT; diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 7bcb43eaf8f..eaafa1251eb 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -367,7 +367,7 @@ edge_aware_upsample_point_set( typedef typename NP_helper::Geom_traits Kernel; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index 092c479c53d..91b29879d1a 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -196,7 +196,7 @@ jet_estimate_normals( typedef typename Kernel::FT FT; typedef typename GetSvdTraits::type SvdTraits; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); CGAL_static_assertion_msg(!(boost::is_same::NoTraits>::value), "Error: no SVD traits"); diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index 18be66609e5..ff81bcb6305 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -631,7 +631,7 @@ mst_orient_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetIsConstrainedMap::type ConstrainedMap; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 9c4f5cde3e6..64a7a99dec0 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -168,7 +168,7 @@ pca_estimate_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h index 272ce021158..a1a8bdf5f8d 100644 --- a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h @@ -478,7 +478,7 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np = pa ::type; using Fallback_scanline_ID = Boolean_tag::value>; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); 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 5930d4b08f0..72785255714 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -234,7 +234,7 @@ public: typedef typename Point_set_processing_3::GetPlaneMap::type PlaneMap; typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); CGAL_static_assertion_msg((!is_default_parameter::value), "Error: no plane index map"); diff --git a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h index de0c26d68f6..afe5c3a2535 100644 --- a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h @@ -321,7 +321,7 @@ vcm_estimate_normals_internal (PointRange& points, typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; - CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); From 04e4eec6fdbf91efcc1af3b9f778e024fe986610 Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Mon, 7 Nov 2022 10:44:02 +0100 Subject: [PATCH 06/13] reuse static assertions --- Point_set_processing_3/include/CGAL/IO/write_ply_points.h | 2 +- .../include/CGAL/bilateral_smooth_point_set.h | 2 +- .../include/CGAL/edge_aware_upsample_point_set.h | 2 +- Point_set_processing_3/include/CGAL/jet_estimate_normals.h | 2 +- Point_set_processing_3/include/CGAL/mst_orient_normals.h | 2 +- Point_set_processing_3/include/CGAL/pca_estimate_normals.h | 2 +- Point_set_processing_3/include/CGAL/scanline_orient_normals.h | 2 +- Point_set_processing_3/include/CGAL/structure_point_set.h | 2 +- Point_set_processing_3/include/CGAL/vcm_estimate_normals.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index faad40b8f9a..38b361ff779 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -201,7 +201,7 @@ bool write_PLY(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(np); + bool has_normals = NP_helper::has_normal_map(); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index 91147a5a6e5..86fa5d23b19 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -278,7 +278,7 @@ bilateral_smooth_point_set( typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Vector_3 Vector_3; - CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); typedef typename Kernel::FT FT; diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index eaafa1251eb..507418d45b8 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -367,7 +367,7 @@ edge_aware_upsample_point_set( typedef typename NP_helper::Geom_traits Kernel; - CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index 91b29879d1a..da74d6e93ee 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -196,7 +196,7 @@ jet_estimate_normals( typedef typename Kernel::FT FT; typedef typename GetSvdTraits::type SvdTraits; - CGAL_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::NoTraits>::value), "Error: no SVD traits"); diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index ff81bcb6305..909dc37a63d 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -631,7 +631,7 @@ mst_orient_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetIsConstrainedMap::type ConstrainedMap; - CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 64a7a99dec0..8447ae952ff 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -168,7 +168,7 @@ pca_estimate_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h index a1a8bdf5f8d..02f956f2416 100644 --- a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h @@ -478,7 +478,7 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np = pa ::type; using Fallback_scanline_ID = Boolean_tag::value>; - CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); 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 72785255714..f0a9fc34c86 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -234,7 +234,7 @@ public: typedef typename Point_set_processing_3::GetPlaneMap::type PlaneMap; typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; - CGAL_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((!is_default_parameter::value), "Error: no plane index map"); diff --git a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h index afe5c3a2535..5b69f3ef0f9 100644 --- a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h @@ -321,7 +321,7 @@ vcm_estimate_normals_internal (PointRange& points, typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; - CGAL_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); From a24c6ac84c90b966a3a33ea58f6a3678f67dea7b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 14:13:18 +0100 Subject: [PATCH 07/13] Apply suggestions from Mael's code review Co-authored-by: Mael --- Point_set_3/include/CGAL/Point_set_3.h | 2 +- Point_set_processing_3/include/CGAL/IO/read_ply_points.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 6ca6be884d5..76f261949ad 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -1358,7 +1358,7 @@ struct Point_set_processing_3_np_helper, NamedParamet static constexpr bool has_normal_map() { - return true;//either available in np, or in point set + return true; // either available in named parameters, and always available in Point_set_3 otherwise } }; diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index 5a38b4fd034..e52a2758f0f 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -264,8 +264,8 @@ bool read_PLY(std::istream& is, NormalMap normal_map = NP_helper::get_normal_map(np); return read_PLY_with_properties(is, output, - make_ply_point_reader(point_map), - make_ply_normal_reader(normal_map)); + make_ply_point_reader(point_map), + make_ply_normal_reader(normal_map)); } /** From 6555faf73f3b2b7dbf0ca81c5802ef9f7625ee17 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 14:14:16 +0100 Subject: [PATCH 08/13] this is only for ranges, not for Point_set_3 --- Point_set_processing_3/include/CGAL/IO/read_off_points.h | 2 -- Point_set_processing_3/include/CGAL/IO/read_ply_points.h | 2 -- Point_set_processing_3/include/CGAL/IO/read_xyz_points.h | 2 -- 3 files changed, 6 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index 7ef015cc018..01a7138eb5b 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -98,8 +98,6 @@ bool read_OFF(std::istream& is, typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - //the default value for normal map, if not provided in the np, - // is a dummy Constant_property_map PointMap point_map = NP_helper::get_point_map(np); NormalMap normal_map = NP_helper::get_normal_map(np); diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index 5a38b4fd034..dd780cc6436 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -258,8 +258,6 @@ bool read_PLY(std::istream& is, typedef typename NP_helper::Point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - //the default value for normal map, if not provided in the np, - // is a dummy Constant_property_map PointMap point_map = NP_helper::get_point_map(np); NormalMap normal_map = NP_helper::get_normal_map(np); diff --git a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h index d2a7f178992..29e48e25918 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h @@ -90,8 +90,6 @@ bool read_XYZ(std::istream& is, typedef typename NP_helper::Normal_map NormalMap; typedef typename NP_helper::Geom_traits Kernel; - //the default value for normal map, if not provided in the np, - // is a dummy Constant_property_map PointMap point_map = NP_helper::get_point_map(np); NormalMap normal_map = NP_helper::get_normal_map(np); From 32486e4be871aa2380e570e746912cf38c02b59d Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 14:14:30 +0100 Subject: [PATCH 09/13] precise default normal --- Point_set_3/include/CGAL/Point_set_3.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 55d2f5bfa5a..fc1da7fe601 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -466,7 +466,8 @@ public: are initialized to their default value. \note If not already added, a normal property is automatically - added to the point set when using this method. + added to the point set when using this method. The default value + for normal vectors is `CGAL::NULL_VECTOR`. \note If a reallocation happens, all iterators, pointers and references related to the container are invalidated. Otherwise, From 0a43b5ff7de697c25a7641878495f74f9c19e865 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Nov 2022 14:55:17 +0100 Subject: [PATCH 10/13] has_normals is const --- Point_set_processing_3/include/CGAL/IO/write_off_points.h | 2 +- Point_set_processing_3/include/CGAL/IO/write_ply_points.h | 2 +- Point_set_processing_3/include/CGAL/IO/write_xyz_points.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index a3435090bb8..379f4afd0bc 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -46,7 +46,7 @@ bool write_OFF_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(); + const bool has_normals = NP_helper::has_normal_map(); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index 38b361ff779..ae47bf501fd 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -201,7 +201,7 @@ bool write_PLY(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(); + const bool has_normals = NP_helper::has_normal_map(); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index 73610c9545f..06f77c4b419 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -47,7 +47,7 @@ bool write_XYZ_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - bool has_normals = NP_helper::has_normal_map(); + const bool has_normals = NP_helper::has_normal_map(); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); From 38fd07dfc45d36868771336da5600b8a1e0937b5 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 8 Nov 2022 10:24:43 +0100 Subject: [PATCH 11/13] differentiate has_normal_map() between const and non-const point set --- BGL/include/CGAL/boost/graph/named_params_helper.h | 2 +- Point_set_3/include/CGAL/Point_set_3.h | 11 +++++++++-- .../include/CGAL/IO/write_off_points.h | 2 +- .../include/CGAL/IO/write_ply_points.h | 2 +- .../include/CGAL/IO/write_xyz_points.h | 2 +- .../include/CGAL/bilateral_smooth_point_set.h | 2 +- .../include/CGAL/edge_aware_upsample_point_set.h | 2 +- .../include/CGAL/jet_estimate_normals.h | 2 +- .../include/CGAL/mst_orient_normals.h | 2 +- .../include/CGAL/pca_estimate_normals.h | 2 +- .../include/CGAL/scanline_orient_normals.h | 2 +- .../include/CGAL/structure_point_set.h | 2 +- .../include/CGAL/vcm_estimate_normals.h | 2 +- 13 files changed, 21 insertions(+), 14 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 948de5dded6..e80cae78072 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -336,7 +336,7 @@ struct Point_set_processing_3_np_helper return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map() + static constexpr bool has_normal_map(const PointRange&, const NamedParameters&) { using CGAL::parameters::is_default_parameter; return !(is_default_parameter::value); diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 539c75e7db6..5a833713161 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -1357,11 +1357,18 @@ struct Point_set_processing_3_np_helper, NamedParamet return parameters::choose_parameter(parameters::get_parameter(np, internal_np::geom_traits)); } - static constexpr bool has_normal_map() + static bool has_normal_map(const Point_set_3& ps, const NamedParameters&) + { + if (ps.has_normal_map()) + return true; + using CGAL::parameters::is_default_parameter; + return !(is_default_parameter::value); + } + + static constexpr bool has_normal_map(Point_set_3& ps, const NamedParameters&) { return true; // either available in named parameters, and always available in Point_set_3 otherwise } - }; /// \endcond diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index 379f4afd0bc..1ae7746e301 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -46,7 +46,7 @@ bool write_OFF_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - const bool has_normals = NP_helper::has_normal_map(); + const bool has_normals = NP_helper::has_normal_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index ae47bf501fd..897f1bbd089 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -201,7 +201,7 @@ bool write_PLY(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - const bool has_normals = NP_helper::has_normal_map(); + const bool has_normals = NP_helper::has_normal_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index 06f77c4b419..45b351d18f0 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -47,7 +47,7 @@ bool write_XYZ_PSP(std::ostream& os, typedef typename NP_helper::Const_point_map PointMap; typedef typename NP_helper::Normal_map NormalMap; - const bool has_normals = NP_helper::has_normal_map(); + const bool has_normals = NP_helper::has_normal_map(points, np); PointMap point_map = NP_helper::get_const_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h index 86fa5d23b19..5c1d2d7cf25 100644 --- a/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/bilateral_smooth_point_set.h @@ -278,7 +278,7 @@ bilateral_smooth_point_set( typedef typename Kernel::Point_3 Point_3; typedef typename Kernel::Vector_3 Vector_3; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); typedef typename Kernel::FT FT; diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 507418d45b8..5c6ab8f9139 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -367,7 +367,7 @@ edge_aware_upsample_point_set( typedef typename NP_helper::Geom_traits Kernel; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index da74d6e93ee..1bd1b57e0e9 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -196,7 +196,7 @@ jet_estimate_normals( typedef typename Kernel::FT FT; typedef typename GetSvdTraits::type SvdTraits; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); CGAL_static_assertion_msg(!(boost::is_same::NoTraits>::value), "Error: no SVD traits"); diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index 909dc37a63d..f5c366c6f7f 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -631,7 +631,7 @@ mst_orient_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetIsConstrainedMap::type ConstrainedMap; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 8447ae952ff..42718e38177 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -168,7 +168,7 @@ pca_estimate_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h index 02f956f2416..da232f97961 100644 --- a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h @@ -478,7 +478,7 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np = pa ::type; using Fallback_scanline_ID = Boolean_tag::value>; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); 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 f0a9fc34c86..e4054c0d11c 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -234,7 +234,7 @@ public: typedef typename Point_set_processing_3::GetPlaneMap::type PlaneMap; typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); CGAL_static_assertion_msg((!is_default_parameter::value), "Error: no plane index map"); diff --git a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h index 5b69f3ef0f9..689bb2df132 100644 --- a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h @@ -321,7 +321,7 @@ vcm_estimate_normals_internal (PointRange& points, typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; - CGAL_static_assertion_msg(NP_helper::has_normal_map(), "Error: no normal map"); + CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); From bccf3990f90d254c50889f643ce4e7cbae9de9f7 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 8 Nov 2022 10:51:46 +0100 Subject: [PATCH 12/13] fix compilation --- .../include/CGAL/edge_aware_upsample_point_set.h | 2 +- Point_set_processing_3/include/CGAL/jet_estimate_normals.h | 2 +- Point_set_processing_3/include/CGAL/mst_orient_normals.h | 2 +- Point_set_processing_3/include/CGAL/pca_estimate_normals.h | 2 +- Point_set_processing_3/include/CGAL/scanline_orient_normals.h | 2 +- Point_set_processing_3/include/CGAL/structure_point_set.h | 2 +- Point_set_processing_3/include/CGAL/vcm_estimate_normals.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h index 5c6ab8f9139..7bcb43eaf8f 100644 --- a/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h +++ b/Point_set_processing_3/include/CGAL/edge_aware_upsample_point_set.h @@ -367,7 +367,7 @@ edge_aware_upsample_point_set( typedef typename NP_helper::Geom_traits Kernel; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index 1bd1b57e0e9..092c479c53d 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -196,7 +196,7 @@ jet_estimate_normals( typedef typename Kernel::FT FT; typedef typename GetSvdTraits::type SvdTraits; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); CGAL_static_assertion_msg(!(boost::is_same::NoTraits>::value), "Error: no SVD traits"); diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index f5c366c6f7f..18be66609e5 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -631,7 +631,7 @@ mst_orient_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Point_set_processing_3::GetIsConstrainedMap::type ConstrainedMap; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 42718e38177..9c4f5cde3e6 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -168,7 +168,7 @@ pca_estimate_normals( typedef typename NP_helper::Geom_traits Kernel; typedef typename Kernel::FT FT; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); diff --git a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h index da232f97961..272ce021158 100644 --- a/Point_set_processing_3/include/CGAL/scanline_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/scanline_orient_normals.h @@ -478,7 +478,7 @@ void scanline_orient_normals (PointRange& points, const NamedParameters& np = pa ::type; using Fallback_scanline_ID = Boolean_tag::value>; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); 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 e4054c0d11c..5930d4b08f0 100644 --- a/Point_set_processing_3/include/CGAL/structure_point_set.h +++ b/Point_set_processing_3/include/CGAL/structure_point_set.h @@ -234,7 +234,7 @@ public: typedef typename Point_set_processing_3::GetPlaneMap::type PlaneMap; typedef typename Point_set_processing_3::GetPlaneIndexMap::type PlaneIndexMap; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); CGAL_static_assertion_msg((!is_default_parameter::value), "Error: no plane index map"); diff --git a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h index 689bb2df132..de0c26d68f6 100644 --- a/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/vcm_estimate_normals.h @@ -321,7 +321,7 @@ vcm_estimate_normals_internal (PointRange& points, typedef typename NP_helper::Geom_traits Kernel; typedef typename GetDiagonalizeTraits::type DiagonalizeTraits; - CGAL_assertion(NP_helper::has_normal_map(points, np), "Error: no normal map"); + CGAL_assertion_msg(NP_helper::has_normal_map(points, np), "Error: no normal map"); PointMap point_map = NP_helper::get_point_map(points, np); NormalMap normal_map = NP_helper::get_normal_map(points, np); From 0fb05d14800de6db73b5d6f0bdf2170fa19c407c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 15 Nov 2022 20:04:23 +0100 Subject: [PATCH 13/13] fix warning --- Point_set_3/include/CGAL/Point_set_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index 5a833713161..c9e6ba4f0ba 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -1365,7 +1365,7 @@ struct Point_set_processing_3_np_helper, NamedParamet return !(is_default_parameter::value); } - static constexpr bool has_normal_map(Point_set_3& ps, const NamedParameters&) + static constexpr bool has_normal_map(Point_set_3&, const NamedParameters&) { return true; // either available in named parameters, and always available in Point_set_3 otherwise }