$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [geometry] access to poligon point list
From: nicola81 (nicola_cavallini_at_[hidden])
Date: 2012-05-19 11:16:10
 
In the example below what I actually
meant, that I could achieve thanks to your suggestion.
I would call solved this point.
Now I need to move to the next phase,
which is intersecting two sets of polygons.
I bumped into this discussion and I
find it extremely interesting.
http://boost-geometry.203548.n3.nabble.com/intersection-of-two-vectors-of-polygons-td2875513.html
Really think this is going to work
great for me.
>Could you point which examples from
the geometry library website 
>do not compile for you? 
I tried compiling them with g++ and I
could get clearer error messages, I was missing some include.
Getting the code from the trunk means
getting an svn directory and update/compile/install new
versions?
Thanks a lot for your help!
#include <iostream> 
#include <deque> 
#include <boost/geometry.hpp> 
#include
<boost/geometry/geometries/point_xy.hpp> 
#include
<boost/geometry/geometries/polygon.hpp> 
#include
<boost/geometry/io/wkt/wkt.hpp> 
#include <boost/foreach.hpp> 
#include
<boost/geometry/multi/geometries/register/multi_polygon.hpp> 
typedef
boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>,false>
polygon; 
BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(std::deque<polygon>); 
int main() 
{ 
using boost::geometry::get; 
typedef
boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>
> polygon; 
polygon green, blue; 
boost::geometry::read_wkt( 
"POLYGON((0 0,0 1.75,1.75
0,0 0))", green); 
boost::geometry::read_wkt( 
"POLYGON((.5 .5, .5 1, 1
1, 1 .5, .5 .5))", blue); 
std::deque<polygon> output; 
boost::geometry::intersection(green, blue, output); 
polygon red; 
red = output[0]; 
// ring is a vector 
typedef
boost::geometry::model::d2::point_xy<double> point; 
std::vector<point> const&
points = red.outer(); 
std::vector<double> Px; 
std::vector<double> Py; 
for (std::vector<point>::size_type
i = 0; i < points.size(); ++i) 
{ 
Px.push_back(get<0>(points[i])); 
Py.push_back(get<1>(points[i])); 
} 
std::cout << "Size Px =
"<< Px.size() << std::endl; 
std::cout << "Size Py =
"<< Py.size() << std::endl; 
for (int i = 0; i < Px.size();
i++) 
{ 
std::cout<< "Px["
<< i << "] = " << Px[i] << ",
Py[" << i << "] = "<< Py[i] <<
std::endl; 
} 
return 0; 
}
________________________________
 Da: Mateusz Loskot [via Boost Geometry] <ml-node+s203548n4000004h50_at_[hidden]>
A: nicola81 <nicola_cavallini_at_[hidden]> 
Inviato: Venerdì 18 Maggio 2012 1:41
Oggetto: Re: access to poligon point list
 
On 17 May 2012 19:23, nicola81 <[hidden email]> wrote: 
> I would like to get the polygon points in a standard vector, or into some 
> other (simple :( ) structure I can access to. 
Based on your example, is this what you look for? 
polygon red; 
red = output[0]; 
// ring is a vector 
std::vector<point> const& points = red.outer(); 
for (std::vector<point>::size_type i = 0; i < points.size(); ++i) 
{ 
    list_coordinates(points[i]); 
} 
> I've spent several days trying to get something out of Google, but I 
> couldn't get anything useful. I cannot compile most of the code examples on 
> stackoverflow or on the geometry library website. 
Could you point which examples from the geometry library website 
do not compile for you? 
> I run the last Intel compiler 12.something, and boost 1.49. 
I'd encourage you to try the geometry library for Boost trunk. 
> The example I was working on is attached, and is actually from the boost 
> website. My guess was trying to get a couple of standard vectors (Px, Py) 
> out object function âlist_coordinatesâ. 
I have to admit, it is not clear to me what you mean as "get a couple of 
standard vectors". But, try my example above and see if this is 
what you are looking for. 
Best regards, 
-- Mateusz Loskot, http://mateusz.loskot.net _______________________________________________ Geometry mailing list [hidden email] http://listarchives.boost.org/mailman/listinfo.cgi/geometry -- Mateusz Loskot http://mateusz.loskot.net ________________________________ If you reply to this email, your message will be added to the discussion below:http://boost-geometry.203548.n3.nabble.com/access-to-poligon-point-list-tp3999541p4000004.html To unsubscribe from access to poligon point list, click here. NAML -- View this message in context: http://boost-geometry.203548.n3.nabble.com/access-to-poligon-point-list-tp3999541p4002387.html Sent from the Boost Geometry mailing list archive at Nabble.com.