#### /Src/Dependencies/Boost/libs/geometry/doc/src/examples/geometries/register/box_2d_4values.cpp

C++ | 51 lines | 20 code | 12 blank | 19 comment | 0 complexity | 3314931294102cfd3a16785abfa01cc6 MD5 | raw file
``` 1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// QuickBook Example
3
4// Copyright (c) 2011 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
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
18struct my_point
19{
20    int x, y;
21};
22
23struct my_box
24{
25    int left, top, right, bottom;
26};
27
28BOOST_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)
32BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(my_box, my_point, left, top, right, bottom)
33
34int 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/*`
46Output:
47[pre
48Area: 4
49]
50*/
51//]
```