diff --git a/Packages/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h b/Packages/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h index 25c92563c58..6d824584630 100644 --- a/Packages/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h +++ b/Packages/Sweep_line_2/include/CGAL/Sweep_line_2/Sweep_line_functors.h @@ -29,6 +29,8 @@ CGAL_BEGIN_NAMESPACE +int g_compare_func = 1; + template class Point_less_functor { @@ -89,6 +91,7 @@ private: }; #endif + template class Status_line_curve_less_functor { @@ -96,11 +99,34 @@ public: typedef SweepLineTraits_2 Traits; typedef typename Traits::Point_2 Point_2; typedef typename Traits::X_curve_2 X_curve_2; - //typedef Sweep_line_subcurve Subcurve; + typedef bool (Status_line_curve_less_functor::*func) + (const Subcurve*, const Subcurve*) const; - Status_line_curve_less_functor(Traits *traits) : m_traits(traits) {} + Status_line_curve_less_functor(Traits *traits) : m_traits(traits) { + m_compare[0] = &Status_line_curve_less_functor::compare_at; + m_compare[1] = &Status_line_curve_less_functor::compare_right; + } - bool operator()(const Subcurve* c1, const Subcurve* c2) const { + bool operator()(const Subcurve* c1, const Subcurve* c2) const { + return (this->*m_compare[g_compare_func])(c1, c2); + } + + func m_compare[2]; + + bool compare_at(const Subcurve* c1, const Subcurve* c2) const + { + const Point_2 *p = c1->getReferencePoint(); + Comparison_result r = + m_traits->curve_compare_at_x(c1->getCurve(), + c2->getCurve(), + *p); + if ( r == SMALLER) { + return true; + } + return false; + } + + bool compare_right(const Subcurve* c1, const Subcurve* c2) const { const Point_2 *p = c1->getReferencePoint(); #if 0 std::cout << "\t\tComparing between:" << *p << "\n" diff --git a/Packages/Sweep_line_2/include/CGAL/Sweep_line_tight_2.h b/Packages/Sweep_line_2/include/CGAL/Sweep_line_tight_2.h index 3d28ab6192b..b7a6780b024 100644 --- a/Packages/Sweep_line_2/include/CGAL/Sweep_line_tight_2.h +++ b/Packages/Sweep_line_2/include/CGAL/Sweep_line_tight_2.h @@ -921,6 +921,7 @@ FirstPass() EventCurveIter rightIter = m_currentEvent->rightCurvesBegin(); m_currentPos = m_sweepLinePos; + g_compare_func = 0; while ( rightIter != m_currentEvent->rightCurvesEnd()) { // if the point is not an end point, skip it @@ -929,7 +930,7 @@ FirstPass() continue; } -#if 1 +#if 0 // improve here StatusLineIter slIter = m_statusLine->begin(); while ( slIter != m_statusLine->end() ) @@ -980,6 +981,7 @@ FirstPass() #endif // 1 ++rightIter; } + g_compare_func = 1; SL_DEBUG(m_currentEvent->Print();) SL_DEBUG(std::cout << "First pass - done\n" ;) @@ -1619,7 +1621,7 @@ inline bool Sweep_line_tight_2:: DoCurvesOverlap(Subcurve *c1, Subcurve *c2) { -#if 0 +#if 1 // improve here... if ( m_traits->curve_compare_at_x_right(c1->getCurve(), c2->getCurve(),