From 25b606c0522c0874cb3a10d90d9cfa419075b474 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Fri, 13 Apr 2001 12:20:52 +0000 Subject: [PATCH] - locate() interface changes to match the 2D case wrt the default start. - minor hierarchy speed up. --- Packages/Triangulation_3/TODO | 5 - Packages/Triangulation_3/changes.txt | 5 + .../include/CGAL/Delaunay_triangulation_3.h | 6 +- .../include/CGAL/Regular_triangulation_3.h | 6 +- .../include/CGAL/Triangulation_3.h | 143 +++++------------- .../CGAL/Triangulation_geom_traits_3.h | 10 -- .../include/CGAL/Triangulation_hierarchy_3.h | 59 +++----- 7 files changed, 73 insertions(+), 161 deletions(-) diff --git a/Packages/Triangulation_3/TODO b/Packages/Triangulation_3/TODO index 36533f82a97..87977b1849f 100644 --- a/Packages/Triangulation_3/TODO +++ b/Packages/Triangulation_3/TODO @@ -11,11 +11,6 @@ - ameliorer user manual - TEST SUITE - Traits : mettre a jour la doc. -- locate() : verifier que l'interface est la meme que dans T2D concernant la - cellule de depart. Plutot que prendre une cellule sur le bord, on peut - peut-etre prendre la premiere cellule de la liste, qui a de bonnes chances - d'y avoir ete mise recemment, et donc d'etre plus pret... ? -- Faire des benchs/profiles de points non-randoms... - Alignement des cellules en memoire : effets de cache + pointeurs a l'interieur des cellules pour le voisinage (Fred a deja fait => ask). - La gestion memoire (interne a l'allocateur new/delete) prend pas mal de diff --git a/Packages/Triangulation_3/changes.txt b/Packages/Triangulation_3/changes.txt index 9979dd8c0dd..f05e336880b 100644 --- a/Packages/Triangulation_3/changes.txt +++ b/Packages/Triangulation_3/changes.txt @@ -1,5 +1,10 @@ +Version 1.49 (13 Apr 01) +- locate() interface changes to match the 2D case wrt the default start. +- minor hierarchy speed up. + Version 1.48 (13 Apr 01) - for() scope VC++ bug workaround. +- facet circulator around an edge fix. Version 1.47 (9 Apr 01) - member template definition in class body for VC++. diff --git a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h index 0d52fbb9207..0419382fc41 100644 --- a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h @@ -295,7 +295,7 @@ insert(const Point & p, Cell_handle start) { Locate_type lt; int li, lj; - Cell_handle c = locate( p, start, lt, li, lj); + Cell_handle c = locate( p, lt, li, lj, start); if ( lt == VERTEX ) return c->vertex(li); // case OUTSIDE_CONVEX_HULL: @@ -312,7 +312,7 @@ insert(const Point & p, Cell_handle start) { Locate_type lt; int li, lj; - Cell_handle c = locate( p, start, lt, li, lj); + Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case OUTSIDE_CONVEX_HULL: case CELL: @@ -1108,7 +1108,7 @@ side_of_sphere(Cell_handle c, const Point & p) const c->vertex(3)->point(),p) ); // else infinite cell : int i0,i1,i2; - if ( (i3%2) == 1 ) { + if ( (i3&1) == 1 ) { i0 = (i3+1)&3; i1 = (i3+2)&3; i2 = (i3+3)&3; diff --git a/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h index d0bfbd6ea69..905dd3d1720 100644 --- a/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -360,7 +360,7 @@ insert(const Weighted_point & p, Cell_handle start ) { Locate_type lt; int li, lj; - Cell_handle c = locate( p, start, lt, li, lj); + Cell_handle c = locate( p, lt, li, lj, start); if ( lt == VERTEX ) { return c->vertex(li); } // TBD : look at the weight... @@ -392,7 +392,7 @@ insert(const Weighted_point & p, Cell_handle start ) { Locate_type lt; int li, lj; - Cell_handle c = locate( p, start, lt, li, lj); + Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case OUTSIDE_CONVEX_HULL: case CELL: @@ -429,7 +429,7 @@ insert(const Weighted_point & p, Cell_handle start ) { Locate_type lt; int li, lj; - Cell_handle c = locate( p, start, lt, li, lj); + Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case OUTSIDE_CONVEX_HULL: case EDGE: diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_3.h index c1887a32615..6f84598970d 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_3.h @@ -311,7 +311,6 @@ public: Segment segment(const Cell_handle c, int i, int j) const; - Segment segment(const Edge & e) const { return segment(e.first,e.second,e.third); } @@ -385,37 +384,27 @@ public: bool are_equal(const Facet & f, const Facet & g) const; bool are_equal(const Facet & f, Cell_handle n, int j) const; - Cell_handle locate(const Point & p) const; + Cell_handle + locate(const Point & p, + Locate_type & lt, int & li, int & lj, + Cell_handle start = Cell_handle()) const; Cell_handle - locate(const Point & p, Cell_handle start) const - { + locate(const Point & p, Cell_handle start = Cell_handle()) const + { Locate_type lt; int li, lj; - return locate( p, start, lt, li, lj); - } - - inline Cell_handle - locate(const Point & p, - Locate_type & lt, int & li, int & lj) const; + return locate( p, lt, li, lj, start); + } + // This one is for backward compatibility with CGAL 2.2. Cell_handle - locate(const Point & p, - Cell_handle start, - Locate_type & lt, int & li, int & lj) const; - // returns the (finite or infinite) cell p lies in - // starts at cell "start" - // start must be non NULL and finite - // if lt == OUTSIDE_CONVEX_HULL, li is the - // index of a facet separating p from the rest of the triangulation - // in dimension 2 : - // returns a facet (Cell_handle,li) if lt == FACET - // returns an edge (Cell_handle,li,lj) if lt == EDGE - // returns a vertex (Cell_handle,li) if lt == VERTEX - // if lt == OUTSIDE_CONVEX_HULL, li, lj give the edge of c - // separating p from the rest of the triangulation - // lt = OUTSIDE_AFFINE_HULL if p is not coplanar with the triangulation - + locate(const Point & p, Cell_handle start, + Locate_type & lt, int & li, int & lj) const + { + bool WARNING_YOU_ARE_USING_THE_DEPRECATED_VERSION_OF_LOCATE; + return locate(p, lt, li, lj, start); + } // PREDICATES ON POINTS ``TEMPLATED'' by the geom traits @@ -617,8 +606,6 @@ private: // traverses the boundary of the hat and finds adjacencies // traversal is done counterclockwise as seen from v - protected: - public: Vertex_handle @@ -756,25 +743,25 @@ public: void incident_cells(Vertex_handle v, std::set & cells, - Cell_handle c = (Cell*) NULL ) const; + Cell_handle c = Cell_handle() ) const; void incident_vertices(Vertex_handle v, std::set & vertices, - Cell_handle c = (Cell*) NULL ) const; + Cell_handle c = Cell_handle() ) const; // old methods, kept for compatibility with previous versions void incident_cells(Vertex_handle v, std::set & cells, - Cell_handle c = (Cell*) NULL, + Cell_handle c = Cell_handle(), int dummy_for_windows = 0) const; void incident_vertices(Vertex_handle v, std::set & vertices, - Cell_handle c = (Cell*) NULL, + Cell_handle c = Cell_handle(), int dummy_for_windows = 0) const; private: @@ -1384,54 +1371,11 @@ are_equal(const Facet & f, Cell_handle n, int j) const template < class GT, class Tds > Triangulation_3::Cell_handle Triangulation_3:: -locate(const Point & p) const -{ - Locate_type lt; - int li, lj; - Cell_handle start; - if ( dimension() >= 1 ) { - // there is at least one finite "cell" (or facet or edge) - start = infinite_vertex()->cell()->neighbor - ( infinite_vertex()->cell()->index( infinite_vertex()) ); - } - else { - start = NULL; - } - return locate( p, start, lt, li, lj); -} - -template < class GT, class Tds > -inline -Triangulation_3::Cell_handle -Triangulation_3:: -locate(const Point & p, - Locate_type & lt, - int & li, - int & lj) const -{ - Cell_handle start; - if ( dimension() >= 1 ) { - // there is at least one finite "cell" (or facet or edge) - start = infinite_vertex()->cell()->neighbor - ( infinite_vertex()->cell()->index( infinite_vertex()) ); - } - else { - start = NULL; - } - return locate( p, start, lt, li, lj); -} - -template < class GT, class Tds > -Triangulation_3::Cell_handle -Triangulation_3:: -locate(const Point & p, - const Cell_handle start, - Locate_type & lt, - int & li, - int & lj) const +locate(const Point & p, Locate_type & lt, int & li, int & lj, + Cell_handle start ) const // returns the (finite or infinite) cell p lies in // starts at cell "start" - // start must be non NULL + // start must be finite // if lt == OUTSIDE_CONVEX_HULL, li is the // index of a facet separating p from the rest of the triangulation // in dimension 2 : @@ -1443,17 +1387,19 @@ locate(const Point & p, // lt = OUTSIDE_AFFINE_HULL if p is not coplanar with the triangulation { int i, inf; + + if ( dimension() >= 1 && start == Cell_handle() ) + // there is at least one finite "cell" (or facet or edge) + start = infinite_vertex()->cell()->neighbor + ( infinite_vertex()->cell()->index( infinite_vertex()) ); + switch (dimension()) { case 3: { -// CGAL_triangulation_precondition -// ( (&(*start) != NULL) -// && ( ! start->has_vertex(infinite) ) ); -// Cell_handle c = start; - CGAL_triangulation_precondition( (&(*start) != NULL) ); - Cell_handle c, previous = NULL; + CGAL_triangulation_precondition( start != Cell_handle() ); + Cell_handle c, previous; int ind_inf; - if ( start->has_vertex(infinite,ind_inf) ) + if ( start->has_vertex(infinite, ind_inf) ) c = start->neighbor(ind_inf); else c = start; @@ -1581,14 +1527,10 @@ locate(const Point & p, } case 2: { -// CGAL_triangulation_precondition -// ( (&(*start) != NULL) -// && ( ! start->has_vertex(infinite) ) ); -// Cell_handle c = start; - CGAL_triangulation_precondition( (&(*start) != NULL) ); + CGAL_triangulation_precondition( start != Cell_handle() ); Cell_handle c; int ind_inf; - if ( start->has_vertex(infinite,ind_inf) ) + if ( start->has_vertex(infinite, ind_inf) ) c = start->neighbor(ind_inf); else c = start; @@ -1675,14 +1617,10 @@ locate(const Point & p, } case 1: { -// CGAL_triangulation_precondition -// ( (&(*start) != NULL) -// && ( ! start->has_vertex(infinite) ) ); -// Cell_handle c = start; - CGAL_triangulation_precondition( (&(*start) != NULL) ); + CGAL_triangulation_precondition( start != Cell_handle() ); Cell_handle c; int ind_inf; - if ( start->has_vertex(infinite,ind_inf) ) + if ( start->has_vertex(infinite, ind_inf) ) c = start->neighbor(ind_inf); else c = start; @@ -1829,7 +1767,6 @@ locate(const Point & p, li = 0; } return vit->cell(); - } case -1: { @@ -2608,17 +2545,13 @@ insert(const Point & p ) { Locate_type lt; int li, lj; - Cell_handle c; - Cell_handle start; + Cell_handle c, start; if ( dimension() >= 1 ) { // there is at least one finite "cell" (or facet or edge) start = infinite_vertex()->cell() ->neighbor( infinite_vertex()->cell()->index( infinite_vertex()) ); } - else { - start = NULL; - } - c = locate( p, start, lt, li, lj); + c = locate( p, lt, li, lj, start); switch (lt) { case VERTEX: return c->vertex(li); @@ -2644,7 +2577,7 @@ insert(const Point & p, Cell_handle start) { Locate_type lt; int li, lj; - Cell_handle c = locate( p, start, lt, li, lj); + Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case VERTEX: return c->vertex(li); diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_geom_traits_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_geom_traits_3.h index ae144bff612..d54a7ef4e70 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_geom_traits_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_geom_traits_3.h @@ -136,16 +136,6 @@ public: // And for the hierarchy : typedef typename Rep::Less_distance_to_point_3 Less_distance_to_point_3; - Triangulation_geom_traits_3() - {} - - Triangulation_geom_traits_3(const Triangulation_geom_traits_3 & ) - {} - - Triangulation_geom_traits_3 & - operator=(const Triangulation_geom_traits_3 & ) - {return *this;} - Compare_x_3 compare_x_3_object() const { return Compare_x_3(); diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index 19c2e18d30d..a2a9539a196 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -120,36 +120,31 @@ public: void remove(Vertex_handle v); //LOCATE - Cell_handle locate(const Point& p, Locate_type& lt,int& li, int &lj) const; - Cell_handle locate(const Point& p) const; + Cell_handle locate(const Point& p, Locate_type& lt, int& li, int& lj) const; + Cell_handle locate(const Point& p) const; private: - void locate(const Point& p, - Locate_type& lt, - int& li, - int& lj, - Cell_handle pos[Triangulation_hierarchy_3__maxlevel]) const; + void locate(const Point& p, Locate_type& lt, int& li, int& lj, + Cell_handle pos[Triangulation_hierarchy_3__maxlevel]) const; int random_level(); - - // added to make the test program of usual triangulations work - // undocuumented + // added to make the test program of usual triangulations work + // undocumented public: - Vertex_handle insert(const Point &p, Cell_handle start){ - return Tr_Base::insert(p,start); + Vertex_handle insert(const Point &p, Cell_handle start) + { + return Tr_Base::insert(p, start); } - Vertex_handle insert(const Point& p, - Locate_type lt, - Cell_handle loc, int li ){ + + Vertex_handle insert(const Point& p, Locate_type lt, Cell_handle loc, int li) + { return Tr_Base::insert(p); } - Cell_handle locate(const Point& p, - Locate_type& lt, - int& li, - int& lj, - Cell_handle start) const{ + Cell_handle locate(const Point& p, Locate_type& lt, int& li, int& lj, + Cell_handle start) const + { return Tr_Base::locate(p, lt, li, lj, start); } }; @@ -401,10 +396,7 @@ locate(const Point& p) const template void Triangulation_hierarchy_3:: -locate(const Point& p, - Locate_type& lt, - int& li, - int& lj, +locate(const Point& p, Locate_type& lt, int& li, int& lj, Cell_handle pos[Triangulation_hierarchy_3__maxlevel]) const { Cell_handle position; @@ -420,10 +412,7 @@ locate(const Point& p, } for (int i=level+1; i 0) { - if (position != NULL) - pos[level]=position=hierarchy[level]->locate(p,position); - else - pos[level]=position=hierarchy[level]->locate(p); + pos[level]=position=hierarchy[level]->locate(p,position); // locate at that level from "position" // result is stored in "position" for the next level // find the nearest between vertices 0 and 1 @@ -437,19 +426,19 @@ locate(const Point& p, else nearest = position->vertex(1); // compare to vertex 2 - if ( ! hierarchy[level]->is_infinite(position->vertex(2))) - if ( closer( position->vertex(2)->point(), - nearest->point())) + if ( ! hierarchy[level]->is_infinite(position->vertex(2))) + if ( closer( position->vertex(2)->point(), nearest->point())) nearest = position->vertex(2); + // compare to vertex 3 + if ( ! hierarchy[level]->is_infinite(position->vertex(3))) + if ( closer( position->vertex(3)->point(), nearest->point())) + nearest = position->vertex(3); // go at the same vertex on level below nearest = (Vertex*)( nearest->down() ); position = nearest->cell(); // incident cell --level; } - if (position != NULL) - pos[0]=hierarchy[level]->locate(p,position,lt,li,lj); // at level 0 - else - pos[0]=hierarchy[level]->locate(p,lt,li,lj); // at level 0 + pos[0]=hierarchy[level]->locate(p,lt,li,lj,position); // at level 0 }