Boost logo

Boost Users :

Subject: Re: [Boost-users] Polygon, accessing Points_Data
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-04-13 14:23:49


AmandaLind wrote:
> Will the following two lines work if pts are of a vector of Points
> instead of an array of points ?
>
> Point pts2[numcorners2]; //chaged to std::vector pts2;
> gtl::set_points(poly2, pts2, pts2+numcorners2);

Yes, vector::iterator supports operator+, however, you can also use pts2.end().

> And lastly, does anything about the following loop stand out to you
> as bad accessing of Polygon points ?
>
> for(std::size_t i = 0; i < num_polys; ++i)
> {
> pts.insert(pts.end(), polys[i].begin(), polys[i].end());
> num_points_in_poly=pts.size();
> numpointsperpoly.push_back(num_points_in_poly);
>
> for(int index =0; i < num_points_in_poly; index++)
> { std::cout<<" Here are the stubborn points x=
> "<<gtl::x(pts[index])<<", y= "<<gtl::y(pts[index])<<std::endl;
>
>
> tempcorner.assign(gtl::x(pts[index]),gtl::y(pts[index]),0);
> unioncorners.push_back(tempcorner); } }

You are forgetting to clear pts before yout insert. You don't want to append the points from each polygon to the same vector each iteration of the outer loop.

Other than that I don't see any obvious problems.

Regards,
Luke


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net