From fe0c6259431fd99a7b32fa3145df4e4b2ba78e6c Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Mon, 27 Jan 2003 11:11:14 +0000 Subject: [PATCH] - Delaunay_3::remove() now returns void. (bool is not needed anymore since it always works now) --- Packages/Triangulation_3/changes.txt | 2 + .../Delaunay_triangulation_3.tex | 8 +-- .../Delaunay_triangulation_3.tex | 8 +-- .../include/CGAL/Delaunay_triangulation_3.h | 69 ++++--------------- .../include/CGAL/Triangulation_hierarchy_3.h | 9 +-- .../include/CGAL/_test_cls_delaunay_3.C | 6 +- 6 files changed, 25 insertions(+), 77 deletions(-) diff --git a/Packages/Triangulation_3/changes.txt b/Packages/Triangulation_3/changes.txt index d3157529e57..6631609400b 100644 --- a/Packages/Triangulation_3/changes.txt +++ b/Packages/Triangulation_3/changes.txt @@ -1,5 +1,7 @@ Version 1.129 (27 Jan 03) - Fix mistakes in Regular documentation. +- Delaunay_3::remove() now returns void. + (bool is not needed anymore since it always works now) Version 1.128 (22 Jan 03) - MipsPro didn't like the changes for newer GCC. diff --git a/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Delaunay_triangulation_3.tex b/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Delaunay_triangulation_3.tex index 8abc73e1745..5ce6ba9cddd 100644 --- a/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Delaunay_triangulation_3.tex +++ b/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Delaunay_triangulation_3.tex @@ -124,12 +124,8 @@ However, when dealing with Delaunay triangulations, the case of such polyhedra that cannot be retriangulated cannot happen, so \cgal\ proposes a vertex removal. -\ccMethod{bool remove(Vertex_handle v);} -{Removes the vertex \ccc{v} from the triangulation and returns -\ccc{true}. It returns false if something went wrong, and in this case -the triangulation is not modified; this should not happen, but may -happen in denegerate cases if the predicates are not exact (which can -occur with a \cgal\ kernel if the arithmetic chosen is not good). +\ccMethod{void remove(Vertex_handle v);} +{Removes the vertex \ccc{v} from the triangulation. \ccPrecond{\ccc{v} is a vertex of the triangulation and it is not the infinite vertex.}} diff --git a/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Delaunay_triangulation_3.tex b/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Delaunay_triangulation_3.tex index 8abc73e1745..5ce6ba9cddd 100644 --- a/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Delaunay_triangulation_3.tex +++ b/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Delaunay_triangulation_3.tex @@ -124,12 +124,8 @@ However, when dealing with Delaunay triangulations, the case of such polyhedra that cannot be retriangulated cannot happen, so \cgal\ proposes a vertex removal. -\ccMethod{bool remove(Vertex_handle v);} -{Removes the vertex \ccc{v} from the triangulation and returns -\ccc{true}. It returns false if something went wrong, and in this case -the triangulation is not modified; this should not happen, but may -happen in denegerate cases if the predicates are not exact (which can -occur with a \cgal\ kernel if the arithmetic chosen is not good). +\ccMethod{void remove(Vertex_handle v);} +{Removes the vertex \ccc{v} from the triangulation. \ccPrecond{\ccc{v} is a vertex of the triangulation and it is not the infinite vertex.}} diff --git a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h index de0922b6e7b..6d1b3ed042f 100644 --- a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h @@ -1,6 +1,6 @@ // ============================================================================ // -// Copyright (c) 1999 The CGAL Consortium +// Copyright (c) 1999,2000,2001,2002,2003 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not @@ -250,7 +250,7 @@ public: } } - bool remove(Vertex_handle v); + void remove(Vertex_handle v); private: typedef Facet Edge_2D; void remove_2D(Vertex_handle v); @@ -326,9 +326,7 @@ private: void make_hole_3D_ear( Vertex_handle v, std::vector & boundhole, std::vector & hole); - void undo_make_hole_3D_ear(const std::vector & boundhole, - const std::vector & hole); - bool fill_hole_3D_ear(const std::vector & boundhole); + void fill_hole_3D_ear(const std::vector & boundhole); class Conflict_tester_3 { @@ -613,7 +611,7 @@ make_hole_2D(Vertex_handle v, std::list & hole) } template < class Gt, class Tds > -bool +void Delaunay_triangulation_3:: remove(Vertex_handle v) { @@ -632,19 +630,19 @@ remove(Vertex_handle v) tds().reorient(); } CGAL_triangulation_expensive_postcondition(is_valid()); - return true; + return; } if (dimension() == 1) { tds().remove_from_maximal_dimension_simplex(v); CGAL_triangulation_expensive_postcondition(is_valid()); - return true; + return; } if (dimension() == 2) { remove_2D(v); CGAL_triangulation_expensive_postcondition(is_valid()); - return true; + return; } CGAL_triangulation_assertion( dimension() == 3 ); @@ -656,16 +654,11 @@ remove(Vertex_handle v) make_hole_3D_ear(v, boundhole, hole); - bool filled = fill_hole_3D_ear(boundhole); - if(filled){ - tds().delete_vertex(v); - tds().delete_cells(hole.begin(), hole.end()); - } else { - undo_make_hole_3D_ear(boundhole, hole); - } + fill_hole_3D_ear(boundhole); + tds().delete_vertex(v); + tds().delete_cells(hole.begin(), hole.end()); CGAL_triangulation_expensive_postcondition(is_valid()); - return filled; } template < class Gt, class Tds > @@ -1121,27 +1114,9 @@ make_hole_3D_ear( Vertex_handle v, } } -// obsolete template < class Gt, class Tds > void Delaunay_triangulation_3:: -undo_make_hole_3D_ear(const std::vector & boundhole, - const std::vector & hole) -{ - typename std::vector::const_iterator cit = hole.begin(); - for(typename std::vector::const_iterator fit = boundhole.begin(); - fit != boundhole.end(); ++fit) { - Cell_handle ch = (*fit).first; - ch->set_neighbor((*fit).second, *cit); - ++cit; - // the vertices on the boundary of the hole still - // point to the cells that form the boundary of the hole - } -} - -template < class Gt, class Tds > -bool -Delaunay_triangulation_3:: fill_hole_3D_ear(const std::vector & boundhole) { typedef Delaunay_remove_tds_3_2 Surface; @@ -1149,11 +1124,6 @@ fill_hole_3D_ear(const std::vector & boundhole) 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 - std::vector cells; - cells.reserve(32); // 20 on average. - Surface surface(boundhole); Face_handle_3_2 f = surface.faces_begin(); @@ -1171,14 +1141,7 @@ fill_hole_3D_ear(const std::vector & boundhole) if(k == 3) { // The faces form a circular list. With f->n() we go to the next face. f = (Face_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. - std::cerr << "\nUnable to find an ear\n" << std::endl; - // std::cerr << surface << std::endl; - tds().delete_cells(cells.begin(), cells.end()); - return false; - } + CGAL_assertion_msg(f != last_op, "Unable to find an ear"); k = 0; } @@ -1246,7 +1209,6 @@ fill_hole_3D_ear(const std::vector & boundhole) // We are ready to plug a new cell Cell_handle ch = tds().create_cell(v0, v1, v2, v3); - cells.push_back(ch); // The new cell touches the faces that form the ear Facet fac = n->info(); @@ -1291,16 +1253,11 @@ fill_hole_3D_ear(const std::vector & boundhole) surface.remove_degree_3(f->vertex(i), f); f->mark_adjacent_edges(); f->set_info(Facet(ch,1)); - } else if (surface.number_of_vertices() != 4) { - // this should not happen at all => panic mode, - //clean up, and say that it didn't work - CGAL_triangulation_warning_msg(true, "panic"); - tds().delete_cells(cells.begin(), cells.end()); - return false; } else { + CGAL_assertion(surface.number_of_vertices() == 4); // when we leave the function the vertices and faces of the surface // are deleted by the destructor - return true; + return; } // we successfully inserted a cell diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index 9a720862534..09a51767f09 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -107,7 +107,7 @@ public: return number_of_vertices() - n; } - bool remove(Vertex_handle v); + void remove(Vertex_handle v); //LOCATE Cell_handle locate(const Point& p, Locate_type& lt, int& li, int& lj) const; @@ -314,23 +314,20 @@ insert(const Point &p) } template -bool +void Triangulation_hierarchy_3:: remove(Vertex_handle v) { CGAL_triangulation_precondition(v != NULL); void * u = v->up(); int l = 0; - bool result = true; while (1) { - if (! hierarchy[l++]->remove(v)) - result = false; + hierarchy[l++]->remove(v); if (!u || l>Triangulation_hierarchy_3__maxlevel) break; v = (Vertex*) u; u = v->up(); } - return result; } template diff --git a/Packages/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.C b/Packages/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.C index fd6d1d38a00..30d50740eb8 100644 --- a/Packages/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.C +++ b/Packages/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.C @@ -426,9 +426,9 @@ _test_cls_delaunay_3(const Triangulation &) vertices[i++] = &*vi; } int n = Tdel.number_of_vertices(); - for(int j = 0; j < n; j++) { - assert(Tdel.remove(Vertex_handle(vertices[j]))); - } + for(int j = 0; j < n; j++) + Tdel.remove(Vertex_handle(vertices[j])); + assert(Tdel.is_valid(false)); std::cout << " successfull" << std::endl; }