]>
Commit | Line | Data |
---|---|---|
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | // QuickBook Example | |
3 | ||
4 | // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | ||
6 | // Use, modification and distribution is subject to the Boost Software License, | |
7 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
8 | // http://www.boost.org/LICENSE_1_0.txt) | |
9 | ||
10 | //[register_box_2d_4values | |
11 | //` Show the use of the macro BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES | |
12 | ||
13 | #include <iostream> | |
14 | #include <boost/geometry.hpp> | |
15 | #include <boost/geometry/geometries/register/point.hpp> | |
16 | #include <boost/geometry/geometries/register/box.hpp> | |
17 | ||
18 | struct my_point | |
19 | { | |
20 | int x, y; | |
21 | }; | |
22 | ||
23 | struct my_box | |
24 | { | |
25 | int left, top, right, bottom; | |
26 | }; | |
27 | ||
28 | BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, int, cs::cartesian, x, y) | |
29 | ||
30 | // Register the box type, also notifying that it is based on "my_point" | |
31 | // (even if it does not contain it) | |
32 | BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(my_box, my_point, left, top, right, bottom) | |
33 | ||
34 | int main() | |
35 | { | |
36 | my_box b = boost::geometry::make<my_box>(0, 0, 2, 2); | |
37 | std::cout << "Area: " << boost::geometry::area(b) << std::endl; | |
38 | return 0; | |
39 | } | |
40 | ||
41 | //] | |
42 | ||
43 | ||
44 | //[register_box_2d_4values_output | |
45 | /*` | |
46 | Output: | |
47 | [pre | |
48 | Area: 4 | |
49 | ] | |
50 | */ | |
51 | //] |