From 619a69fd756da5b1a3d5bdae840eb6eb0fd8dea0 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 20 Aug 2012 15:43:51 +0000 Subject: [PATCH] implement commit r71355 from experimental-GF and remove useless code --- .../include/CGAL/Compact_mesh_vertex_base_3.h | 15 +--- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 64 +++++++-------- .../CGAL/Mesh_3/Mesh_global_optimizer.h | 81 +++++-------------- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 17 +--- 4 files changed, 49 insertions(+), 128 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_vertex_base_3.h index f6ebfb71fd8..4ad5b74cdfe 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_vertex_base_3.h @@ -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_; diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index de5f3ca3562..370da1898a3 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -319,6 +319,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) { @@ -1462,20 +1472,7 @@ 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: // ----------------------------------- // Private data @@ -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) @@ -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_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 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; } diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h index 4cde85bed03..80759fe97e0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h @@ -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 (" @@ -329,10 +318,10 @@ operator()(int nb_iterations, Visitor visitor) // Update mesh with those moves update_mesh(moves, moving_vertices, visitor); visitor.end_of_iteration(i); - + #ifdef CGAL_MESH_3_OPTIMIZER_VERBOSE unsigned int moving_vertices_size = moving_vertices.size(); - + #ifdef CGAL_FREEZE_VERTICES 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 ") @@ -353,7 +342,7 @@ operator()(int nb_iterations, Visitor visitor) % (running_time_.time() / (i+1)) % sum_moves_; #endif - + step_begin = running_time_.time(); #endif @@ -405,30 +394,6 @@ collect_all_vertices(Moving_vertices_set& moving_vertices) moving_vertices.insert(vit); } - -#ifdef CGAL_FREEZE_VERTICES -template -void -Mesh_global_optimizer:: -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 Mesh_global_optimizer::Moves_vector Mesh_global_optimizer:: @@ -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,24 +417,20 @@ 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 ( 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 if ( is_time_limit_reached() ) break; @@ -485,10 +446,6 @@ typename Mesh_global_optimizer::Vector_3 Mesh_global_optimizer:: 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; diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index 8d7860f7c86..ae3397bc663 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -66,10 +66,7 @@ public: Mesh_vertex_base_3() : Surface_mesh_vertex_base_3() , index_() , dimension_(-1) - , meshing_info_(0) -#ifdef CGAL_FREEZE_VERTICES - , frozen_(false) -#endif //CGAL_FREEZE_VERTICES + , meshing_info_(0) {} // 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()() + "+" + Get_io_signature()(); } - 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