From d0578874d64dbeee00f12aa3d97042530b48acfa Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Thu, 27 Sep 2001 15:35:58 +0000 Subject: [PATCH] - Use handles for the TDS_2 in remove(). --- .../include/CGAL/Delaunay_remove_tds_3.h | 32 +++++++++++-------- .../include/CGAL/Delaunay_triangulation_3.h | 21 ++++++------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Packages/Triangulation_3/include/CGAL/Delaunay_remove_tds_3.h b/Packages/Triangulation_3/include/CGAL/Delaunay_remove_tds_3.h index 89c1c1729a0..4ac8a719345 100644 --- a/Packages/Triangulation_3/include/CGAL/Delaunay_remove_tds_3.h +++ b/Packages/Triangulation_3/include/CGAL/Delaunay_remove_tds_3.h @@ -240,26 +240,30 @@ private: Delaunay_remove_tds_vertex_3_2, Delaunay_remove_tds_face_3_2 > TDSUL2; -public: - typedef typename TDSUL2::Vertex Vertex_3_2; typedef typename TDSUL2::Face Face_3_2; +public: typedef typename TDSUL2::Face_iterator Face_iterator; + // At the moment, these handles are pointers. + typedef typename TDSUL2::Vertex* Vertex_handle_3_2; + typedef typename TDSUL2::Face* Face_handle_3_2; + // FIXME : similar to operator>>(), isn't it ? Should we try to factorize ? Delaunay_remove_tds_3_2(const std::vector & boundhole ) { - typedef quadruple Halfedge; + typedef quadruple Halfedge; std::vector halfedges; halfedges.reserve(3*boundhole.size()); - std::map vertex_map; - typename std::map::iterator map_it; + std::map vertex_map; + typename std::map::iterator map_it; for(typename std::vector::const_iterator fit = boundhole.begin(); fit != boundhole.end(); ++fit) { - Face_3_2 * f = create_face(); + Face_handle_3_2 f = create_face(); Facet facet = *fit; Cell_handle h = facet.first; @@ -277,7 +281,7 @@ public: } // We create as many 2d vertices as there are 3d vertices. - Vertex_3_2 *v0, *v1, *v2; + Vertex_handle_3_2 v0, v1, v2; Vertex_handle w0 = h->vertex(i0); @@ -315,8 +319,8 @@ public: f->set_info(facet); for(int j = 0; j < 3; j++) { - void* v = f->vertex(j); - void* w = f->vertex(cw(j)); + Vertex_handle_3_2 v = f->vertex(j); + Vertex_handle_3_2 w = f->vertex(cw(j)); halfedges.push_back((v < w) ? Halfedge(v, w, f, ccw(j)) : Halfedge(w, v, f, ccw(j))); } @@ -342,12 +346,12 @@ public: Face_3_2 dummy; - Face_3_2 *f = &dummy; + Face_handle_3_2 f = &dummy; for( Face_iterator fit2 = faces_begin(); fit2 != faces_end(); ++fit2) { - f->set_n(&(*fit2)); + f->set_n(&*fit2); fit2->set_p(f); - f = &(*fit2); + f = &*fit2; for(int i = 0; i < 3; i++) { // we mark an edge only on one side f->set_edge(i, (f < (f->neighbor(i)))); @@ -355,10 +359,10 @@ public: } // f points to the last face f->set_n(dummy.n()); - ((Face_3_2*)dummy.n())->set_p(f); + ((Face_handle_3_2)dummy.n())->set_p(f); } - void remove_degree_3(Vertex_3_2* v, Face_3_2* f) + void remove_degree_3(Vertex_handle_3_2 v, Face_handle_3_2 f) { int i = f->index(v); // As f->neighbor(cw(i)) and f->neighbor(ccw(i)) will be removed, diff --git a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h index 7f11b6796e0..d6821df45b9 100644 --- a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h @@ -1000,8 +1000,8 @@ Delaunay_triangulation_3:: fill_hole_3D_ear(const std::vector & boundhole) { typedef Delaunay_remove_tds_3_2 Surface; - typedef typename Surface::Face_3_2 Face_3_2; - typedef typename Surface::Vertex_3_2 Vertex_3_2; + typedef typename Surface::Face_handle_3_2 Face_handle_3_2; + typedef typename Surface::Vertex_handle_3_2 Vertex_handle_3_2; // The list of cells that gets created, so that we know what // we have to delete, in case that we cannot fill the hole @@ -1010,10 +1010,9 @@ fill_hole_3D_ear(const std::vector & boundhole) Surface surface(boundhole); - Face_3_2 *f = &(* surface.faces_begin()); - // Face_3_2 *last_op = NULL; // This is where the last ear was inserted - Face_3_2 *last_op = &(* surface.faces_begin()); // This is where the last - // ear was inserted + Face_handle_3_2 f = &* surface.faces_begin(); + Face_handle_3_2 last_op = f; // This is where the last ear was inserted + int k = -1; // This is a loop over the halfedges of the surface of the hole @@ -1025,7 +1024,7 @@ fill_hole_3D_ear(const std::vector & boundhole) k++; if(k == 3) { // The faces form a circular list. With f->n() we go to the next face. - f = (Face_3_2*)f->n(); + f = (Face_handle_3_2)f->n(); if(f == last_op) { // We looked at all edges without doing anything, that is we are // in an infinite loop. ==> Panic mode, delete created cells. @@ -1041,11 +1040,11 @@ fill_hole_3D_ear(const std::vector & boundhole) // This saves time, for example an edge gets not considered // from both adjacent faces. if(f->is_halfedge_marked(k)) { - Vertex_3_2 *w0, *w1, *w2, *w3; + Vertex_handle_3_2 w0, w1, w2, w3; Vertex_handle v0, v1, v2, v3; int i = ccw(k); int j = cw(k); - Face_3_2 *n = f->neighbor(k); + Face_handle_3_2 n = f->neighbor(k); int fi = n->index(f); w1 = f->vertex(i); @@ -1098,8 +1097,8 @@ fill_hole_3D_ear(const std::vector & boundhole) // we looked at all vertices - Face_3_2 *m_i = f->neighbor(i); - Face_3_2 *m_j = f->neighbor(j); + Face_handle_3_2 m_i = f->neighbor(i); + Face_handle_3_2 m_j = f->neighbor(j); bool neighbor_i = m_i == n->neighbor(cw(fi)); bool neighbor_j = m_j == n->neighbor(ccw(fi));