]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/box.cpp
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2015 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)
12 //` Declaration and use of the Boost.Geometry model::box, modelling the Box Concept
15 #include <boost/geometry.hpp>
17 namespace bg
= boost::geometry
;
21 typedef bg::model::point
<double, 2, bg::cs::cartesian
> point_t
;
22 typedef bg::model::box
<point_t
> box_t
;
24 box_t box1
; /*< Default-construct a box. >*/
25 box_t
box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/
27 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
29 box_t box3
{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/
33 bg::set
<bg::min_corner
, 0>(box1
, 1.0); /*< Set a coordinate, generic. >*/
34 bg::set
<bg::min_corner
, 1>(box1
, 2.0);
35 box1
.max_corner().set
<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/
36 box1
.max_corner().set
<1>(4.0);
38 double min_x
= bg::get
<bg::min_corner
, 0>(box1
); /*< Get a coordinate, generic. >*/
39 double min_y
= bg::get
<bg::min_corner
, 1>(box1
);
40 double max_x
= box1
.max_corner().get
<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/
41 double max_y
= box1
.max_corner().get
<1>();
43 std::cout
<< min_x
<< ", " << min_y
<< ", " << max_x
<< ", " << max_y
<< std::endl
;