From 2386142db311d3d55eefb2c4a7f486b9e7609cbe Mon Sep 17 00:00:00 2001 From: Shai Hirsch Date: Sun, 6 May 2001 10:29:52 +0000 Subject: [PATCH] Indentation and 80 column conformity. --- .../Planar_map/include/CGAL/Planar_map_2.h | 1142 +++++++++-------- 1 file changed, 590 insertions(+), 552 deletions(-) diff --git a/Packages/Planar_map/include/CGAL/Planar_map_2.h b/Packages/Planar_map/include/CGAL/Planar_map_2.h index 5f0df615c5e..e1d9100125a 100644 --- a/Packages/Planar_map/include/CGAL/Planar_map_2.h +++ b/Packages/Planar_map/include/CGAL/Planar_map_2.h @@ -170,7 +170,8 @@ public: // constructor #3 - copy traits, set pl and bb // set NULLs for defaults - Planar_map_2(const Traits &tr_, Point_location_base *pl_ptr, Bounding_box_base *bb_ptr) + Planar_map_2(const Traits &tr_, Point_location_base *pl_ptr, + Bounding_box_base *bb_ptr) { traits = new Traits_wrap(tr_); use_delete_traits = true; @@ -183,7 +184,7 @@ public: pl->init(*this,*traits); #else assert(0); - // if no default PL is defined you must supply a pl. + // if no default PL is defined you must supply a pl. #endif } else @@ -209,7 +210,8 @@ public: // constructor #4 - set traits, pl and bb // set NULLs for defaults - Planar_map_2(Traits_wrap *tr_ptr, Point_location_base *pl_ptr, Bounding_box_base *bb_ptr) + Planar_map_2(Traits_wrap *tr_ptr, Point_location_base *pl_ptr, + Bounding_box_base *bb_ptr) { if (tr_ptr == NULL) { @@ -254,20 +256,23 @@ public: } } - //////////////////////////////////////////////////////////////////////////////////// - // Copy constructor. - /////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// Copy constructor. +/////////////////////////////////////////////////////////////////////////////// Planar_map_2(const Self& pm){ - // doing the same as Planar_map_2(pm.get_traits(), pm.get_point_location(), pm.get_point_bbox()); + // doing the same as Planar_map_2(pm.get_traits(),pm.get_point_location(), + // pm.get_point_bbox()); traits = new Traits_wrap(); use_delete_traits = true; - if (Pm_naive_point_location* tmp_pl = dynamic_cast*>(pm.pl) ){ + if (Pm_naive_point_location* tmp_pl = + dynamic_cast*>(pm.pl) ){ //cout<<"Naive"<; } - else if (Pm_walk_along_line_point_location* tmp_pl = dynamic_cast*>(pm.pl) ){ + else if (Pm_walk_along_line_point_location* tmp_pl = + dynamic_cast*>(pm.pl) ){ pl = new Pm_walk_along_line_point_location; //cout<<"Walk"<insert(h_iter, h_iter->curve()); - for (Vertex_iterator v_iter = vertices_begin(); v_iter != vertices_end(); v_iter++) + for (Vertex_iterator v_iter = vertices_begin(); + v_iter != vertices_end(); + v_iter++) bb->insert(v_iter->point()); - for (h_iter = halfedges_begin(); h_iter != halfedges_end(); h_iter++, h_iter++) + for (h_iter = halfedges_begin(); + h_iter != halfedges_end(); + h_iter++, h_iter++) bb->insert(h_iter->curve()); } @@ -424,281 +435,288 @@ public: } */ - virtual ~Planar_map_2 () { - if (use_delete_pl) delete pl; - if (use_delete_bb) delete bb; - if (use_delete_traits) delete traits; - } - - Halfedge_handle insert_in_face_interior(const X_curve& cv, Face_handle f) - { - Halfedge_handle h = Topological_map::insert_in_face_interior(f); - h->set_curve(cv); //should set the curve of the twin as well but for now - h->twin()->set_curve(cv); + virtual ~Planar_map_2 () { + if (use_delete_pl) delete pl; + if (use_delete_bb) delete bb; + if (use_delete_traits) delete traits; + } + + Halfedge_handle insert_in_face_interior(const X_curve& cv, Face_handle f) + { + Halfedge_handle h = Topological_map::insert_in_face_interior(f); + h->set_curve(cv); //should set the curve of the twin as well but for now + h->twin()->set_curve(cv); - //pl->insert(h); //maybe should be above - //iddo - for arrangement - pl->insert(h,cv); + //pl->insert(h); //maybe should be above + //iddo - for arrangement + pl->insert(h,cv); - h->source()->set_point(traits->curve_source(cv)); - h->target()->set_point(traits->curve_target(cv)); + h->source()->set_point(traits->curve_source(cv)); + h->target()->set_point(traits->curve_target(cv)); - return h; - } + return h; + } - Halfedge_handle insert_from_vertex(const X_curve& cv, - Vertex_handle v1, bool source) - { - //find the previous of cv. - Halfedge_around_vertex_circulator - previous=v1->incident_halfedges(), - after=previous, - infinite_loop=previous; - ++after; + Halfedge_handle insert_from_vertex(const X_curve& cv, + Vertex_handle v1, bool source) + { + //find the previous of cv. + Halfedge_around_vertex_circulator + previous=v1->incident_halfedges(), + after=previous, + infinite_loop=previous; + ++after; - if (after!=previous) { - while (!(traits->curve_is_between_cw(cv,previous->curve(),after->curve(),v1->point()))) { - previous=after; - ++after; - if (previous==infinite_loop) // infinite loop indication - { - std::cerr << std::endl << "Planar_map_2::insert_from_vertex(" << - "const X_curve& cv, Vertex_handle v1, " << - "bool source) called with previously " << - "inserted curve " << std::endl; - return Halfedge_handle(); - } - } - } + if (after!=previous) { + while (!(traits->curve_is_between_cw(cv,previous->curve(), + after->curve(),v1->point()))) { + previous=after; + ++after; + if (previous==infinite_loop) // infinite loop indication + { + std::cerr << std::endl << "Planar_map_2::insert_from_vertex(" << + "const X_curve& cv, Vertex_handle v1, " << + "bool source) called with previously " << + "inserted curve " << std::endl; + return Halfedge_handle(); + } + } + } - Halfedge_handle h = Topological_map::insert_from_vertex(previous); - h->set_curve(cv); - h->twin()->set_curve(cv); + Halfedge_handle h = Topological_map::insert_from_vertex(previous); + h->set_curve(cv); + h->twin()->set_curve(cv); - //pl->insert(h); //maybe should be above - //iddo - for arrangement - pl->insert(h,cv); + //pl->insert(h); //maybe should be above + //iddo - for arrangement + pl->insert(h,cv); - //h is now pointing from v1 - if (source) - h->target()->set_point(traits->curve_target(cv)); - else - h->target()->set_point(traits->curve_source(cv)); + //h is now pointing from v1 + if (source) + h->target()->set_point(traits->curve_target(cv)); + else + h->target()->set_point(traits->curve_source(cv)); - return h; - } + return h; + } - - Halfedge_handle insert_at_vertices(const X_curve& cv, - Vertex_handle v1, Vertex_handle v2) - { - Size num_before=number_of_faces(); + Halfedge_handle insert_at_vertices(const X_curve& cv, + Vertex_handle v1, Vertex_handle v2) + { + Size num_before=number_of_faces(); - Halfedge_around_vertex_circulator - previous1=v1->incident_halfedges(), - previous2=v2->incident_halfedges(), - after=previous1, - infinite_loop=previous1; - ++after; + Halfedge_around_vertex_circulator + previous1=v1->incident_halfedges(), + previous2=v2->incident_halfedges(), + after=previous1, + infinite_loop=previous1; + ++after; - if (after!=previous1) { - while (!(traits->curve_is_between_cw(cv,previous1->curve(),after->curve(),v1->point()))) { - previous1=after; - ++after; - if (previous1==infinite_loop) // infinite loop indication - { - std::cerr << std::endl << "Planar_map_2::insert_at_vertices(" << - "const X_curve& cv, Vertex_const_handle v1, " << - "Vertex_const_handle v2) called with previously " << - "inserted curve " << std::endl; - return Halfedge_handle(); - } - } - } + if (after!=previous1) { + while (!(traits->curve_is_between_cw(cv,previous1->curve(), + after->curve(),v1->point()))) { + previous1=after; + ++after; + if (previous1==infinite_loop) // infinite loop indication + { + std::cerr << std::endl << "Planar_map_2::insert_at_vertices(" << + "const X_curve& cv, Vertex_const_handle v1, " << + "Vertex_const_handle v2) called with previously " << + "inserted curve " << std::endl; + return Halfedge_handle(); + } + } + } - after=previous2; - infinite_loop=previous2; - ++after; + after=previous2; + infinite_loop=previous2; + ++after; - if (after!=previous2) { - while (!(traits->curve_is_between_cw(cv,previous2->curve(),after->curve(),v2->point()))) { - previous2=after; - ++after; - if (previous2==infinite_loop) // infinite loop indication - { - std::cerr << std::endl << "Planar_map_2::insert_at_vertices(" << - "const X_curve& cv, Vertex_const_handle v1," << - "Vertex_const_handle v2) called with previously " << - "inserted curve " << std::endl; - return Halfedge_handle(); - } - } - } + if (after!=previous2) { + while (!(traits->curve_is_between_cw(cv,previous2->curve(), + after->curve(),v2->point()))) { + previous2=after; + ++after; + if (previous2==infinite_loop) // infinite loop indication + { + std::cerr << std::endl << "Planar_map_2::insert_at_vertices(" << + "const X_curve& cv, Vertex_const_handle v1," << + "Vertex_const_handle v2) called with previously " << + "inserted curve " << std::endl; + return Halfedge_handle(); + } + } + } - bool prev1_before_prev2 = prev1_inside_hole(previous1,previous2,cv); - Halfedge_handle h; - if (prev1_before_prev2) - h = Topological_map::insert_at_vertices(previous1,previous2); - else - h = Topological_map::insert_at_vertices(previous2,previous1); + bool prev1_before_prev2 = prev1_inside_hole(previous1,previous2,cv); + Halfedge_handle h; + if (prev1_before_prev2) + h = Topological_map::insert_at_vertices(previous1,previous2); + else + h = Topological_map::insert_at_vertices(previous2,previous1); - h->set_curve(cv); - h->twin()->set_curve(cv); + h->set_curve(cv); + h->twin()->set_curve(cv); - Size num_after=number_of_faces(); - if (num_after-num_before) { //if additional face was added - move holes - Face_handle nf = h->face(); //the new face will always be the one pointed at by h - Face_handle of = h->twin()->face(); //old face + Size num_after=number_of_faces(); + if (num_after-num_before) { //if additional face was added - move holes + Face_handle nf = h->face(); //the new face will always be the one + // pointed at by h + Face_handle of = h->twin()->face(); //old face - Holes_iterator it=of->holes_begin(); - while (it!=of->holes_end()) { + Holes_iterator it=of->holes_begin(); + while (it!=of->holes_end()) { - //check if the hole is inside new face - // if ( point_is_in((*it)->target()->point(),nf) ) { - //new for arrangement - if ( point_is_in((*it)->target()->point(),h,cv) ) { - Holes_iterator tmp=it; //deletion invalidates iterators so... - ++it; //assumes only the erased iterator is invalidated (like stl - //list) + //check if the hole is inside new face + // if ( point_is_in((*it)->target()->point(),nf) ) { + //new for arrangement + if ( point_is_in((*it)->target()->point(),h,cv) ) { + Holes_iterator tmp=it; //deletion invalidates iterators so... + ++it; //assumes only the erased iterator is invalidated (like stl + //list) - move_hole( tmp,of,nf); - } - else - ++it; - } + move_hole( tmp,of,nf); + } + else + ++it; + } - } + } - if (!prev1_before_prev2) h=h->twin(); + if (!prev1_before_prev2) h=h->twin(); - //pl->insert(h); - //iddo - for arrangement - pl->insert(h,cv); + //pl->insert(h); + //iddo - for arrangement + pl->insert(h,cv); - return h; - } + return h; + } - bool is_empty() const {return halfedges_begin()==halfedges_end();} - - // Note that the return types are abstract base classes - const Point_location_base* get_point_location() const {return pl;} - const Bounding_box_base* get_bounding_box() const {return bb;} - - const Traits_wrap& get_traits() { return *traits;} + bool is_empty() const {return halfedges_begin()==halfedges_end();} + + // Note that the return types are abstract base classes + const Point_location_base* get_point_location() const {return pl;} + const Bounding_box_base* get_bounding_box() const {return bb;} + + const Traits_wrap& get_traits() { return *traits;} private: - //a private implementation which defines if previous1 is on an outer ccb of - //the new face (returns true) or on an inner ccb (returns false) - bool prev1_inside_hole(Halfedge_const_handle previous1,Halfedge_const_handle previous2, - const X_curve& cv) - { - /* - Defining geometrically whether there is a new face an if - there is find if previous1 is on the outside of the new - face (send previous1,previous2) or on the inside of the new - face (send previous2,previous1) + //a private implementation which defines if previous1 is on an outer ccb of + //the new face (returns true) or on an inner ccb (returns false) + bool prev1_inside_hole(Halfedge_const_handle previous1, + Halfedge_const_handle previous2, + const X_curve& cv) + { + /* + Defining geometrically whether there is a new face an if + there is find if previous1 is on the outside of the new + face (send previous1,previous2) or on the inside of the new + face (send previous2,previous1) - The algorithm: - 1. go over all the halfedges of the face which will hold - previous1 (since the new face is not constructed yet, - this is modeled by going from previous2->next to previous1 and then - over the new curve) + The algorithm: + 1. go over all the halfedges of the face which will hold + previous1 (since the new face is not constructed yet, + this is modeled by going from previous2->next to previous1 and then + over the new curve) - 2. find if the left-most-lower - halfedge in the path (i.e, the one with the leftmost down target and - is the lowest to the right among the incident edges of this vertex) - is directed left (we are on the outside) or right (we are inside ) - (if not on same ccb then it doesn't matter and return true) - */ - Ccb_halfedge_const_circulator left_edge(previous2); - ++left_edge; - Ccb_halfedge_const_circulator first(previous2),curr(left_edge), - last(previous1); - ++last; //we want the previous1 to be checked as well + 2. find if the left-most-lower + halfedge in the path (i.e, the one with the leftmost down target and + is the lowest to the right among the incident edges of this vertex) + is directed left (we are on the outside) or right (we are inside ) + (if not on same ccb then it doesn't matter and return true) + */ + Ccb_halfedge_const_circulator left_edge(previous2); + ++left_edge; + Ccb_halfedge_const_circulator first(previous2),curr(left_edge), + last(previous1); + ++last; //we want the previous1 to be checked as well - Point left = previous2->target()->point(); - bool b; + Point left = previous2->target()->point(); + bool b; - do { - //source - b=false; - if (traits->point_is_left( curr->source()->point(),left)) - b=true; - else - if (traits->point_is_same(curr->source()->point(),left)) { - if (traits->curve_is_vertical(curr->curve()) && - traits->point_is_lower(curr->target()->point(),left) ) - b=true; - else - if (traits->curve_compare_at_x_right(curr->curve(),left_edge->curve(), - left)==SMALLER ) - b=true; - } + do { + //source + b=false; + if (traits->point_is_left( curr->source()->point(),left)) + b=true; + else + if (traits->point_is_same(curr->source()->point(),left)) { + if (traits->curve_is_vertical(curr->curve()) && + traits->point_is_lower(curr->target()->point(),left) ) + b=true; + else + if (traits->curve_compare_at_x_right(curr->curve(), + left_edge->curve(), + left)==SMALLER ) + b=true; + } - if (b) { - left=curr->source()->point(); - left_edge=curr; - } + if (b) { + left=curr->source()->point(); + left_edge=curr; + } //target - b=false; - if (traits->point_is_left( curr->target()->point(),left)) - b=true; - if (traits->point_is_same(curr->target()->point(),left)) { - if (traits->curve_is_vertical(curr->curve()) && - traits->point_is_lower(curr->source()->point(),left) ) - b=true; - else - if (traits->curve_compare_at_x_right(curr->curve(),left_edge->curve(), - left)==SMALLER ) - b=true; + b=false; + if (traits->point_is_left( curr->target()->point(),left)) + b=true; + if (traits->point_is_same(curr->target()->point(),left)) { + if (traits->curve_is_vertical(curr->curve()) && + traits->point_is_lower(curr->source()->point(),left) ) + b=true; + else + if (traits->curve_compare_at_x_right(curr->curve(), + left_edge->curve(), + left)==SMALLER ) + b=true; - //we want in the degenerate case to return the halfedge - //pointing _at_ the left point - else - if ( (curr)==(left_edge->twin()) ) - b=true; + //we want in the degenerate case to return the halfedge + //pointing _at_ the left point + else + if ( (curr)==(left_edge->twin()) ) + b=true; - } + } - if (b) { - left=curr->target()->point(); - left_edge=curr; - } + if (b) { + left=curr->target()->point(); + left_edge=curr; + } - ++curr; - } while ( (curr != first) && (curr != last) ); + ++curr; + } while ( (curr != first) && (curr != last) ); - //test the new curve against left_edge - if (traits->point_is_same(traits->curve_target(cv),left)|| - traits->point_is_same(traits->curve_source(cv),left)) { - if (traits->curve_is_vertical(cv)) { - return (traits->point_is_lower(previous2->target()->point(), - previous1->target()->point())); - } - else - if (traits->curve_compare_at_x_right(cv,left_edge->curve(), - left)==SMALLER ) { - return (traits->point_is_left(previous1->target()->point(), - previous2->target()->point())); - } - } + //test the new curve against left_edge + if (traits->point_is_same(traits->curve_target(cv),left)|| + traits->point_is_same(traits->curve_source(cv),left)) { + if (traits->curve_is_vertical(cv)) { + return (traits->point_is_lower(previous2->target()->point(), + previous1->target()->point())); + } + else + if (traits->curve_compare_at_x_right(cv,left_edge->curve(), + left)==SMALLER ) { + return (traits->point_is_left(previous1->target()->point(), + previous2->target()->point())); + } + } - //check if left_edge is from left to right - if (traits->curve_is_vertical(left_edge->curve())) { - if (traits->point_is_lower(left_edge->source()->point(), - left_edge->target()->point())) - return false; - else - return true; - } + //check if left_edge is from left to right + if (traits->curve_is_vertical(left_edge->curve())) { + if (traits->point_is_lower(left_edge->source()->point(), + left_edge->target()->point())) + return false; + else + return true; + } - return (traits->point_is_left(left_edge->source()->point(),left_edge->target()->point())); + return (traits->point_is_left(left_edge->source()->point(), + left_edge->target()->point())); } @@ -760,7 +778,8 @@ public: } template - Halfedge_iterator insert(const X_curve_iterator& begin,const X_curve_iterator& end) { + Halfedge_iterator insert(const X_curve_iterator& begin, + const X_curve_iterator& end) { X_curve_iterator it=begin; Halfedge_iterator out; if (it!=end) @@ -780,128 +799,136 @@ public: const X_curve& c1, const X_curve& c2) { - CGAL_precondition(traits->point_is_same(traits->curve_source(c2), - traits->curve_target(c1))); + CGAL_precondition(traits->point_is_same(traits->curve_source(c2), + traits->curve_target(c1))); - CGAL_precondition( - traits->point_is_same( - traits->curve_source(c1),e->source()->point()) && - traits->point_is_same( - traits->curve_target(c2),e->target()->point()) || - traits->point_is_same( - traits->curve_source(c1),e->target()->point()) && - traits->point_is_same( - traits->curve_target(c2),e->source()->point()) ); + CGAL_precondition( + traits->point_is_same( + traits->curve_source(c1), + e->source()->point()) && + traits->point_is_same( + traits->curve_target(c2), + e->target()->point()) || + traits->point_is_same( + traits->curve_source(c1), + e->target()->point()) && + traits->point_is_same( + traits->curve_target(c2), + e->source()->point()) ); - X_curve cv(e->curve()); + X_curve cv(e->curve()); - Halfedge_handle h = Topological_map::split_edge(e); + Halfedge_handle h = Topological_map::split_edge(e); - if (traits->point_is_same(traits->curve_source(c1),h->source()->point())) { - h->set_curve(c1); - h->twin()->set_curve(c1); - h->next_halfedge()->set_curve(c2); - h->next_halfedge()->twin()->set_curve(c2); - h->target()->set_point(traits->curve_target(c1)); - pl->split_edge(cv,h,h->next_halfedge(),c1,c2); - } - else { - h->set_curve(c2); - h->twin()->set_curve(c2); - h->next_halfedge()->set_curve(c1); - h->next_halfedge()->twin()->set_curve(c1); - h->target()->set_point(traits->curve_target(c1)); - pl->split_edge(cv,h,h->next_halfedge(),c2,c1); - } + if (traits->point_is_same(traits->curve_source(c1),h->source()->point())) { + h->set_curve(c1); + h->twin()->set_curve(c1); + h->next_halfedge()->set_curve(c2); + h->next_halfedge()->twin()->set_curve(c2); + h->target()->set_point(traits->curve_target(c1)); + pl->split_edge(cv,h,h->next_halfedge(),c1,c2); + } + else { + h->set_curve(c2); + h->twin()->set_curve(c2); + h->next_halfedge()->set_curve(c1); + h->next_halfedge()->twin()->set_curve(c1); + h->target()->set_point(traits->curve_target(c1)); + pl->split_edge(cv,h,h->next_halfedge(),c2,c1); + } - return h; + return h; + } + + + Halfedge_handle merge_edge(Halfedge_handle e1, Halfedge_handle e2, + const X_curve& cv) { + CGAL_precondition( (traits->point_is_same(traits->curve_source(cv), + e1->source()->point() )&& + traits->point_is_same(traits->curve_target(cv), + e2->target()->point())) || + (traits->point_is_same(traits->curve_target(cv), + e1->source()->point() )&& + traits->point_is_same(traits->curve_source(cv), + e2->target()->point())) ); + + X_curve c1(e1->curve()), c2(e2->curve()); + + Halfedge_handle h = Topological_map::merge_edge(e1,e2); + h->set_curve(cv); + h->twin()->set_curve(cv); + + //pl->merge_edge(c1,c2,h); + //iddo - for arrangement + pl->merge_edge(c1,c2,h,cv); + + + return h; + } + + Face_handle remove_edge(Halfedge_handle e) { + pl->remove_edge(e); + + //if a new hole can be created define geometrically the + //halfedge (e or e->twin) that points at the new hole. + //if the leftmost point in the path e...e->twin + //is left of the leftmost point in the path e->twin ... e + //then e->twin points at the hole created. + + if (e->face() == e->twin()->face() ) { + Ccb_halfedge_circulator ccb_e=e->ccb() ; + Ccb_halfedge_circulator ccb_t=e->twin()->ccb(); + + Point e_left=e->target()->point(); + Point t_left=ccb_t->target()->point(); + + //find the leftmost point in the path from e to its twin + Ccb_halfedge_circulator aux=ccb_e; + do { + if (traits->compare_x(aux->target()->point(),e_left)==SMALLER) { + e_left=aux->target()->point(); } - - - Halfedge_handle merge_edge(Halfedge_handle e1, Halfedge_handle e2, - const X_curve& cv) { - CGAL_precondition( (traits->point_is_same(traits->curve_source(cv),e1->source()->point() )&& - traits->point_is_same(traits->curve_target(cv),e2->target()->point())) || - (traits->point_is_same(traits->curve_target(cv),e1->source()->point() )&& - traits->point_is_same(traits->curve_source(cv),e2->target()->point())) ); - - X_curve c1(e1->curve()), c2(e2->curve()); - - Halfedge_handle h = Topological_map::merge_edge(e1,e2); - h->set_curve(cv); - h->twin()->set_curve(cv); - - //pl->merge_edge(c1,c2,h); - //iddo - for arrangement - pl->merge_edge(c1,c2,h,cv); - - - return h; - } - - Face_handle remove_edge(Halfedge_handle e) { - pl->remove_edge(e); - - //if a new hole can be created define geometrically the - //halfedge (e or e->twin) that points at the new hole. - //if the leftmost point in the path e...e->twin - //is left of the leftmost point in the path e->twin ... e - //then e->twin points at the hole created. - - if (e->face() == e->twin()->face() ) { - Ccb_halfedge_circulator ccb_e=e->ccb() ; - Ccb_halfedge_circulator ccb_t=e->twin()->ccb(); + } while (++aux!=ccb_t); - Point e_left=e->target()->point(); - Point t_left=ccb_t->target()->point(); + //find the leftmost point in the path from the twin to e + aux=ccb_t; + do { + if (traits->compare_x(aux->target()->point(),t_left)==SMALLER) { + t_left=aux->target()->point(); + } + } while (++aux!=ccb_e); - //find the leftmost point in the path from e to its twin - Ccb_halfedge_circulator aux=ccb_e; - do { - if (traits->compare_x(aux->target()->point(),e_left)==SMALLER) { - e_left=aux->target()->point(); - } - } while (++aux!=ccb_t); + //compare the two left points + if (traits->compare_x(t_left,e_left) == SMALLER) //e points at hole + return Topological_map::remove_edge(e); + else + return Topological_map::remove_edge(e->twin()); - //find the leftmost point in the path from the twin to e - aux=ccb_t; - do { - if (traits->compare_x(aux->target()->point(),t_left)==SMALLER) { - t_left=aux->target()->point(); - } - } while (++aux!=ccb_e); + } + else { - //compare the two left points - if (traits->compare_x(t_left,e_left) == SMALLER) //e points at hole - return Topological_map::remove_edge(e); - else - return Topological_map::remove_edge(e->twin()); - - } - else { - - return Topological_map::remove_edge(e); - } + return Topological_map::remove_edge(e); + } - } + } - Halfedge_handle vertical_ray_shoot( - const Point& p, Locate_type <, bool up) - { - CGAL_precondition(pl); - return pl->vertical_ray_shoot(p,lt,up); - } + Halfedge_handle vertical_ray_shoot(const Point& p, + Locate_type <, bool up) + { + CGAL_precondition(pl); + return pl->vertical_ray_shoot(p,lt,up); + } - - Halfedge_const_handle vertical_ray_shoot( - const Point& p, Locate_type <, bool up) const - { - CGAL_precondition(pl); - return ((const Point_location_base*)pl)->vertical_ray_shoot(p,lt,up); - // The type cast to const is there to ensure that the planar map - // is not changed. - } + + Halfedge_const_handle vertical_ray_shoot(const Point& p, + Locate_type <, bool up) const + { + CGAL_precondition(pl); + return ((const Point_location_base*)pl)->vertical_ray_shoot(p,lt,up); + // The type cast to const is there to ensure that the planar map + // is not changed. + } @@ -918,171 +945,173 @@ public: } protected: //private implementation - //returns true if the point is inside (in the strict sense) of nf - //algorithm: count the intersections of a vertical ray shoot - are they odd ? - //assumes outer ccb exists - - //CHANGE - for this to work in the arrangement, it should not pass over - //the curve just inserted (i.e the halfedge) - - /* - bool point_is_in(const Point& p, Face_const_handle nf) const - { + //returns true if the point is inside (in the strict sense) of nf + //algorithm: count the intersections of a vertical ray shoot - are they odd ? + //assumes outer ccb exists + + //CHANGE - for this to work in the arrangement, it should not pass over + //the curve just inserted (i.e the halfedge) + + /* + bool point_is_in(const Point& p, Face_const_handle nf) const + { int count = 0; - Ccb_halfedge_const_circulator circ = nf->outer_ccb(); - do { - ++circ; - } while ((traits->curve_is_vertical(circ->curve()))&&circ!=nf->outer_ccb()); - if (circ==nf->outer_ccb() && traits->curve_is_vertical(circ->curve()) ) - return false; - //if the whole ccb is vertical then the point is out. - //else advance to a non vertical curve - - Ccb_halfedge_const_circulator last = circ; + Ccb_halfedge_const_circulator circ = nf->outer_ccb(); + do { + ++circ; + } while ((traits->curve_is_vertical(circ->curve()))&& + circ!=nf->outer_ccb()); + if (circ==nf->outer_ccb() && traits->curve_is_vertical(circ->curve()) ) + return false; + //if the whole ccb is vertical then the point is out. + //else advance to a non vertical curve + + Ccb_halfedge_const_circulator last = circ; + + + do { + if (traits->point_is_same(circ->target()->point(), p)) + //point is on outer ccb + return false; + if (!traits->curve_is_vertical(circ->curve())) { + + if ( (traits->curve_get_point_status(circ->curve(),p) == + Traits::UNDER_CURVE) && + !(traits->point_is_same_x(circ->source()->point(),p)) ) { + //point is under curve in the range (source,target] + + if (traits->point_is_same_x(circ->target()->point(),p)) { + //p is exactly under a vertex of the ccb - if next is not on the + //same side of the vertical line from p as circ is, + //we count one more intersection + + Ccb_halfedge_const_circulator next=circ; + ++next; + if (traits->curve_is_vertical(next->curve())) { + //advance to non-vertical edge + while (traits->curve_is_vertical(next->curve())) { + ++next; + } + } + if ( (traits->point_is_right(circ->source()->point(),p)&& + traits->point_is_left(next->target()->point(),p)) || + (traits->point_is_left(circ->source()->point(),p)&& + traits->point_is_right(next->target()->point(),p)) ) { + + ++count; + } + } + else { + ++count; + } + } + } + } while (++circ!=last); + + return (count%2 != 0); //if count is odd return true + + } + */ + + bool point_is_in(const Point& p, Halfedge_const_handle ne, + const X_curve& ncv) const + // returns true if the points is inside the planar map. + { + int count = 0; + + // Ccb_halfedge_const_circulator circ = nf->outer_ccb(); + Ccb_halfedge_const_circulator circ = ne; + do { + ++circ; + } while (circ!=ne && traits->curve_is_vertical(circ->curve())); + if (circ==ne && traits->curve_is_vertical(ncv) ) + return false; + //if the whole ccb is vertical then the point is out. + //else advance to a non vertical curve + + Ccb_halfedge_const_circulator last = circ; + + + do { + X_curve circv; + if (circ!=ne) { //not on the new halfedge (circ has a curve + circv=circ->curve(); + } + else { //maybe doesn't have a curve yet (e.g in arrangement) + circv=ncv; + } + + if (traits->point_is_same(circ->target()->point(), p)) + //point is on outer ccb + return false; + if (!traits->curve_is_vertical(circv)) { + + if ( (traits->curve_get_point_status(circv,p) == + Traits::UNDER_CURVE) && + !(traits->point_is_same_x(circ->source()->point(),p)) ) { + //point is under curve in the range (source,target] - - do { - if (traits->point_is_same(circ->target()->point(), p)) //point is on outer ccb - return false; - if (!traits->curve_is_vertical(circ->curve())) { - - if ( (traits->curve_get_point_status(circ->curve(),p) == - Traits::UNDER_CURVE) && - !(traits->point_is_same_x(circ->source()->point(),p)) ) { - //point is under curve in the range (source,target] - - if (traits->point_is_same_x(circ->target()->point(),p)) { - //p is exactly under a vertex of the ccb - if next is not on the - //same side of the vertical line from p as circ is, - //we count one more intersection - - Ccb_halfedge_const_circulator next=circ; - ++next; - if (traits->curve_is_vertical(next->curve())) { - //advance to non-vertical edge - while (traits->curve_is_vertical(next->curve())) { - ++next; - } - } - if ( (traits->point_is_right(circ->source()->point(),p)&& - traits->point_is_left(next->target()->point(),p)) || - (traits->point_is_left(circ->source()->point(),p)&& - traits->point_is_right(next->target()->point(),p)) ) { - - ++count; - } - } - else { - ++count; - } - } - } - } while (++circ!=last); - - return (count%2 != 0); //if count is odd return true - - } - */ - - - bool point_is_in(const Point& p, Halfedge_const_handle ne, - const X_curve& ncv) const -// returns true if the points is inside the planar map. - { - int count = 0; - - // Ccb_halfedge_const_circulator circ = nf->outer_ccb(); - Ccb_halfedge_const_circulator circ = ne; - do { - ++circ; - } while (circ!=ne && traits->curve_is_vertical(circ->curve())); - if (circ==ne && traits->curve_is_vertical(ncv) ) - return false; - //if the whole ccb is vertical then the point is out. - //else advance to a non vertical curve - - Ccb_halfedge_const_circulator last = circ; - - - do { - X_curve circv; - if (circ!=ne) { //not on the new halfedge (circ has a curve - circv=circ->curve(); - } - else { //maybe doesn't have a curve yet (e.g in arrangement) - circv=ncv; - } - - if (traits->point_is_same(circ->target()->point(), p)) //point is on outer ccb - return false; - if (!traits->curve_is_vertical(circv)) { - - if ( (traits->curve_get_point_status(circv,p) == - Traits::UNDER_CURVE) && - !(traits->point_is_same_x(circ->source()->point(),p)) ) { - //point is under curve in the range (source,target] - - if (traits->point_is_same_x(circ->target()->point(),p)) { - //p is exactly under a vertex of the ccb - if next is not on the - //same side of the vertical line from p as circ is, - //we count one more intersection - - Ccb_halfedge_const_circulator next=circ; - ++next; - X_curve nextcv; - if (next!=ne) { - nextcv=next->curve(); - } - else { - nextcv=ncv; - } - if (traits->curve_is_vertical(nextcv)) { - //advance to non-vertical edge - while (traits->curve_is_vertical(nextcv)) { - if (next!=ne) { - nextcv=next->curve(); - } - else { - nextcv=ncv; - } - ++next; - - } - } - if ( (traits->point_is_right(circ->source()->point(),p)&& - traits->point_is_left(next->target()->point(),p)) || - (traits->point_is_left(circ->source()->point(),p)&& - traits->point_is_right(next->target()->point(),p)) ) { - - ++count; - } - } - else { - ++count; - } - } - } - - - } while (++circ!=last); - - return (count%2 != 0); //if count is odd return true + if (traits->point_is_same_x(circ->target()->point(),p)) { + //p is exactly under a vertex of the ccb - if next is not on the + //same side of the vertical line from p as circ is, + //we count one more intersection + + Ccb_halfedge_const_circulator next=circ; + ++next; + X_curve nextcv; + if (next!=ne) { + nextcv=next->curve(); + } + else { + nextcv=ncv; + } + if (traits->curve_is_vertical(nextcv)) { + //advance to non-vertical edge + while (traits->curve_is_vertical(nextcv)) { + if (next!=ne) { + nextcv=next->curve(); + } + else { + nextcv=ncv; + } + ++next; + } + } + if ( (traits->point_is_right(circ->source()->point(),p)&& + traits->point_is_left(next->target()->point(),p)) || + (traits->point_is_left(circ->source()->point(),p)&& + traits->point_is_right(next->target()->point(),p)) ) { + + ++count; + } + } + else { + ++count; + } } - - - ///////////////////////////////////////////////////////// - // Assignment functions - // Those are temporary functions and it should not be used + } + + + } while (++circ!=last); + + return (count%2 != 0); //if count is odd return true + + } + + + ///////////////////////////////////////////////////////// + // Assignment functions + // Those are temporary functions and it should not be used public: - void assign(const Self &pm) - { - TPM::assign(pm); - // traits->assign(pm->traits); - // bb->assign(pm->bb); - // pl->assign(pm->pl); - } + void assign(const Self &pm) + { + TPM::assign(pm); + // traits->assign(pm->traits); + // bb->assign(pm->bb); + // pl->assign(pm->pl); + } /*Self& operator=(const Self& pm) { @@ -1098,49 +1127,55 @@ public: */ Self& operator=(const Self& pm) - { - if (this != &pm) { - clear(); - assign(pm); + { + if (this != &pm) { + clear(); + assign(pm); - Halfedge_iterator h_iter; - for (h_iter = halfedges_begin(); h_iter != halfedges_end(); h_iter++, h_iter++) - pl->insert(h_iter, h_iter->curve()); + Halfedge_iterator h_iter; + for (h_iter = halfedges_begin(); + h_iter != halfedges_end(); + h_iter++, h_iter++) + pl->insert(h_iter, h_iter->curve()); - for (Vertex_iterator v_iter = vertices_begin(); v_iter != vertices_end(); v_iter++) - bb->insert(v_iter->point()); + for (Vertex_iterator v_iter = vertices_begin(); + v_iter != vertices_end(); + v_iter++) + bb->insert(v_iter->point()); - for (h_iter = halfedges_begin(); h_iter != halfedges_end(); h_iter++, h_iter++) - bb->insert(h_iter->curve()); - } - return *this; - } + for (h_iter = halfedges_begin(); + h_iter != halfedges_end(); + h_iter++, h_iter++) + bb->insert(h_iter->curve()); + } + return *this; + } - // used in implementation of operator=( - void clear() - { - pl->clear(); - TPM::clear(); - /* - Halfedge_iterator it=halfedges_begin(),prev=it,it_e=halfedges_end(); - while (it!=it_e) {++it;++it;remove_edge(prev);prev=it;} - */ - bb->clear(); - } - + // used in implementation of operator=( + void clear() + { + pl->clear(); + TPM::clear(); + /* + Halfedge_iterator it=halfedges_begin(),prev=it,it_e=halfedges_end(); + while (it!=it_e) {++it;++it;remove_edge(prev);prev=it;} + */ + bb->clear(); + } + protected: // used in implementation of operator=( - void x_curve_container(X_curve_container &l) const - { - Halfedge_const_iterator it=halfedges_begin(),it_e=halfedges_end(); - while (it!=it_e) - { - l.push_back(it->curve()); - ++it;++it; - } - } - // - ///////////////////////////////////////////////////////// + void x_curve_container(X_curve_container &l) const + { + Halfedge_const_iterator it=halfedges_begin(),it_e=halfedges_end(); + while (it!=it_e) + { + l.push_back(it->curve()); + ++it;++it; + } + } + // + ///////////////////////////////////////////////////////// @@ -1151,10 +1186,10 @@ protected: #ifdef CGAL_PM_DEBUG // for private debugging use public: - void debug() - { - if (pl) (pl->debug()); - } + void debug() + { + if (pl) (pl->debug()); + } #endif @@ -1183,7 +1218,9 @@ bool build_dcel (Scanner& scanner) { typedef typename Dcel::Face_iterator D_face_iterator; typedef typename Dcel::Face_const_iterator D_face_const_iterator; - std::vector halfedges_vec; // keeping a vector of halfedges (to access them easily by their indices). + // keeping a vector of halfedges (to access them easily by their indices). + std::vector halfedges_vec; + std::vector vertices_vec; if ( ! scanner.in()) @@ -1218,7 +1255,8 @@ bool build_dcel (Scanner& scanner) { //nv->set_point(p); // for debug. - //std::cout<<"Reading vertex no " <point()<point()<