Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@16
|
6
|
Chris@16
|
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
9
|
Chris@16
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
13
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
|
Chris@16
|
16 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
|
Chris@16
|
17
|
Chris@16
|
18
|
Chris@16
|
19 #include <cstddef>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/concept_check.hpp>
|
Chris@16
|
22
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/geometry/core/access.hpp>
|
Chris@16
|
25 #include <boost/geometry/core/coordinate_dimension.hpp>
|
Chris@16
|
26 #include <boost/geometry/core/point_type.hpp>
|
Chris@16
|
27
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost { namespace geometry { namespace concept
|
Chris@16
|
30 {
|
Chris@16
|
31
|
Chris@16
|
32
|
Chris@16
|
33 /*!
|
Chris@16
|
34 \brief Box concept
|
Chris@16
|
35 \ingroup concepts
|
Chris@16
|
36 \par Formal definition:
|
Chris@16
|
37 The box concept is defined as following:
|
Chris@16
|
38 - there must be a specialization of traits::tag defining box_tag as type
|
Chris@16
|
39 - there must be a specialization of traits::point_type to define the
|
Chris@16
|
40 underlying point type (even if it does not consist of points, it should define
|
Chris@16
|
41 this type, to indicate the points it can work with)
|
Chris@16
|
42 - there must be a specialization of traits::indexed_access, per index
|
Chris@16
|
43 (min_corner, max_corner) and per dimension, with two functions:
|
Chris@16
|
44 - get to get a coordinate value
|
Chris@16
|
45 - set to set a coordinate value (this one is not checked for ConstBox)
|
Chris@16
|
46 */
|
Chris@16
|
47 template <typename Geometry>
|
Chris@16
|
48 class Box
|
Chris@16
|
49 {
|
Chris@16
|
50 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
|
Chris@16
|
51 typedef typename point_type<Geometry>::type point_type;
|
Chris@16
|
52
|
Chris@16
|
53
|
Chris@16
|
54 template
|
Chris@16
|
55 <
|
Chris@16
|
56 std::size_t Index,
|
Chris@16
|
57 std::size_t Dimension,
|
Chris@16
|
58 std::size_t DimensionCount
|
Chris@16
|
59 >
|
Chris@16
|
60 struct dimension_checker
|
Chris@16
|
61 {
|
Chris@16
|
62 static void apply()
|
Chris@16
|
63 {
|
Chris@16
|
64 Geometry* b = 0;
|
Chris@16
|
65 geometry::set<Index, Dimension>(*b, geometry::get<Index, Dimension>(*b));
|
Chris@16
|
66 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
|
Chris@16
|
67 }
|
Chris@16
|
68 };
|
Chris@16
|
69
|
Chris@16
|
70 template <std::size_t Index, std::size_t DimensionCount>
|
Chris@16
|
71 struct dimension_checker<Index, DimensionCount, DimensionCount>
|
Chris@16
|
72 {
|
Chris@16
|
73 static void apply() {}
|
Chris@16
|
74 };
|
Chris@16
|
75
|
Chris@16
|
76 public :
|
Chris@16
|
77 BOOST_CONCEPT_USAGE(Box)
|
Chris@16
|
78 {
|
Chris@16
|
79 static const std::size_t n = dimension<Geometry>::type::value;
|
Chris@16
|
80 dimension_checker<min_corner, 0, n>::apply();
|
Chris@16
|
81 dimension_checker<max_corner, 0, n>::apply();
|
Chris@16
|
82 }
|
Chris@16
|
83 #endif
|
Chris@16
|
84 };
|
Chris@16
|
85
|
Chris@16
|
86
|
Chris@16
|
87 /*!
|
Chris@16
|
88 \brief Box concept (const version)
|
Chris@16
|
89 \ingroup const_concepts
|
Chris@16
|
90 \details The ConstBox concept apply the same as the Box concept,
|
Chris@16
|
91 but does not apply write access.
|
Chris@16
|
92 */
|
Chris@16
|
93 template <typename Geometry>
|
Chris@16
|
94 class ConstBox
|
Chris@16
|
95 {
|
Chris@16
|
96 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
|
Chris@16
|
97 typedef typename point_type<Geometry>::type point_type;
|
Chris@16
|
98 typedef typename coordinate_type<Geometry>::type coordinate_type;
|
Chris@16
|
99
|
Chris@16
|
100 template
|
Chris@16
|
101 <
|
Chris@16
|
102 std::size_t Index,
|
Chris@16
|
103 std::size_t Dimension,
|
Chris@16
|
104 std::size_t DimensionCount
|
Chris@16
|
105 >
|
Chris@16
|
106 struct dimension_checker
|
Chris@16
|
107 {
|
Chris@16
|
108 static void apply()
|
Chris@16
|
109 {
|
Chris@16
|
110 const Geometry* b = 0;
|
Chris@16
|
111 coordinate_type coord(geometry::get<Index, Dimension>(*b));
|
Chris@16
|
112 boost::ignore_unused_variable_warning(coord);
|
Chris@16
|
113 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
|
Chris@16
|
114 }
|
Chris@16
|
115 };
|
Chris@16
|
116
|
Chris@16
|
117 template <std::size_t Index, std::size_t DimensionCount>
|
Chris@16
|
118 struct dimension_checker<Index, DimensionCount, DimensionCount>
|
Chris@16
|
119 {
|
Chris@16
|
120 static void apply() {}
|
Chris@16
|
121 };
|
Chris@16
|
122
|
Chris@16
|
123 public :
|
Chris@16
|
124 BOOST_CONCEPT_USAGE(ConstBox)
|
Chris@16
|
125 {
|
Chris@16
|
126 static const std::size_t n = dimension<Geometry>::type::value;
|
Chris@16
|
127 dimension_checker<min_corner, 0, n>::apply();
|
Chris@16
|
128 dimension_checker<max_corner, 0, n>::apply();
|
Chris@16
|
129 }
|
Chris@16
|
130 #endif
|
Chris@16
|
131 };
|
Chris@16
|
132
|
Chris@16
|
133 }}} // namespace boost::geometry::concept
|
Chris@16
|
134
|
Chris@16
|
135
|
Chris@16
|
136 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
|