]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/index/detail/algorithms/bounds.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / algorithms / bounds.hpp
1 // Boost.Geometry Index
2 //
3 // n-dimensional bounds
4 //
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // This file was modified by Oracle on 2019-2021.
8 // Modifications copyright (c) 2019-2021 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 //
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
16 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
17
18 #include <boost/geometry/algorithms/convert.hpp>
19 #include <boost/geometry/algorithms/detail/covered_by/interface.hpp>
20 #include <boost/geometry/algorithms/detail/envelope/interface.hpp>
21 #include <boost/geometry/algorithms/detail/expand/interface.hpp>
22
23 #include <boost/geometry/index/detail/bounded_view.hpp>
24
25 namespace boost { namespace geometry { namespace index { namespace detail
26 {
27
28 namespace dispatch
29 {
30
31 template <typename Geometry,
32 typename Bounds,
33 typename TagGeometry = typename geometry::tag<Geometry>::type,
34 typename TagBounds = typename geometry::tag<Bounds>::type>
35 struct bounds
36 {
37 template <typename Strategy>
38 static inline void apply(Geometry const& g, Bounds & b, Strategy const& )
39 {
40 geometry::convert(g, b);
41 }
42 };
43
44 template <typename Geometry, typename Bounds>
45 struct bounds<Geometry, Bounds, segment_tag, box_tag>
46 {
47 template <typename Strategy>
48 static inline void apply(Geometry const& g, Bounds & b, Strategy const& s)
49 {
50 index::detail::bounded_view<Geometry, Bounds, Strategy> v(g, s);
51 geometry::convert(v, b);
52 }
53 };
54
55
56 } // namespace dispatch
57
58
59 template <typename Geometry, typename Bounds, typename Strategy>
60 inline void bounds(Geometry const& g, Bounds & b, Strategy const& s)
61 {
62 concepts::check_concepts_and_equal_dimensions<Geometry const, Bounds>();
63 dispatch::bounds<Geometry, Bounds>::apply(g, b, s);
64 }
65
66
67 namespace dispatch
68 {
69
70 template <typename Bounds,
71 typename Geometry,
72 typename TagBounds = typename geometry::tag<Bounds>::type,
73 typename TagGeometry = typename geometry::tag<Geometry>::type>
74 struct expand
75 {
76 // STATIC ASSERT
77 };
78
79 template <typename Bounds, typename Geometry>
80 struct expand<Bounds, Geometry, box_tag, point_tag>
81 {
82 static inline void apply(Bounds & b, Geometry const& g)
83 {
84 geometry::expand(b, g);
85 }
86
87 template <typename Strategy>
88 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
89 {
90 geometry::expand(b, g, s);
91 }
92 };
93
94 template <typename Bounds, typename Geometry>
95 struct expand<Bounds, Geometry, box_tag, box_tag>
96 {
97 static inline void apply(Bounds & b, Geometry const& g)
98 {
99 geometry::expand(b, g);
100 }
101
102 template <typename Strategy>
103 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
104 {
105 geometry::expand(b, g, s);
106 }
107 };
108
109 template <typename Bounds, typename Geometry>
110 struct expand<Bounds, Geometry, box_tag, segment_tag>
111 {
112 static inline void apply(Bounds & b, Geometry const& g)
113 {
114 geometry::expand(b, g);
115 }
116
117 template <typename Strategy>
118 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
119 {
120 geometry::expand(b, geometry::return_envelope<Bounds>(g, s), s);
121 // requires additional strategy
122 //geometry::expand(b, g, s);
123 }
124 };
125
126
127 } // namespace dispatch
128
129
130 template <typename Bounds, typename Geometry, typename Strategy>
131 inline void expand(Bounds & b, Geometry const& g, Strategy const& s)
132 {
133 dispatch::expand<Bounds, Geometry>::apply(b, g, s);
134 }
135
136 template <typename Bounds, typename Geometry>
137 inline void expand(Bounds & b, Geometry const& g, default_strategy const& )
138 {
139 dispatch::expand<Bounds, Geometry>::apply(b, g);
140 }
141
142
143 namespace dispatch
144 {
145
146
147 template <typename Geometry,
148 typename Bounds,
149 typename TagGeometry = typename geometry::tag<Geometry>::type,
150 typename TagBounds = typename geometry::tag<Bounds>::type>
151 struct covered_by_bounds
152 {};
153
154 template <typename Geometry, typename Bounds>
155 struct covered_by_bounds<Geometry, Bounds, point_tag, box_tag>
156 {
157 static inline bool apply(Geometry const& g, Bounds & b)
158 {
159 return geometry::covered_by(g, b);
160 }
161
162 template <typename Strategy>
163 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
164 {
165 return geometry::covered_by(g, b, s);
166 }
167 };
168
169 template <typename Geometry, typename Bounds>
170 struct covered_by_bounds<Geometry, Bounds, box_tag, box_tag>
171 {
172 static inline bool apply(Geometry const& g, Bounds & b)
173 {
174 return geometry::covered_by(g, b);
175 }
176
177 template <typename Strategy>
178 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
179 {
180 return geometry::covered_by(g, b, s);
181 }
182 };
183
184 template <typename Geometry, typename Bounds>
185 struct covered_by_bounds<Geometry, Bounds, segment_tag, box_tag>
186 {
187 static inline bool apply(Geometry const& g, Bounds & b)
188 {
189 typedef typename point_type<Geometry>::type point_type;
190 typedef geometry::model::box<point_type> bounds_type;
191 typedef index::detail::bounded_view<Geometry, bounds_type, default_strategy> view_type;
192
193 return geometry::covered_by(view_type(g, default_strategy()), b);
194 }
195
196 template <typename Strategy>
197 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& strategy)
198 {
199 typedef typename point_type<Geometry>::type point_type;
200 typedef geometry::model::box<point_type> bounds_type;
201 typedef index::detail::bounded_view<Geometry, bounds_type, Strategy> view_type;
202
203 return geometry::covered_by(view_type(g, strategy), b, strategy);
204 }
205 };
206
207
208 } // namespace dispatch
209
210
211 template <typename Geometry, typename Bounds, typename Strategy>
212 inline bool covered_by_bounds(Geometry const& g, Bounds & b, Strategy const& s)
213 {
214 return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b, s);
215 }
216
217 template <typename Geometry, typename Bounds>
218 inline bool covered_by_bounds(Geometry const& g, Bounds & b, default_strategy const& )
219 {
220 return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b);
221 }
222
223
224 }}}} // namespace boost::geometry::index::detail
225
226
227 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP