implement commit r71355 from experimental-GF and remove useless code

This commit is contained in:
Jane Tournois 2012-08-20 15:43:51 +00:00
parent 45016ef87a
commit 619a69fd75
4 changed files with 49 additions and 128 deletions

View File

@ -69,13 +69,10 @@ public:
, meshing_info_(0)
, dimension_(-1)
, cache_validity(false)
#ifdef CGAL_FREEZE_VERTICES
, frozen_(false)
#endif
#ifdef CGAL_INTRUSIVE_LIST
, next_intrusive_()
, previous_intrusive_()
#endif //CGAL_FREEZE_VERTICES
#endif //CGAL_INTRUSIVE_LIST
{}
// Default copy constructor and assignment operator are ok
@ -112,11 +109,6 @@ public:
const FT& meshing_info() const { return meshing_info_; }
void set_meshing_info(const FT& value) { meshing_info_ = value; }
#ifdef CGAL_FREEZE_VERTICES
// Accessors to frozen private data
const bool& frozen() const { return frozen_; }
void set_frozen(const bool& fr) { frozen_ = fr; }
#endif
#ifdef CGAL_INTRUSIVE_LIST
Vertex_handle next_intrusive() const { return next_intrusive_; }
Vertex_handle& next_intrusive() { return next_intrusive_; }
@ -176,11 +168,6 @@ private:
// that contains me. Negative values are a marker for special vertices.
short dimension_;
bool cache_validity;
// sets if I am frozen (not allowed to move anymore for global optimizers)
// (set to true when my move is too small compared to sq_freeze_ratio_)
#ifdef CGAL_FREEZE_VERTICES
bool frozen_;
#endif
#ifdef CGAL_INTRUSIVE_LIST
Vertex_handle next_intrusive_;
Vertex_handle previous_intrusive_;

View File

