Corrected the operator>> in Polyline_2

This commit is contained in:
Dror Atariah 2013-07-03 15:59:35 +02:00
parent 99eff890c5
commit b14a20ab0e
1 changed files with 17 additions and 2 deletions

View File

@ -578,6 +578,7 @@ namespace CGAL {
Polyline_2<SegmentTraits>& pl)
{
typedef Polyline_2<SegmentTraits> 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<Point_2> pts;
@ -596,8 +600,19 @@ namespace CGAL {
pts.push_back(p);
}
std::list<Segment_2> segments;
typename std::list<Point_2>::iterator curr = pts.begin();
typename std::list<Point_2>::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);
}