1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
6
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)
10
11 //[boost_polygon_ring
12 //`Shows how to use Boost.Polygon polygon_data within Boost.Geometry
13
14 #include <iostream>
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/adapted/boost_polygon.hpp>
17
main()18 int main()
19 {
20 typedef boost::polygon::polygon_data<int> polygon;
21 typedef boost::polygon::polygon_traits<polygon>::point_type point;
22
23 point pts[5] = {
24 boost::polygon::construct<point>(0, 0),
25 boost::polygon::construct<point>(0, 10),
26 boost::polygon::construct<point>(10, 10),
27 boost::polygon::construct<point>(10, 0),
28 boost::polygon::construct<point>(0, 0)
29 };
30
31 polygon poly;
32 boost::polygon::set_points(poly, pts, pts+5);
33
34 std::cout << "Area (using Boost.Geometry): "
35 << boost::geometry::area(poly) << std::endl;
36 std::cout << "Area (using Boost.Polygon): "
37 << boost::polygon::area(poly) << std::endl;
38
39 return 0;
40 }
41
42 //]
43
44 //[boost_polygon_ring_output
45 /*`
46 Output:
47 [pre
48 Area (using Boost.Geometry): 100
49 Area (using Boost.Polygon): 100
50 ]
51 */
52 //]
53