From 74cf687dd2020c8984caa73a3a90fdca36eebc92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 15 Apr 2017 20:27:08 +0200 Subject: [PATCH] Improved readability of Triangulation_2.h (no real changes) Only whitespace cleaning, indentation fixing, empty lines removal, etc. --- .../include/CGAL/Triangulation_2.h | 1947 ++++++++--------- 1 file changed, 951 insertions(+), 996 deletions(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 8ca8f7e84bd..c905ad9a848 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -12,10 +12,6 @@ // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // -// $URL$ -// $Id$ -// -// // Author(s) : Olivier Devillers, Mariette Yvinec #ifndef CGAL_TRIANGULATION_2_H @@ -23,7 +19,6 @@ #include - #include #include #include @@ -57,7 +52,7 @@ namespace CGAL { template < class Gt, class Tds > class Triangulation_2; template < class Gt, class Tds > std::istream& operator>> - (std::istream& is, Triangulation_2 &tr); + (std::istream& is, Triangulation_2 &tr); template < class Gt, class Tds > std::ostream& operator<< (std::ostream& os, const Triangulation_2 &tr); @@ -79,7 +74,7 @@ struct Structural_filtering_selector_2 { } #endif // no CGAL_NO_STRUCTURAL_FILTERING -template < class Gt, +template < class Gt, class Tds = Triangulation_data_structure_2 < Triangulation_vertex_base_2, Triangulation_face_base_2 > > @@ -102,7 +97,7 @@ public: typedef typename Tds::size_type size_type; typedef typename Tds::difference_type difference_type; - + typedef typename Tds::Vertex Vertex; typedef typename Tds::Face Face; typedef typename Tds::Edge Edge; @@ -117,24 +112,23 @@ public: typedef typename Tds::Edge_iterator All_edges_iterator; typedef typename Tds::Halfedge_iterator All_halfedges_iterator; typedef typename Tds::Vertex_iterator All_vertices_iterator; - - class Perturbation_order { - const Self *t; + class Perturbation_order + { + const Self *t; public: - Perturbation_order(const Self *tr) - : t(tr) {} + Perturbation_order(const Self *tr) : t(tr) {} - bool operator()(const Point *p, const Point *q) const { - return t->compare_xy(*p, *q) == SMALLER; - } + bool operator()(const Point *p, const Point *q) const { + return t->compare_xy(*p, *q) == SMALLER; + } }; friend class Perturbation_order; - // This class is used to generate the Finite_*_iterators. - class Infinite_tester + // This class is used to generate the Finite_*_iterators. + class Infinite_tester { const Triangulation_2 *t; public: @@ -142,7 +136,7 @@ public: Infinite_tester(const Triangulation_2 *tr) : t(tr) {} bool operator()(const All_vertices_iterator & vit) const { - return t->is_infinite(vit); + return t->is_infinite(vit); } bool operator()(const All_faces_iterator & fit ) const { return t->is_infinite(fit); @@ -150,13 +144,13 @@ public: bool operator()(const All_edges_iterator & eit) const { return t->is_infinite(eit); } - }; + }; //We derive in order to add a conversion to handle. class Finite_vertices_iterator : - public Filter_iterator + public Filter_iterator { - typedef Filter_iterator Base; + typedef Filter_iterator Base; typedef Finite_vertices_iterator Self; public: Finite_vertices_iterator() : Base() {} @@ -169,7 +163,7 @@ public: }; class Finite_faces_iterator - : public Filter_iterator + : public Filter_iterator { typedef Filter_iterator Base; typedef Finite_faces_iterator Self; @@ -182,11 +176,10 @@ public: Self operator--(int) { Self tmp(*this); --(*this); return tmp; } operator Face_handle() const { return Base::base(); } }; - - typedef Filter_iterator - Finite_edges_iterator; - + + typedef Filter_iterator Finite_edges_iterator; + //for backward compatibility typedef Finite_faces_iterator Face_iterator; typedef Finite_edges_iterator Edge_iterator; @@ -198,32 +191,30 @@ public: // do not use default template argument to please VC++ typedef Project_point Proj_point; - typedef boost::transform_iterator Point_iterator; + typedef boost::transform_iterator Point_iterator; typedef Point value_type; // to have a back_inserter - typedef const value_type& const_reference; + typedef const value_type& const_reference; typedef value_type& reference; - - - enum Locate_type {VERTEX=0, - EDGE, //1 - FACE, //2 - OUTSIDE_CONVEX_HULL, //3 - OUTSIDE_AFFINE_HULL}; //4 + + enum Locate_type {VERTEX=0, + EDGE, //1 + FACE, //2 + OUTSIDE_CONVEX_HULL, //3 + OUTSIDE_AFFINE_HULL}; //4 //Tag to distinguish Regular triangulations from others; typedef Tag_false Weighted_tag; - protected: - Gt _gt; + Gt _gt; Tds _tds; Vertex_handle _infinite_vertex; public: // CONSTRUCTORS - Triangulation_2(const Geom_traits& geom_traits=Geom_traits()); + Triangulation_2(const Geom_traits& geom_traits=Geom_traits()); Triangulation_2(const Triangulation_2 &tr); - + //Assignement Triangulation_2 &operator=(const Triangulation_2 &tr); @@ -232,60 +223,58 @@ public: void swap(Triangulation_2 &tr); void clear(); - //ACCESS FUNCTION const Geom_traits& geom_traits() const { return _gt;} - const Tds & tds() const { return _tds;} - Tds & tds() { return _tds;} + const Tds & tds() const { return _tds;} + Tds & tds() { return _tds;} int dimension() const { return _tds.dimension();} size_type number_of_vertices() const {return _tds.number_of_vertices() - 1;} - size_type number_of_faces() const; Vertex_handle infinite_vertex() const; Vertex_handle finite_vertex() const; Face_handle infinite_face() const; Infinite_tester infinite_tester() const; - + //SETTING void set_infinite_vertex(const Vertex_handle& v) {_infinite_vertex=v;} - + // CHECKING bool is_valid(bool verbose = false, int level = 0) const; - + // TEST INFINITE FEATURES AND OTHER FEATURES bool is_infinite(Face_handle f) const; - bool is_infinite(Vertex_handle v) const; + bool is_infinite(Vertex_handle v) const; bool is_infinite(Face_handle f, int i) const; bool is_infinite(const Edge& e) const; bool is_infinite(const Edge_circulator& ec) const; bool is_infinite(const All_edges_iterator& ei) const; bool is_edge(Vertex_handle va, Vertex_handle vb) const; bool is_edge(Vertex_handle va, Vertex_handle vb, Face_handle& fr, - int & i) const; + int & i) const; bool includes_edge(Vertex_handle va, Vertex_handle vb, - Vertex_handle& vbb, - Face_handle& fr, int & i) const; + Vertex_handle& vbb, + Face_handle& fr, int & i) const; bool is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) const; bool is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, - Face_handle &fr) const; + Face_handle &fr) const; - // GEOMETRIC FEATURES AND CONSTRUCTION + // GEOMETRIC FEATURES AND CONSTRUCTION Triangle triangle(Face_handle f) const; Segment segment(Face_handle f, int i) const; Segment segment(const Edge& e) const; Segment segment(const Edge_circulator& ec) const; Segment segment(const All_edges_iterator& ei) const; Segment segment(const Finite_edges_iterator& ei) const; - Point circumcenter(Face_handle f) const; - Point circumcenter(const Point& p0, - const Point& p1, - const Point& p2) const; - + Point circumcenter(Face_handle f) const; + Point circumcenter(const Point& p0, + const Point& p1, + const Point& p2) const; + //MOVE - INSERTION - DELETION - Flip public: - void flip(Face_handle f, int i); - + void flip(Face_handle f, int i); + Vertex_handle insert_first(const Point& p); Vertex_handle insert_second(const Point& p); Vertex_handle insert_in_edge(const Point& p, Face_handle f,int i); @@ -294,76 +283,74 @@ public: Vertex_handle insert_outside_affine_hull(const Point& p); Vertex_handle insert(const Point &p, Face_handle start = Face_handle() ); Vertex_handle insert(const Point& p, - Locate_type lt, - Face_handle loc, int li ); -// template < class InputIterator > -// std::ptrdiff_t insert(InputIterator first, InputIterator last); + Locate_type lt, + Face_handle loc, int li ); +// template < class InputIterator > +// std::ptrdiff_t insert(InputIterator first, InputIterator last); Vertex_handle push_back(const Point& a); - - void remove_degree_3(Vertex_handle v, Face_handle f = Face_handle()); - void remove_first(Vertex_handle v); + + void remove_degree_3(Vertex_handle v, Face_handle f = Face_handle()); + void remove_first(Vertex_handle v); void remove_second(Vertex_handle v); - void remove(Vertex_handle v); + void remove(Vertex_handle v); // MOVE Vertex_handle move_if_no_collision(Vertex_handle v, const Point &p); Vertex_handle move(Vertex_handle v, const Point &p); protected: // some internal methods - + // INSERT, REMOVE, MOVE GIVING NEW FACES template - Vertex_handle insert_and_give_new_faces(const Point &p, + Vertex_handle insert_and_give_new_faces(const Point &p, OutputItFaces fit, Face_handle start = Face_handle() ); template Vertex_handle insert_and_give_new_faces(const Point& p, Locate_type lt, - Face_handle loc, int li, + Face_handle loc, int li, OutputItFaces fit); template - void remove_and_give_new_faces(Vertex_handle v, + void remove_and_give_new_faces(Vertex_handle v, OutputItFaces fit); template - Vertex_handle move_if_no_collision_and_give_new_faces(Vertex_handle v, - const Point &p, + Vertex_handle move_if_no_collision_and_give_new_faces(Vertex_handle v, + const Point &p, OutputItFaces fit); public: - // POINT LOCATION Face_handle march_locate_1D(const Point& t, Locate_type& lt, int& li) const ; Face_handle march_locate_2D(Face_handle start, - const Point& t, - Locate_type& lt, - int& li) const; + const Point& t, + Locate_type& lt, + int& li) const; Face_handle march_locate_2D_LFC(Face_handle start, - const Point& t, - Locate_type& lt, - int& li) const; + const Point& t, + Locate_type& lt, + int& li) const; void compare_walks(const Point& p, - Face_handle c1, Face_handle c2, - Locate_type& lt1, Locate_type& lt2, - int li1, int li2) const; + Face_handle c1, Face_handle c2, + Locate_type& lt1, Locate_type& lt2, + int li1, int li2) const; #ifdef CGAL_NO_STRUCTURAL_FILTERING Face_handle locate(const Point& p, - Locate_type& lt, - int& li, - Face_handle start = Face_handle()) const; + Locate_type& lt, + int& li, + Face_handle start = Face_handle()) const; Face_handle - locate(const Point &p, - Face_handle start = Face_handle()) const; + locate(const Point &p, Face_handle start = Face_handle()) const; #else // no CGAL_NO_STRUCTURAL_FILTERING # ifndef CGAL_T2_STRUCTURAL_FILTERING_MAX_VISITED_CELLS # define CGAL_T2_STRUCTURAL_FILTERING_MAX_VISITED_CELLS 2500 @@ -375,7 +362,7 @@ protected: Locate_type& lt, int& li, Face_handle start) const; - + Face_handle generic_locate(const Point& p, Locate_type& lt, @@ -383,8 +370,8 @@ protected: Face_handle start, internal::Structural_filtering_2_tag) const { return exact_locate(p, lt, li, inexact_locate(p, start)); - } - + } + Face_handle generic_locate(const Point& p, Locate_type& lt, @@ -392,31 +379,30 @@ protected: Face_handle start, internal::No_structural_filtering_2_tag) const { return exact_locate(p, lt, li, start); - } - + } bool has_inexact_negative_orientation(const Point &p, const Point &q, - const Point &r) const; + const Point &r) const; public: Face_handle inexact_locate(const Point& p, - Face_handle start = Face_handle(), - int max_num_cells = + Face_handle start = Face_handle(), + int max_num_cells = CGAL_T2_STRUCTURAL_FILTERING_MAX_VISITED_CELLS) const; Face_handle locate(const Point & p, - Locate_type & lt, int & li, + Locate_type & lt, int & li, Face_handle start = Face_handle()) const { typedef Triangulation_structural_filtering_traits TSFT; - typedef typename internal::Structural_filtering_selector_2< + typedef typename internal::Structural_filtering_selector_2< TSFT::Use_structural_filtering_tag::value >::Tag Should_filter_tag; return generic_locate(p, lt, li, start, Should_filter_tag()); } - + Face_handle locate(const Point & p, Face_handle start = Face_handle()) const { @@ -424,16 +410,16 @@ public: int li; return locate(p, lt, li, start); } - + #endif // no CGAL_NO_STRUCTURAL_FILTERING - + //TRAVERSING : ITERATORS AND CIRCULATORS Finite_faces_iterator finite_faces_begin() const; Finite_faces_iterator finite_faces_end() const; Finite_vertices_iterator finite_vertices_begin() const; Finite_vertices_iterator finite_vertices_end() const; Finite_edges_iterator finite_edges_begin() const; - Finite_edges_iterator finite_edges_end() const; + Finite_edges_iterator finite_edges_end() const; Point_iterator points_begin() const; Point_iterator points_end() const; @@ -442,9 +428,9 @@ public: All_vertices_iterator all_vertices_begin() const; All_vertices_iterator all_vertices_end() const; All_edges_iterator all_edges_begin() const; - All_edges_iterator all_edges_end() const; + All_edges_iterator all_edges_end() const; All_halfedges_iterator all_halfedges_begin() const; - All_halfedges_iterator all_halfedges_end() const; + All_halfedges_iterator all_halfedges_end() const; //for compatibility with previous versions Face_iterator faces_begin() const {return finite_faces_begin();} @@ -454,22 +440,22 @@ public: Vertex_iterator vertices_begin() const {return finite_vertices_begin();} Vertex_iterator vertices_end() const {return finite_vertices_end();} - Face_circulator incident_faces( Vertex_handle v, - Face_handle f = Face_handle()) const; + Face_circulator incident_faces( Vertex_handle v, + Face_handle f = Face_handle()) const; Vertex_circulator incident_vertices(Vertex_handle v, - Face_handle f = Face_handle()) const; + Face_handle f = Face_handle()) const; Edge_circulator incident_edges(Vertex_handle v, - Face_handle f = Face_handle()) const; - + Face_handle f = Face_handle()) const; + size_type degree(Vertex_handle v) const; Vertex_handle mirror_vertex(Face_handle f, int i) const; int mirror_index(Face_handle v, int i) const; Edge mirror_edge(Edge e) const; - Line_face_circulator line_walk(const Point& p, - const Point& q, - Face_handle f = Face_handle()) const; + Line_face_circulator line_walk(const Point& p, + const Point& q, + Face_handle f = Face_handle()) const; // TO DEBUG void show_all() const; @@ -478,41 +464,39 @@ public: // IO // template < class Stream > -// Stream& draw_triangulation(Stream& os) const; +// Stream& draw_triangulation(Stream& os) const; - //PREDICATES - Oriented_side - oriented_side(const Point &p0, const Point &p1, - const Point &p2, const Point &p) const; - - Bounded_side - bounded_side(const Point &p0, const Point &p1, - const Point &p2, const Point &p) const; - - Oriented_side - oriented_side(Face_handle f, const Point &p) const; + //PREDICATES + Oriented_side + oriented_side(const Point &p0, const Point &p1, + const Point &p2, const Point &p) const; + Bounded_side + bounded_side(const Point &p0, const Point &p1, + const Point &p2, const Point &p) const; -Oriented_side -side_of_oriented_circle(const Point &p0, const Point &p1, const Point &p2, - const Point &p, bool perturb) const; + Oriented_side + oriented_side(Face_handle f, const Point &p) const; - Oriented_side - side_of_oriented_circle(Face_handle f, const Point & p, bool perturb = false) const; + Oriented_side + side_of_oriented_circle(const Point &p0, const Point &p1, const Point &p2, + const Point &p, bool perturb) const; - bool - collinear_between(const Point& p, const Point& q, const Point& r) - const; + Oriented_side + side_of_oriented_circle(Face_handle f, const Point & p, bool perturb = false) const; + + bool + collinear_between(const Point& p, const Point& q, const Point& r) + const; Comparison_result compare_x(const Point& p, const Point& q) const; - Comparison_result compare_xy(const Point& p, const Point& q) const; Comparison_result compare_y(const Point& p, const Point& q) const; bool xy_equal(const Point& p, const Point& q) const; - Orientation orientation(const Point& p, - const Point& q, - const Point& r) const; + Orientation orientation(const Point& p, + const Point& q, + const Point& r) const; protected: void remove_1D(Vertex_handle v); @@ -522,10 +506,10 @@ protected: void fill_hole_delaunay(std::list & hole); // output faces - template + template void fill_hole(Vertex_handle v, std::list & hole, OutputItFaces fit); - template + template void fill_hole_delaunay(std::list & hole, OutputItFaces fit); void make_hole(Vertex_handle v, std::list & hole, @@ -533,27 +517,27 @@ protected: public: void make_hole(Vertex_handle v, std::list & hole); -// template -// Vertex_handle star_hole( Point p, -// EdgeIt edge_begin, -// EdgeIt edge_end); +// template +// Vertex_handle star_hole( Point p, +// EdgeIt edge_begin, +// EdgeIt edge_end); -// template -// Vertex_handle star_hole( Point p, -// EdgeIt edge_begin, -// EdgeIt edge_end, -// FaceIt face_begin, -// FaceIt face_end); +// template +// Vertex_handle star_hole( Point p, +// EdgeIt edge_begin, +// EdgeIt edge_end, +// FaceIt face_begin, +// FaceIt face_end); Face_handle create_face(Face_handle f1d, int i1, - Face_handle f2, int i2, - Face_handle f3, int i3); + Face_handle f2, int i2, + Face_handle f3, int i3); Face_handle create_face(Face_handle f1, int i1, - Face_handle f2, int i2); + Face_handle f2, int i2); Face_handle create_face(Face_handle f, int i, Vertex_handle v); Face_handle create_face(Vertex_handle v1, Vertex_handle v2,Vertex_handle v3); Face_handle create_face(Vertex_handle v1, Vertex_handle v2,Vertex_handle v3, - Face_handle f1, Face_handle f2, Face_handle f3); + Face_handle f1, Face_handle f2, Face_handle f3); Face_handle create_face(); Face_handle create_face(Face_handle); //calls copy constructor of Face void delete_face(Face_handle f); @@ -570,18 +554,18 @@ public: private: Vertex_handle insert_outside_convex_hull_1(const Point& p, Face_handle f); Vertex_handle insert_outside_convex_hull_2(const Point& p, Face_handle f); - + // template members public: -template < class Stream > -Stream& draw_triangulation(Stream& os) const -{ - Finite_edges_iterator it = finite_edges_begin(); - for( ;it != finite_edges_end() ; ++it) { - os << segment(it); + template < class Stream > + Stream& draw_triangulation(Stream& os) const + { + Finite_edges_iterator it = finite_edges_begin(); + for( ;it != finite_edges_end() ; ++it) { + os << segment(it); + } + return os; } - return os; -} template < class InputIterator > std::ptrdiff_t insert(InputIterator first, InputIterator last) @@ -606,7 +590,7 @@ bool well_oriented(Vertex_handle v) const Vertex_handle v0 = fc->vertex(0); Vertex_handle v1 = fc->vertex(1); Vertex_handle v2 = fc->vertex(2); - if(orientation(v0->point(),v1->point(),v2->point()) + if(orientation(v0->point(),v1->point(),v2->point()) != COUNTERCLOCKWISE) return false; } } while(++fc != done); @@ -621,52 +605,50 @@ bool from_convex_hull(Vertex_handle v) { } public: - template - Vertex_handle star_hole( const Point& p, - EdgeIt edge_begin, - EdgeIt edge_end) { - std::list empty_list; - return star_hole(p, - edge_begin, - edge_end, - empty_list.begin(), - empty_list.end()); - } - - template - Vertex_handle star_hole( const Point& p, - EdgeIt edge_begin, - EdgeIt edge_end, - FaceIt face_begin, - FaceIt face_end) { - Vertex_handle v = _tds.star_hole( edge_begin, edge_end, - face_begin, face_end); - v->set_point(p); - return v; - } +template +Vertex_handle star_hole( const Point& p, + EdgeIt edge_begin, + EdgeIt edge_end) { + std::list empty_list; + return star_hole(p, + edge_begin, + edge_end, + empty_list.begin(), + empty_list.end()); +} +template +Vertex_handle star_hole( const Point& p, + EdgeIt edge_begin, + EdgeIt edge_end, + FaceIt face_begin, + FaceIt face_end) { + Vertex_handle v = _tds.star_hole( edge_begin, edge_end, + face_begin, face_end); + v->set_point(p); + return v; +} }; // CONSTRUCTORS template Triangulation_2:: -Triangulation_2(const Geom_traits& geom_traits) - : _gt(geom_traits), _tds() +Triangulation_2(const Geom_traits& geom_traits) + : _gt(geom_traits), _tds() { _infinite_vertex = _tds.insert_first(); } - + // copy constructor duplicates vertices and faces template Triangulation_2:: Triangulation_2(const Triangulation_2 &tr) - : _gt(tr._gt) + : _gt(tr._gt) { _infinite_vertex = _tds.copy_tds(tr._tds, tr.infinite_vertex()); -} - +} - //Assignement +//Assignement template Triangulation_2 & Triangulation_2:: @@ -676,11 +658,11 @@ operator=(const Triangulation_2 &tr) return *this; } - // Helping functions +// Helping functions template void -Triangulation_2:: +Triangulation_2:: copy_triangulation(const Triangulation_2 &tr) { _tds.clear(); @@ -690,23 +672,23 @@ copy_triangulation(const Triangulation_2 &tr) template void -Triangulation_2:: +Triangulation_2:: swap(Triangulation_2 &tr) { Vertex_handle v= _infinite_vertex; _infinite_vertex = tr._infinite_vertex; tr._infinite_vertex = v; - + _tds.swap(tr._tds); Geom_traits t = geom_traits(); _gt = tr.geom_traits(); - tr._gt = t; + tr._gt = t; } template void -Triangulation_2:: +Triangulation_2:: clear() { _tds.clear(); //detruit tous les sommets et toutes les faces @@ -719,38 +701,37 @@ Triangulation_2:: number_of_faces() const { size_type count = _tds.number_of_faces(); - Face_circulator fc = incident_faces(infinite_vertex()), - done(fc); + Face_circulator fc = incident_faces(infinite_vertex()), done(fc); if ( ! fc.is_empty() ) { - do { + do { --count; ++fc; - } while (fc != done); + } while (fc != done); } return count; } template inline -typename Triangulation_2::Vertex_handle +typename Triangulation_2::Vertex_handle Triangulation_2:: infinite_vertex() const { - return _infinite_vertex; + return _infinite_vertex; } template inline -typename Triangulation_2::Vertex_handle +typename Triangulation_2::Vertex_handle Triangulation_2:: finite_vertex() const { CGAL_triangulation_precondition (number_of_vertices() >= 1); return (finite_vertices_begin()); } - + template inline -typename Triangulation_2::Face_handle +typename Triangulation_2::Face_handle Triangulation_2:: infinite_face() const { @@ -766,15 +747,14 @@ infinite_tester() const return Infinite_tester(this); } - template bool Triangulation_2:: is_valid(bool verbose, int level) const { bool result = _tds.is_valid(verbose, level); - if (dimension() <= 0 || - (dimension()==1 && number_of_vertices() == 2 ) ) return result; + if (dimension() <= 0 || (dimension()==1 && number_of_vertices() == 2 ) ) + return result; if (dimension() == 1) { Finite_vertices_iterator it1 = finite_vertices_begin(), @@ -783,21 +763,20 @@ is_valid(bool verbose, int level) const ++it3; ++it3; while( it3 != finite_vertices_end()) { Orientation s = orientation(it1->point(), - it2->point(), - it3->point()); + it2->point(), + it3->point()); result = result && s == COLLINEAR ; CGAL_triangulation_assertion(result); ++it1 ; ++it2; ++it3; } - } - + } else { //dimension() == 2 - for(Finite_faces_iterator it=finite_faces_begin(); - it!=finite_faces_end(); it++) { + for(Finite_faces_iterator it=finite_faces_begin(); + it!=finite_faces_end(); it++) { CGAL_triangulation_assertion( ! is_infinite(it)); Orientation s = orientation(it->vertex(0)->point(), - it->vertex(1)->point(), - it->vertex(2)->point()); + it->vertex(1)->point(), + it->vertex(2)->point()); CGAL_triangulation_assertion( s == LEFT_TURN ); result = result && ( s == LEFT_TURN ); } @@ -806,39 +785,37 @@ is_valid(bool verbose, int level) const Vertex_circulator pc(start); Vertex_circulator qc(start); ++qc; Vertex_circulator rc(start); ++rc; ++rc; - do{ + do { Orientation s = orientation(pc->point(), - qc->point(), - rc->point()); + qc->point(), + rc->point()); CGAL_triangulation_assertion( s != LEFT_TURN ); result = result && ( s != LEFT_TURN ); ++pc ; ++qc ; ++rc; - }while(pc != start); + } while(pc != start); // check number of faces. This cannot be done by the Tds // which does not know the number of components nor the genus result = result && (number_of_faces() == 2*(number_of_vertices()+1) - - 4 - - degree(infinite_vertex())); + - 4 + - degree(infinite_vertex())); CGAL_triangulation_assertion( result); } return result; } - template inline bool Triangulation_2:: -is_infinite(Face_handle f) const +is_infinite(Face_handle f) const { return f->has_vertex(infinite_vertex()); } - template inline bool Triangulation_2:: -is_infinite(Vertex_handle v) const +is_infinite(Vertex_handle v) const { return v == infinite_vertex(); } @@ -846,7 +823,7 @@ is_infinite(Vertex_handle v) const template inline bool Triangulation_2:: -is_infinite(Face_handle f, int i) const +is_infinite(Face_handle f, int i) const { return is_infinite(f->vertex(ccw(i))) || is_infinite(f->vertex(cw(i))); @@ -855,15 +832,15 @@ is_infinite(Face_handle f, int i) const template inline bool Triangulation_2:: -is_infinite(const Edge& e) const +is_infinite(const Edge& e) const { return is_infinite(e.first,e.second); } - + template inline bool Triangulation_2:: -is_infinite(const Edge_circulator& ec) const +is_infinite(const Edge_circulator& ec) const { return is_infinite(*ec); } @@ -871,7 +848,7 @@ is_infinite(const Edge_circulator& ec) const template inline bool Triangulation_2:: -is_infinite(const All_edges_iterator& ei) const +is_infinite(const All_edges_iterator& ei) const { return is_infinite(*ei); } @@ -893,47 +870,47 @@ is_edge(Vertex_handle va, Vertex_handle vb, Face_handle& fr, int & i) const } template -bool +bool Triangulation_2:: includes_edge(Vertex_handle va, Vertex_handle vb, - Vertex_handle & vbb, - Face_handle& fr, int & i) const - // returns true if the line segment ab contains an edge e of t - // incident to a, false otherwise - // if true, vbb becomes the vertex of e distinct from a - // fr is the face incident to e and e=(fr,i) - // fr is on the right side of a->b + Vertex_handle & vbb, + Face_handle& fr, int & i) const +// returns true if the line segment ab contains an edge e of t +// incident to a, false otherwise +// if true, vbb becomes the vertex of e distinct from a +// fr is the face incident to e and e=(fr,i) +// fr is on the right side of a->b { Vertex_handle v; Orientation orient; int indv; Edge_circulator ec = incident_edges(va), done(ec); if (ec != 0) { - do { + do { //find the index of the other vertex of *ec - indv = 3 - ((*ec).first)->index(va) - (*ec).second ; + indv = 3 - ((*ec).first)->index(va) - (*ec).second ; v = ((*ec).first)->vertex(indv); if (!is_infinite(v)) { - if (v==vb) { - vbb = vb; - fr=(*ec).first; - i= (*ec).second; - return true; - } - else { - orient = orientation(va->point(), - vb->point(), - v->point()); - if((orient==COLLINEAR) && - (collinear_between (va->point(), - v->point(), - vb->point()))) { - vbb = v; - fr=(*ec).first; - i= (*ec).second; - return true; - } - } + if (v==vb) { + vbb = vb; + fr=(*ec).first; + i= (*ec).second; + return true; + } + else { + orient = orientation(va->point(), + vb->point(), + v->point()); + if((orient==COLLINEAR) && + (collinear_between (va->point(), + v->point(), + vb->point()))) { + vbb = v; + fr=(*ec).first; + i= (*ec).second; + return true; + } + } } } while (++ec != done); } @@ -941,7 +918,7 @@ includes_edge(Vertex_handle va, Vertex_handle vb, } template -inline bool +inline bool Triangulation_2:: is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) const { @@ -949,28 +926,27 @@ is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) const } template -inline bool +inline bool Triangulation_2:: -is_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Face_handle &fr) const +is_face(Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3, + Face_handle &fr) const { return _tds.is_face(v1, v2, v3, fr); } - template typename Triangulation_2::Triangle Triangulation_2:: triangle(Face_handle f) const { CGAL_triangulation_precondition( ! is_infinite(f) ); - typename Gt::Construct_triangle_2 - construct_triangle = geom_traits().construct_triangle_2_object(); + typename Gt::Construct_triangle_2 + construct_triangle = geom_traits().construct_triangle_2_object(); return construct_triangle(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point()); + f->vertex(1)->point(), + f->vertex(2)->point()); } template @@ -979,10 +955,10 @@ Triangulation_2:: segment(Face_handle f, int i) const { CGAL_triangulation_precondition( ! is_infinite(f,i)); - typename Gt::Construct_segment_2 - construct_segment = geom_traits().construct_segment_2_object(); + typename Gt::Construct_segment_2 + construct_segment = geom_traits().construct_segment_2_object(); return construct_segment(f->vertex(ccw(i))->point(), - f->vertex(cw(i))->point()); + f->vertex(cw(i))->point()); } template @@ -990,11 +966,11 @@ typename Triangulation_2::Segment Triangulation_2:: segment(const Edge& e) const { - CGAL_triangulation_precondition(! is_infinite(e)); - typename Gt::Construct_segment_2 - construct_segment = geom_traits().construct_segment_2_object(); + CGAL_triangulation_precondition(! is_infinite(e)); + typename Gt::Construct_segment_2 + construct_segment = geom_traits().construct_segment_2_object(); return construct_segment(e.first->vertex(ccw(e.second))->point(), - e.first->vertex( cw(e.second))->point()); + e.first->vertex( cw(e.second))->point()); } template @@ -1004,7 +980,7 @@ segment(const Edge_circulator& ec) const { return segment(*ec); } - + template typename Triangulation_2::Segment Triangulation_2:: @@ -1028,17 +1004,17 @@ flip(Face_handle f, int i) { CGAL_triangulation_precondition ( f != Face_handle() ); CGAL_triangulation_precondition (i == 0 || i == 1 || i == 2); - CGAL_triangulation_precondition( dimension()==2); - - CGAL_triangulation_precondition( !is_infinite(f) && - !is_infinite(f->neighbor(i)) ); - CGAL_triangulation_precondition( - orientation(f->vertex(i)->point(), - f->vertex(cw(i))->point(), - mirror_vertex(f,i)->point()) == RIGHT_TURN && - orientation(f->vertex(i)->point(), - f->vertex(ccw(i))->point(), - mirror_vertex(f,i)->point()) == LEFT_TURN); + CGAL_triangulation_precondition( dimension()==2); + + CGAL_triangulation_precondition( !is_infinite(f) && + !is_infinite(f->neighbor(i)) ); + CGAL_triangulation_precondition( + orientation(f->vertex(i)->point(), + f->vertex(cw(i))->point(), + mirror_vertex(f,i)->point()) == RIGHT_TURN && + orientation(f->vertex(i)->point(), + f->vertex(ccw(i))->point(), + mirror_vertex(f,i)->point()) == LEFT_TURN); _tds.flip(f, i); return; } @@ -1051,7 +1027,7 @@ insert_first(const Point& p) CGAL_triangulation_precondition(number_of_vertices() == 0); Vertex_handle v = _tds.insert_second(); v->set_point(p); - return v; + return v; } template @@ -1070,11 +1046,11 @@ typename Triangulation_2::Vertex_handle Triangulation_2:: insert_in_edge(const Point& p, Face_handle f,int i) { - CGAL_triangulation_exactness_precondition( - orientation(f->vertex(cw(i))->point(), p, - f->vertex(ccw(i))->point()) == COLLINEAR && - collinear_between(f->vertex(cw(i))->point(), p, - f->vertex(ccw(i))->point() ) ); + CGAL_triangulation_exactness_precondition( + orientation(f->vertex(cw(i))->point(), p, + f->vertex(ccw(i))->point()) == COLLINEAR && + collinear_between(f->vertex(cw(i))->point(), p, + f->vertex(ccw(i))->point() ) ); Vertex_handle v = _tds.insert_in_edge(f,i); v->set_point(p); return v; @@ -1085,7 +1061,7 @@ typename Triangulation_2::Vertex_handle Triangulation_2:: insert_in_face(const Point& p, Face_handle f) { - CGAL_triangulation_precondition(oriented_side(f,p) == ON_POSITIVE_SIDE); + CGAL_triangulation_precondition(oriented_side(f,p) == ON_POSITIVE_SIDE); Vertex_handle v= _tds.insert_in_face(f); v->set_point(p); return v; @@ -1098,8 +1074,11 @@ insert_outside_convex_hull(const Point& p, Face_handle f) { CGAL_triangulation_precondition(is_infinite(f) && dimension() >= 1); Vertex_handle v; - if (dimension() == 1) v=insert_outside_convex_hull_1(p, f); - else v=insert_outside_convex_hull_2(p, f); + if (dimension() == 1) + v=insert_outside_convex_hull_1(p, f); + else + v=insert_outside_convex_hull_2(p, f); + v->set_point(p); return v; } @@ -1110,37 +1089,35 @@ Triangulation_2:: insert_outside_convex_hull_1(const Point& p, Face_handle f) { CGAL_triangulation_precondition( is_infinite(f) && dimension()==1); - CGAL_triangulation_precondition( - orientation( - mirror_vertex(f,f->index(infinite_vertex()))->point(), - f->vertex(1- f->index(infinite_vertex()))->point(), - p) == COLLINEAR && - collinear_between( - mirror_vertex(f,f->index(infinite_vertex()))->point(), - f->vertex(1- f->index(infinite_vertex()))->point(), - p) ); - Vertex_handle v=_tds.insert_in_edge(f, 2); - v->set_point(p); - return v; + CGAL_triangulation_precondition( + orientation(mirror_vertex(f, f->index(infinite_vertex()))->point(), + f->vertex(1- f->index(infinite_vertex()))->point(), + p) == COLLINEAR && + collinear_between(mirror_vertex(f,f->index(infinite_vertex()))->point(), + f->vertex(1- f->index(infinite_vertex()))->point(), + p) ); + Vertex_handle v=_tds.insert_in_edge(f, 2); + v->set_point(p); + return v; } template typename Triangulation_2::Vertex_handle Triangulation_2:: insert_outside_convex_hull_2(const Point& p, Face_handle f) -{ +{ CGAL_triangulation_precondition(is_infinite(f)); - + int li = f->index(infinite_vertex()); - - CGAL_triangulation_precondition( - orientation(p, - f->vertex(ccw(li))->point(), - f->vertex(cw(li))->point()) == LEFT_TURN); + + CGAL_triangulation_precondition( + orientation(p, + f->vertex(ccw(li))->point(), + f->vertex(cw(li))->point()) == LEFT_TURN); std::list ccwlist; std::list cwlist; - + Face_circulator fc = incident_faces(infinite_vertex(), f); bool done = false; while(! done) { @@ -1157,8 +1134,8 @@ insert_outside_convex_hull_2(const Point& p, Face_handle f) while(! done){ fc++; li = fc->index(infinite_vertex()); - const Point& q = fc->vertex(ccw(li))->point(); - const Point& r = fc->vertex(cw(li))->point(); + const Point& q = fc->vertex(ccw(li))->point(); + const Point& r = fc->vertex(cw(li))->point(); if(orientation(p,q,r) == LEFT_TURN ) { cwlist.push_back(fc);} else {done=true;} } @@ -1187,7 +1164,7 @@ insert_outside_convex_hull_2(const Point& p, Face_handle f) infinite_vertex()->set_face(fc); return v; -} +} template typename Triangulation_2::Vertex_handle @@ -1197,12 +1174,12 @@ insert_outside_affine_hull(const Point& p) CGAL_triangulation_precondition(dimension() < 2); bool conform = false; if (dimension() == 1) { - Face_handle f = (*finite_edges_begin()).first; - Orientation orient = orientation( f->vertex(0)->point(), - f->vertex(1)->point(), - p); - CGAL_triangulation_precondition(orient != COLLINEAR); - conform = ( orient == COUNTERCLOCKWISE); + Face_handle f = (*finite_edges_begin()).first; + Orientation orient = orientation( f->vertex(0)->point(), + f->vertex(1)->point(), + p); + CGAL_triangulation_precondition(orient != COLLINEAR); + conform = ( orient == COUNTERCLOCKWISE); } Vertex_handle v = _tds.insert_dim_up( infinite_vertex(), conform); v->set_point(p); @@ -1220,7 +1197,6 @@ insert(const Point &p, Face_handle start) return insert(p, lt, loc, li); } - template typename Triangulation_2::Vertex_handle Triangulation_2:: @@ -1242,13 +1218,13 @@ insert(const Point& p, Locate_type lt, Face_handle loc, int li) case EDGE: return insert_in_edge(p,loc,li); case OUTSIDE_CONVEX_HULL: - return insert_outside_convex_hull(p,loc); + return insert_outside_convex_hull(p,loc); case OUTSIDE_AFFINE_HULL: - return insert_outside_affine_hull(p); + return insert_outside_affine_hull(p); case VERTEX: return loc->vertex(li); } - CGAL_triangulation_assertion(false); // locate step failed + CGAL_triangulation_assertion(false); // locate step failed return Vertex_handle(); } @@ -1263,9 +1239,9 @@ push_back(const Point &p) } template -inline void +inline void Triangulation_2:: -remove_degree_3(Vertex_handle v, Face_handle f) +remove_degree_3(Vertex_handle v, Face_handle f) { if (f == Face_handle()) f=v->face(); _tds.remove_degree_3(v, f); @@ -1275,14 +1251,14 @@ remove_degree_3(Vertex_handle v, Face_handle f) template inline void Triangulation_2:: -remove_first(Vertex_handle v) +remove_first(Vertex_handle v) { _tds.remove_second(v); return; } template -inline void +inline void Triangulation_2:: remove_second(Vertex_handle v) { @@ -1292,16 +1268,20 @@ remove_second(Vertex_handle v) template void -Triangulation_2:: -remove(Vertex_handle v) +Triangulation_2:: +remove(Vertex_handle v) { CGAL_triangulation_precondition( v != Vertex_handle()); CGAL_triangulation_precondition( !is_infinite(v)); - - if (number_of_vertices() == 1) remove_first(v); - else if (number_of_vertices() == 2) remove_second(v); - else if ( dimension() == 1) remove_1D(v); - else remove_2D(v); + + if (number_of_vertices() == 1) + remove_first(v); + else if (number_of_vertices() == 2) + remove_second(v); + else if ( dimension() == 1) + remove_1D(v); + else + remove_2D(v); return; } @@ -1324,7 +1304,7 @@ test_dim_down(Vertex_handle v) const // 1) any finite face is incident to v // 2) all vertices are collinear CGAL_triangulation_precondition(dimension() == 2); - bool dim1 = true; + bool dim1 = true; Finite_faces_iterator fit = finite_faces_begin(); while (dim1==true && fit != finite_faces_end()) { dim1 = dim1 && fit->has_vertex(v); @@ -1334,13 +1314,13 @@ test_dim_down(Vertex_handle v) const while (is_infinite(fic)) {++fic;} Face_circulator done(fic); Face_handle start(fic); int iv = start->index(v); - const Point& p = start->vertex(cw(iv))->point(); + const Point& p = start->vertex(cw(iv))->point(); const Point& q = start->vertex(ccw(iv))->point(); while ( dim1 && ++fic != done) { iv = fic->index(v); if (fic->vertex(ccw(iv)) != infinite_vertex()) { - dim1 = dim1 && - orientation(p, q, fic->vertex(ccw(iv))->point()) == COLLINEAR; + dim1 = dim1 && + orientation(p, q, fic->vertex(ccw(iv))->point()) == COLLINEAR; } } return dim1; @@ -1351,22 +1331,22 @@ void Triangulation_2:: remove_2D(Vertex_handle v) { - if (test_dim_down(v)) { _tds.remove_dim_down(v); } + if (test_dim_down(v)) { _tds.remove_dim_down(v); } else { std::list hole; make_hole(v, hole); fill_hole(v, hole); delete_vertex(v); } - return; + return; } template < class Gt, class Tds > template < class OutputItFaces > inline -typename Triangulation_2::Vertex_handle +typename Triangulation_2::Vertex_handle Triangulation_2:: -insert_and_give_new_faces(const Point &p, +insert_and_give_new_faces(const Point &p, OutputItFaces oif, Face_handle start) { @@ -1388,15 +1368,15 @@ insert_and_give_new_faces(const Point &p, else *oif++ = v->face(); // dimension == 0 return v; } - + template < class Gt, class Tds > template < class OutputItFaces > inline -typename Triangulation_2::Vertex_handle +typename Triangulation_2::Vertex_handle Triangulation_2:: -insert_and_give_new_faces(const Point &p, +insert_and_give_new_faces(const Point &p, Locate_type lt, - Face_handle loc, int li, + Face_handle loc, int li, OutputItFaces oif) { Vertex_handle v = insert(p, lt, loc, li); @@ -1414,8 +1394,8 @@ insert_and_give_new_faces(const Point &p, *oif++ = c; *oif++ = c->neighbor((~(c->index(v)))&1); } - else *oif++ = v->face(); // dimension == 0 - return v; + else *oif++ = v->face(); // dimension == 0 + return v; } template < class Gt, class Tds > @@ -1426,19 +1406,19 @@ remove_and_give_new_faces(Vertex_handle v, OutputItFaces fit) { CGAL_triangulation_precondition( v != Vertex_handle()); CGAL_triangulation_precondition( !is_infinite(v)); - + if(number_of_vertices() == 1) remove_first(v); else if(number_of_vertices() == 2) remove_second(v); - else if( dimension() == 1) + else if( dimension() == 1) { Point p = v->point(); remove(v); *fit++ = locate(p); } - else if (test_dim_down(v)) { - _tds.remove_dim_down(v); - for(All_faces_iterator afi = tds().face_iterator_base_begin(); - afi != tds().face_iterator_base_begin(); + else if (test_dim_down(v)) { + _tds.remove_dim_down(v); + for(All_faces_iterator afi = tds().face_iterator_base_begin(); + afi != tds().face_iterator_base_begin(); afi++) *fit++ = afi; } else { @@ -1447,7 +1427,7 @@ remove_and_give_new_faces(Vertex_handle v, OutputItFaces fit) fill_hole(v, hole, fit); delete_vertex(v); } - return; + return; } template @@ -1458,9 +1438,9 @@ make_hole ( Vertex_handle v, std::list & hole) std::vector to_delete; to_delete.reserve(16); - Face_handle f, fn; + Face_handle f, fn; int i, in ; - Vertex_handle vv; + Vertex_handle vv; Face_circulator fc = incident_faces(v); Face_circulator done(fc); @@ -1486,7 +1466,7 @@ make_hole ( Vertex_handle v, std::list & hole) } template -void +void Triangulation_2:: make_hole(Vertex_handle v, std::list & hole, std::set &faces_set) @@ -1494,9 +1474,9 @@ make_hole(Vertex_handle v, std::list & hole, std::vector to_delete; to_delete.reserve(16); - Face_handle f, fn; + Face_handle f, fn; int i, in ; - Vertex_handle vv; + Vertex_handle vv; Face_circulator fc = incident_faces(v); Face_circulator done(fc); @@ -1524,15 +1504,15 @@ make_hole(Vertex_handle v, std::list & hole, template void -Triangulation_2:: -fill_hole ( Vertex_handle v, std::list< Edge > & hole ) +Triangulation_2:: +fill_hole(Vertex_handle v, std::list< Edge > & hole) { // uses the fact that the hole is starshaped // with repect to v->point() typedef std::list Hole; - Face_handle ff, fn; - int ii , in; + Face_handle ff, fn; + int ii, in; Vertex_handle v0, v1, v2; Bounded_side side; @@ -1543,49 +1523,49 @@ fill_hole ( Vertex_handle v, std::list< Edge > & hole ) // and triangle v0v1v2 does not contain v->point() if( hole.size() != 3) { typename Hole::iterator hit = hole.begin(); - typename Hole::iterator next= hit; + typename Hole::iterator next= hit; while( hit != hole.end() && hole.size() != 3) { - ff = (*hit).first; + ff = (*hit).first; ii = (*hit).second; v0 = ff->vertex(cw(ii)); v1 = ff->vertex(ccw(ii)); if( !is_infinite(v0) && !is_infinite(v1)) { - next=hit; next++; - if(next == hole.end()) next=hole.begin(); - fn = (*next).first; - in = (*next).second; - v2 = fn->vertex(ccw(in)); - if ( !is_infinite(v2) && - orientation(v0->point(), v1->point(), v2->point()) == LEFT_TURN ) { - side = bounded_side(v0->point(), - v1->point(), - v2->point(), - v->point()); + next=hit; next++; + if(next == hole.end()) next=hole.begin(); + fn = (*next).first; + in = (*next).second; + v2 = fn->vertex(ccw(in)); + if ( !is_infinite(v2) && + orientation(v0->point(), v1->point(), v2->point()) == LEFT_TURN ) { + side = bounded_side(v0->point(), + v1->point(), + v2->point(), + v->point()); - if( side == ON_UNBOUNDED_SIDE || - (side == ON_BOUNDARY && orientation(v0->point(), - v->point(), - v2->point()) == COLLINEAR && - collinear_between(v0->point(),v->point(),v2->point()) )) - { - //create face - Face_handle newf = create_face(ff,ii,fn,in); - typename Hole::iterator tempo=hit; - hit = hole.insert(hit,Edge(newf,1)); //push newf - hole.erase(tempo); //erase ff - hole.erase(next); //erase fn - if (hit != hole.begin() ) --hit; - continue; - } - } + if( side == ON_UNBOUNDED_SIDE || + (side == ON_BOUNDARY && orientation(v0->point(), + v->point(), + v2->point()) == COLLINEAR && + collinear_between(v0->point(),v->point(),v2->point()) )) + { + //create face + Face_handle newf = create_face(ff,ii,fn,in); + typename Hole::iterator tempo=hit; + hit = hole.insert(hit,Edge(newf,1)); //push newf + hole.erase(tempo); //erase ff + hole.erase(next); //erase fn + if (hit != hole.begin() ) --hit; + continue; + } + } } - ++hit; - } + ++hit; + } } // either the hole has only three edges // or all its finite vertices are reflex or flat - // except may be one vertex whose corresponding ear + // except may be one vertex whose corresponding ear // includes the vertex being removed // deal with the last left_turn if any @@ -1597,14 +1577,14 @@ fill_hole ( Vertex_handle v, std::list< Edge > & hole ) if(hit != hole.end()) { fn = (*hit).first; in = (*hit).second;} else { fn = ((hole.front()).first); in = (hole.front()).second;} if ( !is_infinite(ff->vertex(cw(ii))) && - !is_infinite(fn->vertex(cw(in))) && - !is_infinite(fn->vertex(ccw(in))) && - orientation(ff->vertex(cw(ii))->point(), - fn->vertex(cw(in))->point(), - fn->vertex(ccw(in))->point()) == LEFT_TURN) { - create_face(ff,ii,fn,in); - break; - } + !is_infinite(fn->vertex(cw(in))) && + !is_infinite(fn->vertex(ccw(in))) && + orientation(ff->vertex(cw(ii))->point(), + fn->vertex(cw(in))->point(), + fn->vertex(ccw(in))->point()) == LEFT_TURN) { + create_face(ff,ii,fn,in); + break; + } } } @@ -1627,18 +1607,18 @@ fill_hole ( Vertex_handle v, std::list< Edge > & hole ) fn = (hole.front()).first; in = (hole.front()).second; hole.pop_front(); - Face_handle newf = create_face(ff,ii,fn,in); + Face_handle newf = create_face(ff,ii,fn,in); hole.push_front(Edge(newf,1)); } } - + // now hole has three edges typename Hole::iterator hit; hit = hole.begin(); - // I don't know why the following yelds a segmentation fault - // create_face( (*hit).first, (*hit).second, - // (* ++hit).first, (*hit).second, - // (* ++hit).first, (*hit).second); +// // I don't know why the following yelds a segmentation fault +// create_face( (*hit).first, (*hit).second, +// (* ++hit).first, (*hit).second, +// (* ++hit).first, (*hit).second); ff = (*hit).first; ii = (*hit).second; fn = (* ++hit).first; in = (*hit).second; Face_handle f3 = (* ++hit).first; @@ -1656,8 +1636,8 @@ fill_hole(Vertex_handle v, std::list & hole, OutputItFaces fit) // with repect to v->point() typedef std::list Hole; - Face_handle ff, fn; - int ii , in; + Face_handle ff, fn; + int ii , in; Vertex_handle v0, v1, v2; Bounded_side side; @@ -1668,30 +1648,30 @@ fill_hole(Vertex_handle v, std::list & hole, OutputItFaces fit) // and triangle v0v1v2 does not contain v->point() if( hole.size() != 3) { typename Hole::iterator hit = hole.begin(); - typename Hole::iterator next= hit; + typename Hole::iterator next= hit; while( hit != hole.end() && hole.size() != 3) { - ff = (*hit).first; + ff = (*hit).first; ii = (*hit).second; v0 = ff->vertex(cw(ii)); v1 = ff->vertex(ccw(ii)); if( !is_infinite(v0) && !is_infinite(v1)) { next=hit; next++; if(next == hole.end()) next=hole.begin(); - fn = (*next).first; + fn = (*next).first; in = (*next).second; - v2 = fn->vertex(ccw(in)); + v2 = fn->vertex(ccw(in)); if ( !is_infinite(v2) && orientation(v0->point(), v1->point(), v2->point()) == LEFT_TURN ) { - side = bounded_side(v0->point(), v1->point(), v2->point(), v->point()); - if( side == ON_UNBOUNDED_SIDE || + side = bounded_side(v0->point(), v1->point(), v2->point(), v->point()); + if( side == ON_UNBOUNDED_SIDE || (side == ON_BOUNDARY && orientation(v0->point(), v->point(), v2->point()) == COLLINEAR && - collinear_between(v0->point(),v->point(),v2->point()) )) + collinear_between(v0->point(),v->point(),v2->point()) )) { //create face - Face_handle newf = create_face(ff,ii,fn,in); - *fit++ = newf; + Face_handle newf = create_face(ff,ii,fn,in); + *fit++ = newf; typename Hole::iterator tempo=hit; hit = hole.insert(hit,Edge(newf,1)); //push newf hole.erase(tempo); //erase ff @@ -1701,20 +1681,21 @@ fill_hole(Vertex_handle v, std::list & hole, OutputItFaces fit) } } } - ++hit; - } + ++hit; + } } // either the hole has only three edges // or all its finite vertices are reflex or flat - // except may be one vertex whose corresponding ear + // except may be one vertex whose corresponding ear // includes the vertex being removed // deal with the last left_turn if any if(hole.size() != 3) { typename Hole::iterator hit=hole.begin(); while(hit != hole.end()) { - ff = (*hit).first; ii = (*hit).second; + ff = (*hit).first; + ii = (*hit).second; hit++; if(hit != hole.end()) { fn = (*hit).first; in = (*hit).second;} else { fn = ((hole.front()).first); in = (hole.front()).second;} @@ -1759,10 +1740,10 @@ fill_hole(Vertex_handle v, std::list & hole, OutputItFaces fit) // now hole has three edges typename Hole::iterator hit; hit = hole.begin(); - // I don't know why the following yelds a segmentation fault - // create_face( (*hit).first, (*hit).second, - // (* ++hit).first, (*hit).second, - // (* ++hit).first, (*hit).second); +// // I don't know why the following yelds a segmentation fault +// create_face( (*hit).first, (*hit).second, +// (* ++hit).first, (*hit).second, +// (* ++hit).first, (*hit).second); ff = (*hit).first; ii = (*hit).second; fn = (* ++hit).first; in = (*hit).second; Face_handle f3 = (* ++hit).first; @@ -1778,131 +1759,131 @@ fill_hole_delaunay(std::list & first_hole) { typedef std::list Hole; typedef std::list Hole_list; - - Face_handle f, ff, fn; + + Face_handle f, ff, fn; int i, ii, in; Hole_list hole_list; - + hole_list.push_front(first_hole); - + while( ! hole_list.empty()) - { - Hole& hole = hole_list.front(); - - typename Hole::iterator hit = hole.begin(); - - // if the hole has only three edges, create the triangle - if (hole.size() == 3) { - hit = hole.begin(); - f = (*hit).first; i = (*hit).second; - ff = (* ++hit).first; ii = (*hit).second; - fn = (* ++hit).first; in = (*hit).second; - create_face(f,i,ff,ii,fn,in); - hole_list.pop_front(); - continue; - } - - // else find an edge with two finite vertices - // on the hole boundary - // and the new triangle adjacent to that edge - // cut the hole and push it back - - // first, ensure that a neighboring face - // whose vertices on the hole boundary are finite - // is the first of the hole - bool finite= false; - while (!finite){ - ff = (hole.front()).first; - ii = (hole.front()).second; - if ( is_infinite(ff->vertex(cw(ii))) || - is_infinite(ff->vertex(ccw(ii)))) { - hole.push_back(hole.front()); - hole.pop_front(); - } - else finite=true; - } - - // take the first neighboring face and pop it; + { + Hole& hole = hole_list.front(); + + typename Hole::iterator hit = hole.begin(); + + // if the hole has only three edges, create the triangle + if (hole.size() == 3) { + hit = hole.begin(); + f = (*hit).first; i = (*hit).second; + ff = (* ++hit).first; ii = (*hit).second; + fn = (* ++hit).first; in = (*hit).second; + create_face(f,i,ff,ii,fn,in); + hole_list.pop_front(); + continue; + } + + // else find an edge with two finite vertices + // on the hole boundary + // and the new triangle adjacent to that edge + // cut the hole and push it back + + // first, ensure that a neighboring face + // whose vertices on the hole boundary are finite + // is the first of the hole + bool finite= false; + while (!finite){ ff = (hole.front()).first; - ii =(hole.front()).second; + ii = (hole.front()).second; + if ( is_infinite(ff->vertex(cw(ii))) || + is_infinite(ff->vertex(ccw(ii)))) { + hole.push_back(hole.front()); + hole.pop_front(); + } + else finite=true; + } + + // take the first neighboring face and pop it; + ff = (hole.front()).first; + ii =(hole.front()).second; + hole.pop_front(); + + Vertex_handle v0 = ff->vertex(cw(ii)); + Vertex_handle v1 = ff->vertex(ccw(ii)); + Vertex_handle v2 = infinite_vertex(); + Vertex_handle v3; + const Point& p0 = v0->point(); + const Point& p1 = v1->point(); + + typename Hole::iterator hdone = hole.end(); + hit = hole.begin(); + typename Hole::iterator cut_after(hit); + + // if tested vertex is c with respect to the vertex opposite + // to NULL neighbor, + // stop at the before last face; + hdone--; + while( hit != hdone) { + fn = (*hit).first; + in = (*hit).second; + Vertex_handle vv = fn->vertex(ccw(in)); + if (is_infinite(vv)) { + if(is_infinite(v2)) cut_after = hit; + } + else { // vv is a finite vertex + const Point & p = vv->point(); + if (orientation(p0,p1,p) == COUNTERCLOCKWISE) { + if (is_infinite(v2)) { v2=vv; v3=vv; cut_after=hit;} + else{ + // + if (this->side_of_oriented_circle(p0,p1,v3->point(),p,true) == ON_POSITIVE_SIDE){ + v2=vv; v3=vv; cut_after=hit;} + } + } + } + ++hit; + } + + // create new triangle and update adjacency relations + Face_handle newf; + + //update the hole and push back in the Hole_List stack + // if v2 belongs to the neighbor following or preceding *f + // the hole remain a single hole + // otherwise it is split in two holes + + fn = (hole.front()).first; + in = (hole.front()).second; + if (fn->has_vertex(v2, i) && i == fn->ccw(in)) { + newf = create_face(ff,ii,fn,in); hole.pop_front(); - - Vertex_handle v0 = ff->vertex(cw(ii)); - Vertex_handle v1 = ff->vertex(ccw(ii)); - Vertex_handle v2 = infinite_vertex(); - Vertex_handle v3; - const Point& p0 = v0->point(); - const Point& p1 = v1->point(); - - typename Hole::iterator hdone = hole.end(); - hit = hole.begin(); - typename Hole::iterator cut_after(hit); - - // if tested vertex is c with respect to the vertex opposite - // to NULL neighbor, - // stop at the before last face; - hdone--; - while( hit != hdone) { - fn = (*hit).first; - in = (*hit).second; - Vertex_handle vv = fn->vertex(ccw(in)); - if (is_infinite(vv)) { - if(is_infinite(v2)) cut_after = hit; - } - else { // vv is a finite vertex - const Point & p = vv->point(); - if (orientation(p0,p1,p) == COUNTERCLOCKWISE) { - if (is_infinite(v2)) { v2=vv; v3=vv; cut_after=hit;} - else{ - // - if (this->side_of_oriented_circle(p0,p1,v3->point(),p,true) == ON_POSITIVE_SIDE){ - v2=vv; v3=vv; cut_after=hit;} - } - } - } - ++hit; + hole.push_front(Edge( newf,1)); + } + else{ + fn = (hole.back()).first; + in = (hole.back()).second; + if (fn->has_vertex(v2, i) && i== fn->cw(in)) { + newf = create_face(fn,in,ff,ii); + hole.pop_back(); + hole.push_back(Edge(newf,1)); } - - // create new triangle and update adjacency relations - Face_handle newf; - - //update the hole and push back in the Hole_List stack - // if v2 belongs to the neighbor following or preceding *f - // the hole remain a single hole - // otherwise it is split in two holes - - fn = (hole.front()).first; - in = (hole.front()).second; - if (fn->has_vertex(v2, i) && i == fn->ccw(in)) { - newf = create_face(ff,ii,fn,in); - hole.pop_front(); - hole.push_front(Edge( newf,1)); - } - else{ - fn = (hole.back()).first; - in = (hole.back()).second; - if (fn->has_vertex(v2, i) && i== fn->cw(in)) { - newf = create_face(fn,in,ff,ii); - hole.pop_back(); - hole.push_back(Edge(newf,1)); - } - else{ - // split the hole in two holes - newf = create_face(ff,ii,v2); - Hole new_hole; - ++cut_after; - while( hole.begin() != cut_after ) - { - new_hole.push_back(hole.front()); - hole.pop_front(); - } - - hole.push_front(Edge( newf,1)); - new_hole.push_front(Edge( newf,0)); - hole_list.push_front(new_hole); - } + else { + // split the hole in two holes + newf = create_face(ff,ii,v2); + Hole new_hole; + ++cut_after; + while( hole.begin() != cut_after ) + { + new_hole.push_back(hole.front()); + hole.pop_front(); + } + + hole.push_front(Edge( newf,1)); + new_hole.push_front(Edge( newf,0)); + hole_list.push_front(new_hole); } } + } } template < class Gt, class Tds > @@ -1917,10 +1898,9 @@ fill_hole_delaunay(std::list & first_hole, OutputItFaces fit) typedef std::list Hole_list; Orientation_2 orientation_2 = geom_traits().orientation_2_object(); - In_circle in_circle = - geom_traits().side_of_oriented_circle_2_object(); + In_circle in_circle = geom_traits().side_of_oriented_circle_2_object(); - Face_handle f, ff, fn; + Face_handle f, ff, fn; int i, ii, in; Hole_list hole_list; hole_list.push_front(first_hole); @@ -1954,15 +1934,15 @@ fill_hole_delaunay(std::list & first_hole, OutputItFaces fit) ff = (hole.front()).first; ii =(hole.front()).second; hole.pop_front(); - - Vertex_handle v0 = ff->vertex(cw(ii)); - Vertex_handle v1 = ff->vertex(ccw(ii)); - Vertex_handle v2 = infinite_vertex(); + + Vertex_handle v0 = ff->vertex(cw(ii)); + Vertex_handle v1 = ff->vertex(ccw(ii)); + Vertex_handle v2 = infinite_vertex(); const Point& p0 = v0->point(); const Point& p1 = v1->point(); typename Hole::iterator hdone = hole.end(); - hit = hole.begin(); + hit = hole.begin(); typename Hole::iterator cut_after(hit); hdone--; @@ -1973,21 +1953,21 @@ fill_hole_delaunay(std::list & first_hole, OutputItFaces fit) if (is_infinite(vv)) { if(is_infinite(v2)) cut_after = hit; } else { // vv is a finite vertex - const Point & p = vv->point(); - if (orientation_2(p0,p1,p) == CGAL::COUNTERCLOCKWISE) { + const Point & p = vv->point(); + if (orientation_2(p0,p1,p) == CGAL::COUNTERCLOCKWISE) { if (is_infinite(v2)) { v2 = vv; cut_after = hit;} - else{ - if (in_circle(p0,p1,v2->point(),p) == CGAL::ON_POSITIVE_SIDE){ - v2 = vv; cut_after = hit; + else{ + if (in_circle(p0,p1,v2->point(),p) == CGAL::ON_POSITIVE_SIDE){ + v2 = vv; cut_after = hit; } - } - } + } + } } ++hit; } Face_handle newf; - + fn = (hole.front()).first; in = (hole.front()).second; if (fn->has_vertex(v2, i) && i == fn->ccw(in)) { @@ -2002,10 +1982,10 @@ fill_hole_delaunay(std::list & first_hole, OutputItFaces fit) hole.pop_back(); hole.push_back(Edge(newf,1)); } else { - newf = create_face(ff,ii,v2); - Hole new_hole; - ++cut_after; - while( hole.begin() != cut_after ) { + newf = create_face(ff,ii,v2); + Hole new_hole; + ++cut_after; + while( hole.begin() != cut_after ) { new_hole.push_back(hole.front()); hole.pop_front(); } @@ -2021,9 +2001,10 @@ fill_hole_delaunay(std::list & first_hole, OutputItFaces fit) template typename Triangulation_2::Vertex_handle Triangulation_2:: -move_if_no_collision(Vertex_handle v, const Point &p) { +move_if_no_collision(Vertex_handle v, const Point &p) +{ CGAL_triangulation_precondition(!is_infinite(v)); - if(v->point() == p) return v; + if(v->point() == p) return v; const int dim = dimension(); @@ -2038,11 +2019,11 @@ move_if_no_collision(Vertex_handle v, const Point &p) { return v; } - size_type n_vertices = tds().number_of_vertices(); + size_type n_vertices = tds().number_of_vertices(); if((lt == OUTSIDE_AFFINE_HULL) && (dim == 1) && (n_vertices == 3)) { - v->set_point(p); - return v; + v->set_point(p); + return v; } if((lt != OUTSIDE_AFFINE_HULL) && (dim == 1)) { @@ -2075,24 +2056,24 @@ move_if_no_collision(Vertex_handle v, const Point &p) { } if((lt != OUTSIDE_AFFINE_HULL) && test_dim_down(v)) { - // verify if p and two static vertices are collinear in this case - int iinf = 0; - Face_circulator finf = incident_faces(infinite_vertex()), fdone(finf); - do { - if(!finf->has_vertex(v)) - { - iinf = ~(finf->index(infinite_vertex())); - break; - } - } while(++finf != fdone); - if(this->orientation(finf->vertex(iinf&1)->point(), - finf->vertex(iinf&2)->point(), - p) == COLLINEAR) - { + // verify if p and two static vertices are collinear in this case + int iinf = 0; + Face_circulator finf = incident_faces(infinite_vertex()), fdone(finf); + do { + if(!finf->has_vertex(v)) + { + iinf = ~(finf->index(infinite_vertex())); + break; + } + } while(++finf != fdone); + if(this->orientation(finf->vertex(iinf&1)->point(), + finf->vertex(iinf&2)->point(), + p) == COLLINEAR) + { v->set_point(p); _tds.dim_down(loc, loc->index(v)); - return v; - } + return v; + } } Vertex_handle inserted = insert(p, lt, loc, li); @@ -2104,15 +2085,15 @@ move_if_no_collision(Vertex_handle v, const Point &p) { // fixing pointer Face_circulator fc = this->incident_faces(inserted), done(fc); std::vector faces_pt; - faces_pt.reserve(16); + faces_pt.reserve(16); do { faces_pt.push_back(fc); } while(++fc != done); std::size_t ss = faces_pt.size(); for(std::size_t k=0; kindex(inserted); - f->set_vertex(i, v); - } + { + Face_handle f = faces_pt[k]; + int i = f->index(inserted); + f->set_vertex(i, v); + } v->set_point(p); v->set_face(inserted->face()); delete_vertex(inserted); @@ -2123,9 +2104,10 @@ move_if_no_collision(Vertex_handle v, const Point &p) { template typename Triangulation_2::Vertex_handle Triangulation_2:: -move(Vertex_handle v, const Point &p) { +move(Vertex_handle v, const Point &p) +{ CGAL_triangulation_precondition(!is_infinite(v)); - if(v->point() == p) return v; + if(v->point() == p) return v; Vertex_handle w = move_if_no_collision(v,p); if(w != v) { remove(v); @@ -2136,14 +2118,14 @@ move(Vertex_handle v, const Point &p) { template template -typename Triangulation_2::Vertex_handle +typename Triangulation_2::Vertex_handle Triangulation_2:: -move_if_no_collision_and_give_new_faces(Vertex_handle v, - const Point &p, - OutputItFaces oif) +move_if_no_collision_and_give_new_faces(Vertex_handle v, + const Point &p, + OutputItFaces oif) { - CGAL_triangulation_precondition(!is_infinite(v)); - if(v->point() == p) return v; + CGAL_triangulation_precondition(!is_infinite(v)); + if(v->point() == p) return v; const int dim = this->dimension(); Locate_type lt; @@ -2162,11 +2144,11 @@ move_if_no_collision_and_give_new_faces(Vertex_handle v, if((lt == OUTSIDE_AFFINE_HULL) && (dim == 1) && (n_vertices == 3)) { v->set_point(p); - - for(All_faces_iterator afi = tds().face_iterator_base_begin(); - afi != tds().face_iterator_base_begin(); + + for(All_faces_iterator afi = tds().face_iterator_base_begin(); + afi != tds().face_iterator_base_begin(); afi++) *oif++ = afi; - + return v; } @@ -2198,10 +2180,10 @@ move_if_no_collision_and_give_new_faces(Vertex_handle v, delete_vertex(inserted); } *oif++ = v->face(); - if(v->face()->neighbor(0)->has_vertex(v)) + if(v->face()->neighbor(0)->has_vertex(v)) *oif++ = v->face()->neighbor(0); - if(v->face()->neighbor(1)->has_vertex(v)) - *oif++ = v->face()->neighbor(1); + if(v->face()->neighbor(1)->has_vertex(v)) + *oif++ = v->face()->neighbor(1); return v; } @@ -2209,32 +2191,32 @@ move_if_no_collision_and_give_new_faces(Vertex_handle v, // verify if p and two static vertices are collinear in this case int iinf; Face_circulator finf = incident_faces(infinite_vertex()), fdone(finf); - do { + do { if(!finf->has_vertex(v)) - { - iinf = ~(finf->index(infinite_vertex())); - break; - } - } while(++finf != fdone); + { + iinf = ~(finf->index(infinite_vertex())); + break; + } + } while (++finf != fdone); if(this->orientation(finf->vertex(iinf&1)->point(), finf->vertex(iinf&2)->point(), p) == COLLINEAR) - { - v->set_point(p); - _tds.dim_down(loc, loc->index(v)); - return v; - } - - for(All_faces_iterator afi = tds().face_iterator_base_begin(); - afi != tds().face_iterator_base_begin(); - afi++) *oif++ = afi; - + { + v->set_point(p); + _tds.dim_down(loc, loc->index(v)); + return v; + } + + for(All_faces_iterator afi = tds().face_iterator_base_begin(); + afi != tds().face_iterator_base_begin(); + afi++) + *oif++ = afi; } std::set faces_set; inserted = insert(p, lt, loc, li); Face_circulator fc = incident_faces(inserted), done(fc); - do { faces_set.insert(fc); } while(++fc != done); + do { faces_set.insert(fc); } while (++fc != done); std::list hole; make_hole(v, hole, faces_set); @@ -2243,46 +2225,47 @@ move_if_no_collision_and_give_new_faces(Vertex_handle v, fc = this->incident_faces(inserted), done(fc); std::vector faces_pt; faces_pt.reserve(16); - do { faces_pt.push_back(fc); } while(++fc != done); + do { faces_pt.push_back(fc); } while (++fc != done); int ss = faces_pt.size(); for(int k=0; kindex(inserted); - f->set_vertex(i, v); - } + { + Face_handle f = faces_pt[k]; + int i = f->index(inserted); + f->set_vertex(i, v); + } v->set_point(p); v->set_face(inserted->face()); delete_vertex(inserted); for(typename std::set::iterator ib = faces_set.begin(), - iend = faces_set.end(); ib != iend; ib++) *oif++ = *ib; + iend = faces_set.end(); ib != iend; ib++) + *oif++ = *ib; return v; } -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: create_face(Face_handle f1, int i1, - Face_handle f2, int i2, - Face_handle f3, int i3) + Face_handle f2, int i2, + Face_handle f3, int i3) { return _tds.create_face(f1, i1, f2, i2, f3, i3); } -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: create_face(Face_handle f1, int i1, - Face_handle f2, int i2) + Face_handle f2, int i2) { return _tds.create_face(f1, i1, f2, i2); } -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: @@ -2291,7 +2274,7 @@ create_face(Face_handle f, int i, Vertex_handle v) return _tds.create_face(f, i, v); } -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: @@ -2300,17 +2283,17 @@ create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) return _tds.create_face(v1, v2, v3); } -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, - Face_handle f1, Face_handle f2, Face_handle f3) + Face_handle f1, Face_handle f2, Face_handle f3) { return _tds.create_face(v1, v2, v3, f1, f2, f3); } -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: @@ -2319,9 +2302,7 @@ create_face(Face_handle fh) return _tds.create_face(fh); } - - -template +template inline typename Triangulation_2::Face_handle Triangulation_2:: @@ -2330,7 +2311,7 @@ create_face() return _tds.create_face(); } -template +template inline void Triangulation_2:: @@ -2339,7 +2320,7 @@ delete_face(Face_handle f) _tds.delete_face(f); } -template +template inline void Triangulation_2:: @@ -2349,19 +2330,19 @@ delete_vertex(Vertex_handle v) } // POINT LOCATION -template +template typename Triangulation_2::Face_handle Triangulation_2:: march_locate_1D(const Point& t, - Locate_type& lt, - int& li) const + Locate_type& lt, + int& li) const { Face_handle ff = infinite_face(); int iv = ff->index(infinite_vertex()); Face_handle f = ff->neighbor(iv); - Orientation pqt = orientation(f->vertex(0)->point(), - f->vertex(1)->point(), - t); + Orientation pqt = orientation(f->vertex(0)->point(), + f->vertex(1)->point(), + t); if(pqt == RIGHT_TURN || pqt == LEFT_TURN) { lt = OUTSIDE_AFFINE_HULL; li = 4 ;// should not be used @@ -2391,11 +2372,11 @@ march_locate_1D(const Point& t, return ff; } if( xy_equal(t,f->vertex(1-i)->point()) ){ - lt = VERTEX; - li=1-i; + lt = VERTEX; + li=1-i; return f; - } - + } + Finite_edges_iterator eit= finite_edges_begin(); Vertex_handle u,v; for( ; eit != finite_edges_end() ; eit++) { @@ -2408,7 +2389,7 @@ march_locate_1D(const Point& t, } if(collinear_between(u->point(), t, v->point())){ lt = EDGE; - li = 2; + li = 2; return (*eit).first; } } @@ -2416,13 +2397,13 @@ march_locate_1D(const Point& t, return Face_handle(); } -template +template typename Triangulation_2::Face_handle Triangulation_2:: march_locate_2D_LFC(Face_handle start, - const Point& t, - Locate_type& lt, - int& li) const + const Point& t, + Locate_type& lt, + int& li) const { // CGAL_triangulation_precondition( ! is_infinite(start) ); const Point& p = start->vertex(0)->point(); @@ -2435,34 +2416,34 @@ march_locate_2D_LFC(Face_handle start, } Line_face_circulator lfc; - + Orientation o2 = orientation(p, q, t); Orientation o0 = orientation(q, r, t); Orientation o1 = orientation(r, p, t); if( (o2 == LEFT_TURN)&& (o1 == LEFT_TURN)) { lfc = Line_face_circulator(start, 0, - Line_face_circulator::vertex_edge, - this, p, t); + Line_face_circulator::vertex_edge, + this, p, t); } else if ( (o0 == LEFT_TURN)&& (o2 == LEFT_TURN)) { lfc = Line_face_circulator(start, 1, - Line_face_circulator::vertex_edge, - this, q, t); + Line_face_circulator::vertex_edge, + this, q, t); } else if ( (o1 == LEFT_TURN)&& (o0 == LEFT_TURN)) { lfc = Line_face_circulator(start, 2, - Line_face_circulator::vertex_edge, - this, r, t); + Line_face_circulator::vertex_edge, + this, r, t); } if( (o2 == RIGHT_TURN)&& (o1 == RIGHT_TURN)) { lfc = Line_face_circulator(start, 0, - Line_face_circulator::edge_vertex, - this, p, t); + Line_face_circulator::edge_vertex, + this, p, t); } else if ( (o0 == RIGHT_TURN)&& (o2 == RIGHT_TURN)) { lfc = Line_face_circulator(start, 1, - Line_face_circulator::edge_vertex, - this, q, t); + Line_face_circulator::edge_vertex, + this, q, t); } else if ( (o1 == RIGHT_TURN)&& (o0 == RIGHT_TURN)) { lfc = Line_face_circulator(start, 2, - Line_face_circulator::edge_vertex, - this, r, t); + Line_face_circulator::edge_vertex, + this, r, t); }else { lfc = Line_face_circulator(start->vertex(0), this, t); } @@ -2476,48 +2457,48 @@ march_locate_2D_LFC(Face_handle start, lt = VERTEX; li = cw(ic); return fc; - } + } Orientation ori; do{ // walking ccw around convex hull ic = fc->index(infinite_vertex()); if (xy_equal(t,fc->vertex(ccw(ic))->point())){ - lt = VERTEX; - li = ccw(ic); - return fc; + lt = VERTEX; + li = ccw(ic); + return fc; } ori = orientation( fc->vertex(cw(ic))->point(), - fc->vertex(ccw(ic))->point(), t); + fc->vertex(ccw(ic))->point(), t); if (ori == RIGHT_TURN) { - lt = OUTSIDE_CONVEX_HULL; - li = ic; - return fc; + lt = OUTSIDE_CONVEX_HULL; + li = ic; + return fc; } if (ori == COLLINEAR && - collinear_between(fc->vertex(cw(ic))->point(), - t, - fc->vertex(ccw(ic))->point()) ) { - lt = EDGE; - li = ic; - return fc; + collinear_between(fc->vertex(cw(ic))->point(), + t, + fc->vertex(ccw(ic))->point()) ) { + lt = EDGE; + li = ic; + return fc; } } while (--fc != done); //should not arrive there; CGAL_triangulation_assertion(fc != done); } - + while(! lfc.locate(t, lt, li) ){ ++lfc; } return lfc; -} +} -template +template void Triangulation_2:: compare_walks(const Point& p, - Face_handle c1, Face_handle c2, - Locate_type& lt1, Locate_type& lt2, - int li1, int li2) const + Face_handle c1, Face_handle c2, + Locate_type& lt1, Locate_type& lt2, + int li1, int li2) const { bool b = true; b = b && (lt1 == lt2); @@ -2525,43 +2506,42 @@ compare_walks(const Point& p, b = b && ( c1->vertex(li1) == c2->vertex(li2) ); } else if((lt1 == lt2) && (lt1 == EDGE)) { b = b && ((c1 == c2) || ( (c1->neighbor(li1) == c2) && (c2->neighbor(li2) == c1))); - }else if((lt1 == lt2) && (lt1 == OUTSIDE_CONVEX_HULL)) { + } else if((lt1 == lt2) && (lt1 == OUTSIDE_CONVEX_HULL)) { b = b && (is_infinite(c1) && is_infinite(c2)); } else { b = b && (lt1 == lt2); b = b && (lt1 == FACE); b = b && (c1 == c2); } - + if ( c1 != c2) { std::cerr << "from compare_walks " << std::endl; std::cerr << "point " << p << std::endl; - std::cerr << "locate 1 " << &*c1 << "\t" << lt1 << "\t" << li1 - << std::endl; - std::cerr << "locate 2 " << &*c2 << "\t" << lt2 << "\t" << li2 - << std::endl; + std::cerr << "locate 1 " << &*c1 << "\t" << lt1 << "\t" << li1 + << std::endl; + std::cerr << "locate 2 " << &*c2 << "\t" << lt2 << "\t" << li2 + << std::endl; std::cerr << std::endl; show_face(c1); std::cerr << std::endl; show_face(c2); std::cerr << std::endl; } - - CGAL_triangulation_assertion(b); + CGAL_triangulation_assertion(b); } - + #if 1 - -template typename Triangulation_2::Face_handle +template +typename Triangulation_2::Face_handle Triangulation_2:: march_locate_2D(Face_handle c, - const Point& t, - Locate_type& lt, - int& li) const + const Point& t, + Locate_type& lt, + int& li) const { CGAL_triangulation_assertion(! is_infinite(c)); - + boost::rand48 rng; boost::uniform_smallint<> two(0, 1); @@ -2576,7 +2556,7 @@ march_locate_2D(Face_handle c, li = c->index(infinite_vertex()); return c; } - + // else c is finite // Instead of testing its edges in a random order we do the following // until we find a neighbor to go further: @@ -2584,10 +2564,10 @@ march_locate_2D(Face_handle c, // Now we flip a coin in order to decide if we start checking the // edge before or the edge after the edge leading to prev // We do loop unrolling in order to find out if this is faster. - // In the very beginning we do not have a prev, but for the first step + // In the very beginning we do not have a prev, but for the first step // we do not need randomness int left_first = coin()%2; - + const Point & p0 = c->vertex( 0 )->point(); const Point & p1 = c->vertex( 1 )->point(); const Point & p2 = c->vertex( 2 )->point(); @@ -2598,150 +2578,148 @@ march_locate_2D(Face_handle c, first = false; o0 = orientation(p0,p1,t); if ( o0 == NEGATIVE ) { - c = c->neighbor( 2 ); - continue; + c = c->neighbor( 2 ); + continue; } o1 = orientation(p1,p2,t); if ( o1 == NEGATIVE ) { - c = c->neighbor( 0 ); - continue; + c = c->neighbor( 0 ); + continue; } o2 = orientation(p2,p0,t); if ( o2 == NEGATIVE ) { - c = c->neighbor( 1 ); - continue; + c = c->neighbor( 1 ); + continue; } } else if(left_first){ if(c->neighbor(0) == prev){ - prev = c; - o0 = orientation(p0,p1,t); - if ( o0 == NEGATIVE ) { - c = c->neighbor( 2 ); - continue; - } - o2 = orientation(p2,p0,t); - if ( o2 == NEGATIVE ) { - c = c->neighbor( 1 ); - continue; - } + prev = c; + o0 = orientation(p0,p1,t); + if ( o0 == NEGATIVE ) { + c = c->neighbor( 2 ); + continue; + } + o2 = orientation(p2,p0,t); + if ( o2 == NEGATIVE ) { + c = c->neighbor( 1 ); + continue; + } o1 = POSITIVE; } else if(c->neighbor(1) == prev){ - prev = c; - o1 = orientation(p1,p2,t); - if ( o1 == NEGATIVE ) { - c = c->neighbor( 0 ); - continue; - } - o0 = orientation(p0,p1,t); - if ( o0 == NEGATIVE ) { - c = c->neighbor( 2 ); - continue; - } + prev = c; + o1 = orientation(p1,p2,t); + if ( o1 == NEGATIVE ) { + c = c->neighbor( 0 ); + continue; + } + o0 = orientation(p0,p1,t); + if ( o0 == NEGATIVE ) { + c = c->neighbor( 2 ); + continue; + } o2 = POSITIVE; } else { - prev = c; - o2 = orientation(p2,p0,t); - if ( o2 == NEGATIVE ) { - c = c->neighbor( 1 ); - continue; - } - o1 = orientation(p1,p2,t); - if ( o1 == NEGATIVE ) { - c = c->neighbor( 0 ); - continue; - } + prev = c; + o2 = orientation(p2,p0,t); + if ( o2 == NEGATIVE ) { + c = c->neighbor( 1 ); + continue; + } + o1 = orientation(p1,p2,t); + if ( o1 == NEGATIVE ) { + c = c->neighbor( 0 ); + continue; + } o0 = POSITIVE; } - + } else { // right_first if(c->neighbor(0) == prev){ - prev = c; - o2 = orientation(p2,p0,t); - if ( o2 == NEGATIVE ) { - c = c->neighbor( 1 ); - continue; - } - o0 = orientation(p0,p1,t); - if ( o0 == NEGATIVE ) { - c = c->neighbor( 2 ); - continue; - } + prev = c; + o2 = orientation(p2,p0,t); + if ( o2 == NEGATIVE ) { + c = c->neighbor( 1 ); + continue; + } + o0 = orientation(p0,p1,t); + if ( o0 == NEGATIVE ) { + c = c->neighbor( 2 ); + continue; + } o1 = POSITIVE; } else if(c->neighbor(1) == prev){ - prev = c; - o0 = orientation(p0,p1,t); - if ( o0 == NEGATIVE ) { - c = c->neighbor( 2 ); - continue; - } - o1 = orientation(p1,p2,t); - if ( o1 == NEGATIVE ) { - c = c->neighbor( 0 ); - continue; - } + prev = c; + o0 = orientation(p0,p1,t); + if ( o0 == NEGATIVE ) { + c = c->neighbor( 2 ); + continue; + } + o1 = orientation(p1,p2,t); + if ( o1 == NEGATIVE ) { + c = c->neighbor( 0 ); + continue; + } o2 = POSITIVE; } else { - prev = c; - o1 = orientation(p1,p2,t); - if ( o1 == NEGATIVE ) { - c = c->neighbor( 0 ); - continue; - } - o2 = orientation(p2,p0,t); - if ( o2 == NEGATIVE ) { - c = c->neighbor( 1 ); - continue; - } + prev = c; + o1 = orientation(p1,p2,t); + if ( o1 == NEGATIVE ) { + c = c->neighbor( 0 ); + continue; + } + o2 = orientation(p2,p0,t); + if ( o2 == NEGATIVE ) { + c = c->neighbor( 1 ); + continue; + } o0 = POSITIVE; } } - + // now p is in c or on its boundary int sum = ( o0 == COLLINEAR ) - + ( o1 == COLLINEAR ) - + ( o2 == COLLINEAR ); + + ( o1 == COLLINEAR ) + + ( o2 == COLLINEAR ); switch (sum) { - case 0: + case 0: { - lt = FACE; - li = 4; - break; + lt = FACE; + li = 4; + break; } - case 1: + case 1: { - lt = EDGE; - li = ( o0 == COLLINEAR ) ? 2 : - ( o1 == COLLINEAR ) ? 0 : - 1; - break; + lt = EDGE; + li = ( o0 == COLLINEAR ) ? 2 : + ( o1 == COLLINEAR ) ? 0 : + 1; + break; } - case 2: + case 2: { - lt = VERTEX; - li = ( o0 != COLLINEAR ) ? 2 : - ( o1 != COLLINEAR ) ? 0 : - 1; - break; + lt = VERTEX; + li = ( o0 != COLLINEAR ) ? 2 : + ( o1 != COLLINEAR ) ? 0 : + 1; + break; } } return c; } -} - - +} #else // not 1 - -template typename Triangulation_2::Face_handle +template +typename Triangulation_2::Face_handle Triangulation_2:: march_locate_2D(Face_handle c, - const Point& t, - Locate_type& lt, - int& li) const + const Point& t, + Locate_type& lt, + int& li) const { CGAL_triangulation_assertion(! is_infinite(c)); boost::uniform_smallint<> three(0, 2); - boost::variate_generator > die3(rng, three); + boost::variate_generator > die3(rng, three); Face_handle prev = Face_handle(); while (1) { @@ -2768,9 +2746,9 @@ march_locate_2D(Face_handle c, } else { o0 = orientation(p0,p1,t); if ( o0 == NEGATIVE ) { - prev = c; - c = c->neighbor( cwi ); - continue; + prev = c; + c = c->neighbor( cwi ); + continue; } } const Point & p2 = c->vertex( cwi )->point(); @@ -2779,9 +2757,9 @@ march_locate_2D(Face_handle c, } else { o1 = orientation(p1,p2,t); if ( o1 == NEGATIVE ) { - prev = c; - c = c->neighbor( i ); - continue; + prev = c; + c = c->neighbor( i ); + continue; } } if(c->neighbor(ccwi) == prev){ @@ -2789,49 +2767,45 @@ march_locate_2D(Face_handle c, } else { o2 = orientation(p2,p0,t); if ( o2 == NEGATIVE ) { - prev = c; - c = c->neighbor( ccwi ); - continue; + prev = c; + c = c->neighbor( ccwi ); + continue; } } // now p is in c or on its boundary int sum = ( o0 == COLLINEAR ) - + ( o1 == COLLINEAR ) - + ( o2 == COLLINEAR ); + + ( o1 == COLLINEAR ) + + ( o2 == COLLINEAR ); switch (sum) { - case 0: + case 0: { - lt = FACE; - li = 4; - break; + lt = FACE; + li = 4; + break; } - case 1: + case 1: { - lt = EDGE; - li = ( o0 == COLLINEAR ) ? cwi : - ( o1 == COLLINEAR ) ? i : - ccwi; - break; + lt = EDGE; + li = ( o0 == COLLINEAR ) ? cwi : + ( o1 == COLLINEAR ) ? i : + ccwi; + break; } - case 2: + case 2: { - lt = VERTEX; - li = ( o0 != COLLINEAR ) ? cwi : - ( o1 != COLLINEAR ) ? i : - ccwi; - break; + lt = VERTEX; + li = ( o0 != COLLINEAR ) ? cwi : + ( o1 != COLLINEAR ) ? i : + ccwi; + break; } } return c; } -} - - +} #endif // not 1 - - template typename Triangulation_2::Face_handle Triangulation_2:: @@ -2842,36 +2816,36 @@ locate(const Point& p, Face_handle start) const #else // no CGAL_NO_STRUCTURAL_FILTERING exact_locate(const Point& p, - Locate_type& lt, - int& li, - Face_handle start) const + Locate_type& lt, + int& li, + Face_handle start) const #endif // no CGAL_NO_STRUCTURAL_FILTERING { if (dimension() < 0) { - lt = OUTSIDE_AFFINE_HULL; - li = 4; // li should not be used in this case - return Face_handle(); + lt = OUTSIDE_AFFINE_HULL; + li = 4; // li should not be used in this case + return Face_handle(); } if( dimension() == 0) { - // Do not use finite_vertex directly because there can be hidden vertices - // (regular triangulations) - if (xy_equal(p,finite_vertex()->face()->vertex(0)->point())){ - lt = VERTEX ; - } - else{ - lt = OUTSIDE_AFFINE_HULL; - } - li = 4; // li should not be used in this case - return Face_handle(); + // Do not use finite_vertex directly because there can be hidden vertices + // (regular triangulations) + if (xy_equal(p,finite_vertex()->face()->vertex(0)->point())){ + lt = VERTEX ; + } + else{ + lt = OUTSIDE_AFFINE_HULL; + } + li = 4; // li should not be used in this case + return Face_handle(); } if(dimension() == 1){ return march_locate_1D(p, lt, li); } - if(start == Face_handle()){ + if(start == Face_handle()) { start = infinite_face()-> - neighbor(infinite_face()->index(infinite_vertex())); - }else if(is_infinite(start)){ + neighbor(infinite_face()->index(infinite_vertex())); + } else if(is_infinite(start)) { start = start->neighbor(start->index(infinite_vertex())); } @@ -2890,9 +2864,9 @@ exact_locate(const Point& p, #if defined(CGAL_ZIG_ZAG_WALK) && defined(CGAL_LFC_WALK) compare_walks(p, - res1, res2, - lt, lt2, - li, li2); + res1, res2, + lt, lt2, + li, li2); #endif #ifdef CGAL_ZIG_ZAG_WALK @@ -2904,7 +2878,6 @@ exact_locate(const Point& p, li = li2; return res2; #endif - } #ifdef CGAL_NO_STRUCTURAL_FILTERING @@ -2920,13 +2893,13 @@ locate(const Point &p, } #else template -inline +inline typename Triangulation_2::Face_handle Triangulation_2:: inexact_locate(const Point & t, Face_handle start, int n_of_turns) const { if(dimension() < 2) return start; - + if(start == Face_handle()){ start = infinite_face()-> neighbor(infinite_face()->index(infinite_vertex())); @@ -2937,11 +2910,11 @@ inexact_locate(const Point & t, Face_handle start, int n_of_turns) const Face_handle prev = Face_handle(), c = start; bool first = true; while (1) { - + if(!(n_of_turns--)) return c; if ( is_infinite(c) ) return c; - + const Point & p0 = c->vertex( 0 )->point(); const Point & p1 = c->vertex( 1 )->point(); const Point & p2 = c->vertex( 2 )->point(); @@ -2992,8 +2965,8 @@ inexact_locate(const Point & t, Face_handle start, int n_of_turns) const c = c->neighbor( 0 ); continue; } - } - } + } + } break; } return c; @@ -3004,12 +2977,12 @@ inline bool Triangulation_2:: has_inexact_negative_orientation(const Point &p, const Point &q, - const Point &r) const -{ + const Point &r) const +{ // So that this code works well with Lazy_kernel internal::Static_filters_predicates::Get_approx get_approx; - const double px = to_double(get_approx(p).x()); + const double px = to_double(get_approx(p).x()); const double py = to_double(get_approx(p).y()); const double qx = to_double(get_approx(q).x()); const double qy = to_double(get_approx(q).y()); @@ -3023,7 +2996,6 @@ has_inexact_negative_orientation(const Point &p, const Point &q, return ( determinant(pqx, pqy, prx, pry) < 0); } - #endif template @@ -3036,15 +3008,15 @@ finite_faces_begin() const return CGAL::filter_iterator( all_faces_end(), Infinite_tester(this), all_faces_begin() ); -} +} template typename Triangulation_2::Finite_faces_iterator Triangulation_2:: finite_faces_end() const { - return CGAL::filter_iterator( all_faces_end(), - Infinite_tester(this) ); + return CGAL::filter_iterator( all_faces_end(), + Infinite_tester(this) ); } template @@ -3052,7 +3024,7 @@ typename Triangulation_2::Finite_vertices_iterator Triangulation_2:: finite_vertices_begin() const { - if ( number_of_vertices() <= 0 ) + if ( number_of_vertices() <= 0 ) return finite_vertices_end(); return CGAL::filter_iterator( all_vertices_end(), Infinite_tester(this), @@ -3065,7 +3037,7 @@ Triangulation_2:: finite_vertices_end() const { return CGAL::filter_iterator(all_vertices_end(), - Infinite_tester(this)); + Infinite_tester(this)); } template @@ -3111,7 +3083,7 @@ Triangulation_2:: all_faces_begin() const { return _tds.faces_begin(); -} +} template typename Triangulation_2::All_faces_iterator @@ -3176,12 +3148,12 @@ Triangulation_2:: incident_faces(Vertex_handle v, Face_handle f) const { return _tds.incident_faces(v,f); -} +} template inline typename Triangulation_2::Vertex_circulator -Triangulation_2:: +Triangulation_2:: incident_vertices(Vertex_handle v, Face_handle f) const { return _tds.incident_vertices(v,f); @@ -3190,7 +3162,7 @@ incident_vertices(Vertex_handle v, Face_handle f) const template inline typename Triangulation_2::Edge_circulator -Triangulation_2:: +Triangulation_2:: incident_edges(Vertex_handle v, Face_handle f) const { return _tds.incident_edges(v,f); @@ -3199,7 +3171,7 @@ incident_edges(Vertex_handle v, Face_handle f) const template inline typename Triangulation_2::size_type -Triangulation_2:: +Triangulation_2:: degree(Vertex_handle v) const { return _tds.degree(v); @@ -3208,7 +3180,7 @@ degree(Vertex_handle v) const template inline typename Triangulation_2::Vertex_handle -Triangulation_2:: +Triangulation_2:: mirror_vertex(Face_handle f, int i) const { return _tds.mirror_vertex(f,i); @@ -3217,7 +3189,7 @@ mirror_vertex(Face_handle f, int i) const template inline int -Triangulation_2:: +Triangulation_2:: mirror_index(Face_handle f, int i) const { return _tds.mirror_index(f,i); @@ -3226,66 +3198,63 @@ mirror_index(Face_handle f, int i) const template inline typename Triangulation_2::Edge -Triangulation_2:: +Triangulation_2:: mirror_edge(const Edge e) const { return _tds.mirror_edge(e); } template -typename Triangulation_2::Line_face_circulator -Triangulation_2:: -line_walk(const Point& p, const Point& q, Face_handle f) const +typename Triangulation_2::Line_face_circulator +Triangulation_2:: +line_walk(const Point& p, const Point& q, Face_handle f) const { - CGAL_triangulation_precondition( (dimension() == 2) && - ! xy_equal(p,q)); + CGAL_triangulation_precondition( (dimension() == 2) && ! xy_equal(p,q)); Line_face_circulator lfc = (f == Face_handle()) - ? Line_face_circulator(p, q, this) - : Line_face_circulator(p, q, f, this); - + ? Line_face_circulator(p, q, this) + : Line_face_circulator(p, q, f, this); + // the following lines may be useless : - // Line_face_circulator(p,q...) returns either a null circulator + // Line_face_circulator(p,q...) returns either a null circulator // or a pointer to a finite face (to be checked) if( (!lfc.is_empty()) && is_infinite( lfc )){ - do { ++lfc ;} + do { ++lfc ;} while (is_infinite(lfc)); } return lfc; } - + template Oriented_side Triangulation_2:: oriented_side(const Point &p0, const Point &p1, - const Point &p2, const Point &p) const + const Point &p2, const Point &p) const { // return position of point p with respect to the oriented triangle p0p1p2 // depends on the orientation of the vertices Bounded_side bs=bounded_side(p0,p1,p2,p); if (bs == ON_BOUNDARY) return ON_ORIENTED_BOUNDARY; - Orientation ot = orientation(p0, p1, p2); + Orientation ot = orientation(p0, p1, p2); if (bs == ON_BOUNDED_SIDE) return (ot == LEFT_TURN) ? ON_POSITIVE_SIDE : ON_NEGATIVE_SIDE; // bs == ON_UNBOUNDED_SIDE return (ot == LEFT_TURN) ? ON_NEGATIVE_SIDE : ON_POSITIVE_SIDE; } - - template Bounded_side Triangulation_2:: bounded_side(const Point &p0, const Point &p1, - const Point &p2, const Point &p) const + const Point &p2, const Point &p) const { // return position of point p with respect to triangle p0p1p2 CGAL_triangulation_precondition( orientation(p0, p1, p2) != COLLINEAR); Orientation o1 = orientation(p0, p1, p), o2 = orientation(p1, p2, p), o3 = orientation(p2, p0, p); - + if (o1 == COLLINEAR){ - if (o2 == COLLINEAR || o3 == COLLINEAR) return ON_BOUNDARY; + if (o2 == COLLINEAR || o3 == COLLINEAR) return ON_BOUNDARY; if (collinear_between(p0, p, p1)) return ON_BOUNDARY; return ON_UNBOUNDED_SIDE; } @@ -3302,70 +3271,63 @@ bounded_side(const Point &p0, const Point &p1, } // from here none ot, o1, o2 and o3 are known to be non null - if (o1 == o2 && o2 == o3) return ON_BOUNDED_SIDE; + if (o1 == o2 && o2 == o3) return ON_BOUNDED_SIDE; return ON_UNBOUNDED_SIDE; } - template Oriented_side Triangulation_2:: oriented_side(Face_handle f, const Point &p) const { - CGAL_triangulation_precondition ( dimension()==2); + CGAL_triangulation_precondition ( dimension()==2); return oriented_side(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point(), - p); + f->vertex(1)->point(), + f->vertex(2)->point(), + p); } - template Oriented_side Triangulation_2:: side_of_oriented_circle(const Point &p0, const Point &p1, const Point &p2, - const Point &p, bool perturb) const + const Point &p, bool perturb) const { //CGAL_triangulation_precondition( orientation(p0, p1, p2) == POSITIVE ); // no reason for such precondition and it invalidates fast removal in Delaunay - typename Gt::Side_of_oriented_circle_2 pred = geom_traits().side_of_oriented_circle_2_object(); - Oriented_side os = - pred(p0, p1, p2, p); - if ((os != ON_ORIENTED_BOUNDARY) || (! perturb)) - return os; + typename Gt::Side_of_oriented_circle_2 pred = geom_traits().side_of_oriented_circle_2_object(); + Oriented_side os = + pred(p0, p1, p2, p); + if ((os != ON_ORIENTED_BOUNDARY) || (! perturb)) + return os; - // We are now in a degenerate case => we do a symbolic perturbation. + // We are now in a degenerate case => we do a symbolic perturbation. - // We sort the points lexicographically. - const Point * points[4] = {&p0, &p1, &p2, &p}; - std::sort(points, points+4, Perturbation_order(this) ); + // We sort the points lexicographically. + const Point * points[4] = {&p0, &p1, &p2, &p}; + std::sort(points, points+4, Perturbation_order(this) ); - // We successively look whether the leading monomial, then 2nd monomial - // of the determinant has non null coefficient. - // 2 iterations are enough if p0p1p2 is positive (cf paper) - for (int i=3; i>0; --i) { - if (points[i] == &p) - return ON_NEGATIVE_SIDE; // since p0 p1 p2 are non collinear - // and "conceptually" positively oriented - Orientation o; - if (points[i] == &p2 && (o = orientation(p0,p1,p)) != COLLINEAR ) - return Oriented_side(o); - if (points[i] == &p1 && (o = orientation(p0,p,p2)) != COLLINEAR ) - return Oriented_side(o); - if (points[i] == &p0 && (o = orientation(p,p1,p2)) != COLLINEAR ) - return Oriented_side(o); - } - // CGAL_triangulation_assertion(false); - //no reason for such precondition and it invalidates fast removal in Delaunay - return ON_NEGATIVE_SIDE; + // We successively look whether the leading monomial, then 2nd monomial + // of the determinant has non null coefficient. + // 2 iterations are enough if p0p1p2 is positive (cf paper) + for (int i=3; i>0; --i) { + if (points[i] == &p) + return ON_NEGATIVE_SIDE; // since p0 p1 p2 are non collinear + // and "conceptually" positively oriented + Orientation o; + if (points[i] == &p2 && (o = orientation(p0,p1,p)) != COLLINEAR ) + return Oriented_side(o); + if (points[i] == &p1 && (o = orientation(p0,p,p2)) != COLLINEAR ) + return Oriented_side(o); + if (points[i] == &p0 && (o = orientation(p,p1,p2)) != COLLINEAR ) + return Oriented_side(o); + } + // CGAL_triangulation_assertion(false); + //no reason for such precondition and it invalidates fast removal in Delaunay + return ON_NEGATIVE_SIDE; } - - - - - template < class Gt, class Tds > Oriented_side Triangulation_2:: @@ -3373,28 +3335,26 @@ side_of_oriented_circle(Face_handle f, const Point & p, bool perturb) const { if ( ! is_infinite(f) ) { /* - typename Gt::Side_of_oriented_circle_2 + typename Gt::Side_of_oriented_circle_2 in_circle = geom_traits().side_of_oriented_circle_2_object(); return in_circle(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point(),p); + f->vertex(1)->point(), + f->vertex(2)->point(),p); */ return this->side_of_oriented_circle(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point(),p, perturb); + f->vertex(1)->point(), + f->vertex(2)->point(),p, perturb); } int i = f->index(infinite_vertex()); Orientation o = orientation(f->vertex(ccw(i))->point(), - f->vertex(cw(i))->point(), - p); + f->vertex(cw(i))->point(), + p); return (o == NEGATIVE) ? ON_NEGATIVE_SIDE : - (o == POSITIVE) ? ON_POSITIVE_SIDE : - ON_ORIENTED_BOUNDARY; + (o == POSITIVE) ? ON_POSITIVE_SIDE : + ON_ORIENTED_BOUNDARY; } - - template bool Triangulation_2:: @@ -3414,8 +3374,8 @@ collinear_between(const Point& p, const Point& q, const Point& r) const c_qr = compare_x(q, r); } return ( (c_pq == SMALLER) && (c_qr == SMALLER) ) || - ( (c_pq == LARGER) && (c_qr == LARGER) ); - + ( (c_pq == LARGER) && (c_qr == LARGER) ); + } template @@ -3471,40 +3431,38 @@ template inline typename Triangulation_2::Point Triangulation_2:: -circumcenter (const Point& p0, const Point& p1, const Point& p2) const +circumcenter(const Point& p0, const Point& p1, const Point& p2) const { - return + return geom_traits().construct_circumcenter_2_object()(p0,p1,p2); } - template typename Triangulation_2::Point Triangulation_2:: -circumcenter(Face_handle f) const +circumcenter(Face_handle f) const { CGAL_triangulation_precondition (dimension()==2); // typename Gt::Construct_circumcenter_2 // circumcenter = geom_traits().construct_circumcenter_2_object(); - return circumcenter((f->vertex(0))->point(), - (f->vertex(1))->point(), - (f->vertex(2))->point()); + return circumcenter((f->vertex(0))->point(), + (f->vertex(1))->point(), + (f->vertex(2))->point()); } - template void Triangulation_2:: show_all() const { std::cerr<< "AFFICHE TOUTE LA TRIANGULATION :"< "<< this; - std::cerr << " dimension " << dimension() << std::endl; + std::cerr << std::endl<<"====> "<< this; + std::cerr << " dimension " << dimension() << std::endl; std::cerr << "nb of vertices " << number_of_vertices() << std::endl; - + if (dimension() < 1) return; if(dimension() == 1) { - std::cerr<<" all edges "<first); @@ -3523,15 +3481,15 @@ show_all() const for(afi = all_faces_begin(); afi != all_faces_end(); afi++) { if(is_infinite(afi)) show_face(afi); } - + if (number_of_vertices()>1) { std::cerr << "affichage des sommets de la triangulation reguliere" - <face())))<< std::endl;; + << (void*)(&(*(vi->face())))<< std::endl;; } std::cerr<:: show_face(Face_handle fh) const { std::cerr << "face : "<<(void*)&(*fh)<<" => "<dimension(); + int i = fh->dimension(); switch(i){ case 0: std::cerr <<"point :" ; show_vertex(fh->vertex(0)); @@ -3628,8 +3586,6 @@ operator<<(std::ostream& os, const Triangulation_2 &tr) return os ; } - - template < class Gt, class Tds > std::istream& operator>>(std::istream& is, Triangulation_2 &tr) @@ -3638,8 +3594,7 @@ operator>>(std::istream& is, Triangulation_2 &tr) CGAL_triangulation_assertion(tr.is_valid()); return is; } - + } //namespace CGAL - #endif //CGAL_TRIANGULATION_2_H