return Mesh_optimization_return_code as Mesh_3 optimizers do
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <CGAL/Timer.h>
|
||||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/Mesh_optimization_return_code.h>
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@@ -92,7 +93,7 @@ public:
|
||||
void set_time_limit(double time) { time_limit_ = time; }
|
||||
double time_limit() const { return time_limit_; }
|
||||
|
||||
void operator()(const int nb_iterations)
|
||||
Mesh_optimization_return_code operator()(const int nb_iterations)
|
||||
{
|
||||
running_time_.reset();
|
||||
running_time_.start();
|
||||
@@ -172,10 +173,9 @@ public:
|
||||
}
|
||||
|
||||
move_function_.after_all_moves(cdt_);
|
||||
running_time_.stop();
|
||||
|
||||
#ifdef CGAL_MESH_2_OPTIMIZER_VERBOSE
|
||||
running_time_.stop();
|
||||
std::cerr << std::endl;
|
||||
if(sq_freeze_ratio_ > 0. && moving_vertices.empty())
|
||||
std::cerr << "All vertices frozen" << std::endl;
|
||||
else if(sq_freeze_ratio_ > 0. && convergence_stop)
|
||||
@@ -190,6 +190,19 @@ public:
|
||||
std::cerr << "Total optimization time: " << running_time_.time()
|
||||
<< "s" << std::endl << std::endl;
|
||||
#endif
|
||||
|
||||
if( sq_freeze_ratio_ > 0. && moving_vertices.empty() )
|
||||
return ALL_VERTICES_FROZEN;
|
||||
else if( sq_freeze_ratio_ > 0. && convergence_stop )
|
||||
return CANT_IMPROVE_ANYMORE;
|
||||
else if( is_time_limit_reached() )
|
||||
return TIME_LIMIT_REACHED;
|
||||
else if( check_convergence() )
|
||||
return CONVERGENCE_REACHED;
|
||||
else if( i >= nb_iterations )
|
||||
return MAX_ITERATION_NUMBER_REACHED;
|
||||
else
|
||||
return MESH_OPTIMIZATION_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <CGAL/Mesh_2/Mesh_global_optimizer_2.h>
|
||||
#include <CGAL/Mesh_2/Lloyd_move_2.h>
|
||||
#include <CGAL/Mesh_2/Mesh_sizing_field.h>
|
||||
#include <CGAL/Mesh_optimization_return_code.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/parameter.hpp>
|
||||
@@ -18,7 +19,7 @@ BOOST_PARAMETER_NAME( (freeze_bound, tag) freeze_bound_)
|
||||
namespace CGAL
|
||||
{
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(void),
|
||||
(Mesh_optimization_return_code),
|
||||
lloyd_optimize_mesh_2,
|
||||
tag,
|
||||
(required (in_out(cdt),*))
|
||||
@@ -38,8 +39,9 @@ namespace CGAL
|
||||
}
|
||||
|
||||
template<typename CDT>
|
||||
void lloyd_optimize_mesh_2_impl(CDT& cdt,
|
||||
const unsigned int max_iterations,
|
||||
Mesh_optimization_return_code
|
||||
lloyd_optimize_mesh_2_impl(CDT& cdt,
|
||||
const int max_iterations,
|
||||
const double convergence_ratio,
|
||||
const double freeze_bound,
|
||||
const double time_limit)
|
||||
@@ -65,13 +67,15 @@ namespace CGAL
|
||||
: max_iterations;
|
||||
|
||||
//run optimization
|
||||
lloyd(nb_iterations);
|
||||
Mesh_optimization_return_code rc = lloyd(nb_iterations);
|
||||
|
||||
#ifdef CGAL_MESH_2_OPTIMIZERS_DEBUG
|
||||
std::ofstream os2("after_lloyd.angles.txt");
|
||||
lloyd.output_angles_histogram(os2);
|
||||
os2.close();
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
} //end namespace CGAL
|
||||
|
||||
Reference in New Issue
Block a user