diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polylines.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polylines.cpp index b9a211852da..6475e747a81 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polylines.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/polylines.cpp @@ -41,6 +41,7 @@ int main () points1[3] = Point_2 (4, 4); points1[4] = Point_2 (6, 0); Polyline_2 pi1 (&points1[0], &points1[5]); + // insert (arr, pi1); /* Polyline's outline: * @@ -67,6 +68,7 @@ int main () points2.push_back (Point_2 (5, 3)); points2.push_back (Point_2 (4, 2)); Polyline_2 pi2 (points2.begin(), points2.end()); + // insert (arr, pi2); /* Polyline's outline: * @@ -83,6 +85,8 @@ int main () points3[2] = Point_2 (3, 6); points3[3] = Point_2 (5, 2); Polyline_2 pi3 (points3.begin(), points3.end()); + // insert (arr, pi3); + /*Polyline's outline: * @@ -101,11 +105,20 @@ int main () points4.push_back (Point_2(0,1)); points4.push_back (Point_2(-1,0)); Polyline_2 pi4 (points4.begin(),points4.end()); - - // insert (arr, pi1); - // insert (arr, pi2); - // insert (arr, pi3); - insert (arr, pi4); + // insert (arr, pi4); + + /*Polyline's outline: + * + */ + std::list points5; + points5.push_back (Point_2(-2,-2)); + points5.push_back (Point_2(2,-2)); + points5.push_back (Point_2(2,2)); + points5.push_back (Point_2(-2,2)); + points5.push_back (Point_2(-2,-2)); + Polyline_2 pi5 (points5.begin(),points5.end()); + insert (arr, pi5); + print_arrangement (arr); return 0; diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h index 3b2bf3d7cf2..ba3f330f4a0 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h @@ -481,19 +481,25 @@ public: return oi; } + // Polyline contains at least 2 segments! + typename Segment_traits_2::Compare_xy_2 comp_xy = seg_traits->compare_xy_2_object(); + typename Segment_traits_2::Is_vertical_2 is_vertical = + seg_traits->is_vertical_2_object(); Construct_x_monotone_curve_2 construct_x_monotone_curve = m_traits->construct_x_monotone_curve_2_object(); const_seg_iterator it_start = start_seg; const_seg_iterator it_curr = start_seg; - for (; it_next != end_seg; ++it_next) + for (/*it_next was advanced earlier*/; it_next != end_seg; ++it_next) { + // TODO: Improve this test. Avoid double tests of geometrical elements. if ((comp_xy(max_v(*it_curr), min_v(*it_next)) != EQUAL) && (comp_xy(min_v(*it_curr), max_v(*it_next)) != EQUAL) ) { + // Construct an x-monotone curve from the sub-range which was found *oi++ = make_object(construct_x_monotone_curve(it_start, it_next)); it_start = it_next; } @@ -531,6 +537,9 @@ public: void operator()(const X_monotone_curve_2& cv, const Point_2& p, X_monotone_curve_2& c1, X_monotone_curve_2& c2) const { + + // TODO: Should this be rewritten using iterators over the segments? + typename Segment_traits_2::Construct_min_vertex_2 min_vertex = m_seg_traits->construct_min_vertex_2_object(); typename Segment_traits_2::Construct_max_vertex_2 max_vertex = @@ -954,6 +963,20 @@ public: return (X_monotone_curve_2(pts + 0, pts + 2)); } + /*! Returns an x-monotone curve consists of one given segment. + * \param seg input segment + * \return A polyline with one segment, namely seg. + * TODO: Implement this overload + * TODO: Use this implementations in the Make_x_monotone_2, when there's + * only one segment. + */ + X_monotone_curve_2 operator()(const Segment_2 seg) const + { + X_monotone_curve_2 res; + return res; + } + + template X_monotone_curve_2 operator()(InputIterator begin, InputIterator end) const {