From 2d7450cbf79bce3abfe37ec752066eb3a5ef2b6d Mon Sep 17 00:00:00 2001 From: Ron Wein Date: Mon, 24 Feb 2003 08:15:13 +0000 Subject: [PATCH] Added a precondition to curve_get_point_status() and removed the special enum. --- .../include/CGAL/Arr_circles_real_traits.h | 59 ++++--------- .../include/CGAL/Arr_conic_traits_2.h | 61 ++++---------- .../include/CGAL/Arr_leda_polyline_traits.h | 41 +++------ .../include/CGAL/Arr_leda_segment_traits_2.h | 4 +- .../include/CGAL/Arr_polyline_traits.h | 42 +++------- .../CGAL/Arr_segment_cached_traits_2.h | 48 +++++------ .../include/CGAL/Arr_segment_circle_traits.h | 57 +++---------- .../include/CGAL/Arr_segment_traits_2.h | 3 +- .../include/CGAL/Arr_segment_traits_tight_2.h | 3 +- .../include/CGAL/Pm_with_intersections.h | 3 +- .../Sweep_line_2/Pmwx_aggregate_insert_impl.h | 48 ++++++----- .../Pmwx_aggregate_insert_tight.h | 45 +++++----- .../DATA/conic_arcs/conic_get_point_status | 35 ++++---- .../DATA/polylines/big_overlap2 | 13 +-- .../DATA/polylines/get_point_status | 7 +- .../DATA/polylines/partial_overlap_reverse | 12 +-- .../DATA/segment_circles/get_point_status | 20 ++--- .../DATA/segments/get_point_status | 7 +- .../include/Base_traits_test.h | 16 +--- .../include/Conic_traits_test.h | 13 +-- .../include/Polyline_traits_test.h | 69 +++++++++------ .../include/Segment_circle_traits_test.h | 16 ++-- .../include/Segment_traits_test.h | 61 ++++++++------ .../include/CGAL/Td_X_trapezoid.h | 83 ++++++++++++------- .../include/CGAL/Td_traits.h | 13 ++- .../CGAL/Trapezoidal_decomposition_2.h | 70 +++------------- 26 files changed, 347 insertions(+), 502 deletions(-) diff --git a/Packages/Arrangement/include/CGAL/Arr_circles_real_traits.h b/Packages/Arrangement/include/CGAL/Arr_circles_real_traits.h index 6dd3f0c3433..295fa576b29 100644 --- a/Packages/Arrangement/include/CGAL/Arr_circles_real_traits.h +++ b/Packages/Arrangement/include/CGAL/Arr_circles_real_traits.h @@ -137,33 +137,8 @@ public: typedef Circle_2 Circle; typedef Vector_2 Vector; - // The workaround below seems obsolete and produces an error on gcc-3. - typedef enum { - UNDER_CURVE = -1, - CURVE_NOT_IN_RANGE, - ABOVE_CURVE, - ON_CURVE - } Curve_point_status; - -// #ifndef __GNUC__ -// enum Curve_point_status { -// UNDER_CURVE = -1, -// ABOVE_CURVE = 1, -// ON_CURVE = 2, -// CURVE_NOT_IN_RANGE = 0 -// }; -// #else -// //workaround for egcs, otherwise we get an ICE -// typedef int Curve_point_status; -// static const int UNDER_CURVE = -1; -// static const int ABOVE_CURVE = 1; -// static const int ON_CURVE = 2; -// static const int CURVE_NOT_IN_RANGE = 0; -// #endif - Arr_circles_real_traits() {} - Comparison_result compare_x(const Point_2& p0, const Point_2& p1) const { return _compare_value(p0.x(),p1.x()); } @@ -407,21 +382,13 @@ public: } } - Curve_point_status - curve_get_point_status(const X_curve_2 &cv, const Point_2& p) const + Comparison_result curve_get_point_status (const X_curve_2 &cv, + const Point_2& p) const { CGAL_precondition(is_x_monotone(cv)); - - if (!curve_is_in_x_range(cv, p)) - return CURVE_NOT_IN_RANGE; - int res = _compare_value(p.y(), curve_calc_point(cv, p).y()); - if (res == SMALLER) - return UNDER_CURVE; - if (res == LARGER) - return ABOVE_CURVE; - if (res == EQUAL) - return ON_CURVE; - return ON_CURVE; + CGAL_precondition(curve_is_in_x_range(cv, p)); + + return (_compare_value(curve_calc_point(cv, p).y(), p.y())); } @@ -685,7 +652,7 @@ public: CGAL_precondition(is_x_monotone(cv)); //split curve at split point (x coordinate) into c1 and c2 - CGAL_precondition(curve_get_point_status(cv,split_pt)==ON_CURVE); + CGAL_precondition(curve_get_point_status(cv,split_pt)==EQUAL); CGAL_precondition(compare_x(curve_source(cv),split_pt)!=EQUAL); CGAL_precondition(compare_x(curve_target(cv),split_pt)!=EQUAL); @@ -800,16 +767,22 @@ public: } if (compare_x(rgt,pt)==LARGER) { - if ((curve_get_point_status(c1,rgt) == ON_CURVE) && - (curve_get_point_status(c2,rgt) == ON_CURVE) ) { + if (curve_is_in_x_range(c1, rgt) && + (curve_get_point_status(c1, rgt) == EQUAL) && + curve_is_in_x_range(c2, rgt) && + (curve_get_point_status(c2, rgt) == EQUAL) ) + { p1=p2=rgt; return true; } } if (compare_x(lft,pt)==LARGER) { - if ((curve_get_point_status(c1,lft) == ON_CURVE) && - (curve_get_point_status(c2,lft) == ON_CURVE) ) { + if (curve_is_in_x_range(c1, lft) && + (curve_get_point_status(c1,lft) == EQUAL) && + curve_is_in_x_range(c2, lft) && + (curve_get_point_status(c2,lft) == EQUAL) ) + { p1=p2=lft; return true; } diff --git a/Packages/Arrangement/include/CGAL/Arr_conic_traits_2.h b/Packages/Arrangement/include/CGAL/Arr_conic_traits_2.h index f23f1818973..e5512fa4b7d 100644 --- a/Packages/Arrangement/include/CGAL/Arr_conic_traits_2.h +++ b/Packages/Arrangement/include/CGAL/Arr_conic_traits_2.h @@ -65,14 +65,6 @@ class Arr_conic_traits_2 typedef Circle_2 Circle; typedef Segment_2 Segment; - enum Curve_point_status - { - UNDER_CURVE = -1, - ABOVE_CURVE = 1, - ON_CURVE = 2, - CURVE_NOT_IN_RANGE = 0, - }; - #ifdef CGAL_CONIC_ARC_USE_CACHING private: @@ -126,7 +118,10 @@ class Arr_conic_traits_2 // Since the curve is x-monotone, if the point x co-ordinate is to the // left (or to the right of both curve's source and target points), then // the point is obviously not in the curve's x range. - return (compare_x(p, curve.source()) != compare_x(p, curve.target())); + Comparison_result res1 = compare_x(p, curve.source()); + Comparison_result res2 = compare_x(p, curve.target()); + + return ((res1 == EQUAL) || (res2 == EQUAL) || (res1 != res2)); } } @@ -377,46 +372,29 @@ class Arr_conic_traits_2 } // Check whether the given point is above, under or on the given curve. - Curve_point_status curve_get_point_status (const X_curve_2& curve, - const Point_2& p) const + Comparison_result curve_get_point_status (const X_curve_2& curve, + const Point_2& p) const { CGAL_precondition(is_x_monotone(curve)); + CGAL_precondition(curve_is_in_x_range(curve,p)); // A special treatment for vertical segments: if (curve.is_vertical_segment()) { - if (compare_x (curve.source(), p) != EQUAL) - return (CURVE_NOT_IN_RANGE); - // In case p has the same x c-ordinate of the vertical segment, compare // it to the segment endpoints to determine its position. - if (_compare_y (curve.source(), p) == SMALLER && - _compare_y (curve.target(), p) == SMALLER) - { - return (ABOVE_CURVE); - } - else if (_compare_y (curve.source(), p) == LARGER && - _compare_y (curve.target(), p) == LARGER) - { - return (UNDER_CURVE); - } - else - { - return (ON_CURVE); - } - } + Comparison_result res1 = _compare_y (curve.source(), p); + Comparison_result res2 = _compare_y (curve.target(), p); - // Since the curve is x-monotone, if the point x co-ordinate is to the - // left (or to the right of both curve's source and target points), then - // the point is obviously not in the curve's x range. - if (compare_x(p, curve.source()) == compare_x(p, curve.target())) - { - return (CURVE_NOT_IN_RANGE); + if (res1 == res2) + return (res1); + else + return (EQUAL); } // Check whether the point is exactly on the curve. if (curve.contains_point(p)) - return (ON_CURVE); + return (EQUAL); // Get the points on the arc with the same x co-ordinate as p. int n; @@ -428,16 +406,7 @@ class Arr_conic_traits_2 CGAL_assertion(n == 1); // Compare p with the a point of the curve with the same x co-ordinate. - int result = _compare_y (p, ps[0]); - - if (result == SMALLER) - return (UNDER_CURVE); - else if (result == LARGER) - return (ABOVE_CURVE); - - // We should never reach here: - CGAL_assertion(false); - return (ON_CURVE); + return (_compare_y(ps[0], p)); } // Check whether the given curve in between c1 and c2, when going in the diff --git a/Packages/Arrangement/include/CGAL/Arr_leda_polyline_traits.h b/Packages/Arrangement/include/CGAL/Arr_leda_polyline_traits.h index cfb0b6d0a77..5affebaf200 100644 --- a/Packages/Arrangement/include/CGAL/Arr_leda_polyline_traits.h +++ b/Packages/Arrangement/include/CGAL/Arr_leda_polyline_traits.h @@ -61,14 +61,6 @@ public: typedef Curve_2 Curve; typedef Segment_2 Segment; - typedef enum - { - UNDER_CURVE = -1, - ABOVE_CURVE = 1, - ON_CURVE = 2, - CURVE_NOT_IN_RANGE = 0 - } Curve_point_status; - Arr_leda_polyline_traits() { } @@ -270,24 +262,18 @@ public: - Curve_point_status - curve_get_point_status(const X_curve_2 &cv, const Point_2& p) const + Comparison_result curve_get_point_status (const X_curve_2 &cv, + const Point_2& p) const { CGAL_assertion(is_x_monotone(cv)); - - if (!curve_is_in_x_range(cv, p)) - return CURVE_NOT_IN_RANGE; - if (curve_is_vertical(cv)) { - if (_compare_y(curve_source(cv),p)*_compare_y(curve_target(cv),p)<=0) - return ON_CURVE; - if (_compare_y(curve_source(cv),p)==LARGER) - //bug fix (2/11) - //return ABOVE_CURVE; - return UNDER_CURVE; + CGAL_precondition(curve_is_in_x_range(cv, p)); - if (_compare_y(curve_source(cv),p)==SMALLER) - //return UNDER_CURVE; - return ABOVE_CURVE; + if (curve_is_vertical(cv)) + { + if (_compare_y(curve_source(cv),p)*_compare_y(curve_target(cv),p)<=0) + return EQUAL; + else + return (_compare_y(curve_source(cv),p)); } typename X_curve_2::const_iterator pit=cv.begin(); @@ -306,13 +292,10 @@ public: o = (Orientation)CGAL_LEDA_SCOPE::orientation(l.target(), l.source(), p); if (o < 0) - return UNDER_CURVE; + return LARGER; if (o > 0) - return ABOVE_CURVE; - if (o == 0) - return ON_CURVE; - return ON_CURVE; - + return SMALLER; + return EQUAL; // if (o == 0) } diff --git a/Packages/Arrangement/include/CGAL/Arr_leda_segment_traits_2.h b/Packages/Arrangement/include/CGAL/Arr_leda_segment_traits_2.h index c33b3994153..dd46f66c1fc 100644 --- a/Packages/Arrangement/include/CGAL/Arr_leda_segment_traits_2.h +++ b/Packages/Arrangement/include/CGAL/Arr_leda_segment_traits_2.h @@ -60,8 +60,6 @@ public: typedef typename Base::X_curve_2 X_curve_2; typedef X_curve_2 Curve_2; - typedef typename Base::Curve_point_status Curve_point_status; - // Obsolete, for backward compatibility typedef Point_2 Point; typedef X_curve_2 X_curve; @@ -80,7 +78,7 @@ public: const Point_2 & split_pt) const { //split curve at split point (x coordinate) into c1 and c2 - CGAL_precondition(curve_get_point_status(cv,split_pt) == ON_CURVE); + CGAL_precondition(curve_get_point_status(cv,split_pt) == EQUAL); // does not suit pmwx //CGAL_precondition(curve_source(cv) != split_pt); //CGAL_precondition(curve_target(cv) != split_pt); diff --git a/Packages/Arrangement/include/CGAL/Arr_polyline_traits.h b/Packages/Arrangement/include/CGAL/Arr_polyline_traits.h index 2aabc178f31..c6f1a6b24be 100644 --- a/Packages/Arrangement/include/CGAL/Arr_polyline_traits.h +++ b/Packages/Arrangement/include/CGAL/Arr_polyline_traits.h @@ -67,17 +67,6 @@ public: protected: typedef typename Kernel::Segment_2 Segment_2; -public: - - typedef enum - { - UNDER_CURVE = -1, - ABOVE_CURVE = 1, - ON_CURVE = 2, - CURVE_NOT_IN_RANGE = 0 - //CURVE_VERTICAL = 3 - } Curve_point_status; - protected: // Functors: typedef typename Kernel::Is_vertical_2 Is_vertical_2; @@ -279,24 +268,19 @@ public: } } - Curve_point_status - curve_get_point_status(const X_curve_2 &cv, const Point_2& p) const + Comparison_result curve_get_point_status (const X_curve_2 &cv, + const Point_2& p) const { CGAL_assertion(is_x_monotone(cv)); + CGAL_precondition(curve_is_in_x_range(cv, p)); - if (!curve_is_in_x_range(cv, p)) - return CURVE_NOT_IN_RANGE; - if (curve_is_vertical(cv)) { + if (curve_is_vertical(cv)) + { if (CGAL::compare_y(curve_source(cv),p)* CGAL::compare_y(curve_target(cv),p)<=0) - return ON_CURVE; - if (CGAL::compare_y(curve_source(cv),p)==LARGER) - //bug fix (2/11) - //return ABOVE_CURVE; - return UNDER_CURVE; - if (CGAL::compare_y(curve_source(cv),p)==SMALLER) - //return UNDER_CURVE; - return ABOVE_CURVE; + return EQUAL; + else + return (CGAL::compare_y(curve_source(cv),p)); } typename X_curve_2::const_iterator pit = cv.begin(),after=pit; ++after; @@ -309,12 +293,10 @@ public: Comparison_result res = CGAL::compare_y_at_x(p, l); if (res == SMALLER) - return UNDER_CURVE; + return LARGER; if (res == LARGER) - return ABOVE_CURVE; - if (res == EQUAL) - return ON_CURVE; - return ON_CURVE; + return SMALLER; + return EQUAL; } @@ -492,7 +474,7 @@ public: const Point_2& split_pt) { //split curve at split point into c1 and c2 - CGAL_precondition(curve_get_point_status(cv,split_pt)==ON_CURVE); + CGAL_precondition(curve_get_point_status(cv,split_pt)==EQUAL); CGAL_precondition(CGAL::compare_lexicographically_xy(curve_source(cv), split_pt) != EQUAL); CGAL_precondition(CGAL::compare_lexicographically_xy(curve_target(cv), diff --git a/Packages/Arrangement/include/CGAL/Arr_segment_cached_traits_2.h b/Packages/Arrangement/include/CGAL/Arr_segment_cached_traits_2.h index 5f843c34c18..b2b9c468656 100644 --- a/Packages/Arrangement/include/CGAL/Arr_segment_cached_traits_2.h +++ b/Packages/Arrangement/include/CGAL/Arr_segment_cached_traits_2.h @@ -118,17 +118,6 @@ public: typedef X_curve_2 X_curve; typedef X_curve_2 Curve; - // Currently, I leave this in the traits - // Maybe we can change the usage inside Planar_map_2 - typedef enum - { - UNDER_CURVE = -1, - CURVE_NOT_IN_RANGE = 0, - ABOVE_CURVE = 1, - ON_CURVE = 2 - - } Curve_point_status; - protected: // Functors: @@ -373,37 +362,38 @@ public: * Return the location of the given point with respect to the input curve. * \param cv The curve. * \param p The point. - * \return CURVE_NOT_IN_RANGE if p is not in the x-range of cv; - * ABOVE_CURVE if cv(x(p)) < y(p); - * UNDER_CURVE if cv(x(p)) > y(p); - * or else ON_CURVE (if p is on the curve). + * \pre p is in the x-range of cv. + * \return SMALLER if cv(x(p)) < y(p); + * LARGER if cv(x(p)) > y(p); + * or else (if p is on the curve) EQUAL. */ - Curve_point_status curve_get_point_status (const X_curve_2 & cv, - const Point_2 & p) const + Comparison_result curve_get_point_status (const X_curve_2 & cv, + const Point_2 & p) const { - if (! curve_is_in_x_range(cv, p)) - return (CURVE_NOT_IN_RANGE); + CGAL_precondition(curve_is_in_x_range(cv, p)); if (! cv.is_vert) { // Compare with the supporting line. Comparison_result res = compare_y_at_x_2_object()(p, cv.line); - return ((res == LARGER) ? ABOVE_CURVE : - ((res == SMALLER) ? UNDER_CURVE : ON_CURVE)); + + if (res == LARGER) + return (SMALLER); + else if (res == SMALLER) + return (LARGER); + return (EQUAL); } else { // Compare with the vertical segment's end-points. Compare_y_2 compare_y = compare_y_2_object(); - Comparison_result res1 = compare_y (p, cv.ps); - Comparison_result res2 = compare_y (p, cv.pt); + Comparison_result res1 = compare_y (cv.ps, p); + Comparison_result res2 = compare_y (cv.pt, p); - if (res1 == LARGER && res2 == LARGER) - return (ABOVE_CURVE); - else if (res1 == SMALLER && res2 == SMALLER) - return (UNDER_CURVE); + if (res1 == res2) + return (res1); else - return (ON_CURVE); + return (EQUAL); } } @@ -666,7 +656,7 @@ public: const Point_2& p) const { // Check preconditions. - CGAL_precondition(curve_get_point_status(cv, p) == ON_CURVE); + CGAL_precondition(curve_get_point_status(cv, p) == EQUAL); CGAL_precondition_code(Compare_xy_2 compare_xy = compare_xy_2_object()); CGAL_precondition(compare_xy(cv.ps, p) != EQUAL); CGAL_precondition(compare_xy(cv.pt, p) != EQUAL); diff --git a/Packages/Arrangement/include/CGAL/Arr_segment_circle_traits.h b/Packages/Arrangement/include/CGAL/Arr_segment_circle_traits.h index 97ba5bb316a..0f3f01fc7e3 100644 --- a/Packages/Arrangement/include/CGAL/Arr_segment_circle_traits.h +++ b/Packages/Arrangement/include/CGAL/Arr_segment_circle_traits.h @@ -61,13 +61,6 @@ class Arr_segment_circle_traits typedef Circle_2 Circle; typedef Conic_2 Conic; - enum Curve_point_status { - UNDER_CURVE = -1, - CURVE_NOT_IN_RANGE = 0, - ABOVE_CURVE = 1, - ON_CURVE = 2 - }; - // Constructor. Arr_segment_circle_traits() {} @@ -641,31 +634,22 @@ class Arr_segment_circle_traits } // Check whether the given point is above, under or on the given curve. - Curve_point_status curve_get_point_status (const X_curve_2& curve, - const Point_2& p) const + Comparison_result curve_get_point_status (const X_curve_2& curve, + const Point_2& p) const { CGAL_precondition(is_x_monotone(curve)); + CGAL_precondition(curve_is_in_x_range(curve, p)); // A special treatment for vertical segments: if (curve.is_vertical_segment()) { - if (compare_x (curve.source(), p) != EQUAL) - return (CURVE_NOT_IN_RANGE); + Comparison_result res1 = _compare_y (curve.source(), p); + Comparison_result res2 = _compare_y (curve.target(), p); - if (_compare_y (curve.source(), p) == SMALLER && - _compare_y (curve.target(), p) == SMALLER) - { - return (ABOVE_CURVE); - } - else if (_compare_y (curve.source(), p) == LARGER && - _compare_y (curve.target(), p) == LARGER) - { - return (UNDER_CURVE); - } + if (res1 == res2) + return (res1); else - { - return (ON_CURVE); - } + return (EQUAL); } // Get the points on the arc with the same x co-ordinate as p. @@ -675,29 +659,10 @@ class Arr_segment_circle_traits n = curve.get_points_at_x (p.x(), ps); // Make sure there is at most one point. - CGAL_assertion(n <= 1); + CGAL_assertion(n == 1); - if (n == 0) - { - // p is not in the x-range of the curve. - return (CURVE_NOT_IN_RANGE); - } - else - { - // Compare p with the a point of the curve with the same x co-ordinate. - int result = _compare_y (p, ps[0]); - - if (result == SMALLER) - return (UNDER_CURVE); - else if (result == LARGER) - return (ABOVE_CURVE); - else if (result == EQUAL) - return (ON_CURVE); - } - - // We should never reach here: - CGAL_assertion(false); - return (ON_CURVE); + // Compare p with the a point of the curve with the same x co-ordinate. + return (_compare_y (ps[0], p)); } // Check whether the given curve in between c1 and c2, when going in the diff --git a/Packages/Arrangement/include/CGAL/Arr_segment_traits_2.h b/Packages/Arrangement/include/CGAL/Arr_segment_traits_2.h index aeb1baa0fae..bae621cf3ca 100644 --- a/Packages/Arrangement/include/CGAL/Arr_segment_traits_2.h +++ b/Packages/Arrangement/include/CGAL/Arr_segment_traits_2.h @@ -51,7 +51,6 @@ public: typedef X_curve_2 Curve_2; // Obsolete, for backward compatibility - typedef typename Base::Curve_point_status Curve_point_status; typedef Point_2 Point; typedef X_curve_2 X_curve; typedef Curve_2 Curve; @@ -101,7 +100,7 @@ public: const Point_2 & split_pt) { //split curve at split point (x coordinate) into c1 and c2 - CGAL_precondition(curve_get_point_status(cv, split_pt) == ON_CURVE); + CGAL_precondition(curve_get_point_status(cv, split_pt) == EQUAL); CGAL_precondition_code(Compare_xy_2 compare_xy = compare_xy_2_object()); CGAL_precondition(compare_xy(curve_source(cv), split_pt) != EQUAL); CGAL_precondition(compare_xy(curve_target(cv), split_pt) != EQUAL); diff --git a/Packages/Arrangement/include/CGAL/Arr_segment_traits_tight_2.h b/Packages/Arrangement/include/CGAL/Arr_segment_traits_tight_2.h index 8fb88fd96a3..8d2aef6b4ab 100644 --- a/Packages/Arrangement/include/CGAL/Arr_segment_traits_tight_2.h +++ b/Packages/Arrangement/include/CGAL/Arr_segment_traits_tight_2.h @@ -51,7 +51,6 @@ public: typedef X_curve_2 Curve_2; // Obsolete, for backward compatibility - typedef typename Base::Curve_point_status Curve_point_status; typedef Point_2 Point; typedef X_curve_2 X_curve; typedef Curve_2 Curve; @@ -101,7 +100,7 @@ public: const Point_2 & split_pt) { //split curve at split point (x coordinate) into c1 and c2 - CGAL_precondition(curve_get_point_status(cv, split_pt) == ON_CURVE); + CGAL_precondition(curve_get_point_status(cv, split_pt) == EQUAL); CGAL_precondition_code(Compare_xy_2 compare_xy = compare_xy_2_object()); CGAL_precondition(compare_xy(curve_source(cv), split_pt) != EQUAL); CGAL_precondition(compare_xy(curve_target(cv), split_pt) != EQUAL); diff --git a/Packages/Arrangement/include/CGAL/Pm_with_intersections.h b/Packages/Arrangement/include/CGAL/Pm_with_intersections.h index e0e82271f3d..4bd1c60bab4 100644 --- a/Packages/Arrangement/include/CGAL/Pm_with_intersections.h +++ b/Packages/Arrangement/include/CGAL/Pm_with_intersections.h @@ -174,7 +174,8 @@ public: // the intersection is only one point const X_curve_2 &he_cv = he->curve(); if (traits->point_is_same(xp1, xp2)) { - if (traits->curve_get_point_status(he_cv, xp1) == Traits::ON_CURVE) { + if (traits->curve_is_in_x_range(he_cv, xp1) && + traits->curve_get_point_status(he_cv, xp1) == EQUAL) { intersection_exists = true; } } diff --git a/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_impl.h b/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_impl.h index f7a07302824..0e5d6d5b4aa 100644 --- a/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_impl.h +++ b/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_impl.h @@ -333,12 +333,15 @@ protected: assert(topEndEventIter!=m_queue->end()); Event *topEndEvent = topEndEventIter->second; - while ( slIter != m_statusLine->end() && - m_traits->curve_get_point_status((*slIter)->getCurve(), topEnd) - != Traits::UNDER_CURVE && + while (slIter != m_statusLine->end() && + (! m_traits->curve_is_in_x_range((*slIter)->getCurve(), + topEnd) || m_traits->curve_get_point_status((*slIter)->getCurve(), - currentPoint) - != Traits::ABOVE_CURVE ) + topEnd) != LARGER) && + (! m_traits->curve_is_in_x_range((*slIter)->getCurve(), + currentPoint) || + m_traits->curve_get_point_status((*slIter)->getCurve(), + currentPoint) != SMALLER)) { SL_DEBUG(std::cout<<"intersecting with \n";) SL_DEBUG((*slIter)->Print();) @@ -441,13 +444,15 @@ protected: SL_DEBUG(std::cout<<"starting at curve \n";) SL_DEBUG((*slIter)->Print();) - while ( slIter != m_statusLine->end() && - m_traits->curve_get_point_status((*slIter)->getCurve(), - topPoint) - == Traits::ABOVE_CURVE && - m_traits->curve_get_point_status((*slIter)->getCurve(), - vcurve->getBottomEnd()) - == Traits::UNDER_CURVE ) + while (slIter != m_statusLine->end() && + m_traits->curve_is_in_x_range((*slIter)->getCurve(), + topPoint) && + m_traits->curve_get_point_status((*slIter)->getCurve(), + topPoint) == SMALLER && + m_traits->curve_is_in_x_range((*slIter)->getCurve(), + vcurve->getBottomEnd()) && + m_traits->curve_get_point_status((*slIter)->getCurve(), + vcurve->getBottomEnd()) == LARGER) { SL_DEBUG(std::cout<<"checking \n";) SL_DEBUG((*slIter)->Print();) @@ -525,8 +530,8 @@ protected: { const Point_2 &topEnd = vcurve->getTopEnd(); // handle a curve that goes through the top point of the vertical curve - if (m_traits->curve_get_point_status(curve->getCurve(), topEnd) - == Traits::ON_CURVE ) + if (m_traits->curve_is_in_x_range(curve->getCurve(), topEnd) && + m_traits->curve_get_point_status(curve->getCurve(), topEnd) == EQUAL) { if ( !curve->isLeftEnd(topEnd)) { topEndEvent->addCurveToLeft(curve, m_prevPos); @@ -539,8 +544,9 @@ protected: // handle a curve that goes through the bottom point of the vertical curve const Point_2 ¤tPoint = m_currentEvent->getPoint(); - if (m_traits->curve_get_point_status((curve)->getCurve(), currentPoint) - == Traits::ON_CURVE) + if (m_traits->curve_is_in_x_range((curve)->getCurve(), currentPoint) && + m_traits->curve_get_point_status((curve)->getCurve(), + currentPoint) == EQUAL) { if ( !(curve)->isLeftEnd(currentPoint)) { m_currentEvent->addCurveToLeft(curve, m_prevPos); @@ -570,13 +576,13 @@ protected: while ( iter != m_verticals.end() ) { Subcurve *curve = *iter; - typename Traits::Curve_point_status pstatus = - m_traits->curve_get_point_status(curve->getCurve(), point); - if ( pstatus == Traits::ABOVE_CURVE ) { + if (m_traits->curve_is_in_x_range(curve->getCurve(), point) && + m_traits->curve_get_point_status(curve->getCurve(), point)==SMALLER) + { iter = m_verticals.erase(iter); - - } else if (!curve->isEndPoint(point)) { + } + else if (!curve->isEndPoint(point)) { EventQueueIter eventIter = m_queue->find(curve->getTopEnd()); assert(eventIter!=m_queue->end()); (eventIter->second)->addVerticalCurveXPoint(point, true); diff --git a/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_tight.h b/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_tight.h index 86118e14da9..d87b4d130f4 100644 --- a/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_tight.h +++ b/Packages/Arrangement/include/CGAL/Sweep_line_2/Pmwx_aggregate_insert_tight.h @@ -341,12 +341,15 @@ protected: bool lastEventCreatedHere = false; Event *prevEvent = 0; - while ( slIter != m_statusLine->end() && - m_traits->curve_get_point_status((*slIter)->getCurve(), topEnd) - != Traits::UNDER_CURVE && + while (slIter != m_statusLine->end() && + (! m_traits->curve_is_in_x_range((*slIter)->getCurve(), + topEnd) || m_traits->curve_get_point_status((*slIter)->getCurve(), - currentPoint) - != Traits::ABOVE_CURVE ) + topEnd) != LARGER) && + (! m_traits->curve_is_in_x_range((*slIter)->getCurve(), + currentPoint) || + m_traits->curve_get_point_status((*slIter)->getCurve(), + currentPoint) != SMALLER)) { SL_DEBUG(std::cout<<"intersecting with \n";) SL_DEBUG((*slIter)->Print();) @@ -462,13 +465,15 @@ protected: SL_DEBUG(std::cout<<"starting at curve \n";) SL_DEBUG((*slIter)->Print();) - while ( slIter != m_statusLine->end() && - m_traits->curve_get_point_status((*slIter)->getCurve(), - topPoint) - == Traits::ABOVE_CURVE && - m_traits->curve_get_point_status((*slIter)->getCurve(), - vcurve->getBottomEnd()) - == Traits::UNDER_CURVE ) + while (slIter != m_statusLine->end() && + m_traits->curve_is_in_x_range((*slIter)->getCurve(), + topPoint) && + m_traits->curve_get_point_status((*slIter)->getCurve(), + topPoint) == SMALLER && + m_traits->curve_is_in_x_range((*slIter)->getCurve(), + vcurve->getBottomEnd()) && + m_traits->curve_get_point_status((*slIter)->getCurve(), + vcurve->getBottomEnd()) == LARGER) { SL_DEBUG(std::cout<<"checking \n";) SL_DEBUG((*slIter)->Print();) @@ -544,8 +549,9 @@ protected: { const Point_2 &topEnd = vcurve->getTopEnd(); // handle a curve that goes through the top point of the vertical curve - if (m_traits->curve_get_point_status(curve->getCurve(), topEnd) - == Traits::ON_CURVE ) + if (m_traits->curve_is_in_x_range(curve->getCurve(), topEnd) && + m_traits->curve_get_point_status(curve->getCurve(), + topEnd) == EQUAL) { if ( !curve->isLeftEnd(topEnd)) { topEndEvent->addCurveToLeft(curve, m_prevPos); @@ -558,8 +564,9 @@ protected: // handle a curve that goes through the bottom point of the vertical curve const Point_2 ¤tPoint = m_currentEvent->getPoint(); - if (m_traits->curve_get_point_status((curve)->getCurve(), currentPoint) - == Traits::ON_CURVE) + if (m_traits->curve_is_in_x_range((curve)->getCurve(), currentPoint) && + m_traits->curve_get_point_status((curve)->getCurve(), + currentPoint) == EQUAL) { if ( !(curve)->isLeftEnd(currentPoint)) { m_currentEvent->addCurveToLeft(curve, m_prevPos); @@ -589,10 +596,10 @@ protected: while ( iter != m_verticals.end() ) { Subcurve *curve = *iter; - typename Traits::Curve_point_status pstatus = - m_traits->curve_get_point_status(curve->getCurve(), point); - if ( pstatus == Traits::ABOVE_CURVE ) { + if (m_traits->curve_is_in_x_range(curve->getCurve(), point) && + m_traits->curve_get_point_status(curve->getCurve(), point)==SMALLER) + { iter = m_verticals.erase(iter); } else if (!curve->isEndPoint(point)) { diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/conic_arcs/conic_get_point_status b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/conic_arcs/conic_get_point_status index 9f6cac7bed5..181569f35d1 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/conic_arcs/conic_get_point_status +++ b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/conic_arcs/conic_get_point_status @@ -28,27 +28,22 @@ a 3 0 0 -2 -1 5 2 13 -1 10 #----------------------------------------------------------- # Execution block #----------------------------------------------------------- -curve_get_point_status 0 0 ON_CURVE. -curve_get_point_status 0 1 UNDER_CURVE. -curve_get_point_status 0 2 ABOVE_CURVE. -curve_get_point_status 0 3 CURVE_NOT_IN_RANGE. +curve_get_point_status 0 0 EQUAL. +curve_get_point_status 0 1 LARGER. +curve_get_point_status 0 2 SMALLER. -curve_get_point_status 1 0 ABOVE_CURVE. -curve_get_point_status 1 1 ON_CURVE. -curve_get_point_status 1 4 UNDER_CURVE. -curve_get_point_status 0 3 CURVE_NOT_IN_RANGE. +curve_get_point_status 1 0 SMALLER. +curve_get_point_status 1 1 EQUAL. +curve_get_point_status 1 4 LARGER. -curve_get_point_status 2 0 ABOVE_CURVE. -curve_get_point_status 2 5 ON_CURVE. -curve_get_point_status 2 6 UNDER_CURVE. -curve_get_point_status 2 4 CURVE_NOT_IN_RANGE. +curve_get_point_status 2 0 SMALLER. +curve_get_point_status 2 5 EQUAL. +curve_get_point_status 2 6 LARGER. -curve_get_point_status 3 2 ABOVE_CURVE. -curve_get_point_status 3 1 ON_CURVE. -curve_get_point_status 3 4 UNDER_CURVE. -curve_get_point_status 3 0 CURVE_NOT_IN_RANGE. +curve_get_point_status 3 2 SMALLER. +curve_get_point_status 3 1 EQUAL. +curve_get_point_status 3 4 LARGER. -curve_get_point_status 4 8 ABOVE_CURVE. -curve_get_point_status 4 7 ON_CURVE. -curve_get_point_status 4 5 UNDER_CURVE. -curve_get_point_status 4 3 CURVE_NOT_IN_RANGE. +curve_get_point_status 4 8 SMALLER. +curve_get_point_status 4 7 EQUAL. +curve_get_point_status 4 5 LARGER. diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/big_overlap2 b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/big_overlap2 index d5899ea7bd4..81c9754beca 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/big_overlap2 +++ b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/big_overlap2 @@ -21,15 +21,4 @@ 1 1/1 1/1 #----------------------------------------------------------- -curve_get_point_status 0 0 ABOVE_CURVE. -#curve_get_point_status 1 0 ABOVE_CURVE. #Must fail on precondition, it's not x-monotone - -# -# No. of expected vertices : -#8 -# No. of expected halfedges: -#8 -# No. of expected faces : -#2 -# No. of expected overlaps : -#3 +curve_get_point_status 0 0 SMALLER. diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/get_point_status b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/get_point_status index a2ef9c653c5..f7559104068 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/get_point_status +++ b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/get_point_status @@ -26,7 +26,6 @@ #----------------------------------------------------------- # Execution block #----------------------------------------------------------- -curve_get_point_status 1 0 ABOVE_CURVE. -curve_get_point_status 1 1 UNDER_CURVE. -curve_get_point_status 1 2 ON_CURVE. -curve_get_point_status 0 3 CURVE_NOT_IN_RANGE. \ No newline at end of file +curve_get_point_status 1 0 SMALLER. +curve_get_point_status 1 1 LARGER. +curve_get_point_status 1 2 EQUAL. diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/partial_overlap_reverse b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/partial_overlap_reverse index cbbe42eab0e..654cd2963af 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/partial_overlap_reverse +++ b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/polylines/partial_overlap_reverse @@ -22,9 +22,9 @@ 9/1 10/1 0/1 5/1 #----------------------------------------------------------- -curve_get_point_status 0 0 ON_CURVE. -curve_get_point_status 0 1 ON_CURVE. -curve_get_point_status 0 2 UNDER_CURVE. -curve_get_point_status 1 0 ON_CURVE. -curve_get_point_status 1 1 ABOVE_CURVE. -curve_get_point_status 1 2 ABOVE_CURVE. \ No newline at end of file +curve_get_point_status 0 0 EQUAL. +curve_get_point_status 0 1 EQUAL. +curve_get_point_status 0 2 LARGER. +curve_get_point_status 1 0 EQUAL. +curve_get_point_status 1 1 SMALLER. +curve_get_point_status 1 2 SMALLER. \ No newline at end of file diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segment_circles/get_point_status b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segment_circles/get_point_status index 0ff60d77fbe..0d8239c1186 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segment_circles/get_point_status +++ b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segment_circles/get_point_status @@ -20,14 +20,12 @@ s 0 0 0 0.5 #----------------------------------------------------------- # Execution block #----------------------------------------------------------- -curve_get_point_status 0 0 CURVE_NOT_IN_RANGE. -curve_get_point_status 0 1 ABOVE_CURVE. -curve_get_point_status 0 2 UNDER_CURVE. -curve_get_point_status 0 5 ON_CURVE. -curve_get_point_status 1 1 CURVE_NOT_IN_RANGE. -curve_get_point_status 1 6 UNDER_CURVE. -curve_get_point_status 1 7 ON_CURVE. -curve_get_point_status 2 2 UNDER_CURVE. -curve_get_point_status 2 3 ON_CURVE. -curve_get_point_status 2 4 ON_CURVE. -curve_get_point_status 2 5 ABOVE_CURVE. \ No newline at end of file +curve_get_point_status 0 1 SMALLER. +curve_get_point_status 0 2 LARGER. +curve_get_point_status 0 5 EQUAL. +curve_get_point_status 1 6 LARGER. +curve_get_point_status 1 7 EQUAL. +curve_get_point_status 2 2 LARGER. +curve_get_point_status 2 3 EQUAL. +curve_get_point_status 2 4 EQUAL. +curve_get_point_status 2 5 SMALLER. \ No newline at end of file diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segments/get_point_status b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segments/get_point_status index 7094b7d393f..28c50e6c3a0 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segments/get_point_status +++ b/Packages/Arrangement/test/Arrangement_2_Traits/DATA/segments/get_point_status @@ -21,7 +21,6 @@ #----------------------------------------------------------- # Execution block #----------------------------------------------------------- -curve_get_point_status 1 0 ABOVE_CURVE. -curve_get_point_status 1 1 UNDER_CURVE. -curve_get_point_status 1 2 ON_CURVE. -curve_get_point_status 0 3 CURVE_NOT_IN_RANGE. \ No newline at end of file +curve_get_point_status 1 0 SMALLER. +curve_get_point_status 1 1 LARGER. +curve_get_point_status 1 2 EQUAL. diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/include/Base_traits_test.h b/Packages/Arrangement/test/Arrangement_2_Traits/include/Base_traits_test.h index 2f9e845d653..e2cbb92f68f 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/include/Base_traits_test.h +++ b/Packages/Arrangement/test/Arrangement_2_Traits/include/Base_traits_test.h @@ -383,9 +383,7 @@ curve_compare_at_x_smth_wrapper( std::istringstream& strLine, * curve_get_point_status n1 n2 STATUS_RESULT, where * n1 - curve index in all_curves_vec * n2 - point index in all_points_vec - * STATUS_RESULT - expected result, enum{ UNDER_CURVE, - * CURVE_NOT_IN_RANGE, - * ABOVE_CURVE, ON_CURVE } type + * STATUS_RESULT - expected result, enum{SMALLER,LARGER,EQUAL} type */ template< class Traits_class, class Number_type > bool Base_traits_test< Traits_class, Number_type >:: @@ -728,18 +726,6 @@ translate_enumerator( std::string& strValue ) else if( strValue == "EQUAL" ) { return CGAL::EQUAL; } - else if( strValue == "UNDER_CURVE" ) { - return tr.UNDER_CURVE; - } - else if( strValue == "CURVE_NOT_IN_RANGE" ) { - return tr.CURVE_NOT_IN_RANGE; - } - else if( strValue == "ABOVE_CURVE" ) { - return tr.ABOVE_CURVE; - } - else if( strValue == "ON_CURVE" ) { - return tr.ON_CURVE; - } return -220776; // My birthday :-) } diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/include/Conic_traits_test.h b/Packages/Arrangement/test/Arrangement_2_Traits/include/Conic_traits_test.h index cb5ca0449fc..f6d03644e76 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/include/Conic_traits_test.h +++ b/Packages/Arrangement/test/Arrangement_2_Traits/include/Conic_traits_test.h @@ -250,7 +250,8 @@ make_x_monotone_wrapper (std::istringstream& str_line) str_line >> cv_index >> n_exp_curves; - std::cout << "Test: make_x_monotone( Curve" << cv_index << " ) ? " << std::endl; + std::cout << "Test: make_x_monotone( Curve" << cv_index << " ) ? " + << std::endl; // Make x-monotone ! std::list x_curves; @@ -300,8 +301,10 @@ curve_split_wrapper (std::istringstream& str_line) return (false); } - if (tr.curve_get_point_status (all_curves_vec[cv_index], - all_points_vec[pt_index]) != tr.ON_CURVE) + if (! tr.curve_is_in_x_range (all_curves_vec[cv_index], + all_points_vec[pt_index]) || + tr.curve_get_point_status (all_curves_vec[cv_index], + all_points_vec[pt_index]) != CGAL::EQUAL) { std::cout << "Was NOT successful" << std::endl; std::cout << "Precondition fault: Split point is not on the curve" @@ -313,8 +316,8 @@ curve_split_wrapper (std::istringstream& str_line) all_curves_vec[cv_index].target() == all_points_vec[pt_index]) { std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is an end point of the curve" - << std::endl; + std::cout << "Precondition fault: " + << "Split point is an end point of the curve" << std::endl; return (false); } diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/include/Polyline_traits_test.h b/Packages/Arrangement/test/Arrangement_2_Traits/include/Polyline_traits_test.h index adaee3b2899..e6b20f5dbb8 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/include/Polyline_traits_test.h +++ b/Packages/Arrangement/test/Arrangement_2_Traits/include/Polyline_traits_test.h @@ -2,7 +2,9 @@ #include "Base_traits_test.h" template< class Traits_class, class Number_type > -class Polyline_traits_test : public Base_traits_test< Traits_class, Number_type >{ +class Polyline_traits_test : + public Base_traits_test< Traits_class, Number_type > +{ public: typedef Number_type NT; typedef typename Traits_class::Point Point; @@ -16,28 +18,28 @@ public: ~Polyline_traits_test(); }; -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* Constructor. Nothing to do. Just calls super class ctor */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > Polyline_traits_test< Traits_class, Number_type >:: Polyline_traits_test( int argc, char** argv ) : Base_traits_test< Traits_class, Number_type >(argc, argv) {}; -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* Destructor. Nothing to do. Implements super class virtual dtor. */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > Polyline_traits_test< Traits_class, Number_type >:: ~Polyline_traits_test( ){} -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* Reads on curve. This method is called by collect_data. */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > void Polyline_traits_test< Traits_class, Number_type >:: read_curve( std::ifstream& is, Curve& cv ){ @@ -57,14 +59,14 @@ read_curve( std::ifstream& is, Curve& cv ){ cv.push_back( Point( x,y ) ); } } -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* input case: make_x_monotone n1 n2, where n1 - curve index in all_curves_vec n2 - number of expected X-monotonian subcurves */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > bool Polyline_traits_test< Traits_class, Number_type >:: make_x_monotone_wrapper( std::istringstream & strLine ) @@ -86,7 +88,8 @@ make_x_monotone_wrapper( std::istringstream & strLine ) curr_source_point = *( it->begin() ); if( !tr.is_x_monotone( *it ) ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "One of the result subcurves is not x-monotone" << std::endl; + std::cout << "One of the result subcurves is not x-monotone" + << std::endl; std::cout << "Subcurve index: " << nSubcurveIndex << std::endl; return false; } @@ -99,19 +102,24 @@ make_x_monotone_wrapper( std::istringstream & strLine ) << prev_target_point << std::endl; return false; } - prev_target_point = *( it->rbegin() ); // Assumption: container is bi-direcional + prev_target_point = *( it->rbegin() ); + // Assumption: container is bi-direcional ++nSubcurveIndex; } if( exp_number < real_number ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "Number of x-monotone subcurves is greater than expected " << std::endl; - std::cout << "Expected: " << exp_number << "Actual: " << real_number << std::endl; + std::cout << "Number of x-monotone subcurves is greater than expected " + << std::endl; + std::cout << "Expected: " << exp_number << "Actual: " + << real_number << std::endl; return false; } else if( exp_number > real_number ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "Number of x-monotone subcurves is less than expected " << std::endl; - std::cout << "Expected: " << exp_number << "Actual: " << real_number << std::endl; + std::cout << "Number of x-monotone subcurves is less than expected " + << std::endl; + std::cout << "Expected: " << exp_number << "Actual: " << real_number + << std::endl; return false; } else{ @@ -119,7 +127,7 @@ make_x_monotone_wrapper( std::istringstream & strLine ) return true; } } -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* input case: curve_split n1 n2, where @@ -127,7 +135,7 @@ make_x_monotone_wrapper( std::istringstream & strLine ) n2 - point index in all_points_vec Does NOT take any expected result */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > bool Polyline_traits_test< Traits_class, Number_type >:: curve_split_wrapper( std::istringstream & strLine ) @@ -136,23 +144,30 @@ curve_split_wrapper( std::istringstream & strLine ) X_curve cv1, cv2; strLine >> index1 >> index2; - std::cout << "Test: curve_split( Curve" << index1 << ", " << all_points_vec[index2] - << " ) ? " << std::endl; + std::cout << "Test: curve_split( Curve" << index1 << ", " + << all_points_vec[index2] + << " ) ? " << std::endl; if( !tr.is_x_monotone( all_curves_vec[index1] ) ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Input curve is not x-monotone" << std::endl; + std::cout << "Precondition fault: Input curve is not x-monotone" + << std::endl; return false; } - if( tr.curve_get_point_status( all_curves_vec[index1], - all_points_vec[index2] ) != tr.ON_CURVE ){ + if (! tr.curve_is_in_x_range (all_curves_vec[index1], + all_points_vec[index2]) || + tr.curve_get_point_status (all_curves_vec[index1], + all_points_vec[index2]) != CGAL::EQUAL) + { std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is not on the curve " << std::endl; + std::cout << "Precondition fault: Split point is not on the curve " + << std::endl; return false; } if( *( (all_curves_vec[index1]).begin() ) == all_points_vec[index2] || *( (all_curves_vec[index1]).rbegin() ) == all_points_vec[index2] ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is the end point of the curve " << std::endl; + std::cout << "Precondition fault: " + << "Split point is the end point of the curve " << std::endl; return false; } tr.curve_split( all_curves_vec[index1], cv1, cv2, all_points_vec[index2] ); @@ -163,7 +178,7 @@ curve_split_wrapper( std::istringstream & strLine ) std::cout << "Some point is absent in the 1st part" << std::endl; std::cout << "Original curve[" << i << "]: " << (all_curves_vec[index1])[ i ] << std::endl; - std::cout << "obtained curve[ "<< i << "] " << cv1[i] << std::endl; + std::cout << "obtained curve[ "<< i << "] " << cv1[i] << std::endl; return false; } } @@ -176,7 +191,7 @@ curve_split_wrapper( std::istringstream & strLine ) std::cout << "Some point is absent in the 2nd part" << std::endl; std::cout << "Original curve[" << i << "]: " << (all_curves_vec[index1])[ i ] << std::endl; - std::cout << "obtained curve[ "<< j << "] " << cv2[j] << std::endl; + std::cout << "obtained curve[ "<< j << "] " << cv2[j] << std::endl; return false; } ++i; @@ -184,4 +199,4 @@ curve_split_wrapper( std::istringstream & strLine ) std::cout << "Was successfull" << std::endl; return true; } -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_circle_traits_test.h b/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_circle_traits_test.h index 54a0058a23e..5aac74a4130 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_circle_traits_test.h +++ b/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_circle_traits_test.h @@ -175,15 +175,19 @@ curve_split_wrapper (std::istringstream& str_line) if (! tr.is_x_monotone(all_curves_vec[cv_index])) { std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Input curve is not x-monotone" << std::endl; + std::cout << "Precondition fault: Input curve is not x-monotone" + << std::endl; return (false); } - if (tr.curve_get_point_status (all_curves_vec[cv_index], - all_points_vec[pt_index]) != tr.ON_CURVE) + if (! tr.curve_is_in_x_range (all_curves_vec[cv_index], + all_points_vec[pt_index]) || + tr.curve_get_point_status (all_curves_vec[cv_index], + all_points_vec[pt_index]) != CGAL::EQUAL) { std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is not on the curve" << std::endl; + std::cout << "Precondition fault: Split point is not on the curve" + << std::endl; return (false); } @@ -191,8 +195,8 @@ curve_split_wrapper (std::istringstream& str_line) all_curves_vec[cv_index].target() == all_points_vec[pt_index]) { std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is an end point of the curve" - << std::endl; + std::cout << "Precondition fault: " + << "Split point is an end point of the curve" << std::endl; return (false); } diff --git a/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_traits_test.h b/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_traits_test.h index ca319be1ea3..bf55be6a92f 100644 --- a/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_traits_test.h +++ b/Packages/Arrangement/test/Arrangement_2_Traits/include/Segment_traits_test.h @@ -1,7 +1,9 @@ #include "Base_traits_test.h" template< class Traits_class, class Number_type > -class Segment_traits_test : public Base_traits_test< Traits_class, Number_type >{ +class Segment_traits_test : +public Base_traits_test< Traits_class, Number_type > +{ public: typedef Number_type NT; typedef typename Traits_class::Point_2 Point; @@ -15,28 +17,28 @@ public: ~Segment_traits_test(); }; -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* Constructor. Nothing to do. Just calls super class ctor */ -//------------------------------------------------------------------------------ +//-------------------------------------------------------------------------- template< class Traits_class, class Number_type > Segment_traits_test< Traits_class, Number_type >:: Segment_traits_test( int argc, char** argv ) : Base_traits_test< Traits_class, Number_type >(argc, argv) {}; -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* Destructor. Nothing to do. Implements super class virtual dtor. */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > Segment_traits_test< Traits_class, Number_type >:: ~Segment_traits_test( ){} -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* Reads one curve. This method is called by collect_data. */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > void Segment_traits_test< Traits_class, Number_type >:: read_curve( std::ifstream & is, Curve & cv ) @@ -56,22 +58,23 @@ read_curve( std::ifstream & is, Curve & cv ) std::cout << " -------------------- " << cv << std::endl; } -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* input case: make_x_monotone n1 n2, where n1 - curve index in all_curves_vec n2 - number of expected X-monotonian subcurves */ -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- template< class Traits_class, class Number_type > bool Segment_traits_test< Traits_class, Number_type >:: make_x_monotone_wrapper( std::istringstream & /* strLine */){ - std::cout << "Test: make_x_monotone - nothing to do in segment case" << std::endl; + std::cout << "Test: make_x_monotone - nothing to do in segment case" + << std::endl; std::cout << "Was successful" << std::endl; return true; } -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- /* input case: curve_split n1 n2, where @@ -79,7 +82,7 @@ make_x_monotone_wrapper( std::istringstream & /* strLine */){ n2 - point index in all_points_vec Does NOT take any expected result */ -//------------------------------------------------------------------------------ +//-------------------------------------------------------------------------- template< class Traits_class, class Number_type > bool Segment_traits_test< Traits_class, Number_type >:: curve_split_wrapper( std::istringstream& strLine ){ @@ -87,23 +90,29 @@ curve_split_wrapper( std::istringstream& strLine ){ X_curve cv1, cv2; strLine >> index1 >> index2; - std::cout << "Test: curve_split( Curve" << index1 << ", " << all_points_vec[index2] - << " ) ? " << std::endl; + std::cout << "Test: curve_split( Curve" << index1 << ", " + << all_points_vec[index2] << " ) ? " << std::endl; if( !tr.is_x_monotone( all_curves_vec[index1] ) ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Input curve is not x-monotone" << std::endl; + std::cout << "Precondition fault: Input curve is not x-monotone" + << std::endl; return false; } - if( tr.curve_get_point_status( all_curves_vec[index1], - all_points_vec[index2] ) != tr.ON_CURVE ){ + if (! tr.curve_is_in_x_range (all_curves_vec[index1], + all_points_vec[index2]) || + tr.curve_get_point_status( all_curves_vec[index1], + all_points_vec[index2]) != CGAL::EQUAL) + { std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is not on the curve " << std::endl; + std::cout << "Precondition fault: Split point is not on the curve " + << std::endl; return false; } if( all_curves_vec[index1].source() == all_points_vec[index2] || all_curves_vec[index1].target() == all_points_vec[index2] ){ std::cout << "Was NOT successful" << std::endl; - std::cout << "Precondition fault: Split point is the end point of the curve " << std::endl; + std::cout << "Precondition fault: " + << "Split point is the end point of the curve " << std::endl; return false; } tr.curve_split( all_curves_vec[index1], cv1, cv2, all_points_vec[index2] ); @@ -112,7 +121,8 @@ curve_split_wrapper( std::istringstream& strLine ){ std::cout << "Was NOT successful" << std::endl; std::cout << "Source points of first parts are different" << std::endl; std::cout << "The original source point: " << cv1.source() << std::endl; - std::cout << "The obtained source point: " << all_curves_vec[index1].source() << std::endl; + std::cout << "The obtained source point: " + << all_curves_vec[index1].source() << std::endl; return false; } if( cv1.target() != all_points_vec[index2] ) @@ -120,7 +130,8 @@ curve_split_wrapper( std::istringstream& strLine ){ std::cout << "Was NOT successful" << std::endl; std::cout << "Target points of first parts are different" << std::endl; std::cout << "The original target point: " << cv1.target() << std::endl; - std::cout << "The obtained target point: " << all_curves_vec[index1].target() << std::endl; + std::cout << "The obtained target point: " + << all_curves_vec[index1].target() << std::endl; return false; } if( cv2.source() != all_points_vec[index2] ) @@ -128,7 +139,8 @@ curve_split_wrapper( std::istringstream& strLine ){ std::cout << "Was NOT successful" << std::endl; std::cout << "Source points of second parts are different" << std::endl; std::cout << "The original source point: " << cv1.source() << std::endl; - std::cout << "The obtained source point: " << all_curves_vec[index1].source() << std::endl; + std::cout << "The obtained source point: " + << all_curves_vec[index1].source() << std::endl; return false; } if( cv2.target() != all_curves_vec[index1].target() ) @@ -136,11 +148,12 @@ curve_split_wrapper( std::istringstream& strLine ){ std::cout << "Was NOT successful" << std::endl; std::cout << "Target points of second are different" << std::endl; std::cout << "The original target point: " << cv1.target() << std::endl; - std::cout << "The obtained target point: " << all_curves_vec[index1].target() << std::endl; + std::cout << "The obtained target point: " + << all_curves_vec[index1].target() << std::endl; return false; } std::cout << "Was successfull" << std::endl; return true; } -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- diff --git a/Packages/Trapezoidal_decomposition/include/CGAL/Td_X_trapezoid.h b/Packages/Trapezoidal_decomposition/include/CGAL/Td_X_trapezoid.h index c65a16cad99..70f313136a6 100644 --- a/Packages/Trapezoidal_decomposition/include/CGAL/Td_X_trapezoid.h +++ b/Packages/Trapezoidal_decomposition/include/CGAL/Td_X_trapezoid.h @@ -294,7 +294,9 @@ public: #ifdef CGAL_TD_DEBUG bool is_valid(const Traits* traits) const { - typename Traits::Curve_point_status t; + Comparison_result t; + bool b; + if (is_active()) { if (get_node() && **get_node()!=*this) @@ -324,22 +326,30 @@ public: CGAL_warning(!(is_left_unbounded() ||is_right_unbounded())); return false; } - t=traits->curve_get_point_status(bottom(),left()); - if (!(t==traits->ABOVE_CURVE || t==traits->ON_CURVE)) + + b=traits->curve_is_in_x_range(bottom(),left()); + if (b) + t=traits->curve_get_point_status(bottom(),left()); + + if (!b || t == LARGER) { std::cerr << "\nthis="; write(std::cerr,*this,*traits,false) << std::flush; std::cerr << "\nt==" << t << std::flush; - CGAL_warning(t==Traits::ABOVE_CURVE || t==Traits::ON_CURVE); + CGAL_warning(!b || t == LARGER); return false; } - t=traits->curve_get_point_status(bottom(),right()); - if (!(t==traits->ABOVE_CURVE || t==traits->ON_CURVE)) + + b=traits->curve_is_in_x_range(bottom(),right()); + if (b) + t=traits->curve_get_point_status(bottom(),right()); + + if (!b || t == LARGER) { std::cerr << "\nthis="; write(std::cerr,*this,*traits,false) << std::flush; std::cerr << "\nt==" << t << std::flush; - CGAL_warning(!(!(t==Traits::ABOVE_CURVE || t==Traits::ON_CURVE))); + CGAL_warning(!b || t == LARGER); return false; } } @@ -352,22 +362,30 @@ public: CGAL_warning(!(is_left_unbounded() || is_right_unbounded())); return false; } - t=traits->curve_get_point_status(top(),left()); - if (!(t==traits->UNDER_CURVE || t==traits->ON_CURVE)) + + b=traits->curve_is_in_x_range(top(),left()); + if (b) + t=traits->curve_get_point_status(top(),left()); + + if (!b || t == SMALLER) { std::cerr << "\nthis="; write(std::cerr,*this,*traits,false) << std::flush; std::cerr << "\nt==" << t << std::flush; - CGAL_warning(!(!(t==Traits::UNDER_CURVE || t==Traits::ON_CURVE))); + CGAL_warning(!b || t == SMALLER); return false; } - t=traits->curve_get_point_status(top(),right()); - if (!(t==traits->UNDER_CURVE || t==traits->ON_CURVE)) + + b=traits->curve_is_in_x_range(top(),right()); + if (b) + t=traits->curve_get_point_status(top(),right()); + + if (!b || t == SMALLER) { std::cerr << "\nthis="; write(std::cerr,*this,*traits,false) << std::flush; std::cerr << "\nt==" << t << std::flush; - CGAL_warning(!(!(t==Traits::UNDER_CURVE || t==Traits::ON_CURVE))); + CGAL_warning(!b || t == SMALLER); return false; } } @@ -451,43 +469,44 @@ public: CGAL_warning((!is_right_unbounded())); return false; } - if (!(traits->curve_get_point_status(bottom(),left()) == - Traits::ON_CURVE)) + if (!traits->curve_is_in_x_range(bottom(),left()) || + traits->curve_get_point_status(bottom(),left()) != EQUAL) { std::cerr << "\nbottom()==" << bottom() << std::flush; std::cerr << "\nleft()==" << left() << std::flush; - CGAL_warning(traits-> - curve_get_point_status(bottom(), - left()) == Traits::ON_CURVE); + CGAL_warning(traits->curve_is_in_x_range(bottom(),left()) && + traits->curve_get_point_status(bottom(), + left()) == EQUAL); return false; } - if (!(traits->curve_get_point_status(bottom(), - right()) == Traits::ON_CURVE)) + if (!traits->curve_is_in_x_range(bottom(),right()) || + traits->curve_get_point_status(bottom(),right()) != EQUAL) { std::cerr << "\nbottom()==" << bottom() << std::flush; std::cerr << "\nright()==" << right() << std::flush; - CGAL_warning(traits-> - curve_get_point_status(bottom(), - right()) == Traits::ON_CURVE); + CGAL_warning(traits->curve_is_in_x_range(bottom(),right()) && + traits->curve_get_point_status(bottom(), + right()) == EQUAL); return false; } - if(!(traits->curve_get_point_status(top(), left()) == - Traits::ON_CURVE)) + if (!traits->curve_is_in_x_range(top(),left()) || + traits->curve_get_point_status(top(),left()) != EQUAL) { std::cerr << "\ntop()==" << top() << std::flush; std::cerr << "\nleft()==" << left() << std::flush; - CGAL_warning(traits-> - curve_get_point_status(top(), - left()) == Traits::ON_CURVE); + CGAL_warning(!traits->curve_is_in_x_range(top(),left()) && + traits->curve_get_point_status(top(), + left()) == EQUAL); return false; } - if(!(traits->curve_get_point_status(top(),right())==Traits::ON_CURVE)) + if (!traits->curve_is_in_x_range(top(),right()) || + traits->curve_get_point_status(top(),right()) != EQUAL) { std::cerr << "\ntop()==" << top() << std::flush; std::cerr << "\nright()==" << right() << std::flush; - CGAL_warning(traits-> - curve_get_point_status(top(), - right()) == Traits::ON_CURVE); + CGAL_warning(traits->curve_is_in_x_range(top(),right()) && + traits->curve_get_point_status(top(), + right()) == EQUAL); return false; } if (traits->is_degenerate_curve(*this)) diff --git a/Packages/Trapezoidal_decomposition/include/CGAL/Td_traits.h b/Packages/Trapezoidal_decomposition/include/CGAL/Td_traits.h index f64d46c0261..5d057b77e5a 100644 --- a/Packages/Trapezoidal_decomposition/include/CGAL/Td_traits.h +++ b/Packages/Trapezoidal_decomposition/include/CGAL/Td_traits.h @@ -116,10 +116,11 @@ inline bool trapezoid_top_curve_is_same(X_trapezoid_const_ref left, (tr.is_right_unbounded()|| point_is_right_top(tr.right(),p))&& (tr.is_bottom_unbounded()|| - curve_get_point_status(tr.bottom(),p)==Traits_base::ABOVE_CURVE)&& + curve_get_point_status(tr.bottom(),p) == SMALLER)&& (tr.is_top_unbounded()|| - curve_get_point_status(tr.top(),p)==Traits_base::UNDER_CURVE); + curve_get_point_status(tr.top(),p) == LARGER); } + bool is_in_closure(const_ref tr,const Point& p) const { // test left and right sides @@ -131,17 +132,13 @@ inline bool trapezoid_top_curve_is_same(X_trapezoid_const_ref left, // test bottom side if (!tr.is_bottom_unbounded()) { - typename Traits_base::Curve_point_status - s=curve_get_point_status(tr.bottom(),p); - if (s!=Traits_base::ABOVE_CURVE&&s!=Traits_base::ON_CURVE) + if (curve_get_point_status(tr.bottom(),p) == LARGER) return false; } // test top side if (!tr.is_top_unbounded()) { - typename Traits_base::Curve_point_status - s=curve_get_point_status(tr.top(),p); - if (s!=Traits_base::UNDER_CURVE&&s!=Traits_base::ON_CURVE) + if (curve_get_point_status(tr.top(),p) == SMALLER) return false; } return true; diff --git a/Packages/Trapezoidal_decomposition/include/CGAL/Trapezoidal_decomposition_2.h b/Packages/Trapezoidal_decomposition/include/CGAL/Trapezoidal_decomposition_2.h index f9a50704784..c64b5be6202 100644 --- a/Packages/Trapezoidal_decomposition/include/CGAL/Trapezoidal_decomposition_2.h +++ b/Packages/Trapezoidal_decomposition/include/CGAL/Trapezoidal_decomposition_2.h @@ -231,42 +231,17 @@ public: { switch(traits->curve_get_point_status(sep,right)) { - case Traits::UNDER_CURVE: + case LARGER: curr=curr->right_top_neighbour(); break; - case Traits::ABOVE_CURVE: + case SMALLER: curr=curr->right_bottom_neighbour(); break; - case Traits::ON_CURVE: + case EQUAL: // end reached curr=0; break; - default: -#ifndef CGAL_TD_DEBUG - - std::cout << - "\nmake sure input intersects only on common end points"; - CGAL_warning(traits->curve_get_point_status(sep,curr->right()) == - Traits::UNDER_CURVE || - traits->curve_get_point_status(sep,curr->right()) == - Traits::ABOVE_CURVE || - traits->curve_get_point_status(sep,curr->right()) == - Traits::ON_CURVE); - -#else - std::cout << "\nsep==" << sep << std::flush; - std::cout << "\ncurr->right()==" << curr->right() << std::flush; - std::cout << - "\nmake sure input intersects only on common end points"; - CGAL_assertion(traits->curve_get_point_status(sep,curr->right()) - == Traits::UNDER_CURVE || - traits->curve_get_point_status(sep,curr->right()) - == Traits::ABOVE_CURVE || - traits->curve_get_point_status(sep,curr->right()) - == Traits::ON_CURVE); - -#endif - + default: curr=0; break; } @@ -1489,29 +1464,28 @@ output: trapezoid iterator // CURVE SEPRATION { pc = &curr->top(); - typename Traits::Curve_point_status c = - traits->curve_get_point_status(*pc,p); - if (c==Traits::UNDER_CURVE) + Comparison_result cres = traits->curve_get_point_status(*pc,p); + if (cres == LARGER) { curr=curr.left(); continue; } - else if (c==Traits::ABOVE_CURVE) + else if (cres == SMALLER) { curr=curr.right(); continue; } - else if (c==Traits::ON_CURVE) - { // p on CURVE - + else + { + // p on CURVE #ifndef CGAL_TD_DEBUG - CGAL_warning(c == Traits::ON_CURVE && + CGAL_warning(cres == EQUAL && !traits->point_is_right(p,traits->curve_rightmost(*pc))&& !traits->point_is_left(p,traits->curve_leftmost(*pc))); #else - CGAL_postcondition(c == Traits::ON_CURVE && + CGAL_postcondition(cres == EQUAL && !traits->point_is_right(p,traits->curve_rightmost(*pc))&& !traits->point_is_left(p,traits->curve_leftmost(*pc))); #endif @@ -1615,25 +1589,7 @@ output: trapezoid iterator } } - } - -#ifdef CGAL_TD_DEBUG - - else //traits->curve_get_point_status(*pc,p)== - //Traits::CURVE_NOT_IN_RANGE - { - std::cerr << "\ncurr->top()==" << *pc; - std::cerr << "\np==" << p; - CGAL_assertion( - c==Traits::UNDER_CURVE|| - c==Traits::ABOVE_CURVE|| - c==Traits::ON_CURVE - ); - return Locate_type(); - } - -#endif - + } } else // !is_degenerate()