diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polyline_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polyline_2.h index ec31e760c31..7161c02474d 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polyline_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polyline_2.h @@ -577,7 +577,8 @@ namespace CGAL { std::istream& operator>> (std::istream& is, Polyline_2& pl) { - typedef Polyline_2 Curve_2; + typedef Polyline_2 Curve_2; + typedef typename Curve_2::Segment_2 Segment_2; typedef typename Curve_2::Point_2 Point_2; // Read the number of input points. @@ -585,6 +586,9 @@ namespace CGAL { is >> n_pts; + CGAL_precondition_msg(n_pts > 1, + "Input must contain at least two points"); + // Read m_num_pts points to a list. Point_2 p; std::list pts; @@ -596,8 +600,19 @@ namespace CGAL { pts.push_back(p); } + std::list segments; + typename std::list::iterator curr = pts.begin(); + typename std::list::iterator next = pts.begin(); + ++next; + while (next != pts.end()) + { + segments.push_back(Segment_2(*curr,*next)); + ++curr; + ++next; + } + // Create the polyline curve. - pl = Curve_2(pts.begin(), pts.end()); + pl = Curve_2(segments.begin(),segments.end()); return (is); }