diff --git a/Packages/Triangulation_3/changes.txt b/Packages/Triangulation_3/changes.txt index a798de54ae6..83af97b3a03 100644 --- a/Packages/Triangulation_3/changes.txt +++ b/Packages/Triangulation_3/changes.txt @@ -1,5 +1,6 @@ Version 1.105 (?? February 02) - Shorten DS_Container::Free_elt so that TDS_2 can use it. +- New insert(Point, Locate_type, Cell_handle, int, int). Version 1.104 (5 February 02) - Various internal cleanups. 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 147d99bcad8..0e7d2684f88 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 @@ -81,6 +81,13 @@ triangulations. addition the empty sphere property of all the created faces. The optional argument \ccc{start} is used as a starting place for the search.} +\ccMethod{Vertex_handle insert(const Point & p, Locate_type lt, + Cell_handle loc, int li, int lj);} +{Inserts point \ccc{p} in the triangulation and returns the corresponding + vertex. Similar to the above \ccc{insert()} function, but takes as additional + parameter the return values of a previous location query. See description of + \ccc{locate()} above.} + The following method allows one to insert several points. It returns the number of inserted points. @@ -91,21 +98,6 @@ number of inserted points. \ccc{last}$\left.\right)$. \ccPrecond{The \ccc{value_type} of \ccc{first} and \ccc{last} is \ccc{Point}.}} -%\ccMethod{int insert(list::const_iterator first, -% list::const_iterator last);} -%{} -%\ccGlue -%\ccMethod{int insert(vector::const_iterator first, -% vector::const_iterator last);} -%{} -%\ccGlue -%\ccMethod{int insert(istream_iterator first, -% istream_iterator last);} -%{} -%\ccGlue -%\ccMethod{int insert(Point* first, -% Point* last);} -%{} \ccHeading{Removal} diff --git a/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Regular_triangulation_3.tex b/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Regular_triangulation_3.tex index 130edaa3f59..6b63cd44b4b 100644 --- a/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Regular_triangulation_3.tex +++ b/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Regular_triangulation_3.tex @@ -90,6 +90,13 @@ insertion creates a vertex, this vertex is returned. Otherwise, this method returns \ccc{NULL}. The optional argument \ccc{start} is used as a starting place for the search.} +\ccMethod{Vertex_handle insert(const Weighted_point & p, Locate_type lt, + Cell_handle loc, int li, int lj);} +{Inserts point \ccc{p} in the triangulation and returns the corresponding + vertex. Similar to the above \ccc{insert()} function, but takes as additional + parameter the return values of a previous location query. See description of + \ccc{locate()} above.} + The following method allows one to insert several points. It returns the number of inserted points. diff --git a/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Triangulation_3.tex b/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Triangulation_3.tex index 0ce2e582d2d..ba80d70a15e 100644 --- a/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Triangulation_3.tex +++ b/Packages/Triangulation_3/doc_tex/Triangulation_3_ref/Triangulation_3.tex @@ -564,6 +564,13 @@ triangulate the new infinite face. See Figure~\ref{Triangulation3-fig-insert_outside_affine_hull}. The optional argument \ccc{start} is used as a starting place for the search.} +\ccMethod{Vertex_handle insert(const Point & p, Locate_type lt, + Cell_handle loc, int li, int lj);} +{Inserts point \ccc{p} in the triangulation and returns the corresponding + vertex. Similar to the above \ccc{insert()} function, but takes as additional + parameter the return values of a previous location query. See description of + \ccc{locate()} above.} + \ccMethod{template < class InputIterator > int insert(InputIterator first, InputIterator last);} 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 147d99bcad8..0e7d2684f88 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 @@ -81,6 +81,13 @@ triangulations. addition the empty sphere property of all the created faces. The optional argument \ccc{start} is used as a starting place for the search.} +\ccMethod{Vertex_handle insert(const Point & p, Locate_type lt, + Cell_handle loc, int li, int lj);} +{Inserts point \ccc{p} in the triangulation and returns the corresponding + vertex. Similar to the above \ccc{insert()} function, but takes as additional + parameter the return values of a previous location query. See description of + \ccc{locate()} above.} + The following method allows one to insert several points. It returns the number of inserted points. @@ -91,21 +98,6 @@ number of inserted points. \ccc{last}$\left.\right)$. \ccPrecond{The \ccc{value_type} of \ccc{first} and \ccc{last} is \ccc{Point}.}} -%\ccMethod{int insert(list::const_iterator first, -% list::const_iterator last);} -%{} -%\ccGlue -%\ccMethod{int insert(vector::const_iterator first, -% vector::const_iterator last);} -%{} -%\ccGlue -%\ccMethod{int insert(istream_iterator first, -% istream_iterator last);} -%{} -%\ccGlue -%\ccMethod{int insert(Point* first, -% Point* last);} -%{} \ccHeading{Removal} diff --git a/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Regular_triangulation_3.tex b/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Regular_triangulation_3.tex index 130edaa3f59..6b63cd44b4b 100644 --- a/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Regular_triangulation_3.tex +++ b/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Regular_triangulation_3.tex @@ -90,6 +90,13 @@ insertion creates a vertex, this vertex is returned. Otherwise, this method returns \ccc{NULL}. The optional argument \ccc{start} is used as a starting place for the search.} +\ccMethod{Vertex_handle insert(const Weighted_point & p, Locate_type lt, + Cell_handle loc, int li, int lj);} +{Inserts point \ccc{p} in the triangulation and returns the corresponding + vertex. Similar to the above \ccc{insert()} function, but takes as additional + parameter the return values of a previous location query. See description of + \ccc{locate()} above.} + The following method allows one to insert several points. It returns the number of inserted points. diff --git a/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Triangulation_3.tex b/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Triangulation_3.tex index 0ce2e582d2d..ba80d70a15e 100644 --- a/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Triangulation_3.tex +++ b/Packages/Triangulation_3/doc_tex/basic/Triangulation_3_ref/Triangulation_3.tex @@ -564,6 +564,13 @@ triangulate the new infinite face. See Figure~\ref{Triangulation3-fig-insert_outside_affine_hull}. The optional argument \ccc{start} is used as a starting place for the search.} +\ccMethod{Vertex_handle insert(const Point & p, Locate_type lt, + Cell_handle loc, int li, int lj);} +{Inserts point \ccc{p} in the triangulation and returns the corresponding + vertex. Similar to the above \ccc{insert()} function, but takes as additional + parameter the return values of a previous location query. See description of + \ccc{locate()} above.} + \ccMethod{template < class InputIterator > int insert(InputIterator first, InputIterator last);} diff --git a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h index 178b85719f2..79def31e677 100644 --- a/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h @@ -201,6 +201,9 @@ public: Vertex_handle insert(const Point & p, Cell_handle start = NULL); + Vertex_handle insert(const Point & p, Locate_type lt, + Cell_handle c, int li, int); + // Obsolete. Vertex_handle push_back(const Point & p) { @@ -372,13 +375,21 @@ template < class Gt, class Tds > typename Delaunay_triangulation_3::Vertex_handle Delaunay_triangulation_3:: insert(const Point & p, Cell_handle start) +{ + Locate_type lt; + int li, lj; + Cell_handle c = locate(p, lt, li, lj, start); + return insert(p, lt, c, li, lj); +} + +template < class Gt, class Tds > +typename Delaunay_triangulation_3::Vertex_handle +Delaunay_triangulation_3:: +insert(const Point & p, Locate_type lt, Cell_handle c, int li, int) { switch (dimension()) { case 3: { - Locate_type lt; - int li, lj; - Cell_handle c = locate( p, lt, li, lj, start); if ( lt == VERTEX ) return c->vertex(li); @@ -389,9 +400,6 @@ insert(const Point & p, Cell_handle start) }// dim 3 case 2: { - Locate_type lt; - int li, lj; - Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case OUTSIDE_CONVEX_HULL: case CELL: @@ -413,9 +421,9 @@ insert(const Point & p, Cell_handle start) }//dim 2 default : // dimension <= 1 - return Tr_Base::insert(p,start); + return Tr_Base::insert(p, c); } -}// insert(p) +} template < class Gt, class Tds > void diff --git a/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 407e31eeb31..60acffe0e0b 100644 --- a/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -95,7 +95,10 @@ public: return number_of_vertices() - n; } - Vertex_handle insert( const Weighted_point & p, Cell_handle start = NULL); + Vertex_handle insert(const Weighted_point & p, Cell_handle start = NULL); + + Vertex_handle insert(const Weighted_point & p, Locate_type lt, + Cell_handle c, int li, int); Vertex_handle push_back(const Weighted_point &p) { @@ -353,14 +356,21 @@ template < class Gt, class Tds > typename Regular_triangulation_3::Vertex_handle Regular_triangulation_3:: insert(const Weighted_point & p, Cell_handle start) +{ + Locate_type lt; + int li, lj; + Cell_handle c = locate(p, lt, li, lj, start); + return insert(p, lt, c, li, lj); +} + +template < class Gt, class Tds > +typename Regular_triangulation_3::Vertex_handle +Regular_triangulation_3:: +insert(const Weighted_point & p, Locate_type lt, Cell_handle c, int li, int) { switch (dimension()) { case 3: { - Locate_type lt; - int li, lj; - Cell_handle c = locate( p, lt, li, lj, start); - if ( lt == VERTEX ) return c->vertex(li); // choice: not to do anything @@ -389,9 +399,6 @@ insert(const Weighted_point & p, Cell_handle start) } case 2: { - Locate_type lt; - int li, lj; - Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case OUTSIDE_CONVEX_HULL: case CELL: @@ -429,9 +436,6 @@ insert(const Weighted_point & p, Cell_handle start) }//dim 2 case 1: { - Locate_type lt; - int li, lj; - Cell_handle c = locate( p, lt, li, lj, start); switch (lt) { case OUTSIDE_CONVEX_HULL: case EDGE: @@ -488,7 +492,7 @@ insert(const Weighted_point & p, Cell_handle start) } default : { - return Tr_Base::insert(p,start); + return Tr_Base::insert(p, c); } } } diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_3.h index deb914540e5..0418451b760 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_3.h @@ -470,7 +470,9 @@ public: //INSERTION Vertex_handle insert(const Point & p, Cell_handle start = NULL); - + Vertex_handle insert(const Point & p, Locate_type lt, Cell_handle c, + int li, int lj); + // Obsolete. Vertex_handle push_back(const Point & p) { @@ -2297,6 +2299,14 @@ insert(const Point & p, Cell_handle start) Locate_type lt; int li, lj; Cell_handle c = locate( p, lt, li, lj, start); + return insert(p, lt, c, li, lj); +} + +template < class GT, class Tds > +typename Triangulation_3::Vertex_handle +Triangulation_3:: +insert(const Point & p, Locate_type lt, Cell_handle c, int li, int lj) +{ switch (lt) { case VERTEX: return c->vertex(li); diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h index b360a3e0356..0dc830698d4 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_hierarchy_3.h @@ -103,18 +103,25 @@ public: Cell_handle locate(const Point& p) const; private: + + struct locs { + Cell_handle pos; + int li, lj; + Locate_type lt; + }; + void locate(const Point& p, Locate_type& lt, int& li, int& lj, - Cell_handle pos[Triangulation_hierarchy_3__maxlevel]) const; + locs pos[Triangulation_hierarchy_3__maxlevel]) const; int random_level(); // added to make the test program of usual triangulations work // undocumented public: - // FIXME : This one could benefit from the hierarchy too. - 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, int lj) { - return Tr_Base::insert(p); + return Tr_Base::insert(p, lt, loc, li, lj); } Vertex_handle insert(const Point &p, Cell_handle start) @@ -266,16 +273,27 @@ insert(const Point &p) Locate_type lt; int i, j; // locate using hierarchy - Cell_handle positions[Triangulation_hierarchy_3__maxlevel]; + locs positions[Triangulation_hierarchy_3__maxlevel]; locate(p, lt, i, j, positions); // insert at level 0 - Vertex_handle vertex = hierarchy[0]->insert(p, positions[0]); + Vertex_handle vertex = hierarchy[0]->insert(p, + positions[0].lt, + positions[0].pos, + positions[0].li, + positions[0].lj); Vertex_handle previous = vertex; Vertex_handle first = vertex; int level = 1; while (level <= vertex_level ){ - vertex = hierarchy[level]->insert(p, positions[level]); + if (positions[level].pos == NULL) + vertex = hierarchy[level]->insert(p); + else + vertex = hierarchy[level]->insert(p, + positions[level].lt, + positions[level].pos, + positions[level].li, + positions[level].lj); vertex->set_down((void *) &*previous);// link with level above previous->set_up((void *) &*vertex); previous=vertex; @@ -310,9 +328,9 @@ typename Triangulation_hierarchy_3::Cell_handle Triangulation_hierarchy_3:: locate(const Point& p, Locate_type& lt, int& li, int& lj) const { - Cell_handle positions[Triangulation_hierarchy_3__maxlevel]; + locs positions[Triangulation_hierarchy_3__maxlevel]; locate(p, lt, li, lj, positions); - return positions[0]; + return positions[0].pos; } template @@ -330,7 +348,7 @@ template void Triangulation_hierarchy_3:: locate(const Point& p, Locate_type& lt, int& li, int& lj, - Cell_handle pos[Triangulation_hierarchy_3__maxlevel]) const + locs pos[Triangulation_hierarchy_3__maxlevel]) const { int level = Triangulation_hierarchy_3__maxlevel; @@ -342,13 +360,17 @@ locate(const Point& p, Locate_type& lt, int& li, int& lj, } for (int i=level+1; i 0) { // locate at that level from "position" // result is stored in "position" for the next level - pos[level] = position = hierarchy[level]->locate(p, position); + pos[level].pos = position = hierarchy[level]->locate(p, + pos[level].lt, + pos[level].li, + pos[level].lj, + position); // find the nearest vertex. Vertex_handle nearest = hierarchy[level]->nearest_vertex_in_cell(p, position); @@ -358,7 +380,10 @@ locate(const Point& p, Locate_type& lt, int& li, int& lj, position = nearest->cell(); // incident cell --level; } - pos[0] = hierarchy[level]->locate(p, lt, li, lj, position); // at level 0 + pos[0].pos = hierarchy[level]->locate(p, lt, li, lj, position); // at level 0 + pos[0].lt = lt; + pos[0].li = li; + pos[0].lj = lj; }