diff --git a/Packages/Map_overlay_2/include/CGAL/Bops/Holes_split.h b/Packages/Map_overlay_2/include/CGAL/Bops/Holes_split.h index 720fd389344..966d9d6197a 100644 --- a/Packages/Map_overlay_2/include/CGAL/Bops/Holes_split.h +++ b/Packages/Map_overlay_2/include/CGAL/Bops/Holes_split.h @@ -26,37 +26,25 @@ #ifndef CGAL_HOLES_SPLIT_H #define CGAL_HOLES_SPLIT_H -//#ifndef LEDA_RAT_RAY_H -//#include -//#endif - - -//#ifndef CGAL_RAY_2_SEGMENT_2_INTERSECTION_H -//#include -//#endif - #ifndef CGAL_ASSERTIONS_H #include #endif CGAL_BEGIN_NAMESPACE -template +template class Holes_split { //typedef enum { EPSILON=0.01 }; static const int EPSILON=1; //change it to work on VC++. typedef Planar_map_ Planar_map; typedef Notifier_ Notifier; - typedef BopsTraits_2_ BopsTraits_2; typedef typename Planar_map_::Traits Traits; typedef typename Traits::Point Point; typedef typename Traits::X_curve X_curve; typedef typename Traits::Curve Curve; - typedef typename BopsTraits_2::Ray Ray; - typedef typename Planar_map::Vertex Vertex; typedef typename Planar_map::Face Face; typedef typename Planar_map::Halfedge Halfedge; @@ -80,15 +68,17 @@ class Holes_split { typedef typename Planar_map::Locate_type Locate_type; typedef typename Planar_map::Traits_wrap Traits_wrap; - typedef typename Point::R Kernel; + //typedef typename Point::R Kernel; //typedef Ray_2 Ray; - //typedef leda_rat_ray Ray; class less_xy_Vertex_handle { public: - inline bool operator()(Vertex_handle v1, Vertex_handle v2) const { - return CGAL::compare_lexicographically_xy(v1->point(),v2->point()) == CGAL::SMALLER ; + inline bool operator()(Vertex_handle v1, + Vertex_handle v2) const + { + return CGAL::compare_lexicographically_xy( + v1->point(),v2->point()) == CGAL::SMALLER; } }; @@ -97,10 +87,11 @@ class Holes_split { { Halfedge_around_vertex_circulator circ = v->incident_halfedges(); - do { - if (circ->decomposing()) - return true; - } while(++circ!=v->incident_halfedges()); + do + { + if (circ->decomposing()) + return true; + } while(++circ!=v->incident_halfedges()); return false; } @@ -111,54 +102,51 @@ class Holes_split { bool b=false; Halfedge_around_vertex_circulator circ = v->incident_halfedges(); - do { - if (circ->decomposing()){ - b=true; - *halfedges++ = circ; - } - } while(++circ!=v->incident_halfedges()); + do + { + if (circ->decomposing()){ + b=true; + *halfedges++ = circ; + } + } while(++circ!=v->incident_halfedges()); return b; } - void add_vertical_curve(Vertex_handle v, Planar_map& pm, Notifier& notf, bool up) + void add_vertical_curve(Vertex_handle v, + Planar_map& pm, + Notifier& notf, + bool up) { // debugging. //cout<< "In add_vertical_curve" <point().xcoordD()<<","<point().ycoordD() << endl; Locate_type lt; - int eps = up? EPSILON: -EPSILON; - Point pertrubed_p = Point(v->point().x(), - v->point().y() + eps); + //int eps = up? EPSILON: -EPSILON; + //Point pertrubed_p = Point(v->point().x(), + // v->point().y() + eps); //cout<<"pertrubed_p="<< pertrubed_p.xcoordD()<<","<point(), lt, up); - //cout <<"h->curve()="<curve()<face()->is_unbounded()) return; // what we should do here is using the bbox and adding // a vertical curve upward (downward) will it hits the bbox. - Ray ray(v->point(), pertrubed_p); - Point hitting_point; + //Ray ray(v->point(), pertrubed_p); + //Point hitting_point; - if (!bops_traits_->intersection(h->curve(), ray, hitting_point)) - return; - - //Object obj=intersection(h->curve(), ray); - //if (!assign(hitting_point, obj)) + Point hitting_point = traits_->calc_hitting_point(h->curve(), + v->point()); + + //if (!bops_traits_->intersection(h->curve(), ray, hitting_point)) // return; - //if (!ray.intersection(h->curve(), hitting_point)) // only for LEDA - // return; - //cout<<"hitting_point="<point(),hitting_point), // v,up,¬f); @@ -167,7 +155,8 @@ class Holes_split { X_curve c1,c2; traits.curve_split(h->curve(), c1, c2, hitting_point); - Halfedge_handle split_h = pm.split_edge(h,c1,c2,¬f); + //Halfedge_handle split_h = + pm.split_edge(h,c1,c2,¬f); CGAL_assertion(v->point() != hitting_point); pm.insert(Curve(v->point(),hitting_point),¬f); @@ -193,7 +182,7 @@ public: Holes_split() {} - Holes_split(BopsTraits_2* bops_traits) : bops_traits_(bops_traits) {} + Holes_split(Traits* traits) : traits_(traits) {} // This function splits the holes in pm. // Here, pm has a special structure of one face with possibly many holes. @@ -210,77 +199,82 @@ public: continue; // splitting only bounded faces. // keeping all Ccb in a seperate vector, since face is going to be changed. - std::vector holes(face->holes_begin(),face->holes_end()); + std::vector + holes(face->holes_begin(),face->holes_end()); //for (Holes_iterator holes_it = face->holes_begin(); // holes_it != face->holes_end(); ++holes_it) { for (std::vector::iterator holes_it = holes.begin(); - holes_it != holes.end(); ++holes_it) { - Ccb_halfedge_circulator face_cc(*holes_it); - - // finding the leftmost and the rightmost points of the hole. - std::vector vertices_cc; - do { - vertices_cc.push_back(face_cc->source()); - } while (++face_cc != *holes_it); - - std::sort(vertices_cc.begin(), vertices_cc.end(), less_xy_Vertex_handle() ); - - Vertex_handle leftlow_most = vertices_cc[0]; - Vertex_handle lefthigh_most = vertices_cc[0]; - - // updating lefthigh_most to have the highest value of y. - for (unsigned int i=0; i < vertices_cc.size() - 1 && - vertices_cc[i]->point().x() == vertices_cc[i+1]->point().x(); ++i) - lefthigh_most=vertices_cc[i+1]; - - Vertex_handle righthigh_most = vertices_cc.back(); - Vertex_handle rightlow_most = vertices_cc.back(); - - // updating rightlow_most to have the lowest value of y. - for (unsigned int i=vertices_cc.size() - 1; i > 1 && - vertices_cc[i]->point().x() == vertices_cc[i-1]->point().x(); --i) - lefthigh_most=vertices_cc[i-1]; - - /*Vertex_handle leftlow_most=face_cc->source(); - Vertex_handle lefthigh_most=face_cc->source(); - Vertex_handle rightlow_most=face_cc->source(); - Vertex_handle righthigh_most=face_cc->source(); - do { - if (face_cc->source()->point().xcoord() < leftmost->point().xcoord()) - lefthigh_most=leftlow_most=face_cc->source(); - else if (face_cc->source()->point().xcoord() == leftmost->point().xcoord()){ + holes_it != holes.end(); ++holes_it) + { + Ccb_halfedge_circulator face_cc(*holes_it); - } - if (face_cc->source()->point().xcoord() > rightmost->point().xcoord()) - rightmost=face_cc->source(); + // finding the leftmost and the rightmost points of the hole. + std::vector vertices_cc; + do + { + vertices_cc.push_back(face_cc->source()); + } while (++face_cc != *holes_it); + + std::sort(vertices_cc.begin(), + vertices_cc.end(), + less_xy_Vertex_handle() ); + + Vertex_handle leftlow_most = vertices_cc[0]; + Vertex_handle lefthigh_most = vertices_cc[0]; + + // updating lefthigh_most to have the highest value of y. + for (unsigned int i=0; i < vertices_cc.size() - 1 && + vertices_cc[i]->point().x() == vertices_cc[i+1]->point().x(); ++i) + lefthigh_most=vertices_cc[i+1]; + + Vertex_handle righthigh_most = vertices_cc.back(); + Vertex_handle rightlow_most = vertices_cc.back(); + + // updating rightlow_most to have the lowest value of y. + for (unsigned int i=vertices_cc.size() - 1; i > 1 && + vertices_cc[i]->point().x() == vertices_cc[i-1]->point().x(); --i) + lefthigh_most=vertices_cc[i-1]; + + /*Vertex_handle leftlow_most=face_cc->source(); + Vertex_handle lefthigh_most=face_cc->source(); + Vertex_handle rightlow_most=face_cc->source(); + Vertex_handle righthigh_most=face_cc->source(); + do { + if (face_cc->source()->point().xcoord() < leftmost->point().xcoord()) + lefthigh_most=leftlow_most=face_cc->source(); + else if (face_cc->source()->point().xcoord() == leftmost->point().xcoord()){ + + } + if (face_cc->source()->point().xcoord() > rightmost->point().xcoord()) + rightmost=face_cc->source(); } while (++face_cc != *holes_it);*/ - bool b_lefthigh=has_decomposing_edge(lefthigh_most); - bool b_leftlow=has_decomposing_edge(leftlow_most); - bool b_righthigh=has_decomposing_edge(righthigh_most); - bool b_rightlow=has_decomposing_edge(rightlow_most); + bool b_lefthigh=has_decomposing_edge(lefthigh_most); + bool b_leftlow=has_decomposing_edge(leftlow_most); + bool b_righthigh=has_decomposing_edge(righthigh_most); + bool b_rightlow=has_decomposing_edge(rightlow_most); - if (!b_lefthigh) - add_vertical_curve(lefthigh_most, pm, notf, true); - - //bool b_leftlow=has_decomposing_edge(leftlow_most); - if (!b_leftlow) + if (!b_lefthigh) + add_vertical_curve(lefthigh_most, pm, notf, true); + + //bool b_leftlow=has_decomposing_edge(leftlow_most); + if (!b_leftlow) add_vertical_curve(leftlow_most, pm, notf, false); - - //bool b_righthigh=has_decomposing_edge(righthigh_most); - if (!b_righthigh) - add_vertical_curve(righthigh_most, pm, notf, true); - + + //bool b_righthigh=has_decomposing_edge(righthigh_most); + if (!b_righthigh) + add_vertical_curve(righthigh_most, pm, notf, true); + //bool b_rightlow=has_decomposing_edge(rightlow_most); - if (!b_rightlow) - add_vertical_curve(rightlow_most, pm, notf, false); - } + if (!b_rightlow) + add_vertical_curve(rightlow_most, pm, notf, false); + } } } private: - BopsTraits_2* bops_traits_; + Traits* traits_; }; CGAL_END_NAMESPACE