diff --git a/Mesh_2/include/CGAL/Mesher_level.h b/Mesh_2/include/CGAL/Mesher_level.h index 0a79f939336..a5809abbab4 100644 --- a/Mesh_2/include/CGAL/Mesher_level.h +++ b/Mesh_2/include/CGAL/Mesher_level.h @@ -1289,8 +1289,7 @@ public: { // Lock the element area on the grid Element element = derivd.extract_element_from_container_value(ce); - bool locked = triangulation().try_lock_element(element, - FIRST_GRID_LOCK_RADIUS); + bool locked = derivd.try_lock_element(element, FIRST_GRID_LOCK_RADIUS); if( locked ) { diff --git a/Mesh_3/demo/Mesh_3/C3t3_type.h b/Mesh_3/demo/Mesh_3/C3t3_type.h index 0d944ae4a36..c024b19d2c1 100644 --- a/Mesh_3/demo/Mesh_3/C3t3_type.h +++ b/Mesh_3/demo/Mesh_3/C3t3_type.h @@ -10,7 +10,9 @@ #include #include -#include +#ifdef CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN +# include +#endif #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Locking_data_structures.h b/Mesh_3/include/CGAL/Mesh_3/Locking_data_structures.h index c3f4e16fe10..4550ac23236 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Locking_data_structures.h +++ b/Mesh_3/include/CGAL/Mesh_3/Locking_data_structures.h @@ -22,14 +22,11 @@ #ifdef CGAL_LINKED_WITH_TBB -#include - #include #include #include - #if TBB_IMPLEMENT_CPP0X # include #else @@ -44,7 +41,7 @@ namespace CGAL { namespace Mesh_3 { //****************************************************************************** -// class Grid_locking_ds_base +// class Grid_locking_ds_base_3 // (Uses Curiously recurring template pattern) //****************************************************************************** @@ -59,7 +56,7 @@ static bool *init_TLS_grid(int num_cells_per_axis) } template -class Grid_locking_ds_base +class Grid_locking_ds_base_3 { #ifdef CGAL_DEBUG_GLOBAL_LOCK_DS @@ -67,17 +64,17 @@ class Grid_locking_ds_base // for debugging purpose... private: - static Grid_locking_ds_base*& debug_global_lock_ds() + static Grid_locking_ds_base_3*& debug_global_lock_ds() { - static Grid_locking_ds_base *p_g_lock_ds = 0; + static Grid_locking_ds_base_3 *p_g_lock_ds = 0; return p_g_lock_ds; } public: - static Grid_locking_ds_base* get_global_lock_ds() + static Grid_locking_ds_base_3* get_global_lock_ds() { return debug_global_lock_ds(); } - static void set_global_lock_ds(Grid_locking_ds_base *ds) + static void set_global_lock_ds(Grid_locking_ds_base_3 *ds) { debug_global_lock_ds() = ds; } @@ -116,18 +113,7 @@ public: { return m_tls_grids.local()[get_grid_index(point)]; } - - template - bool is_tetrahedra_locked_by_this_thread(const Tetrahedra &tet) - { - bool locked = true; - for (int iVertex = 0 ; locked && iVertex < 4 ; ++iVertex) - { - locked = is_locked_by_this_thread(tet.vertex(iVertex)->point()); - } - return locked; - } - + bool try_lock(int cell_index, bool no_spin = false) { return m_tls_grids.local()[cell_index] @@ -290,7 +276,7 @@ public: protected: // Constructor - Grid_locking_ds_base(const Bbox_3 &bbox, + Grid_locking_ds_base_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : m_num_grid_cells_per_axis(num_grid_cells_per_axis), m_tls_grids(boost::bind(init_TLS_grid, num_grid_cells_per_axis)) @@ -299,7 +285,7 @@ protected: } /// Destructor - virtual ~Grid_locking_ds_base() + virtual ~Grid_locking_ds_base_3() { for( TLS_grid::iterator it_grid = m_tls_grids.begin() ; it_grid != m_tls_grids.end() ; @@ -358,17 +344,17 @@ protected: //****************************************************************************** -// class Simple_grid_locking_ds +// class Simple_grid_locking_ds_3 //****************************************************************************** -class Simple_grid_locking_ds - : public Grid_locking_ds_base +class Simple_grid_locking_ds_3 + : public Grid_locking_ds_base_3 { public: - typedef Grid_locking_ds_base Base; + typedef Grid_locking_ds_base_3 Base; // Constructors - Simple_grid_locking_ds(const Bbox_3 &bbox, + Simple_grid_locking_ds_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis) { @@ -381,7 +367,7 @@ public: m_grid[i] = false; } - virtual ~Simple_grid_locking_ds() + virtual ~Simple_grid_locking_ds_3() { delete [] m_grid; } @@ -409,7 +395,7 @@ protected: //****************************************************************************** -// class Simple_grid_locking_ds_with_thread_ids +// class Simple_grid_locking_ds_with_thread_ids_3 //****************************************************************************** static unsigned int init_TLS_thread_ids() @@ -420,15 +406,15 @@ static unsigned int init_TLS_thread_ids() return (1 + id%(std::numeric_limits::max())); } -class Simple_grid_locking_ds_with_thread_ids - : public Grid_locking_ds_base +class Simple_grid_locking_ds_with_thread_ids_3 + : public Grid_locking_ds_base_3 { public: - typedef Grid_locking_ds_base Base; + typedef Grid_locking_ds_base_3 Base; // Constructors - Simple_grid_locking_ds_with_thread_ids(const Bbox_3 &bbox, + Simple_grid_locking_ds_with_thread_ids_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis), m_tls_thread_ids(init_TLS_thread_ids) @@ -442,7 +428,7 @@ public: } /// Destructor - virtual ~Simple_grid_locking_ds_with_thread_ids() + virtual ~Simple_grid_locking_ds_with_thread_ids_3() { delete [] m_grid; } @@ -508,17 +494,17 @@ protected: }; //****************************************************************************** -// class Simple_grid_locking_ds_with_mutex +// class Simple_grid_locking_ds_with_mutex_3 //****************************************************************************** -class Simple_grid_locking_ds_with_mutex - : public Grid_locking_ds_base +class Simple_grid_locking_ds_with_mutex_3 + : public Grid_locking_ds_base_3 { public: - typedef Grid_locking_ds_base Base; + typedef Grid_locking_ds_base_3 Base; // Constructors - Simple_grid_locking_ds_with_mutex(const Bbox_3 &bbox, + Simple_grid_locking_ds_with_mutex_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis) { @@ -528,7 +514,7 @@ public: } /// Destructor - virtual ~Simple_grid_locking_ds_with_mutex() + virtual ~Simple_grid_locking_ds_with_mutex_3() { delete [] m_grid; } @@ -557,9 +543,9 @@ protected: }; -//typedef Simple_grid_locking_ds LockDataStructureType; -//typedef Simple_grid_locking_ds_with_mutex LockDataStructureType; -typedef Simple_grid_locking_ds_with_thread_ids LockDataStructureType; +//typedef Simple_grid_locking_ds_3 LockDataStructureType; +//typedef Simple_grid_locking_ds_with_mutex_3 LockDataStructureType; +typedef Simple_grid_locking_ds_with_thread_ids_3 LockDataStructureType; } } //namespace CGAL::Mesh_3 diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h index caf2806b988..a8b6446a963 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h @@ -50,7 +50,11 @@ #endif #ifdef CGAL_LINKED_WITH_TBB -# include +# if TBB_IMPLEMENT_CPP0X +# include +# else +# include +# endif #endif #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 433404ae9d2..5cd71d428da 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -440,6 +440,11 @@ public: /// Handle cells contained in \c zone (before their destruction by insertion) void before_insertion_handle_cells_in_conflict_zone(Zone& zone); + bool try_lock_element(const Cell_handle &ch, int lock_radius = 0) const + { + return triangulation().try_lock_cell(ch, lock_radius); + } + /// debug info: class name std::string debug_info_class_name_impl() const { diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 82faa1a0a1c..adcbfc071bc 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -565,6 +565,11 @@ public: /// Restore restricted Delaunay ; may be call by Cells_mesher visitor void restore_restricted_Delaunay(const Vertex_handle& v); + + bool try_lock_element(const Facet &f, int lock_radius = 0) const + { + return triangulation().try_lock_facet(f, lock_radius); + } /// debug info: class name std::string debug_info_class_name_impl() const diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index a58b2941e09..089f07e46ab 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -679,9 +679,11 @@ private: // Timer double time_limit_; CGAL::Timer running_time_; - + +#ifdef CGAL_LINKED_WITH_TBB // CJTOTO: change this for a better solution tbb::atomic m_lets_start_the_tasks; +#endif #ifdef CGAL_MESH_3_DEBUG_SLIVERS_EXUDER // ----------------------------------- @@ -772,8 +774,6 @@ Slivers_exuder:: pump_vertices(double sliver_criterion_limit, Visitor& visitor) { - m_lets_start_the_tasks = false; - #ifdef MESH_3_PROFILING WallClockTimer t; #endif @@ -805,8 +805,9 @@ pump_vertices(double sliver_criterion_limit, // Parallel if (boost::is_base_of::value) { + m_lets_start_the_tasks = false; this->create_root_task(); - + while (!cells_queue_.empty()) { typename Tet_priority_queue::Reverse_entry front = *(cells_queue_.front()); @@ -1133,7 +1134,7 @@ get_best_weight(const Vertex_handle& v, bool *p_could_lock_zone) const Facet link = pre_star.front()->second; const Cell_handle& opposite_cell = tr_.mirror_facet(link).first; // CJTODO: useless? - if (p_could_lock_zone && !tr_.try_lock_element(opposite_cell)) + if (p_could_lock_zone && !tr_.try_lock_cell(opposite_cell)) { *p_could_lock_zone = false; return 0.; @@ -1404,7 +1405,7 @@ enqueue_task(Cell_handle ch, double value) if (ch->get_erase_counter() != erase_counter) break; - if (!tr_.try_lock_element(ch)) + if (!tr_.try_lock_cell(ch)) { #ifdef CGAL_CONCURRENT_MESH_3_PROFILING bcounter.increment_branch_2(); // THIS is an early withdrawal! diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index a046e8f67cd..bfab5721c48 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -32,6 +32,8 @@ #include #include +#include + #ifdef CGAL_COMPACT_MESH_VERTEX_CELL #include #include @@ -123,7 +125,8 @@ private: typedef Triangulation_data_structure_3< Vertex_base, Cell_base, true> Tds; - typedef Regular_triangulation_3 Triangulation; + typedef Regular_triangulation_3< + Geom_traits, Tds, Mesh_3::LockDataStructureType> Triangulation; #else // !CGAL_LINKED_WITH_TBB diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 2fc3223b0a6..92019bfa590 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -54,29 +54,30 @@ namespace CGAL { /************************************************ * * Regular_triangulation_3 class - * used_by_parallel_mesh_3: for parallel Mesh_3 + * ************************************************/ - template < class Gt, class Tds_ = Default, bool used_by_parallel_mesh_3 = false > + template < class Gt, class Tds_ = Default, class Locking_data_structure = void > class Regular_triangulation_3 : public Triangulation_3< Gt, typename Default::Get, Regular_triangulation_cell_base_3 > >::type, - used_by_parallel_mesh_3> + Locking_data_structure> { - typedef Regular_triangulation_3 Self; + typedef Regular_triangulation_3 Self; typedef typename Default::Get, Regular_triangulation_cell_base_3 > >::type Tds; - typedef Triangulation_3 Tr_Base; + typedef Triangulation_3 Tr_Base; public: - static const bool Is_for_parallel_mesh_3 = used_by_parallel_mesh_3; + static const bool Is_for_parallel_mesh_3 = + !boost::is_same::value; // CJTODO: remove this Mesh_3 thing typedef Tds Triangulation_data_structure; typedef Gt Geom_traits; @@ -967,7 +968,7 @@ namespace CGAL { }; #endif // CGAL_LINKED_WITH_TBB - Hidden_point_visitor &get_hidden_point_visitor() + Hidden_point_visitor &get_hidden_point_visitor() // CJTODO: remove this Mesh_3 thing { return hidden_point_visitor; } @@ -978,13 +979,13 @@ namespace CGAL { template < class RegularTriangulation_3 > class Vertex_inserter; - Hidden_point_visitor hidden_point_visitor; + Hidden_point_visitor hidden_point_visitor; // CJTODO: remove this Mesh_3 thing }; - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: nearest_power_vertex_in_cell(const Bare_point& p, Cell_handle c) const // Returns the finite vertex of the cell c with smaller @@ -1003,9 +1004,9 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: nearest_power_vertex(const Bare_point& p, Cell_handle start) const { if (number_of_vertices() == 0) @@ -1047,9 +1048,9 @@ namespace CGAL { return nearest; } - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Bare_point - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Bare_point + Regular_triangulation_3:: dual(Cell_handle c, bool force_exact) const { CGAL_triangulation_precondition(dimension()==3); @@ -1061,9 +1062,9 @@ namespace CGAL { force_exact); } - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Object - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Object + Regular_triangulation_3:: dual(Cell_handle c, int i, bool force_exact) const { CGAL_triangulation_precondition(dimension()>=2); @@ -1106,9 +1107,9 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Oriented_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_oriented_power_sphere(const Weighted_point &p0, const Weighted_point &p1, const Weighted_point &p2, @@ -1155,9 +1156,9 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Bounded_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_power_sphere(Cell_handle c, const Weighted_point &p, bool perturb) const { @@ -1198,9 +1199,9 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Bounded_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_bounded_power_circle(const Weighted_point &p0, const Weighted_point &p1, const Weighted_point &p2, @@ -1217,9 +1218,9 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Oriented_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_oriented_power_circle(const Weighted_point &p0, const Weighted_point &p1, const Weighted_point &p2, @@ -1264,9 +1265,9 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Bounded_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_power_circle(Cell_handle c, int i, const Weighted_point &p, bool perturb) const { @@ -1334,9 +1335,9 @@ namespace CGAL { p, perturb); } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Bounded_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_bounded_power_segment(const Weighted_point &p0, const Weighted_point &p1, const Weighted_point &p, bool perturb) const @@ -1361,9 +1362,9 @@ namespace CGAL { return ON_UNBOUNDED_SIDE; } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > Bounded_side - Regular_triangulation_3:: + Regular_triangulation_3:: side_of_power_segment(Cell_handle c, const Weighted_point &p, bool perturb) const { @@ -1384,17 +1385,17 @@ namespace CGAL { p, perturb); } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > bool - Regular_triangulation_3:: + Regular_triangulation_3:: is_Gabriel(const Facet& f) const { return is_Gabriel(f.first, f.second); } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > bool - Regular_triangulation_3:: + Regular_triangulation_3:: is_Gabriel(Cell_handle c, int i) const { CGAL_triangulation_precondition(dimension() == 3 && !is_infinite(c,i)); @@ -1423,17 +1424,17 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > bool - Regular_triangulation_3:: + Regular_triangulation_3:: is_Gabriel(const Edge& e) const { return is_Gabriel(e.first, e.second, e.third); } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > bool - Regular_triangulation_3:: + Regular_triangulation_3:: is_Gabriel(Cell_handle c, int i, int j) const { CGAL_triangulation_precondition(dimension() == 3 && !is_infinite(c,i,j)); @@ -1459,25 +1460,31 @@ namespace CGAL { return true; } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > bool - Regular_triangulation_3:: + Regular_triangulation_3:: is_Gabriel(Vertex_handle v) const { return nearest_power_vertex( v->point().point(), v->cell()) == v; } // Returns - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: insert(const Weighted_point & p, Cell_handle start) { Locate_type lt; int li, lj; + // Sequential + if (boost::is_same::value) + { + Cell_handle c = locate(p, lt, li, lj, start); + return insert(p, lt, c, li, lj); + } // Parallel - if (Upm) + else { bool could_lock_zone; Cell_handle c = locate(p, lt, li, lj, start, &could_lock_zone); @@ -1486,17 +1493,11 @@ namespace CGAL { else return Vertex_handle(); } - // Sequential - else - { - Cell_handle c = locate(p, lt, li, lj, start); - return insert(p, lt, c, li, lj); - } } - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: insert(const Weighted_point & p, Locate_type lt, Cell_handle c, int li, int lj) { switch (dimension()) { @@ -1522,10 +1523,10 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > template - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: insert_in_hole(const Weighted_point & p, CellIt cell_begin, CellIt cell_end, Cell_handle begin, int i) { @@ -1543,10 +1544,10 @@ namespace CGAL { } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > template - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: insert_in_hole(const Weighted_point & p, CellIt cell_begin, CellIt cell_end, Cell_handle begin, int i, Vertex_handle newv) { @@ -1563,9 +1564,9 @@ namespace CGAL { return v; } - template + template template - class Regular_triangulation_3::Vertex_remover { + class Regular_triangulation_3::Vertex_remover { typedef RegularTriangulation_3 Regular; typedef typename Gt::Point_3 Point; public: @@ -1603,9 +1604,9 @@ namespace CGAL { // on regular triangulation without hidden points at any time // the vertex inserter is used only // for the purpose of displacements - template + template template - class Regular_triangulation_3::Vertex_inserter { + class Regular_triangulation_3::Vertex_inserter { typedef RegularTriangulation_3 Regular; public: typedef Nullptr_t Hidden_points_iterator; @@ -1632,9 +1633,9 @@ namespace CGAL { } }; - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > void - Regular_triangulation_3:: + Regular_triangulation_3:: remove(Vertex_handle v) { Cell_handle c; @@ -1656,9 +1657,9 @@ namespace CGAL { } // Again, verbatim copy from Delaunay. - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: move_point(Vertex_handle v, const Weighted_point & p) { CGAL_triangulation_precondition(! is_infinite(v)); @@ -1681,9 +1682,9 @@ namespace CGAL { // Displacement works only for Regular triangulation // without hidden points at any time - template < class Gt, class Tds, bool Upm > - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template < class Gt, class Tds, class Lds > + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: move_if_no_collision(Vertex_handle v, const Weighted_point &p) { Self tmp; @@ -1695,9 +1696,9 @@ namespace CGAL { return res; } - template - typename Regular_triangulation_3::Vertex_handle - Regular_triangulation_3:: + template + typename Regular_triangulation_3::Vertex_handle + Regular_triangulation_3:: move(Vertex_handle v, const Weighted_point &p) { CGAL_triangulation_precondition(!is_infinite(v)); if(v->point() == p) return v; @@ -1707,9 +1708,9 @@ namespace CGAL { return Tr_Base::move(v,p,remover,inserter); } - template < class Gt, class Tds, bool Upm > + template < class Gt, class Tds, class Lds > bool - Regular_triangulation_3:: + Regular_triangulation_3:: is_valid(bool verbose, int level) const { if ( ! Tr_Base::is_valid(verbose,level) ) { diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 1ebad975da5..4c71013b653 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -57,16 +57,14 @@ #include #endif // no CGAL_NO_STRUCTURAL_FILTERING -#include - namespace CGAL { template < class GT, class Tds = Default, - bool used_by_parallel_mesh_3 = false > + class Locking_data_structure = void > class Triangulation_3; -template < class GT, class Tds, bool Upm > std::istream& operator>> -(std::istream& is, Triangulation_3 &tr); +template < class GT, class Tds, class Lds > std::istream& operator>> +(std::istream& is, Triangulation_3 &tr); #ifndef CGAL_NO_STRUCTURAL_FILTERING namespace internal { @@ -92,56 +90,97 @@ struct Structural_filtering_selector_3 { /************************************************ // Class Triangulation_3_base -// Two versions: sequential / parallel +// Two versions: with locking / without locking ************************************************/ -// Sequential -template +// With locking +template class Triangulation_3_base { -protected: - Triangulation_3_base() {} - - Triangulation_3_base(Mesh_3::LockDataStructureType *) {} - void swap(Triangulation_3_base &tr) {} - -public: - Mesh_3::LockDataStructureType *get_lock_data_structure() const - { - return 0; - } - - void set_lock_data_structure(Mesh_3::LockDataStructureType *) const - { - } - - void unlock_all_elements() {} -}; - -#ifdef CGAL_LINKED_WITH_TBB -// Parallel -template <> -class Triangulation_3_base -{ protected: Triangulation_3_base() : m_lock_ds(0) {} - Triangulation_3_base(Mesh_3::LockDataStructureType *p_lock_ds) + Triangulation_3_base(Locking_data_structure *p_lock_ds) : m_lock_ds(p_lock_ds) {} - void swap(Triangulation_3_base &tr) + void swap(Triangulation_3_base &tr) { std::swap(tr.m_lock_ds, m_lock_ds); } - + public: - Mesh_3::LockDataStructureType *get_lock_data_structure() const + // LOCKS + template + bool try_lock_vertex(const Vertex_handle &vh, int lock_radius = 0) const + { + bool locked = true; + if (m_lock_ds) + { + locked = m_lock_ds->try_lock(vh->point(), lock_radius).first; + } + return locked; + } + + template + bool try_lock_cell(const Cell_handle &cell_handle, int lock_radius = 0) const + { + bool success = true; + // Lock the element area on the grid + for (int iVertex = 0 ; success && iVertex < 4 ; ++iVertex) + { + success = try_lock_vertex(cell_handle->vertex(iVertex), lock_radius); + } + return success; + } + + template + bool try_lock_facet(const Facet &facet, int lock_radius = 0) const + { + bool success = true; + + // Lock the element area on the grid + for (int iVertex = (facet.second+1)&3 ; + success && iVertex != facet.second ; iVertex = (iVertex+1)&3) + { + success = try_lock_vertex(facet.first->vertex(iVertex), lock_radius); + } + + return success; + } + + template + bool is_point_locked_by_this_thread(const P3 &p) const + { + bool locked = true; + if (m_lock_ds) + { + locked = m_lock_ds->is_locked_by_this_thread(p); + } + return locked; + } + + template + bool is_cell_locked_by_this_thread(const Cell_handle &cell_handle) const + { + bool locked = true; + if (m_lock_ds) + { + for (int iVertex = 0 ; locked && iVertex < 4 ; ++iVertex) + { + locked = m_lock_ds->is_locked_by_this_thread( + cell_handle->vertex(iVertex)->point()); + } + } + return locked; + } + + Locking_data_structure *get_lock_data_structure() const { return m_lock_ds; } - void set_lock_data_structure(Mesh_3::LockDataStructureType *p_lock_ds) + void set_lock_data_structure(Locking_data_structure *p_lock_ds) { m_lock_ds = p_lock_ds; } @@ -155,9 +194,52 @@ public: } protected: - Mesh_3::LockDataStructureType *m_lock_ds; + Locking_data_structure *m_lock_ds; +}; + +// Without locking +template <> +class Triangulation_3_base +{ +protected: + Triangulation_3_base() {} + + Triangulation_3_base(void *) {} + void swap(Triangulation_3_base &tr) {} + +public: + // LOCKS (no-op functions) + template + bool try_lock_vertex(const Vertex_handle &, int = 0) const + { return true; } + + template + bool try_lock_cell(const Cell_handle &, int = 0) const + { return true; } + + template + bool try_lock_facet(const Facet &, int = 0) const + { return true; } + + template + bool is_point_locked_by_this_thread(const P3 &) const + { return false; } + + template + bool is_cell_locked_by_this_thread(const Cell_handle &) const + { return false; } + + void *get_lock_data_structure() const + { + return 0; + } + + void set_lock_data_structure(void *) const + { + } + + void unlock_all_elements() {} }; -#endif // CGAL_LINKED_WITH_TBB /************************************************ * @@ -165,17 +247,22 @@ protected: * ************************************************/ -template < class GT, class Tds_, bool used_by_parallel_mesh_3 > +template < class GT, class Tds_, class Locking_data_structure > class Triangulation_3 - : public Triangulation_3_base + : public Triangulation_3_base , public Triangulation_utils_3 { friend std::istream& operator>> <> - (std::istream& is, Triangulation_3 &tr); - - typedef Triangulation_3 Self; - typedef Triangulation_3_base Base; + (std::istream& is, Triangulation_3 &tr); + typedef Triangulation_3 Self; + typedef Triangulation_3_base Base; + + typedef typename Default::Get, + Triangulation_cell_base_3 > >::type Tds; +/* + // Useless: the user is responsible for providing a good TDS typedef typename Default::Get < Tds_, @@ -191,14 +278,14 @@ class Triangulation_3 && !defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) ,typename boost::mpl::if_c < - used_by_parallel_mesh_3, - Triangulation_lazy_ds_cell_base_3<>, - Triangulation_ds_cell_base_3<> + boost::is_same, + Triangulation_ds_cell_base_3<>, + Triangulation_lazy_ds_cell_base_3<> >::type #endif > > - >::type Tds; + >::type Tds;*/ public: @@ -582,100 +669,6 @@ public: bool is_infinite(const Edge & e) const { return is_infinite(e.first,e.second,e.third); } - // LOCKS (CONCURRENCY) - - bool try_lock_vertex(Vertex_handle vh, int lock_radius = 0) const - { -#ifdef CGAL_LINKED_WITH_TBB - // Parallel Mesh_3 - if (used_by_parallel_mesh_3) - { - Mesh_3::LockDataStructureType *p_lock_ds = Base::get_lock_data_structure(); - if (p_lock_ds) - { - return p_lock_ds->try_lock(vh->point(), lock_radius).first; - } - } -#endif // CGAL_LINKED_WITH_TBB - return true; - } - - bool try_lock_element(Cell_handle cell_handle, int lock_radius = 0) const - { - bool success = true; - -#ifdef CGAL_LINKED_WITH_TBB -# ifdef CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING - if (used_by_parallel_mesh_3) - { - // Lock the element area on the grid - for (int iVertex = 0 ; success && iVertex < 4 ; ++iVertex) - { - Vertex_handle vh = cell_handle->vertex(iVertex); - - success = try_lock_vertex(vh, lock_radius); - } - } -# endif -#endif // CGAL_LINKED_WITH_TBB - - return success; - } - bool try_lock_element(const Facet &facet, int lock_radius = 0) const - { - bool success = true; - -#ifdef CGAL_LINKED_WITH_TBB -# ifdef CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING - if (used_by_parallel_mesh_3) - { - // Lock the element area on the grid - Cell_handle cell = facet.first; - for (int iVertex = (facet.second+1)&3 ; - success && iVertex != facet.second ; iVertex = (iVertex+1)&3) - { - Vertex_handle vh = cell->vertex(iVertex); - success = try_lock_vertex(vh, lock_radius); - } - } -# endif // CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING -#endif // CGAL_LINKED_WITH_TBB - - return success; - } - - template - bool is_point_locked_by_this_thread(const P3 &p) const - { - bool locked = true; -#ifdef CGAL_LINKED_WITH_TBB -# ifdef CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING - Mesh_3::LockDataStructureType *p_lock_ds = Base::get_lock_data_structure(); - if (p_lock_ds) - { - locked = p_lock_ds->is_locked_by_this_thread(p); - } -# endif // CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING -#endif // CGAL_LINKED_WITH_TBB - return locked; - } - - bool is_element_locked_by_this_thread(Cell_handle cell_handle) const - { - bool locked = true; -#ifdef CGAL_LINKED_WITH_TBB -# ifdef CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING - Mesh_3::LockDataStructureType *p_lock_ds = Base::get_lock_data_structure(); - if (p_lock_ds) - { - locked = p_lock_ds->is_tetrahedra_locked_by_this_thread(*cell_handle); - } -# endif // CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING -#endif // CGAL_LINKED_WITH_TBB - return locked; - } - - //QUERIES bool is_vertex(const Point & p, Vertex_handle & v) const; @@ -1083,11 +1076,9 @@ protected: if (p_could_lock_zone) *p_could_lock_zone = true; - - // CJTODO: useless? if (p_could_lock_zone) { - if (!try_lock_element(d)) + if (!try_lock_cell(d)) { *p_could_lock_zone = false; return it; @@ -1095,7 +1086,6 @@ protected: } // To store the boundary cells, in case we need to rollback - // CJTODO: useless because it's already done in Regular_tri_3::find_conflicts? std::stack cell_stack; cell_stack.push(d); d->tds_data().mark_in_conflict(); @@ -1116,7 +1106,7 @@ protected: #ifdef CGAL_MESH_3_CONCURRENT_REFINEMENT_LOCK_ADJ_CELLS if (p_could_lock_zone) { - if (!try_lock_element(test)) + if (!try_lock_cell(test)) { *p_could_lock_zone = false; return it; @@ -1147,7 +1137,7 @@ protected: #if !defined(CGAL_MESH_3_CONCURRENT_REFINEMENT_LOCK_ADJ_CELLS) if (p_could_lock_zone) { - if (!try_lock_element(test)) + if (!try_lock_cell(test)) { *p_could_lock_zone = false; // Unlock @@ -1788,9 +1778,9 @@ public: bool is_valid_finite(Cell_handle c, bool verbose = false, int level=0) const; }; -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > std::istream & -operator>> (std::istream& is, Triangulation_3 &tr) +operator>> (std::istream& is, Triangulation_3 &tr) // reads // the dimension // the number of finite vertices @@ -1840,9 +1830,9 @@ operator>> (std::istream& is, Triangulation_3 &tr) return is; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > std::ostream & -operator<< (std::ostream& os, const Triangulation_3 &tr) +operator<< (std::ostream& os, const Triangulation_3 &tr) // writes : // the dimension // the number of finite vertices @@ -1938,60 +1928,60 @@ operator<< (std::ostream& os, const Triangulation_3 &tr) return os ; } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::size_type -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::size_type +Triangulation_3:: number_of_finite_cells() const { if ( dimension() < 3 ) return 0; return std::distance(finite_cells_begin(), finite_cells_end()); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::size_type -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::size_type +Triangulation_3:: number_of_cells() const { return _tds.number_of_cells(); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::size_type -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::size_type +Triangulation_3:: number_of_finite_facets() const { if ( dimension() < 2 ) return 0; return std::distance(finite_facets_begin(), finite_facets_end()); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::size_type -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::size_type +Triangulation_3:: number_of_facets() const { return _tds.number_of_facets(); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::size_type -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::size_type +Triangulation_3:: number_of_finite_edges() const { if ( dimension() < 1 ) return 0; return std::distance(finite_edges_begin(), finite_edges_end()); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::size_type -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::size_type +Triangulation_3:: number_of_edges() const { return _tds.number_of_edges(); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Triangle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Triangle +Triangulation_3:: triangle(const Cell_handle c, int i) const { CGAL_triangulation_precondition( dimension() == 2 || dimension() == 3 ); @@ -2007,9 +1997,9 @@ triangle(const Cell_handle c, int i) const c->vertex( (i+3)&3 )->point()); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Segment -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Segment +Triangulation_3:: segment(const Cell_handle c, int i, int j) const { CGAL_triangulation_precondition( i != j ); @@ -2020,10 +2010,10 @@ segment(const Cell_handle c, int i, int j) const return construct_segment( c->vertex(i)->point(), c->vertex(j)->point() ); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: is_infinite(const Cell_handle c, int i) const { CGAL_triangulation_precondition( dimension() == 2 || dimension() == 3 ); @@ -2034,10 +2024,10 @@ is_infinite(const Cell_handle c, int i) const is_infinite(c->vertex(i<=2 ? 3 : 2)); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: is_infinite(const Cell_handle c, int i, int j) const { CGAL_triangulation_precondition( i != j ); @@ -2047,9 +2037,9 @@ is_infinite(const Cell_handle c, int i, int j) const return is_infinite( c->vertex(i) ) || is_infinite( c->vertex(j) ); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_vertex(const Point & p, Vertex_handle & v) const { Locate_type lt; @@ -2061,45 +2051,45 @@ is_vertex(const Point & p, Vertex_handle & v) const return true; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: is_vertex(Vertex_handle v) const { return _tds.is_vertex(v); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_edge(Vertex_handle u, Vertex_handle v, Cell_handle & c, int & i, int & j) const { return _tds.is_edge(u, v, c, i, j); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_facet(Vertex_handle u, Vertex_handle v, Vertex_handle w, Cell_handle & c, int & i, int & j, int & k) const { return _tds.is_facet(u, v, w, c, i, j, k); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: is_cell(Cell_handle c) const { return _tds.is_cell(c); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_cell(Vertex_handle u, Vertex_handle v, Vertex_handle w, Vertex_handle t, Cell_handle & c, int & i, int & j, int & k, int & l) const @@ -2107,9 +2097,9 @@ is_cell(Vertex_handle u, Vertex_handle v, return _tds.is_cell(u, v, w, t, c, i, j, k, l); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_cell(Vertex_handle u, Vertex_handle v, Vertex_handle w, Vertex_handle t, Cell_handle & c) const @@ -2118,72 +2108,72 @@ is_cell(Vertex_handle u, Vertex_handle v, return _tds.is_cell(u, v, w, t, c, i, j, k, l); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: has_vertex(const Facet & f, Vertex_handle v, int & j) const { return _tds.has_vertex(f.first, f.second, v, j); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: has_vertex(Cell_handle c, int i, Vertex_handle v, int & j) const { return _tds.has_vertex(c, i, v, j); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: has_vertex(const Facet & f, Vertex_handle v) const { return _tds.has_vertex(f.first, f.second, v); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: has_vertex(Cell_handle c, int i, Vertex_handle v) const { return _tds.has_vertex(c, i, v); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: are_equal(Cell_handle c, int i, Cell_handle n, int j) const { return _tds.are_equal(c, i, n, j); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: are_equal(const Facet & f, const Facet & g) const { return _tds.are_equal(f.first, f.second, g.first, g.second); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline bool -Triangulation_3:: +Triangulation_3:: are_equal(const Facet & f, Cell_handle n, int j) const { return _tds.are_equal(f.first, f.second, n, j); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Cell_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Cell_handle +Triangulation_3:: #ifdef CGAL_NO_STRUCTURAL_FILTERING locate(const Point & p, Locate_type & lt, int & li, int & lj, Cell_handle start, bool *p_could_lock_zone) const @@ -2235,9 +2225,7 @@ exact_locate(const Point & p, Locate_type & lt, int & li, int & lj, #ifdef CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING if (p_could_lock_zone) { - // CJTODO: useless? already locked buy Mesher_level? - //c->lock(); // WARNING: not atomic! => DEADLOCKS? - if (!try_lock_element(c)) + if (!try_lock_cell(c)) { *p_could_lock_zone = false; return Cell_handle(); @@ -2308,7 +2296,7 @@ exact_locate(const Point & p, Locate_type & lt, int & li, int & lj, //previous->unlock(); // DON'T do that, "c" may be in // the same locking cell as "previous" //c->lock(); // WARNING: not atomic! => DEADLOCKS? - if (!try_lock_element(c)) + if (!try_lock_cell(c)) { *p_could_lock_zone = false; return Cell_handle(); @@ -2525,10 +2513,10 @@ exact_locate(const Point & p, Locate_type & lt, int & li, int & lj, } #ifndef CGAL_NO_STRUCTURAL_FILTERING -template +template inline -typename Triangulation_3::Cell_handle -Triangulation_3:: +typename Triangulation_3::Cell_handle +Triangulation_3:: inexact_locate(const Point & t, Cell_handle start, bool *p_could_lock_zone, int n_of_turns) const { @@ -2560,9 +2548,7 @@ inexact_locate(const Point & t, Cell_handle start, #ifdef CGAL_MESH_3_LOCKING_STRATEGY_SIMPLE_GRID_LOCKING if (p_could_lock_zone) { - // CJTODO: useless? already locked buy Mesher_level? - //c->lock(); // WARNING: not atomic! => DEADLOCKS? - if (!try_lock_element(c)) + if (!try_lock_cell(c)) { *p_could_lock_zone = false; return Cell_handle(); @@ -2608,7 +2594,7 @@ inexact_locate(const Point & t, Cell_handle start, //previous->unlock(); // DON'T do that, "c" may be in // the same locking cell as "previous" //c->lock(); // WARNING: not atomic! => DEADLOCKS? - if (!try_lock_element(c)) + if (!try_lock_cell(c)) { *p_could_lock_zone = false; return Cell_handle(); @@ -2622,9 +2608,9 @@ inexact_locate(const Point & t, Cell_handle start, } #endif // no CGAL_NO_STRUCTURAL_FILTERING -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > Bounded_side -Triangulation_3:: +Triangulation_3:: side_of_tetrahedron(const Point & p, const Point & p0, const Point & p1, @@ -2707,9 +2693,9 @@ side_of_tetrahedron(const Point & p, } } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > Bounded_side -Triangulation_3:: +Triangulation_3:: side_of_cell(const Point & p, Cell_handle c, Locate_type & lt, int & i, int & j) const @@ -2803,9 +2789,9 @@ side_of_cell(const Point & p, } // else infinite cell } // side_of_cell -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > Bounded_side -Triangulation_3:: +Triangulation_3:: side_of_triangle(const Point & p, const Point & p0, const Point & p1, @@ -2876,9 +2862,9 @@ side_of_triangle(const Point & p, } } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > Bounded_side -Triangulation_3:: +Triangulation_3:: side_of_facet(const Point & p, Cell_handle c, Locate_type & lt, int & li, int & lj) const @@ -2966,9 +2952,9 @@ side_of_facet(const Point & p, } } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > Bounded_side -Triangulation_3:: +Triangulation_3:: side_of_segment(const Point & p, const Point & p0, const Point & p1, @@ -3001,9 +2987,9 @@ side_of_segment(const Point & p, } } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > Bounded_side -Triangulation_3:: +Triangulation_3:: side_of_edge(const Point & p, Cell_handle c, Locate_type & lt, int & li) const @@ -3038,9 +3024,9 @@ side_of_edge(const Point & p, } } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: flip( Cell_handle c, int i ) { CGAL_triangulation_precondition( (dimension() == 3) && (0<=i) && (i<4) @@ -3089,9 +3075,9 @@ flip( Cell_handle c, int i ) return true; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > void -Triangulation_3:: +Triangulation_3:: flip_flippable( Cell_handle c, int i ) { CGAL_triangulation_precondition( (dimension() == 3) && (0<=i) && (i<4) @@ -3139,9 +3125,9 @@ flip_flippable( Cell_handle c, int i ) _tds.flip_flippable(c, i); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: flip( Cell_handle c, int i, int j ) // flips edge i,j of cell c { @@ -3182,9 +3168,9 @@ flip( Cell_handle c, int i, int j ) return true; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > void -Triangulation_3:: +Triangulation_3:: flip_flippable( Cell_handle c, int i, int j ) // flips edge i,j of cell c { @@ -3222,9 +3208,9 @@ flip_flippable( Cell_handle c, int i, int j ) _tds.flip_flippable(c, i, j); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert(const Point & p, Cell_handle start) { Locate_type lt; @@ -3233,9 +3219,9 @@ insert(const Point & p, Cell_handle start) return insert(p, lt, c, li, lj); } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert(const Point & p, Locate_type lt, Cell_handle c, int li, int lj) { switch (lt) { @@ -3257,10 +3243,10 @@ insert(const Point & p, Locate_type lt, Cell_handle c, int li, int lj) -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > template < class Conflict_tester, class Hidden_points_visitor > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert_in_conflict(const Point & p, Locate_type lt, Cell_handle c, int li, int /*lj*/, const Conflict_tester &tester, @@ -3407,9 +3393,9 @@ insert_in_conflict(const Point & p, } } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert_in_cell(const Point & p, Cell_handle c) { CGAL_triangulation_precondition( dimension() == 3 ); @@ -3429,10 +3415,10 @@ insert_in_cell(const Point & p, Cell_handle c) return v; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > inline -typename Triangulation_3::Vertex_handle -Triangulation_3:: +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert_in_facet(const Point & p, Cell_handle c, int i) { CGAL_triangulation_precondition( dimension() == 2 || dimension() == 3); @@ -3457,9 +3443,9 @@ insert_in_facet(const Point & p, Cell_handle c, int i) return v; } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert_in_edge(const Point & p, Cell_handle c, int i, int j) { CGAL_triangulation_precondition( i != j ); @@ -3495,9 +3481,9 @@ insert_in_edge(const Point & p, Cell_handle c, int i, int j) return v; } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert_outside_convex_hull(const Point & p, Cell_handle c) // c is an infinite cell containing p // p is strictly outside the convex hull @@ -3532,9 +3518,9 @@ insert_outside_convex_hull(const Point & p, Cell_handle c) } } -template < class GT, class Tds, bool Upm > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +template < class GT, class Tds, class Lds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: insert_outside_affine_hull(const Point & p) { CGAL_triangulation_precondition( dimension() < 3 ); @@ -3574,10 +3560,10 @@ insert_outside_affine_hull(const Point & p) return v; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > template < class OutputItCells > -typename Triangulation_3::Vertex_handle -Triangulation_3::insert_and_give_new_cells(const Point &p, +typename Triangulation_3::Vertex_handle +Triangulation_3::insert_and_give_new_cells(const Point &p, OutputItCells fit, Cell_handle start) { @@ -3603,10 +3589,10 @@ Triangulation_3::insert_and_give_new_cells(const Point &p, return v; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > template < class OutputItCells > -typename Triangulation_3::Vertex_handle -Triangulation_3::insert_and_give_new_cells(const Point& p, +typename Triangulation_3::Vertex_handle +Triangulation_3::insert_and_give_new_cells(const Point& p, OutputItCells fit, Vertex_handle hint) { @@ -3632,10 +3618,10 @@ Triangulation_3::insert_and_give_new_cells(const Point& p, return v; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > template < class OutputItCells > -typename Triangulation_3::Vertex_handle -Triangulation_3::insert_and_give_new_cells(const Point& p, +typename Triangulation_3::Vertex_handle +Triangulation_3::insert_and_give_new_cells(const Point& p, Locate_type lt, Cell_handle c, int li, int lj, OutputItCells fit) @@ -3662,9 +3648,9 @@ Triangulation_3::insert_and_give_new_cells(const Point& p, return v; } -template -typename Triangulation_3::Vertex_triple -Triangulation_3:: +template +typename Triangulation_3::Vertex_triple +Triangulation_3:: make_vertex_triple(const Facet& f) const { Cell_handle ch = f.first; @@ -3675,9 +3661,9 @@ make_vertex_triple(const Facet& f) const ch->vertex(vertex_triple_index(i,2))); } -template +template void -Triangulation_3:: +Triangulation_3:: make_canonical(Vertex_triple& t) const { int i = (&*(t.first) < &*(t.second))? 0 : 1; @@ -3703,9 +3689,9 @@ make_canonical(Vertex_triple& t) const } } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: test_dim_down(Vertex_handle v) const // tests whether removing v decreases the dimension of the triangulation // true iff @@ -3759,10 +3745,10 @@ test_dim_down(Vertex_handle v) const return true; } -template +template template < class VertexRemover > VertexRemover& -Triangulation_3:: +Triangulation_3:: make_hole_2D(Vertex_handle v, std::list &hole, VertexRemover &remover) { std::vector to_delete; @@ -3797,10 +3783,10 @@ make_hole_2D(Vertex_handle v, std::list &hole, VertexRemover &remover) // this one also erases a set of cells // which is useful to the move method // outputting newly created cells -template +template template < class VertexRemover > VertexRemover& -Triangulation_3:: +Triangulation_3:: make_hole_2D(Vertex_handle v, std::list &hole, VertexRemover &remover, std::set &cells_set) { @@ -3836,10 +3822,10 @@ make_hole_2D(Vertex_handle v, std::list &hole, VertexRemover &remover, return remover; } -template +template template < class VertexRemover > void -Triangulation_3:: +Triangulation_3:: fill_hole_2D(std::list & first_hole, VertexRemover &remover) { typedef std::list Hole; @@ -3973,10 +3959,10 @@ fill_hole_2D(std::list & first_hole, VertexRemover &remover) } } -template +template template < class VertexRemover, class OutputItCells > void -Triangulation_3:: +Triangulation_3:: fill_hole_2D(std::list & first_hole, VertexRemover &remover, OutputItCells fit) { @@ -4111,9 +4097,9 @@ fill_hole_2D(std::list & first_hole, VertexRemover &remover, } } -template +template void -Triangulation_3:: +Triangulation_3:: make_hole_3D( Vertex_handle v, std::map& outer_map, std::vector & hole) @@ -4136,10 +4122,10 @@ make_hole_3D( Vertex_handle v, } } -template +template template < class VertexRemover > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_dim_down(Vertex_handle v, VertexRemover &remover) { CGAL_triangulation_precondition (dimension() >= 0); @@ -4163,10 +4149,10 @@ remove_dim_down(Vertex_handle v, VertexRemover &remover) return remover; } -template +template template < class VertexRemover > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_1D(Vertex_handle v, VertexRemover &remover) { CGAL_triangulation_precondition (dimension() == 1); @@ -4181,10 +4167,10 @@ remove_1D(Vertex_handle v, VertexRemover &remover) return remover; } -template +template template < class VertexRemover > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_2D(Vertex_handle v, VertexRemover &remover) { CGAL_triangulation_precondition(dimension() == 2); @@ -4195,10 +4181,10 @@ remove_2D(Vertex_handle v, VertexRemover &remover) return remover; } -template +template template < class VertexRemover > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_3D(Vertex_handle v, VertexRemover &remover) { std::vector hole; @@ -4338,10 +4324,10 @@ remove_3D(Vertex_handle v, VertexRemover &remover) return remover; } -template +template template < class VertexRemover > void -Triangulation_3:: +Triangulation_3:: remove(Vertex_handle v, VertexRemover &remover) { CGAL_triangulation_precondition( v != Vertex_handle()); CGAL_triangulation_precondition( !is_infinite(v)); @@ -4364,10 +4350,10 @@ remove(Vertex_handle v, VertexRemover &remover) { // The remove here uses the remover, but // no function envolving hidden points // will be used in this internal version -template +template template < class VertexRemover, class OutputItCells > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_dim_down(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { remove_dim_down(v, remover); for(All_cells_iterator afi = tds().raw_cells_begin(); @@ -4376,10 +4362,10 @@ remove_dim_down(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { return remover; } -template +template template < class VertexRemover, class OutputItCells > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_1D(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { Point p = v->point(); remove_1D(v, remover); @@ -4387,10 +4373,10 @@ remove_1D(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { return remover; } -template +template template < class VertexRemover, class OutputItCells > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_2D(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { CGAL_triangulation_precondition(dimension() == 2); std::list hole; @@ -4400,10 +4386,10 @@ remove_2D(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { return remover; } -template +template template < class VertexRemover, class OutputItCells > VertexRemover& -Triangulation_3:: +Triangulation_3:: remove_3D(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { CGAL_triangulation_precondition(dimension() == 3); @@ -4550,10 +4536,10 @@ remove_3D(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { } -template +template template < class VertexRemover, class OutputItCells > void -Triangulation_3:: +Triangulation_3:: remove_and_give_new_cells(Vertex_handle v, VertexRemover &remover, OutputItCells fit) { CGAL_triangulation_precondition( v != Vertex_handle()); @@ -4577,10 +4563,10 @@ remove_and_give_new_cells(Vertex_handle v, VertexRemover &remover, // The VertexInserter is needed so as to // allow us the usage of the insertion method // from the particular triangulation -template +template template < class VertexRemover, class VertexInserter > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +typename Triangulation_3::Vertex_handle +Triangulation_3:: move_if_no_collision(Vertex_handle v, const Point &p, VertexRemover &remover, VertexInserter &inserter) { CGAL_assertion(remover.hidden_points_begin() == @@ -4894,13 +4880,13 @@ move_if_no_collision(Vertex_handle v, const Point &p, tds().delete_cells(hole.begin(), hole.end()); return v; } // end of Vertex_handle - // Triangulation_3:: + // Triangulation_3:: // move_if_no_collision(Vertex_handle,Point, VertexRemover, VertexInserter) -template +template template < class VertexRemover, class VertexInserter > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +typename Triangulation_3::Vertex_handle +Triangulation_3:: move(Vertex_handle v, const Point &p, VertexRemover &remover, VertexInserter &inserter) { CGAL_assertion(remover.hidden_points_begin() == @@ -4918,10 +4904,10 @@ move(Vertex_handle v, const Point &p, // The VertexInserter is needed so as to // allow us the usage of the insertion method // from the particular triangulation -template +template template < class VertexRemover, class VertexInserter, class OutputItCells > -typename Triangulation_3::Vertex_handle -Triangulation_3:: +typename Triangulation_3::Vertex_handle +Triangulation_3:: move_if_no_collision_and_give_new_cells(Vertex_handle v, const Point &p, VertexRemover &remover, VertexInserter &inserter, OutputItCells fit) { CGAL_assertion(remover.hidden_points_begin() == @@ -5280,9 +5266,9 @@ move_if_no_collision_and_give_new_cells(Vertex_handle v, const Point &p, return v; } -template +template void -Triangulation_3:: +Triangulation_3:: _make_big_hole_3D( Vertex_handle v, std::map& outer_map, std::vector & hole, @@ -5383,10 +5369,10 @@ _make_big_hole_3D( Vertex_handle v, } -template +template template < class InputIterator, class VertexRemover > bool -Triangulation_3:: +Triangulation_3:: _remove_cluster_3D(InputIterator first, InputIterator beyond, VertexRemover &remover, std::map &vstates) { InputIterator init = first; @@ -5567,29 +5553,29 @@ _remove_cluster_3D(InputIterator first, InputIterator beyond, VertexRemover &rem return true; } -template +template template < class InputIterator > bool -Triangulation_3:: +Triangulation_3:: does_repeat_in_range(InputIterator first, InputIterator beyond) const { std::set s; while (first!=beyond) if (! s.insert(*first++).second ) return true; return false; } -template +template template < class InputIterator > bool -Triangulation_3:: +Triangulation_3:: infinite_vertex_in_range(InputIterator first, InputIterator beyond) const { while(first != beyond) if(is_infinite(*first++)) return true; return false; } -template +template template < class InputIterator, class VertexRemover > -typename Triangulation_3::size_type -Triangulation_3:: +typename Triangulation_3::size_type +Triangulation_3:: remove(InputIterator first, InputIterator beyond, VertexRemover &remover) { CGAL_triangulation_precondition(!does_repeat_in_range(first, beyond)); CGAL_triangulation_precondition(!infinite_vertex_in_range(first, beyond)); @@ -5619,9 +5605,9 @@ remove(InputIterator first, InputIterator beyond, VertexRemover &remover) { return n - number_of_vertices(); } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_valid(bool verbose, int level) const { if ( ! _tds.is_valid(verbose,level) ) { @@ -5666,9 +5652,9 @@ is_valid(bool verbose, int level) const return true; } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_valid(Cell_handle c, bool verbose, int level) const { if ( ! _tds.is_valid(c,verbose,level) ) { @@ -5689,9 +5675,9 @@ is_valid(Cell_handle c, bool verbose, int level) const } -template < class GT, class Tds, bool Upm > +template < class GT, class Tds, class Lds > bool -Triangulation_3:: +Triangulation_3:: is_valid_finite(Cell_handle c, bool verbose, int) const { switch ( dimension() ) {