Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/geometries/box.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | |
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | |
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
9 | |
10 // Use, modification and distribution is subject to the Boost Software License, | |
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 // http://www.boost.org/LICENSE_1_0.txt) | |
13 | |
14 #ifndef BOOST_GEOMETRY_GEOMETRIES_BOX_HPP | |
15 #define BOOST_GEOMETRY_GEOMETRIES_BOX_HPP | |
16 | |
17 #include <cstddef> | |
18 | |
19 #include <boost/concept/assert.hpp> | |
20 | |
21 #include <boost/geometry/algorithms/convert.hpp> | |
22 #include <boost/geometry/geometries/concepts/point_concept.hpp> | |
23 | |
24 | |
25 | |
26 namespace boost { namespace geometry | |
27 { | |
28 | |
29 namespace model | |
30 { | |
31 | |
32 | |
33 /*! | |
34 \brief Class box: defines a box made of two describing points | |
35 \ingroup geometries | |
36 \details Box is always described by a min_corner() and a max_corner() point. If another | |
37 rectangle is used, use linear_ring or polygon. | |
38 \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms | |
39 are implemented for box. Boxes are also used in Spatial Indexes. | |
40 \tparam Point point type. The box takes a point type as template parameter. | |
41 The point type can be any point type. | |
42 It can be 2D but can also be 3D or more dimensional. | |
43 The box can also take a latlong point type as template parameter. | |
44 */ | |
45 | |
46 template<typename Point> | |
47 class box | |
48 { | |
49 BOOST_CONCEPT_ASSERT( (concept::Point<Point>) ); | |
50 | |
51 public: | |
52 | |
53 inline box() {} | |
54 | |
55 /*! | |
56 \brief Constructor taking the minimum corner point and the maximum corner point | |
57 */ | |
58 inline box(Point const& min_corner, Point const& max_corner) | |
59 { | |
60 geometry::convert(min_corner, m_min_corner); | |
61 geometry::convert(max_corner, m_max_corner); | |
62 } | |
63 | |
64 inline Point const& min_corner() const { return m_min_corner; } | |
65 inline Point const& max_corner() const { return m_max_corner; } | |
66 | |
67 inline Point& min_corner() { return m_min_corner; } | |
68 inline Point& max_corner() { return m_max_corner; } | |
69 | |
70 private: | |
71 | |
72 Point m_min_corner; | |
73 Point m_max_corner; | |
74 }; | |
75 | |
76 | |
77 } // namespace model | |
78 | |
79 | |
80 // Traits specializations for box above | |
81 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS | |
82 namespace traits | |
83 { | |
84 | |
85 template <typename Point> | |
86 struct tag<model::box<Point> > | |
87 { | |
88 typedef box_tag type; | |
89 }; | |
90 | |
91 template <typename Point> | |
92 struct point_type<model::box<Point> > | |
93 { | |
94 typedef Point type; | |
95 }; | |
96 | |
97 template <typename Point, std::size_t Dimension> | |
98 struct indexed_access<model::box<Point>, min_corner, Dimension> | |
99 { | |
100 typedef typename geometry::coordinate_type<Point>::type coordinate_type; | |
101 | |
102 static inline coordinate_type get(model::box<Point> const& b) | |
103 { | |
104 return geometry::get<Dimension>(b.min_corner()); | |
105 } | |
106 | |
107 static inline void set(model::box<Point>& b, coordinate_type const& value) | |
108 { | |
109 geometry::set<Dimension>(b.min_corner(), value); | |
110 } | |
111 }; | |
112 | |
113 template <typename Point, std::size_t Dimension> | |
114 struct indexed_access<model::box<Point>, max_corner, Dimension> | |
115 { | |
116 typedef typename geometry::coordinate_type<Point>::type coordinate_type; | |
117 | |
118 static inline coordinate_type get(model::box<Point> const& b) | |
119 { | |
120 return geometry::get<Dimension>(b.max_corner()); | |
121 } | |
122 | |
123 static inline void set(model::box<Point>& b, coordinate_type const& value) | |
124 { | |
125 geometry::set<Dimension>(b.max_corner(), value); | |
126 } | |
127 }; | |
128 | |
129 } // namespace traits | |
130 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS | |
131 | |
132 }} // namespace boost::geometry | |
133 | |
134 #endif // BOOST_GEOMETRY_GEOMETRIES_BOX_HPP |