From 720244f8f8fb902aae8bbb034f8fd779abd646cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 24 Oct 2012 21:39:38 +0000 Subject: [PATCH] apply the same choice as the one made in r73262 for CDT_2 --- .../Constrained_Delaunay_triangulation_2.h | 95 +++++++++++++------ 1 file changed, 66 insertions(+), 29 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h index 209fb4f58e5..1b8d744c818 100644 --- a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h @@ -120,7 +120,12 @@ public: void flip(Face_handle& f, int i); void flip_around(Vertex_handle va); void flip_around(List_vertices & new_vertices); - void propagating_flip(Face_handle& f,int i); +#ifdef CGAL_CDT2_USE_RECURSIVE_PROPAGATING_FLIP + void non_recursive_propagating_flip(Face_handle f,int i); + void propagating_flip(Face_handle f,int i, int depth=0); +#else + void propagating_flip(Face_handle f,int i); +#endif void propagating_flip(List_edges & edges); // CONFLICTS @@ -483,38 +488,70 @@ flip_around(List_vertices& new_vertices) } -template < class Gt, class Tds, class Itag > -void +#ifndef CGAL_DT2_USE_RECURSIVE_PROPAGATING_FLIP +template +void Constrained_Delaunay_triangulation_2:: -propagating_flip(Face_handle& f,int i) -// similar to the corresponding function in Delaunay_triangulation_2.h -{ -#ifdef CGAL_TRIANGULATION_2_USE_OLD_PROPAGATING_FLIP - if (!is_flipable(f,i)) return; - Face_handle ni = f->neighbor(i); - flip(f, i); // flip for constrained triangulations - propagating_flip(f,i); - i = ni->index(f->vertex(i)); - propagating_flip(ni,i); -#else // NO CGAL_TRIANGULATION_2_USE_OLD_PROPAGATING_FLIP - const Vertex_handle v = f->vertex(i); - std::stack stack; - stack.push(f); - while(!stack.empty()) { - Face_handle f = stack.top(); - stack.pop(); - const int i = f->index(v); - if (!is_flipable(f,i,true)) continue; - const Face_handle n = f->neighbor(i); - flip(f, i); // flip for constrained triangulations - stack.push(n); - stack.push(f); +non_recursive_propagating_flip(Face_handle f , int i) +{ + std::stack edges; + const Vertex_handle& vp = f->vertex(i); + edges.push(Edge(f,i)); + + while(! edges.empty()){ + const Edge& e = edges.top(); + f = e.first; + i = e.second; + + Face_handle ni = f->neighbor(i); + flip(f,i); + if ( !is_flipable(f,i) ) edges.pop(); + + i = n->index(vp); + if ( is_flipable(n,i) ) edges.push( Edge(n,i) ); } -#endif // NO CGAL_TRIANGULATION_2_USE_OLD_PROPAGATING_FLIP -} +} + +template +void +Constrained_Delaunay_triangulation_2:: +propagating_flip(Face_handle f,int i, int depth) +{ + if (!is_flipable(f,i)) return; +#ifdef CGAL_DT2_IMMEDIATELY_NON_RECURSIVE_PROPAGATING_FLIP + non_recursive_propagating_flip(f,i); +#else + int max_depth = 100; + if(depth==max_depth){ + non_recursive_propagating_flip(f,i); + return; + } + + Face_handle ni = f->neighbor(i); + flip(f, i); // flip for constrained triangulations + propagating_flip(f,i); + i = ni->index(f->vertex(i)); + propagating_flip(ni,i); +#endif +} +#else +template < class Gt, class Tds, class Itag > +void +Constrained_Delaunay_triangulation_2:: +propagating_flip(Face_handle f,int i) +// similar to the corresponding function in Delaunay_triangulation_2.h +{ + if (!is_flipable(f,i)) return; + Face_handle ni = f->neighbor(i); + flip(f, i); // flip for constrained triangulations + propagating_flip(f,i); + i = ni->index(f->vertex(i)); + propagating_flip(ni,i); +} +#endif template < class Gt, class Tds, class Itag > - void + void Constrained_Delaunay_triangulation_2:: propagating_flip(List_edges & edges) { propagating_flip(edges,Emptyset_iterator());