@ -320,6 +320,16 @@ public:
return f == Type_handle();
}
bool contains(Type_handle th) const
{
if(th->next_intrusive() == Type_handle())
{
assert(th->previous_intrusive() == Type_handle());
return true;
}
else return false;
}
void push_back(Type_handle ch)
{
insert(ch);
@ -1462,19 +1472,6 @@ private:
bl::bind(&Cell::reset_cache_validity, *bl::_1) );
}
public:
#ifdef CGAL_FREEZE_VERTICES
/**
* Unfreeze all vertices of the triangulation for global optimizers
*/
void unfreeze_all_vertices()
{
for(typename Tr::Finite_vertices_iterator vit = tr_.finite_vertices_begin();
vit != tr_.finite_vertices_end();
vit++)
vit->set_frozen(false);
}
#endif
private:
// -----------------------------------
@ -1732,11 +1729,7 @@ rebuild_restricted_delaunay(OutdatedCells& outdated_cells,
{
for ( int i=0 ; i<4 ; ++i )
{
#ifdef CGAL_FREEZE_VERTICES
Vertex_handle vi = cell->vertex(i);
if(!vi->frozen())
#endif //CGAL_FREEZE_VERTICES
moving_vertices.insert(cell->vertex(i));
moving_vertices.insert(cell->vertex(i));
}
}
#endif //CGAL_IMPROVE_FREEZE
@ -1802,11 +1795,7 @@ rebuild_restricted_delaunay(ForwardIterator first_cell,
{
for ( int i=0 ; i<4 ; ++i )
{
#ifdef CGAL_FREEZE_VERTICES
Vertex_handle vi = cell->vertex(i);
if(!vi->frozen())
#endif //CGAL_FREEZE_VERTICES
moving_vertices.insert(cell->vertex(i));
moving_vertices.insert(cell->vertex(i));
}
}
#endif //!defined(CGAL_IMPROVE_FREEZE)
@ -2062,12 +2051,13 @@ move_point_topo_change_conflict_zone_known(
// Remove conflict zone cells from c3t3 (they will be deleted by insert/remove)
remove_cells_and_facets_from_c3t3(conflict_zone.begin(), conflict_zone.end());
// Start Move point // Insert new_vertex, remove old_vertex
// Start Move point // Insert new_vertex, remove old_vertex
int dimension = c3t3_.in_dimension(old_vertex);
Index vertice_index = c3t3_.index(old_vertex);
FT meshing_info = old_vertex->meshing_info();
#ifdef CGAL_FREEZE_VERTICES
bool frozen = old_vertex->frozen();
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
Vertex_handle next = old_vertex->next_intrusive();
Vertex_handle prev = old_vertex->previous_intrusive();
#endif
// insert new point
@ -2089,12 +2079,14 @@ move_point_topo_change_conflict_zone_known(
c3t3_.set_dimension(new_vertex,dimension);
c3t3_.set_index(new_vertex,vertice_index);
new_vertex->set_meshing_info(meshing_info);
#ifdef CGAL_FREEZE_VERTICES
new_vertex->set_frozen(frozen);
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
new_vertex->next_intrusive() = next;
new_vertex->previous_intrusive() = prev;
#endif
// End Move point
//// Fill outdated_cells
// Get conflict zone in new triangulation and set cells outdated
Cell_vector new_conflict_cells;
new_conflict_cells.reserve(64);
get_conflict_zone_topo_change(new_vertex, old_position,
@ -2108,7 +2100,6 @@ move_point_topo_change_conflict_zone_known(
return new_vertex;
}
template <typename C3T3, typename MD>
template < typename ConflictCellsInputIterator,
typename OutdatedCellsOutputIterator,
@ -2172,8 +2163,9 @@ move_point_topo_change(const Vertex_handle& old_vertex,
int dimension = c3t3_.in_dimension(old_vertex);
Index vertice_index = c3t3_.index(old_vertex);
FT meshing_info = old_vertex->meshing_info();
#ifdef CGAL_FREEZE_VERTICES
bool frozen = old_vertex->frozen();
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
Vertex_handle next = old_vertex->next_intrusive();
Vertex_handle prev = old_vertex->previous_intrusive();
#endif
// insert new point
@ -2186,9 +2178,11 @@ move_point_topo_change(const Vertex_handle& old_vertex,
c3t3_.set_dimension(new_vertex,dimension);
c3t3_.set_index(new_vertex,vertice_index);
new_vertex->set_meshing_info(meshing_info);
#ifdef CGAL_FREEZE_VERTICES
new_vertex->set_frozen(frozen);
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
new_vertex->next_intrusive() = next;
new_vertex->previous_intrusive() = prev;
#endif
return new_vertex;
}

View File

@ -114,13 +114,6 @@ public:
Mesh_optimization_return_code operator()(int nb_iterations,
Visitor v = Visitor());
#ifdef CGAL_FREEZE_VERTICES
/**
* resets everything about frozen vertices
*/
void unfreeze_all();
#endif
/**
* collects all vertices of the triangulation in moving_vertices
* (even the frozen ones)
@ -139,6 +132,8 @@ private:
/**
* Returns the move for vertex \c v
* warning : this function should be called only on moving vertices
* even for frozen vertices, it could return a non-zero vector
*/
Vector_3 compute_move(const Vertex_handle& v);
@ -277,12 +272,6 @@ operator()(int nb_iterations, Visitor visitor)
running_time_.reset();
running_time_.start();
// unfreeze everything : needed if the user wants to
// run a global optimization after another
#ifdef CGAL_FREEZE_VERTICES
unfreeze_all();
#endif
// Fill set containing moving vertices
// first, take them all
#ifdef CGAL_CONSTRUCT_INTRUSIVE_LIST_RANGE_CONSTRUCTOR
@ -294,7 +283,7 @@ operator()(int nb_iterations, Visitor visitor)
collect_all_vertices(moving_vertices);
#endif
unsigned int initial_vertices_nb = moving_vertices.size();
std::size_t initial_vertices_nb = moving_vertices.size();
#ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE
double step_begin = running_time_.time();
std::cerr << "Running " << Mf::name() << "-smoothing ("
@ -405,30 +394,6 @@ collect_all_vertices(Moving_vertices_set& moving_vertices)
moving_vertices.insert(vit);
}
#ifdef CGAL_FREEZE_VERTICES
template <typename C3T3, typename Md, typename Mf, typename V_>
void
Mesh_global_optimizer<C3T3,Md,Mf,V_>::
unfreeze_all()
{
#ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE
std::cerr << "Unfreeze all...";
CGAL::Timer timer;
timer.start();
double t = timer.time();
#endif
nb_frozen_points_ = 0;
if(do_freeze_)
helper_.unfreeze_all_vertices();
#ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE
std::cerr << " done ("<< (timer.time() - t) << " sec).";
#endif
}
#endif
template <typename C3T3, typename Md, typename Mf, typename V_>
typename Mesh_global_optimizer<C3T3,Md,Mf,V_>::Moves_vector
Mesh_global_optimizer<C3T3,Md,Mf,V_>::
@ -437,7 +402,7 @@ compute_moves(/*const */Moving_vertices_set& moving_vertices)
typename Gt::Construct_translated_point_3 translate =
Gt().construct_translated_point_3_object();
// Store new location of points which have to move
// Store new position of points which have to move
Moves_vector moves;
moves.reserve(moving_vertices.size());
@ -452,23 +417,19 @@ compute_moves(/*const */Moving_vertices_set& moving_vertices)
typename Moving_vertices_set::iterator vit = moving_vertices.begin();
for ( ; vit != moving_vertices.end() ; )
{
Vector_3 move = compute_move(*vit);
if ( CGAL::NULL_VECTOR != move )
{
Point_3 new_position = translate((*vit)->point(),move);
moves.push_back(std::make_pair(*vit,new_position));
}
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
Vertex_handle oldv = *vit;
#endif //CGAL_IMPROVE_FREEZE
Vector_3 move = compute_move(oldv);
++vit;
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
if(oldv->frozen())
moving_vertices.erase(oldv);
#endif //CGAL_IMPROVE_FREEZE
if ( CGAL::NULL_VECTOR != move )
{
Point_3 new_position = translate(oldv->point(),move);
moves.push_back(std::make_pair(oldv,new_position));
}
#if defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
else // CGAL::NULL_VECTOR == move
moving_vertices.erase(oldv);
#endif
// Stop if time_limit_ is reached
if ( is_time_limit_reached() )
@ -485,10 +446,6 @@ typename Mesh_global_optimizer<C3T3,Md,Mf,V_>::Vector_3
Mesh_global_optimizer<C3T3,Md,Mf,V_>::
compute_move(const Vertex_handle& v)
{
#ifdef CGAL_FREEZE_VERTICES
if(do_freeze_ && v->frozen())
return CGAL::NULL_VECTOR;
#endif
typename Gt::Compute_squared_length_3 sq_length =
Gt().compute_squared_length_3_object();
@ -522,8 +479,6 @@ compute_move(const Vertex_handle& v)
if ( local_move_sq_ratio < sq_freeze_ratio_ )
{
#ifdef CGAL_FREEZE_VERTICES
if(do_freeze_)
v->set_frozen(true);
nb_frozen_points_++;
#endif
return CGAL::NULL_VECTOR;

View File

@ -67,9 +67,6 @@ public:
, index_()
, dimension_(-1)
, meshing_info_(0)
#ifdef CGAL_FREEZE_VERTICES
, frozen_(false)
#endif //CGAL_FREEZE_VERTICES
{}
// Default copy constructor and assignment operator are ok
@ -106,12 +103,6 @@ public:
const FT& meshing_info() const { return meshing_info_; }
void set_meshing_info(const FT& value) { meshing_info_ = value; }
#ifdef CGAL_FREEZE_VERTICES
// Accessors to frozen private data
const bool& frozen() const { return frozen_; }
void set_frozen(const bool& fr) { frozen_ = fr; }
#endif // CGAL_FREEZE_VERTICES
static
std::string io_signature()
{
@ -120,7 +111,6 @@ public:
Get_io_signature<int>()() + "+" +
Get_io_signature<Index>()();
}
private:
// Index of the lowest dimensional face of the input 3D complex
// that contains me
@ -130,11 +120,6 @@ private:
int dimension_;
// Stores info needed by optimizers
FT meshing_info_;
#ifdef CGAL_FREEZE_VERTICES
// sets if I am frozen (not allowed to move anymore for global optimizers)
// (set to true when my move is too small compared to sq_freeze_ratio_)
bool frozen_;
#endif // CGAL_FREEZE_VERTICES
}; // end class Mesh_vertex_base_3
template<class GT,