mirror of https://github.com/CGAL/cgal
make default edge distance be 0 for consistency with other criteria (instead of DBL_MAX)
rename check_distance_field() to has_distance_field()
This commit is contained in:
parent
3d8346c8e0
commit
973f8a1f66
|
|
@ -53,9 +53,10 @@ typedef unspecified_type Index;
|
|||
|
||||
/*!
|
||||
|
||||
Returns the value of the sizing field (i.e., the maximum edge length) at point `p`.
|
||||
Returns the value of the sizing field (i.e., the maximum edge length) at point `p`,
|
||||
lying on subcomplex of dimension `dim` and index `index`.
|
||||
*/
|
||||
FT sizing_field(const Point_3& p);
|
||||
FT sizing_field(const Point_3& p, const int dim, const Index& index);
|
||||
|
||||
/*!
|
||||
Returns the lower bound on edge length, set by the user.
|
||||
|
|
@ -64,18 +65,16 @@ The lower bound is ignored when its value is 0.
|
|||
const FT& min_length_bound() const;
|
||||
|
||||
/*!
|
||||
|
||||
Returns the value of the distance field (i.e., the maximum edge distance) at point `p` of dimension `dim` and index `index`.
|
||||
Returns the value of the distance field (i.e., the maximum edge distance) at point `p`
|
||||
lying on subcomplex of dimension `dim` and index `index`.
|
||||
*/
|
||||
FT distance_field(const Point_3& p, const int dim, const Index& index);
|
||||
|
||||
/*!
|
||||
|
||||
Returns wether or not the distance field should be checked during the protection phase.
|
||||
Returns whether or not the distance field should be checked during the protection phase.
|
||||
If false, the distance field is ignored.
|
||||
*/
|
||||
bool check_distance_field();
|
||||
|
||||
bool has_distance_field() const;
|
||||
/// @}
|
||||
|
||||
}; /* end MeshEdgeCriteria_3 */
|
||||
|
|
|
|||
|
|
@ -106,12 +106,10 @@ void debug_dump_c3t3(const std::string filename, const C3t3& c3t3)
|
|||
out << c3t3;
|
||||
}
|
||||
|
||||
template <typename FT>
|
||||
struct NoDistanceFunction {
|
||||
template <typename Bare_point, typename Index>
|
||||
FT operator()(const Bare_point& p, int dim, const Index& index) const {
|
||||
return FT(DBL_MAX);
|
||||
}
|
||||
double operator()(const Bare_point&, int, const Index&) const
|
||||
{ return 0.; }
|
||||
};
|
||||
|
||||
template<typename C3T3,
|
||||
|
|
@ -142,9 +140,8 @@ public:
|
|||
typedef typename MeshDomain::Corner_index Corner_index;
|
||||
typedef typename MeshDomain::Index Index;
|
||||
|
||||
using Distance_Function = typename CGAL::Default::Get<
|
||||
DistanceFunction,
|
||||
NoDistanceFunction<FT> >::type;
|
||||
using Distance_Function =
|
||||
typename CGAL::Default::Get<DistanceFunction, NoDistanceFunction>::type;
|
||||
|
||||
private:
|
||||
typedef typename CGAL::Kernel_traits<MeshDomain>::Kernel Kernel;
|
||||
|
|
@ -505,6 +502,10 @@ private:
|
|||
else
|
||||
return Weight(0);
|
||||
}
|
||||
bool use_distance_field() const
|
||||
{
|
||||
return use_edge_distance_;
|
||||
}
|
||||
|
||||
private:
|
||||
C3T3& c3t3_;
|
||||
|
|
@ -513,6 +514,7 @@ private:
|
|||
const FT minimal_size_;
|
||||
const Weight minimal_weight_;
|
||||
const Distance_Function edge_distance_;
|
||||
const bool use_edge_distance_;
|
||||
std::set<Curve_index> treated_edges_;
|
||||
Vertex_set unchecked_vertices_;
|
||||
int refine_balls_iteration_nb;
|
||||
|
|
@ -543,6 +545,7 @@ Protect_edges_sizing_field(C3T3& c3t3, const MD& domain,
|
|||
, minimal_size_(minimal_size)
|
||||
, minimal_weight_(CGAL::square(minimal_size))
|
||||
, edge_distance_(edge_distance)
|
||||
, use_edge_distance_(!std::is_same_v<Distance_Function, NoDistanceFunction>)
|
||||
, refine_balls_iteration_nb(0)
|
||||
, nonlinear_growth_of_balls(false)
|
||||
, maximal_number_of_vertices_(maximal_number_of_vertices)
|
||||
|
|
@ -1391,7 +1394,6 @@ refine_balls()
|
|||
Triangulation& tr = c3t3_.triangulation();
|
||||
|
||||
// Loop
|
||||
bool check_edge_distance = !std::is_same_v<Distance_Function, NoDistanceFunction<FT>>;
|
||||
bool restart = true;
|
||||
using CGAL::Mesh_3::internal::refine_balls_max_nb_of_loops;
|
||||
this->refine_balls_iteration_nb = 0;
|
||||
|
|
@ -1425,7 +1427,7 @@ refine_balls()
|
|||
|
||||
// If those vertices are not adjacent
|
||||
if( non_adjacent_but_intersect(va, vb, is_edge_in_complex)
|
||||
|| (check_edge_distance && approx_is_too_large(va, vb, is_edge_in_complex)))
|
||||
|| (use_distance_field() && approx_is_too_large(va, vb, is_edge_in_complex)))
|
||||
{
|
||||
using CGAL::Mesh_3::internal::distance_divisor;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public:
|
|||
Mesh_criteria_3_impl(const CGAL_NP_CLASS& np)
|
||||
:edge_criteria_(parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::edge_size_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_reference(np, internal_np::edge_distance_param), FT(DBL_MAX))),
|
||||
parameters::choose_parameter(parameters::get_parameter_reference(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_reference(np, internal_np::facet_size_param), FT(0)),
|
||||
parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::facet_distance_param), FT(0)),
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ provides a bound for the size criterion.
|
|||
|
||||
\cgalModels{MeshEdgeCriteria_3}
|
||||
|
||||
\sa `MeshCriteria_3`
|
||||
\sa `MeshCriteriaWithFeatures_3`
|
||||
\sa `CGAL::Mesh_criteria_3<Tr>`
|
||||
\sa `MeshDomainField_3`
|
||||
*/
|
||||
|
|
@ -136,7 +136,7 @@ public:
|
|||
* 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 distance from the
|
||||
* edge to the 1D feature.
|
||||
* edge to the corresponding 1D feature.
|
||||
* It can be a functional or a constant.
|
||||
*
|
||||
* \note If one parameter is set to 0, then its corresponding criterion is ignored.
|
||||
|
|
@ -147,12 +147,11 @@ public:
|
|||
template < typename SizingField, typename DistanceField = FT >
|
||||
Mesh_edge_criteria_3(const SizingField& length_bound,
|
||||
const FT& min_length_bound = 0,
|
||||
const DistanceField& distance_bound = FT(DBL_MAX))
|
||||
const DistanceField& distance_bound = FT(0))
|
||||
: min_length_bound_(min_length_bound)
|
||||
{
|
||||
init_p_size(length_bound,
|
||||
Mesh_3::Is_mesh_domain_field_3<Tr, SizingField>());
|
||||
is_distance_field_default_ = false;
|
||||
init_distance_bound(distance_bound,
|
||||
Mesh_3::Is_mesh_domain_field_3<Tr, DistanceField>());
|
||||
}
|
||||
|
|
@ -163,14 +162,17 @@ 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_->clone())
|
||||
, distance_bound_(rhs.distance_bound_ == nullptr
|
||||
? nullptr
|
||||
: rhs.distance_bound_->clone())
|
||||
{}
|
||||
|
||||
/// Destructor
|
||||
~Mesh_edge_criteria_3()
|
||||
{
|
||||
delete p_size_;
|
||||
delete distance_bound_;
|
||||
if(distance_bound_ != nullptr)
|
||||
delete distance_bound_;
|
||||
}
|
||||
|
||||
/// Returns size of tuple (p,dim,index)
|
||||
|
|
@ -178,16 +180,21 @@ public:
|
|||
{ return (*p_size_)(p,dim,index); }
|
||||
|
||||
FT distance_field(const Point_3& p, const int dim, const Index& index) const
|
||||
{ return (*distance_bound_)(p,dim,index); }
|
||||
|
||||
bool check_distance_field() const
|
||||
{ return !is_distance_field_default_; }
|
||||
{
|
||||
if (distance_bound_ == nullptr)
|
||||
return FT(0);
|
||||
return (*distance_bound_)(p,dim,index);
|
||||
}
|
||||
|
||||
public:
|
||||
const FT& min_length_bound() const
|
||||
{
|
||||
return min_length_bound_;
|
||||
}
|
||||
bool has_distance_field() const
|
||||
{
|
||||
return distance_bound_ != nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -216,20 +223,21 @@ private:
|
|||
|
||||
void init_distance_bound(const FT& distance_bound, Tag_false)
|
||||
{
|
||||
if (distance_bound == FT(DBL_MAX))
|
||||
is_distance_field_default_ = true;
|
||||
distance_bound_ = new Mesh_3::internal::Sizing_field_container<
|
||||
if (distance_bound == 0.)
|
||||
distance_bound_ = nullptr;
|
||||
else
|
||||
distance_bound_ = new Mesh_3::internal::Sizing_field_container<
|
||||
Mesh_constant_domain_field_3<GT,Index> ,
|
||||
FT,
|
||||
Point_3,
|
||||
Index>(distance_bound);
|
||||
}
|
||||
|
||||
template <typename SizingField>
|
||||
void init_distance_bound(const SizingField& distance_bound, Tag_true)
|
||||
template <typename DistanceField>
|
||||
void init_distance_bound(const DistanceField& distance_bound, Tag_true)
|
||||
{
|
||||
distance_bound_ = new Mesh_3::internal::Sizing_field_container<
|
||||
SizingField,
|
||||
DistanceField,
|
||||
FT,
|
||||
Point_3,
|
||||
Index>(distance_bound);
|
||||
|
|
@ -240,7 +248,6 @@ private:
|
|||
Sizing_field_interface* p_size_;
|
||||
const FT min_length_bound_;
|
||||
Sizing_field_interface* distance_bound_;
|
||||
bool is_distance_field_default_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -125,12 +125,7 @@ void init_c3t3_with_features(C3T3& c3t3,
|
|||
typedef typename MeshCriteria::Edge_criteria Edge_criteria;
|
||||
typedef Edge_criteria_sizing_field_wrapper<Edge_criteria> Sizing_field;
|
||||
|
||||
const bool check_edge_distance_field = criteria.edge_criteria_object().check_distance_field();
|
||||
|
||||
// typedef Sizing_field_container<Sizing_field,FT,Point_3,Index>
|
||||
// Sizing_field_container;
|
||||
|
||||
if (check_edge_distance_field)
|
||||
if (criteria.edge_criteria_object().has_distance_field())
|
||||
{
|
||||
typedef Edge_criteria_distance_field_wrapper<Edge_criteria> Distance_field;
|
||||
CGAL::Mesh_3::Protect_edges_sizing_field<C3T3,MeshDomain,Sizing_field,Distance_field>
|
||||
|
|
@ -151,14 +146,12 @@ void init_c3t3_with_features(C3T3& c3t3,
|
|||
}
|
||||
else
|
||||
{
|
||||
typedef CGAL::Default Distance_field;
|
||||
typedef CGAL::Mesh_3::Protect_edges_sizing_field<C3T3,MeshDomain,Sizing_field,Distance_field> Protect_edges_sizing_field;
|
||||
Protect_edges_sizing_field
|
||||
CGAL::Mesh_3::Protect_edges_sizing_field<C3T3,MeshDomain,Sizing_field>
|
||||
protect_edges(c3t3,
|
||||
domain,
|
||||
Sizing_field(criteria.edge_criteria_object()),
|
||||
criteria.edge_criteria_object().min_length_bound(),
|
||||
typename Protect_edges_sizing_field::Distance_Function(),
|
||||
CGAL::Mesh_3::NoDistanceFunction(),
|
||||
maximal_number_of_vertices,
|
||||
pointer_to_error_code
|
||||
#ifndef CGAL_NO_ATOMIC
|
||||
|
|
|
|||
Loading…
Reference in New Issue