Boost logo

Boost Users :

Subject: [Boost-users] Polygon, accessing Points_Data
From: AmandaLind (abl128_at_[hidden])
Date: 2011-04-12 21:11:05


Greetings,
This is my first post here. Please help me as I am stuck on how to access
the points defining the new polygon generated with two other polygons and a
boolean operation.

I am having a hard time with using the iterators properly. The code runs
well up to that point.

Thanks in advance,
~Amanda

       namespace gtl = boost::polygon;
        using namespace boost::polygon::operators;
        using namespace gtl;
        
        //lets construct the two polygons
        typedef gtl::polygon_data Polygon;
        typedef gtl::polygon_traits::point_type Point;
        
        
        //Polygon1
        Point pts1[numcorners1];
        for (int index=0; index<numcorners1; index++)
        {
           
pts1[index]=gtl::construct<Point>(rotated_corners1[index].x*1000,
rotated_corners1[index].y*1000);
        }
        Polygon poly1;
        gtl::set_points(poly1, pts1, pts1+numcorners1);
        
        //Polygon 2
        Point pts2[numcorners2];
        for (int index=0; index<numcorners2; index++)
        {
           
pts2[index]=gtl::construct<Point>(rotated_corners2[index].x*1000,
rotated_corners2[index].y*1000);
            //mult by 1000 because it rounds to integers.
            
        }
        Polygon poly2;
        gtl::set_points(poly2, pts2, pts2+numcorners2);
        
        using namespace boost::polygon::operators;
        
        Polygon poly3;
        poly3 = poly1 & poly2;
        
        
        Point pts3[poly3.size()];
    
        //how does one use iterators ?!
    std::vector<point_data<int> >::iterator itr ;
    itr= poly3.begin();
    int index=0
        for(itr; itr != ploy3.end(); ++itr)
        {
            pts3(index)=*itr;
              index++;
        }
    
    

--
View this message in context: http://boost.2283326.n4.nabble.com/Polygon-accessing-Points-Data-tp3446015p3446015.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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