mirror of https://github.com/CGAL/cgal
use SliverCriterion in CGAL::perturb_mesh_3.
a boost parameter sliver_criterion is added to perturb_mesh_3, and by default, sliver_bound is used in the min_dihedral_criterion, as before
This commit is contained in:
parent
6dbc94ed77
commit
aefda6b8c1
|
|
@ -1,3 +1,6 @@
|
|||
#define CGAL_MESH_3_VERBOSE
|
||||
#define CGAL_MESH_3_PERTURBER_VERBOSE
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Mesh_triangulation_3.h>
|
||||
|
|
@ -45,7 +48,7 @@ int main()
|
|||
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_perturb(), no_exude());
|
||||
|
||||
// Mesh perturbation
|
||||
CGAL::perturb_mesh_3(c3t3, domain, time_limit=15);
|
||||
CGAL::perturb_mesh_3(c3t3, domain, time_limit=15, sliver_bound=10);
|
||||
|
||||
// Output
|
||||
std::ofstream medit_file("out.mesh");
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include <CGAL/Mesh_optimization_return_code.h>
|
||||
#include <CGAL/Timer.h>
|
||||
#include <CGAL/Mesh_3/Null_perturber_visitor.h>
|
||||
#include <CGAL/Mesh_3/sliver_criteria.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#ifdef CGAL_MESH_3_USE_RELAXED_HEAP
|
||||
|
|
@ -64,7 +65,8 @@ namespace Mesh_3 {
|
|||
|
||||
template < typename C3T3,
|
||||
typename MeshDomain,
|
||||
typename SliverCriterion,
|
||||
typename SliverCriterion = Mesh_3::Min_dihedral_angle_criterion
|
||||
<typename C3T3::Triangulation::Geom_traits>,
|
||||
typename Visitor_ = Null_perturber_visitor<C3T3> >
|
||||
class Sliver_perturber
|
||||
{
|
||||
|
|
@ -233,8 +235,7 @@ public:
|
|||
* The perturber runs step by step, using delta as step size.
|
||||
*/
|
||||
Mesh_optimization_return_code
|
||||
operator()(const FT& sliver_bound = SliverCriterion::max_value,
|
||||
const FT& delta = FT(1.),
|
||||
operator()(const FT& delta = FT(1.),
|
||||
Visitor visitor = Visitor());
|
||||
|
||||
/**
|
||||
|
|
@ -245,6 +246,10 @@ public:
|
|||
/// Time accessors
|
||||
void set_time_limit(double time) { time_limit_ = time; }
|
||||
double time_limit() const { return time_limit_; }
|
||||
|
||||
/// Sliver bound
|
||||
void set_sliver_bound(double bound) { sliver_bound_ = bound; }
|
||||
double sliver_bound() const { return sliver_bound_; }
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -342,8 +347,8 @@ private:
|
|||
Tr& tr_;
|
||||
const MeshDomain& domain_;
|
||||
double sliver_bound_;
|
||||
Perturbation_vector perturbation_vector_;
|
||||
SliverCriterion sliver_criterion_;
|
||||
Perturbation_vector perturbation_vector_;
|
||||
C3T3_helpers helper_;
|
||||
|
||||
// Internal perturbation ordering
|
||||
|
|
@ -368,6 +373,7 @@ Sliver_perturber(C3T3& c3t3,
|
|||
: c3t3_(c3t3)
|
||||
, tr_(c3t3_.triangulation())
|
||||
, domain_(domain)
|
||||
, sliver_bound_(Sc::max_value)
|
||||
, sliver_criterion_(criterion)
|
||||
, helper_(c3t3_,domain_)
|
||||
, next_perturbation_order_(0)
|
||||
|
|
@ -380,7 +386,7 @@ Sliver_perturber(C3T3& c3t3,
|
|||
template <typename C3T3, typename Md, typename Sc, typename V_>
|
||||
Mesh_optimization_return_code
|
||||
Sliver_perturber<C3T3,Md,Sc,V_>::
|
||||
operator()(const FT& sliver_bound, const FT& delta, Visitor visitor)
|
||||
operator()(const FT& delta, Visitor visitor)
|
||||
{
|
||||
// Reset sliver value cache
|
||||
helper_.reset_cache();
|
||||
|
|
@ -407,7 +413,7 @@ operator()(const FT& sliver_bound, const FT& delta, Visitor visitor)
|
|||
|
||||
FT current_bound = delta;
|
||||
bool perturbation_ok = true;
|
||||
while ( current_bound <= sliver_bound && perturbation_ok)
|
||||
while ( current_bound <= sliver_bound() && perturbation_ok)
|
||||
{
|
||||
#ifdef CGAL_MESH_3_PERTURBER_HIGH_VERBOSITY
|
||||
// reset_perturbation_counters is not const
|
||||
|
|
@ -418,10 +424,10 @@ operator()(const FT& sliver_bound, const FT& delta, Visitor visitor)
|
|||
visitor.bound_reached(current_bound);
|
||||
|
||||
current_bound += delta;
|
||||
if ( (current_bound >= sliver_bound)
|
||||
&& (current_bound < sliver_bound + delta) )
|
||||
if ( (current_bound >= sliver_bound())
|
||||
&& (current_bound < sliver_bound() + delta) )
|
||||
{
|
||||
current_bound = sliver_bound;
|
||||
current_bound = sliver_bound();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ BOOST_PARAMETER_NAME( criteria )
|
|||
|
||||
BOOST_PARAMETER_NAME( (time_limit, tag) time_limit_ )
|
||||
BOOST_PARAMETER_NAME( (sliver_bound, tag) sliver_bound_)
|
||||
BOOST_PARAMETER_NAME( (sliver_criterion, tag) sliver_criterion_)
|
||||
BOOST_PARAMETER_NAME( (freeze_bound, tag) freeze_bound_)
|
||||
BOOST_PARAMETER_NAME( (do_freeze, tag) do_freeze_)
|
||||
BOOST_PARAMETER_NAME( (max_iteration_number, tag) max_iteration_number_ )
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#ifndef CGAL_MESH_3_PARAMETERS_DEFAULTS_H
|
||||
#define CGAL_MESH_3_PARAMETERS_DEFAULTS_H
|
||||
|
||||
#include <CGAL/Mesh_3/sliver_criteria.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace parameters { namespace default_values {
|
||||
|
||||
|
|
@ -34,6 +36,14 @@ const double exude_sliver_bound = 0.;
|
|||
|
||||
// perturb_mesh_3
|
||||
const double perturb_sliver_bound = 0.;
|
||||
template<typename C3T3>
|
||||
CGAL::Mesh_3::Min_dihedral_angle_criterion
|
||||
<typename C3T3::Triangulation::Geom_traits>
|
||||
default_sliver_criterion(const C3T3&)
|
||||
{
|
||||
typedef typename C3T3::Triangulation::Geom_traits Gt;
|
||||
return CGAL::Mesh_3::Min_dihedral_angle_criterion<Gt>();
|
||||
}
|
||||
|
||||
// global optimizers
|
||||
const bool do_freeze = true;
|
||||
|
|
|
|||
|
|
@ -32,9 +32,17 @@ namespace CGAL {
|
|||
|
||||
namespace Mesh_3 {
|
||||
|
||||
template<typename K>
|
||||
class Sliver_criterion
|
||||
{
|
||||
typedef typename K::Tetrahedron_3 Tetrahedron_3;
|
||||
|
||||
public:
|
||||
virtual double operator()(const Tetrahedron_3& t) const = 0;
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Min_dihedral_angle_criterion
|
||||
class Min_dihedral_angle_criterion : public Sliver_criterion<K>
|
||||
{
|
||||
typedef typename K::Tetrahedron_3 Tetrahedron_3;
|
||||
|
||||
|
|
@ -55,7 +63,7 @@ template<typename K> double Min_dihedral_angle_criterion<K>::max_value = 90.;
|
|||
template<typename K> double Min_dihedral_angle_criterion<K>::min_value = 0.;
|
||||
|
||||
template <typename K>
|
||||
class Radius_radio_criterion
|
||||
class Radius_radio_criterion : public Sliver_criterion<K>
|
||||
{
|
||||
typedef typename K::Tetrahedron_3 Tetrahedron_3;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,25 +42,29 @@ BOOST_PARAMETER_FUNCTION(
|
|||
(optional
|
||||
(time_limit_, *, 0 )
|
||||
(sliver_bound_, *, parameters::default_values::perturb_sliver_bound )
|
||||
(sliver_criterion_, *,
|
||||
parameters::default_values::default_sliver_criterion(c3t3))
|
||||
)
|
||||
)
|
||||
{
|
||||
return perturb_mesh_3_impl(c3t3, domain, time_limit_, sliver_bound_);
|
||||
return perturb_mesh_3_impl(c3t3, domain, time_limit_, sliver_criterion_, sliver_bound_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename C3T3, typename MeshDomain>
|
||||
template <typename C3T3,
|
||||
typename MeshDomain,
|
||||
typename SliverCriterion>
|
||||
Mesh_optimization_return_code
|
||||
perturb_mesh_3_impl(C3T3& c3t3,
|
||||
const MeshDomain& domain,
|
||||
const double time_limit,
|
||||
const SliverCriterion& sliver_criterion,
|
||||
const double sliver_bound)
|
||||
{
|
||||
typedef MeshDomain Md;
|
||||
typedef typename C3T3::Triangulation::Geom_traits Gt;
|
||||
typedef Mesh_3::Min_dihedral_angle_criterion<Gt> Sc;
|
||||
//typedef Mesh_3::Radius_radio_criterion<Gt> Sc;
|
||||
typedef SliverCriterion Sc;
|
||||
|
||||
typedef Mesh_3::Sliver_perturber<C3T3,Md,Sc> Perturber;
|
||||
typedef Mesh_3::Sq_radius_perturbation<C3T3,Md,Sc> Sq_radius;
|
||||
|
|
@ -78,12 +82,12 @@ perturb_mesh_3_impl(C3T3& c3t3,
|
|||
|
||||
// Set max time
|
||||
perturber.set_time_limit(time_limit);
|
||||
|
||||
// Set sliver bound
|
||||
perturber.set_sliver_bound(sliver_bound);
|
||||
|
||||
// Launch perturber
|
||||
if ( sliver_bound != 0 )
|
||||
return perturber(sliver_bound);
|
||||
else
|
||||
return perturber();
|
||||
return perturber();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue