Subject: CGAL users discussion list
List archive
- From: Efraim Fogel <>
- To:
- Subject: Re: [cgal-discuss] Re: Problem with push_back on a polyline
- Date: Mon, 10 Mar 2008 14:59:54 +0200
This method, (void _Polyline_2::push_back (const Point_2 & p)) has a precondition that 'segments' is not empty. It is missing, and I'll add it to the code.
Is it used anywhere in a way that violates this precondition?
Olivier Tournaire wrote:
Hi,--
The code in the push_back method is the following :
void push_back (const Point_2 & p)
{
Point_2 pt = p;
Point_2 ps = segments.back().target();
segments.push_back (Segment_2 (ps, pt));
}
As I use the empty constructor, the std::vector<Segment_2> segments; is empty. Then, if I want to insert a point in the polyline, segments.back() returns a null iterator, and, .target() on a null iterator certainly crashes. So, how can we use this method ? Maybe I did not understand the underlying concept of CGAL polylines ...
Regards,
Olivier
2008/3/4, Olivier Tournaire < <mailto:>>:
Hi all,
I have a problem with a push_back on a polyline. Here are some
samples of my code :
typedef CGAL::Arr_polyline_traits_2< CGAL::Arr_segment_traits_2<
CGAL::Cartesian<int> > >::Curve_2 polyline_int;
// ...
polyline_int polyline;
chains.push_back( polyline ); // chains is a std::vector<
polyline_int >
MakeAChain( *copy , NLD[iNode].position , iDirection ,
chains[chains.size()-1] , FinalNode , FinalDirection );
// MakeAChain
void MakeAChain( itk::Image<unsigned char,2> &image , CGAL_Point2i
BeginPoint , unsigned char BeginDirection , polyline_int
&CurrentPolyline , CGAL_Point2i EndPoint , unsigned char
EndDirection )
{
// ...
CurrentPolyline.push_back( BeginPoint ); // crashes because
CurrentPolyline.segments is NULL (from the debugger)
// ...
}
I do not understand why CurrentPolyline.segments is NULL. Could
you please help ?
Regards.
Olivier
____ _ ____ _
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/
- Problem with push_back on a polyline, Olivier Tournaire, 03/04/2008
- Re: Problem with push_back on a polyline, Olivier Tournaire, 03/06/2008
- Re: [cgal-discuss] Re: Problem with push_back on a polyline, Efraim Fogel, 03/10/2008
- Re: Problem with push_back on a polyline, Olivier Tournaire, 03/06/2008
Archive powered by MHonArc 2.6.16.