diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index 6a99119535b..81eecb71be2 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -140,6 +140,7 @@ public: const MeshDomain& domain, SizingFunction size=SizingFunction(), const FT minimal_size = FT(), + const FT edge_distance = FT(), std::size_t maximal_number_of_vertices = 0, Mesh_error_code* error_code = 0 #ifndef CGAL_NO_ATOMIC @@ -255,6 +256,11 @@ private: /// an edge of the complex. bool non_adjacent_but_intersect(const Vertex_handle& va, const Vertex_handle& vb) const; + + /// Returns `true` if the edge `(va,vb)` is a not good enough approimation + /// of it's feature. + bool approx_is_too_large(const Vertex_handle& va, + const Vertex_handle& vb) const; /// Returns `true` if the balls of `va` and `vb` intersect. bool do_balls_intersect(const Vertex_handle& va, @@ -461,6 +467,7 @@ private: SizingFunction size_; FT minimal_size_; Weight minimal_weight_; + FT edge_distance_; std::set treated_edges_; Vertex_set unchecked_vertices_; int refine_balls_iteration_nb; @@ -478,6 +485,7 @@ template Protect_edges_sizing_field:: Protect_edges_sizing_field(C3T3& c3t3, const MD& domain, Sf size, const FT minimal_size, + const FT edge_distance, std::size_t maximal_number_of_vertices, Mesh_error_code* error_code #ifndef CGAL_NO_ATOMIC @@ -489,6 +497,7 @@ Protect_edges_sizing_field(C3T3& c3t3, const MD& domain, , size_(size) , minimal_size_(minimal_size) , minimal_weight_(CGAL::square(minimal_size)) + , edge_distance_(edge_distance) , refine_balls_iteration_nb(0) , nonlinear_growth_of_balls(false) , maximal_number_of_vertices_(maximal_number_of_vertices) @@ -1363,7 +1372,8 @@ refine_balls() const Vertex_handle& vb = eit->first->vertex(eit->third); // If those vertices are not adjacent - if( non_adjacent_but_intersect(va, vb) ) + if( non_adjacent_but_intersect(va, vb) + || approx_is_too_large(va, vb)) { using CGAL::Mesh_3::internal::distance_divisor; @@ -1470,6 +1480,15 @@ non_adjacent_but_intersect(const Vertex_handle& va, const Vertex_handle& vb) con return false; } +template +bool +Protect_edges_sizing_field:: +approx_is_too_large(const Vertex_handle& va, const Vertex_handle& vb) const +{ + // TODO + return false; +} + template bool diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 5358e813742..f54ca2f7ae5 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -73,7 +73,8 @@ public: :edge_criteria_(parameters::choose_parameter(parameters::get_parameter(np, internal_np::edge_size_param), parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::edge_sizing_field_param), parameters::choose_parameter(parameters::get_parameter(np, internal_np::sizing_field_param), FT(DBL_MAX)))), - parameters::choose_parameter(parameters::get_parameter(np, internal_np::edge_min_size_param), FT(0))), + parameters::choose_parameter(parameters::get_parameter(np, internal_np::edge_min_size_param), FT(0)), + parameters::choose_parameter(parameters::get_parameter(np, internal_np::edge_distance_param), FT(0))), facet_criteria_(parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_angle_param), FT(0)), parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_size_param), parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::facet_sizing_field_param), @@ -268,6 +269,10 @@ typedef Mesh_cell_criteria_3 Cell_criteria; * \cgalParamExtra{Note this lower-bound may not be respected everywhere in the output mesh, * to keep the feature graph valid.} * \cgalParamNEnd + * \cgalParamNBegin{edge_distance} + * \cgalParamDescription{a constant describing a upper bound for the distances between the + * edge and it's coresponding input feature.} + * \cgalParamNEnd * \cgalParamNBegin{facet_angle} * \cgalParamDescription{a lower bound for the angles (in degrees) of the * surface mesh facets.} diff --git a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h index 8846555dc6b..fbc56a7965d 100644 --- a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h @@ -130,17 +130,21 @@ public: * this lower bound can be handy on some domains, but using it may * break all the surface topology guarantees of the meshing algorithm. * It is not guaranteed to be exactly respected in the output mesh. + * \param distance_bound is an upper bound for the distances of the + * edge to the input feature. * * Note that if one parameter is set to 0, then its corresponding criterion is ignored. */ Mesh_edge_criteria_3(const FT& length_bound, - const FT& min_length_bound = 0) + 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_(distance_bound) {} // Nb: SFINAE to avoid wrong matches with built-in numerical types @@ -157,12 +161,14 @@ public: Mesh_edge_criteria_3 ( const SizingField& length_bound, - const FT& min_length_bound = 0 + 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_(distance_bound) { p_size_ = new Mesh_3::internal::Sizing_field_containerclone()) , min_length_bound_(rhs.min_length_bound_) + , distance_bound_(rhs.distance_bound_) {} /// Destructor @@ -193,6 +200,11 @@ public: { return min_length_bound_; } + + const FT& distance_bound() const + { + return distance_bound_; + } #endif private: @@ -203,6 +215,7 @@ private: // real Sizing_field type Sizing_field_interface* p_size_; const FT min_length_bound_; + const FT distance_bound_; }; } // end namespace CGAL diff --git a/Mesh_3/include/CGAL/make_mesh_3.h b/Mesh_3/include/CGAL/make_mesh_3.h index 79277f1643f..313787b2471 100644 --- a/Mesh_3/include/CGAL/make_mesh_3.h +++ b/Mesh_3/include/CGAL/make_mesh_3.h @@ -112,6 +112,7 @@ void init_c3t3_with_features(C3T3& c3t3, domain, Sizing_field(criteria.edge_criteria_object()), criteria.edge_criteria_object().min_length_bound(), + criteria.edge_criteria_object().distance_bound(), maximal_number_of_vertices, pointer_to_error_code #ifndef CGAL_NO_ATOMIC diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 7792ad5cdb6..2940f20cdd0 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -339,6 +339,7 @@ CGAL_add_named_parameter_with_compatibility(input_features_param_t, input_featur CGAL_add_named_parameter_with_compatibility(edge_size_param_t, edge_size_param, edge_size) CGAL_add_named_parameter_with_compatibility_cref_only(edge_sizing_field_param_t, edge_sizing_field_param, edge_sizing_field) CGAL_add_named_parameter_with_compatibility(edge_min_size_param_t, edge_min_size_param, edge_min_size) +CGAL_add_named_parameter_with_compatibility_cref_only(edge_distance_param_t, edge_distance_param, edge_distance) CGAL_add_named_parameter_with_compatibility(facet_angle_param_t, facet_angle_param, facet_angle) CGAL_add_named_parameter_with_compatibility(facet_size_param_t, facet_size_param, facet_size) CGAL_add_named_parameter_with_compatibility_cref_only(facet_sizing_field_param_t, facet_sizing_field_param, facet_sizing_field)