mirror of https://github.com/CGAL/cgal
Corrected the operator>> in Polyline_2
This commit is contained in:
parent
99eff890c5
commit
b14a20ab0e
|
|
@ -578,6 +578,7 @@ namespace CGAL {
|
||||||
Polyline_2<SegmentTraits>& pl)
|
Polyline_2<SegmentTraits>& pl)
|
||||||
{
|
{
|
||||||
typedef Polyline_2<SegmentTraits> Curve_2;
|
typedef Polyline_2<SegmentTraits> Curve_2;
|
||||||
|
typedef typename Curve_2::Segment_2 Segment_2;
|
||||||
typedef typename Curve_2::Point_2 Point_2;
|
typedef typename Curve_2::Point_2 Point_2;
|
||||||
|
|
||||||
// Read the number of input points.
|
// Read the number of input points.
|
||||||
|
|
@ -585,6 +586,9 @@ namespace CGAL {
|
||||||
|
|
||||||
is >> n_pts;
|
is >> n_pts;
|
||||||
|
|
||||||
|
CGAL_precondition_msg(n_pts > 1,
|
||||||
|
"Input must contain at least two points");
|
||||||
|
|
||||||
// Read m_num_pts points to a list.
|
// Read m_num_pts points to a list.
|
||||||
Point_2 p;
|
Point_2 p;
|
||||||
std::list<Point_2> pts;
|
std::list<Point_2> pts;
|
||||||
|
|
@ -596,8 +600,19 @@ namespace CGAL {
|
||||||
pts.push_back(p);
|
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.
|
// Create the polyline curve.
|
||||||
pl = Curve_2(pts.begin(), pts.end());
|
pl = Curve_2(segments.begin(),segments.end());
|
||||||
|
|
||||||
return (is);
|
return (is);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue