Skip to Content.
Sympa Menu

cgal-discuss - Re: Problem with push_back on a polyline

Subject: CGAL users discussion list

List archive

Re: Problem with push_back on a polyline


Chronological Thread 
  • From: "Olivier Tournaire" <>
  • To:
  • Subject: Re: Problem with push_back on a polyline
  • Date: Thu, 6 Mar 2008 23:15:28 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=sGlj8zwjg+2Vu2QUPZoIX7IhLIbbZBF51GjRHa2M/Sj76Y93j9otV61QzgOFabKceq+XfZ7nI64azb5WV8mj6KKcSO1Bj+dTyP6hFOaMxpCUR+gyiAZQRTcVFMSKYOFjTCgUngLz3DpZsj67QHuldqOEleNsFNcHrgIskF9nutk=

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 <>:
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




Archive powered by MHonArc 2.6.16.

Top of Page