1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 //[boost_polygon_polygon
12 //`Shows how to use Boost.Polygon polygon_with_holes_data within Boost.Geometry
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/adapted/boost_polygon.hpp>
20 typedef boost::polygon::polygon_with_holes_data
<int> polygon
;
21 typedef boost::polygon::polygon_traits
<polygon
>::point_type point
;
22 typedef boost::polygon::polygon_with_holes_traits
<polygon
>::hole_type hole
;
25 boost::polygon::construct
<point
>(0, 0),
26 boost::polygon::construct
<point
>(0, 10),
27 boost::polygon::construct
<point
>(10, 10),
28 boost::polygon::construct
<point
>(10, 0),
29 boost::polygon::construct
<point
>(0, 0)
32 boost::polygon::construct
<point
>(1, 1),
33 boost::polygon::construct
<point
>(9, 1),
34 boost::polygon::construct
<point
>(9, 9),
35 boost::polygon::construct
<point
>(1, 9),
36 boost::polygon::construct
<point
>(1, 1)
40 boost::polygon::set_points(hls
[0], hole_pts
, hole_pts
+5);
43 boost::polygon::set_points(poly
, pts
, pts
+5);
44 boost::polygon::set_holes(poly
, hls
, hls
+1);
46 std::cout
<< "Area (using Boost.Geometry): "
47 << boost::geometry::area(poly
) << std::endl
;
48 std::cout
<< "Area (using Boost.Polygon): "
49 << boost::polygon::area(poly
) << std::endl
;
56 //[boost_polygon_polygon_output
60 Area (using Boost.Geometry): 36
61 Area (using Boost.Polygon): 36