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) , meshing_info_(0)
, dimension_(-1) , dimension_(-1)
, cache_validity(false) , cache_validity(false)
#ifdef CGAL_FREEZE_VERTICES
, frozen_(false)
#endif
#ifdef CGAL_INTRUSIVE_LIST #ifdef CGAL_INTRUSIVE_LIST
, next_intrusive_() , next_intrusive_()
, previous_intrusive_() , previous_intrusive_()
#endif //CGAL_FREEZE_VERTICES #endif //CGAL_INTRUSIVE_LIST
{} {}
// Default copy constructor and assignment operator are ok // Default copy constructor and assignment operator are ok
@ -112,11 +109,6 @@ public:
const FT& meshing_info() const { return meshing_info_; } const FT& meshing_info() const { return meshing_info_; }
void set_meshing_info(const FT& value) { meshing_info_ = value; } 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 #ifdef CGAL_INTRUSIVE_LIST
Vertex_handle next_intrusive() const { return next_intrusive_; } Vertex_handle next_intrusive() const { return next_intrusive_; }
Vertex_handle& next_intrusive() { 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. // that contains me. Negative values are a marker for special vertices.
short dimension_; short dimension_;
bool cache_validity; 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 #ifdef CGAL_INTRUSIVE_LIST
Vertex_handle next_intrusive_; Vertex_handle next_intrusive_;
Vertex_handle previous_intrusive_; Vertex_handle previous_intrusive_;

View File

@ -319,6 +319,16 @@ public:
} }
return f == Type_handle(); 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) void push_back(Type_handle ch)
{ {
@ -1462,20 +1472,7 @@ private:
bl::bind(&Cell::reset_cache_validity, *bl::_1) ); 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: private:
// ----------------------------------- // -----------------------------------
// Private data // Private data
@ -1732,11 +1729,7 @@ rebuild_restricted_delaunay(OutdatedCells& outdated_cells,
{ {
for ( int i=0 ; i<4 ; ++i ) for ( int i=0 ; i<4 ; ++i )
{ {
#ifdef CGAL_FREEZE_VERTICES moving_vertices.insert(cell->vertex(i));
Vertex_handle vi = cell->vertex(i);
if(!vi->frozen())
#endif //CGAL_FREEZE_VERTICES
moving_vertices.insert(cell->vertex(i));
} }
} }
#endif //CGAL_IMPROVE_FREEZE #endif //CGAL_IMPROVE_FREEZE
@ -1802,11 +1795,7 @@ rebuild_restricted_delaunay(ForwardIterator first_cell,
{ {
for ( int i=0 ; i<4 ; ++i ) for ( int i=0 ; i<4 ; ++i )
{ {
#ifdef CGAL_FREEZE_VERTICES moving_vertices.insert(cell->vertex(i));
Vertex_handle vi = cell->vertex(i);
if(!vi->frozen())
#endif //CGAL_FREEZE_VERTICES
moving_vertices.insert(cell->vertex(i));
} }
} }
#endif //!defined(CGAL_IMPROVE_FREEZE) #endif //!defined(CGAL_IMPROVE_FREEZE)
@ -2061,13 +2050,14 @@ move_point_topo_change_conflict_zone_known(
// Remove conflict zone cells from c3t3 (they will be deleted by insert/remove) // 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()); 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); int dimension = c3t3_.in_dimension(old_vertex);
Index vertice_index = c3t3_.index(old_vertex); Index vertice_index = c3t3_.index(old_vertex);
FT meshing_info = old_vertex->meshing_info(); FT meshing_info = old_vertex->meshing_info();
#ifdef CGAL_FREEZE_VERTICES #if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
bool frozen = old_vertex->frozen(); Vertex_handle next = old_vertex->next_intrusive();
Vertex_handle prev = old_vertex->previous_intrusive();
#endif #endif
// insert new point // insert new point
@ -2089,12 +2079,14 @@ move_point_topo_change_conflict_zone_known(
c3t3_.set_dimension(new_vertex,dimension); c3t3_.set_dimension(new_vertex,dimension);
c3t3_.set_index(new_vertex,vertice_index); c3t3_.set_index(new_vertex,vertice_index);
new_vertex->set_meshing_info(meshing_info); new_vertex->set_meshing_info(meshing_info);
#ifdef CGAL_FREEZE_VERTICES #if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
new_vertex->set_frozen(frozen); new_vertex->next_intrusive() = next;
new_vertex->previous_intrusive() = prev;
#endif #endif
// End Move point // End Move point
//// Fill outdated_cells //// Fill outdated_cells
// Get conflict zone in new triangulation and set cells outdated
Cell_vector new_conflict_cells; Cell_vector new_conflict_cells;
new_conflict_cells.reserve(64); new_conflict_cells.reserve(64);
get_conflict_zone_topo_change(new_vertex, old_position, get_conflict_zone_topo_change(new_vertex, old_position,
@ -2108,7 +2100,6 @@ move_point_topo_change_conflict_zone_known(
return new_vertex; return new_vertex;
} }
template <typename C3T3, typename MD> template <typename C3T3, typename MD>
template < typename ConflictCellsInputIterator, template < typename ConflictCellsInputIterator,
typename OutdatedCellsOutputIterator, typename OutdatedCellsOutputIterator,
@ -2172,8 +2163,9 @@ move_point_topo_change(const Vertex_handle& old_vertex,
int dimension = c3t3_.in_dimension(old_vertex); int dimension = c3t3_.in_dimension(old_vertex);
Index vertice_index = c3t3_.index(old_vertex); Index vertice_index = c3t3_.index(old_vertex);
FT meshing_info = old_vertex->meshing_info(); FT meshing_info = old_vertex->meshing_info();
#ifdef CGAL_FREEZE_VERTICES #if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
bool frozen = old_vertex->frozen(); Vertex_handle next = old_vertex->next_intrusive();
Vertex_handle prev = old_vertex->previous_intrusive();
#endif #endif
// insert new point // insert new point
@ -2186,9 +2178,11 @@ move_point_topo_change(const Vertex_handle& old_vertex,
c3t3_.set_dimension(new_vertex,dimension); c3t3_.set_dimension(new_vertex,dimension);
c3t3_.set_index(new_vertex,vertice_index); c3t3_.set_index(new_vertex,vertice_index);
new_vertex->set_meshing_info(meshing_info); new_vertex->set_meshing_info(meshing_info);
#ifdef CGAL_FREEZE_VERTICES #if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
new_vertex->set_frozen(frozen); new_vertex->next_intrusive() = next;
new_vertex->previous_intrusive() = prev;
#endif #endif
return new_vertex; return new_vertex;
} }

View File

@ -114,13 +114,6 @@ public:
Mesh_optimization_return_code operator()(int nb_iterations, Mesh_optimization_return_code operator()(int nb_iterations,
Visitor v = Visitor()); 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 * collects all vertices of the triangulation in moving_vertices
* (even the frozen ones) * (even the frozen ones)
@ -139,6 +132,8 @@ private:
/** /**
* Returns the move for vertex \c v * 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); Vector_3 compute_move(const Vertex_handle& v);
@ -277,12 +272,6 @@ operator()(int nb_iterations, Visitor visitor)
running_time_.reset(); running_time_.reset();
running_time_.start(); 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 // Fill set containing moving vertices
// first, take them all // first, take them all
#ifdef CGAL_CONSTRUCT_INTRUSIVE_LIST_RANGE_CONSTRUCTOR #ifdef CGAL_CONSTRUCT_INTRUSIVE_LIST_RANGE_CONSTRUCTOR
@ -294,7 +283,7 @@ operator()(int nb_iterations, Visitor visitor)
collect_all_vertices(moving_vertices); collect_all_vertices(moving_vertices);
#endif #endif
unsigned int initial_vertices_nb = moving_vertices.size(); std::size_t initial_vertices_nb = moving_vertices.size();
#ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE #ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE
double step_begin = running_time_.time(); double step_begin = running_time_.time();
std::cerr << "Running " << Mf::name() << "-smoothing (" std::cerr << "Running " << Mf::name() << "-smoothing ("
@ -329,10 +318,10 @@ operator()(int nb_iterations, Visitor visitor)
// Update mesh with those moves // Update mesh with those moves
update_mesh(moves, moving_vertices, visitor); update_mesh(moves, moving_vertices, visitor);
visitor.end_of_iteration(i); visitor.end_of_iteration(i);
#ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE #ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE
unsigned int moving_vertices_size = moving_vertices.size(); unsigned int moving_vertices_size = moving_vertices.size();
#ifdef CGAL_FREEZE_VERTICES #ifdef CGAL_FREEZE_VERTICES
std::cerr << boost::format("\r \r" std::cerr << boost::format("\r \r"
"end iteration %1% (%2% frozen), %3% / %4%, last step:%5$.2fs, step avg:%6$.2fs, avg large move:%7$.3f ") "end iteration %1% (%2% frozen), %3% / %4%, last step:%5$.2fs, step avg:%6$.2fs, avg large move:%7$.3f ")
@ -353,7 +342,7 @@ operator()(int nb_iterations, Visitor visitor)
% (running_time_.time() / (i+1)) % (running_time_.time() / (i+1))
% sum_moves_; % sum_moves_;
#endif #endif
step_begin = running_time_.time(); step_begin = running_time_.time();
#endif #endif
@ -405,30 +394,6 @@ collect_all_vertices(Moving_vertices_set& moving_vertices)
moving_vertices.insert(vit); 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_> template <typename C3T3, typename Md, typename Mf, typename V_>
typename Mesh_global_optimizer<C3T3,Md,Mf,V_>::Moves_vector typename Mesh_global_optimizer<C3T3,Md,Mf,V_>::Moves_vector
Mesh_global_optimizer<C3T3,Md,Mf,V_>:: 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 = typename Gt::Construct_translated_point_3 translate =
Gt().construct_translated_point_3_object(); 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_vector moves;
moves.reserve(moving_vertices.size()); moves.reserve(moving_vertices.size());
@ -452,24 +417,20 @@ compute_moves(/*const */Moving_vertices_set& moving_vertices)
typename Moving_vertices_set::iterator vit = moving_vertices.begin(); typename Moving_vertices_set::iterator vit = moving_vertices.begin();
for ( ; vit != moving_vertices.end() ; ) 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; Vertex_handle oldv = *vit;
#endif //CGAL_IMPROVE_FREEZE Vector_3 move = compute_move(oldv);
++vit; ++vit;
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
#if defined(CGAL_INTRUSIVE_LIST) && defined(CGAL_IMPROVE_FREEZE) && defined(CGAL_FREEZE_VERTICES)
if(oldv->frozen())
moving_vertices.erase(oldv);
#endif //CGAL_IMPROVE_FREEZE
// Stop if time_limit_ is reached // Stop if time_limit_ is reached
if ( is_time_limit_reached() ) if ( is_time_limit_reached() )
break; break;
@ -485,10 +446,6 @@ typename Mesh_global_optimizer<C3T3,Md,Mf,V_>::Vector_3
Mesh_global_optimizer<C3T3,Md,Mf,V_>:: Mesh_global_optimizer<C3T3,Md,Mf,V_>::
compute_move(const Vertex_handle& 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 = typename Gt::Compute_squared_length_3 sq_length =
Gt().compute_squared_length_3_object(); Gt().compute_squared_length_3_object();
@ -522,8 +479,6 @@ compute_move(const Vertex_handle& v)
if ( local_move_sq_ratio < sq_freeze_ratio_ ) if ( local_move_sq_ratio < sq_freeze_ratio_ )
{ {
#ifdef CGAL_FREEZE_VERTICES #ifdef CGAL_FREEZE_VERTICES
if(do_freeze_)
v->set_frozen(true);
nb_frozen_points_++; nb_frozen_points_++;
#endif #endif
return CGAL::NULL_VECTOR; return CGAL::NULL_VECTOR;

View File

@ -66,10 +66,7 @@ public:
Mesh_vertex_base_3() : Surface_mesh_vertex_base_3<GT, Vb>() Mesh_vertex_base_3() : Surface_mesh_vertex_base_3<GT, Vb>()
, index_() , index_()
, dimension_(-1) , dimension_(-1)
, meshing_info_(0) , meshing_info_(0)
#ifdef CGAL_FREEZE_VERTICES
, frozen_(false)
#endif //CGAL_FREEZE_VERTICES
{} {}
// Default copy constructor and assignment operator are ok // Default copy constructor and assignment operator are ok
@ -106,12 +103,6 @@ public:
const FT& meshing_info() const { return meshing_info_; } const FT& meshing_info() const { return meshing_info_; }
void set_meshing_info(const FT& value) { meshing_info_ = value; } 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 static
std::string io_signature() std::string io_signature()
{ {
@ -120,7 +111,6 @@ public:
Get_io_signature<int>()() + "+" + Get_io_signature<int>()() + "+" +
Get_io_signature<Index>()(); Get_io_signature<Index>()();
} }
private: private:
// Index of the lowest dimensional face of the input 3D complex // Index of the lowest dimensional face of the input 3D complex
// that contains me // that contains me
@ -130,11 +120,6 @@ private:
int dimension_; int dimension_;
// Stores info needed by optimizers // Stores info needed by optimizers
FT meshing_info_; 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 }; // end class Mesh_vertex_base_3
template<class GT, template<class GT,