From c73da52cf49f1cef7bd10566fa619180ea2ecb0d Mon Sep 17 00:00:00 2001 From: ange-clement Date: Wed, 6 Sep 2023 10:41:31 +0200 Subject: [PATCH] Rework of Mesh_edge_criteria's constructor. Now using same principle as Mesh_facet_criteria. --- Mesh_3/include/CGAL/Mesh_edge_criteria_3.h | 155 +++++++-------------- 1 file changed, 51 insertions(+), 104 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h index a8226d69ba1..78095c19fc4 100644 --- a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h @@ -120,10 +120,12 @@ public: /// \name Creation /// @{ + /*! * Returns an object to serve as criteria for edges. * \param length_bound is an upper bound * for the length of the edges which are used to discretize the curves. + * It can be a functional or a constant. * \param min_length_bound is a desired lower bound * for the length of the edges which are used to discretize the curves. * Only edges that are longer than this bound will be refined. Using @@ -132,115 +134,20 @@ public: * It is not guaranteed to be exactly respected in the output mesh. * \param distance_bound is an upper bound for the distance from the * edge to the 1D feature. + * It can be a functional or a constant. * * Note that if one parameter is set to 0, then its corresponding criterion is ignored. */ - Mesh_edge_criteria_3(const FT& length_bound, + template < typename Sizing_field, typename Sizing_field2 = FT > + Mesh_edge_criteria_3(const Sizing_field& length_bound, const FT& min_length_bound = 0, - const FT& distance_bound = 0) - : p_size_(new Mesh_3::internal::Sizing_field_container< - Mesh_constant_domain_field_3 , - FT, - Point_3, - Index>(length_bound)) - , min_length_bound_(min_length_bound) - , distance_bound_(new Mesh_3::internal::Sizing_field_container< - Mesh_constant_domain_field_3 , - FT, - Point_3, - Index>(distance_bound)) - {} - - // Nb: SFINAE to avoid wrong matches with built-in numerical types - // as int. - /*! - * @tparam SizingField a model of `MeshDomainField_3` - * - * Returns an object to serve as criteria for edges. - * The behavior and semantic of the argument are the same - * as above, except that the `length_bound` - * parameter is a functional instead of a constant. - */ - template < typename SizingField > - Mesh_edge_criteria_3 - ( - const SizingField& length_bound, - const FT& min_length_bound = 0, - const FT& distance_bound = 0 -#ifndef DOXYGEN_RUNNING - , std::enable_if_t::value>* = 0 -#endif - ) - : min_length_bound_(min_length_bound) - , distance_bound_(new Mesh_3::internal::Sizing_field_container< - Mesh_constant_domain_field_3 , - FT, - Point_3, - Index>(distance_bound)) - { - p_size_ = new Mesh_3::internal::Sizing_field_container(length_bound); - } - - /*! - * @tparam DistanceField a model of `MeshDomainField_3` - * - * Returns an object to serve as criteria for edges. - * The behavior and semantic of the argument are the same - * as above, except that the `distance_bound` - * parameter is a functional instead of a constant. - */ - template < typename DistanceField > - Mesh_edge_criteria_3(const FT& length_bound, - const FT& min_length_bound = 0, - const DistanceField& distance_bound = 0 -#ifndef DOXYGEN_RUNNING - , std::enable_if_t::value>* = 0 -#endif - ) - : p_size_(new Mesh_3::internal::Sizing_field_container< - Mesh_constant_domain_field_3 , - FT, - Point_3, - Index>(length_bound)) - , min_length_bound_(min_length_bound) - { - distance_bound_ = new Mesh_3::internal::Sizing_field_container(distance_bound); - } - - /*! - * @tparam SizingField a model of `MeshDomainField_3` - * @tparam DistanceField a model of `MeshDomainField_3` - * - * Returns an object to serve as criteria for edges. - * The behavior and semantic of the argument are the same - * as above, except that the `distance_bound` and `length_bound` - * parameters are functional instead of a constant. - */ - template < typename SizingField, typename DistanceField> - Mesh_edge_criteria_3(const SizingField& length_bound, - const FT& min_length_bound = 0, - const DistanceField& distance_bound = 0 -#ifndef DOXYGEN_RUNNING - , std::enable_if_t::value>* = 0 - , std::enable_if_t::value>* = 0 -#endif - ) + const Sizing_field2& distance_bound = 0) : min_length_bound_(min_length_bound) { - p_size_ = new Mesh_3::internal::Sizing_field_container(length_bound); - distance_bound_ = new Mesh_3::internal::Sizing_field_container(distance_bound); + init_p_size(length_bound, + Mesh_3::Is_mesh_domain_field_3()); + init_distance_bound(distance_bound, + Mesh_3::Is_mesh_domain_field_3()); } /// @} @@ -249,13 +156,14 @@ public: Mesh_edge_criteria_3(const Self& rhs) : p_size_(rhs.p_size_->clone()) , min_length_bound_(rhs.min_length_bound_) - , distance_bound_(rhs.distance_bound_) + , distance_bound_(rhs.distance_bound_->clone()) {} /// Destructor ~Mesh_edge_criteria_3() { delete p_size_; + delete distance_bound_; } /// Returns size of tuple (p,dim,index) @@ -277,6 +185,44 @@ private: typedef Mesh_3::internal::Sizing_field_interface Sizing_field_interface; + void init_p_size(const FT& length_bound, Tag_false) + { + p_size_ = new Mesh_3::internal::Sizing_field_container< + Mesh_constant_domain_field_3 , + FT, + Point_3, + Index>(length_bound); + } + + template + void init_p_size(const Sizing_field& length_bound, Tag_true) + { + p_size_ = new Mesh_3::internal::Sizing_field_container< + Sizing_field, + FT, + Point_3, + Index>(length_bound); + } + + void init_distance_bound(const FT& distance_bound, Tag_false) + { + distance_bound_ = new Mesh_3::internal::Sizing_field_container< + Mesh_constant_domain_field_3 , + FT, + Point_3, + Index>(distance_bound); + } + + template + void init_distance_bound(const Sizing_field& distance_bound, Tag_true) + { + distance_bound_ = new Mesh_3::internal::Sizing_field_container< + Sizing_field, + FT, + Point_3, + Index>(distance_bound); + } + // A pointer to Sizing_field_interface to handle dynamic wrapping of // real Sizing_field type Sizing_field_interface* p_size_; @@ -284,6 +230,7 @@ private: Sizing_field_interface* distance_bound_; }; + } // end namespace CGAL #endif // CGAL_MESH_EDGE_CRITERIA_3_H