]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/crosses.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / crosses.hpp
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 // Copyright (c) 2014 Samuel Debionne, Grenoble, France.
7
8 // This file was modified by Oracle on 2014-2021.
9 // Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
10
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
19
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
22
23 #include <cstddef>
24
25 #include <boost/variant/apply_visitor.hpp>
26 #include <boost/variant/static_visitor.hpp>
27 #include <boost/variant/variant_fwd.hpp>
28
29 #include <boost/geometry/algorithms/relate.hpp>
30 #include <boost/geometry/algorithms/detail/relate/relate_impl.hpp>
31 #include <boost/geometry/core/access.hpp>
32 #include <boost/geometry/geometries/concepts/check.hpp>
33 #include <boost/geometry/strategies/default_strategy.hpp>
34 #include <boost/geometry/strategies/detail.hpp>
35 #include <boost/geometry/strategies/relate/cartesian.hpp>
36 #include <boost/geometry/strategies/relate/geographic.hpp>
37 #include <boost/geometry/strategies/relate/spherical.hpp>
38
39
40 namespace boost { namespace geometry
41 {
42
43 #ifndef DOXYGEN_NO_DISPATCH
44 namespace dispatch
45 {
46
47
48 template
49 <
50 typename Geometry1,
51 typename Geometry2,
52 typename Tag1 = typename tag<Geometry1>::type,
53 typename Tag2 = typename tag<Geometry2>::type
54 >
55 struct crosses
56 : detail::relate::relate_impl
57 <
58 detail::de9im::static_mask_crosses_type,
59 Geometry1,
60 Geometry2
61 >
62 {};
63
64
65 } // namespace dispatch
66 #endif // DOXYGEN_NO_DISPATCH
67
68
69 namespace resolve_strategy
70 {
71
72 template
73 <
74 typename Strategy,
75 bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
76 >
77 struct crosses
78 {
79 template <typename Geometry1, typename Geometry2>
80 static inline bool apply(Geometry1 const& geometry1,
81 Geometry2 const& geometry2,
82 Strategy const& strategy)
83 {
84 concepts::check<Geometry1 const>();
85 concepts::check<Geometry2 const>();
86
87 return dispatch::crosses
88 <
89 Geometry1, Geometry2
90 >::apply(geometry1, geometry2, strategy);
91 }
92 };
93
94 template <typename Strategy>
95 struct crosses<Strategy, false>
96 {
97 template <typename Geometry1, typename Geometry2>
98 static inline bool apply(Geometry1 const& geometry1,
99 Geometry2 const& geometry2,
100 Strategy const& strategy)
101 {
102 //using strategies::crosses::services::strategy_converter;
103 using strategies::relate::services::strategy_converter;
104 return crosses
105 <
106 decltype(strategy_converter<Strategy>::get(strategy))
107 >::apply(geometry1, geometry2,
108 strategy_converter<Strategy>::get(strategy));
109 }
110 };
111
112 template <>
113 struct crosses<default_strategy, false>
114 {
115 template <typename Geometry1, typename Geometry2>
116 static inline bool apply(Geometry1 const& geometry1,
117 Geometry2 const& geometry2,
118 default_strategy)
119 {
120 //typedef typename strategies::crosses::services::default_strategy
121 typedef typename strategies::relate::services::default_strategy
122 <
123 Geometry1,
124 Geometry2
125 >::type strategy_type;
126
127 return crosses
128 <
129 strategy_type
130 >::apply(geometry1, geometry2, strategy_type());
131 }
132 };
133
134 } // namespace resolve_strategy
135
136
137 namespace resolve_variant
138 {
139 template <typename Geometry1, typename Geometry2>
140 struct crosses
141 {
142 template <typename Strategy>
143 static inline bool apply(Geometry1 const& geometry1,
144 Geometry2 const& geometry2,
145 Strategy const& strategy)
146 {
147 return resolve_strategy::crosses
148 <
149 Strategy
150 >::apply(geometry1, geometry2, strategy);
151 }
152 };
153
154
155 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
156 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
157 {
158 template <typename Strategy>
159 struct visitor: static_visitor<bool>
160 {
161 Geometry2 const& m_geometry2;
162 Strategy const& m_strategy;
163
164 visitor(Geometry2 const& geometry2, Strategy const& strategy)
165 : m_geometry2(geometry2)
166 , m_strategy(strategy)
167 {}
168
169 template <typename Geometry1>
170 result_type operator()(Geometry1 const& geometry1) const
171 {
172 return crosses
173 <
174 Geometry1,
175 Geometry2
176 >::apply(geometry1, m_geometry2, m_strategy);
177 }
178 };
179
180 template <typename Strategy>
181 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
182 Geometry2 const& geometry2,
183 Strategy const& strategy)
184 {
185 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
186 }
187 };
188
189
190 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
191 struct crosses<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
192 {
193 template <typename Strategy>
194 struct visitor: static_visitor<bool>
195 {
196 Geometry1 const& m_geometry1;
197 Strategy const& m_strategy;
198
199 visitor(Geometry1 const& geometry1, Strategy const& strategy)
200 : m_geometry1(geometry1)
201 , m_strategy(strategy)
202 {}
203
204 template <typename Geometry2>
205 result_type operator()(Geometry2 const& geometry2) const
206 {
207 return crosses
208 <
209 Geometry1,
210 Geometry2
211 >::apply(m_geometry1, geometry2, m_strategy);
212 }
213 };
214
215 template <typename Strategy>
216 static inline bool apply(Geometry1 const& geometry1,
217 variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
218 Strategy const& strategy)
219 {
220 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
221 }
222 };
223
224
225 template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)>
226 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> >
227 {
228 template <typename Strategy>
229 struct visitor: static_visitor<bool>
230 {
231 Strategy const& m_strategy;
232
233 visitor(Strategy const& strategy)
234 : m_strategy(strategy)
235 {}
236
237 template <typename Geometry1, typename Geometry2>
238 result_type operator()(Geometry1 const& geometry1,
239 Geometry2 const& geometry2) const
240 {
241 return crosses
242 <
243 Geometry1,
244 Geometry2
245 >::apply(geometry1, geometry2, m_strategy);
246 }
247 };
248
249 template <typename Strategy>
250 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
251 variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
252 Strategy const& strategy)
253 {
254 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
255 }
256 };
257
258 } // namespace resolve_variant
259
260
261 /*!
262 \brief \brief_check2{crosses}
263 \ingroup crosses
264 \tparam Geometry1 \tparam_geometry
265 \tparam Geometry2 \tparam_geometry
266 \tparam Strategy \tparam_strategy{Crosses}
267 \param geometry1 \param_geometry
268 \param geometry2 \param_geometry
269 \param strategy \param_strategy{crosses}
270 \return \return_check2{crosses}
271
272 \qbk{distinguish,with strategy}
273 \qbk{[include reference/algorithms/crosses.qbk]}
274 */
275 template <typename Geometry1, typename Geometry2, typename Strategy>
276 inline bool crosses(Geometry1 const& geometry1,
277 Geometry2 const& geometry2,
278 Strategy const& strategy)
279 {
280 return resolve_variant::crosses
281 <
282 Geometry1, Geometry2
283 >::apply(geometry1, geometry2, strategy);
284 }
285
286 /*!
287 \brief \brief_check2{crosses}
288 \ingroup crosses
289 \tparam Geometry1 \tparam_geometry
290 \tparam Geometry2 \tparam_geometry
291 \param geometry1 \param_geometry
292 \param geometry2 \param_geometry
293 \return \return_check2{crosses}
294
295 \qbk{[include reference/algorithms/crosses.qbk]}
296 \qbk{
297 [heading Examples]
298 [crosses]
299 [crosses_output]
300 }
301 */
302 template <typename Geometry1, typename Geometry2>
303 inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2)
304 {
305 return resolve_variant::crosses
306 <
307 Geometry1, Geometry2
308 >::apply(geometry1, geometry2, default_strategy());
309 }
310
311 }} // namespace boost::geometry
312
313 #endif // BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP