]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/crosses.hpp
update sources to v12.2.3
[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, 2017.
9 // Modifications copyright (c) 2014-2017 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
35
36 namespace boost { namespace geometry
37 {
38
39 #ifndef DOXYGEN_NO_DISPATCH
40 namespace dispatch
41 {
42
43
44 template
45 <
46 typename Geometry1,
47 typename Geometry2,
48 typename Tag1 = typename tag<Geometry1>::type,
49 typename Tag2 = typename tag<Geometry2>::type
50 >
51 struct crosses
52 : detail::relate::relate_impl
53 <
54 detail::de9im::static_mask_crosses_type,
55 Geometry1,
56 Geometry2
57 >
58 {};
59
60
61 } // namespace dispatch
62 #endif // DOXYGEN_NO_DISPATCH
63
64
65 namespace resolve_strategy
66 {
67
68 struct crosses
69 {
70 template <typename Geometry1, typename Geometry2, typename Strategy>
71 static inline bool apply(Geometry1 const& geometry1,
72 Geometry2 const& geometry2,
73 Strategy const& strategy)
74 {
75 concepts::check<Geometry1 const>();
76 concepts::check<Geometry2 const>();
77
78 return dispatch::crosses<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy);
79 }
80
81 template <typename Geometry1, typename Geometry2>
82 static inline bool apply(Geometry1 const& geometry1,
83 Geometry2 const& geometry2,
84 default_strategy)
85 {
86 typedef typename strategy::relate::services::default_strategy
87 <
88 Geometry1,
89 Geometry2
90 >::type strategy_type;
91
92 return apply(geometry1, geometry2, strategy_type());
93 }
94 };
95
96 } // namespace resolve_strategy
97
98
99 namespace resolve_variant
100 {
101 template <typename Geometry1, typename Geometry2>
102 struct crosses
103 {
104 template <typename Strategy>
105 static inline bool apply(Geometry1 const& geometry1,
106 Geometry2 const& geometry2,
107 Strategy const& strategy)
108 {
109 return resolve_strategy::crosses::apply(geometry1, geometry2, strategy);
110 }
111 };
112
113
114 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
115 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
116 {
117 template <typename Strategy>
118 struct visitor: static_visitor<bool>
119 {
120 Geometry2 const& m_geometry2;
121 Strategy const& m_strategy;
122
123 visitor(Geometry2 const& geometry2, Strategy const& strategy)
124 : m_geometry2(geometry2)
125 , m_strategy(strategy)
126 {}
127
128 template <typename Geometry1>
129 result_type operator()(Geometry1 const& geometry1) const
130 {
131 return crosses
132 <
133 Geometry1,
134 Geometry2
135 >::apply(geometry1, m_geometry2, m_strategy);
136 }
137 };
138
139 template <typename Strategy>
140 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
141 Geometry2 const& geometry2,
142 Strategy const& strategy)
143 {
144 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
145 }
146 };
147
148
149 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
150 struct crosses<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
151 {
152 template <typename Strategy>
153 struct visitor: static_visitor<bool>
154 {
155 Geometry1 const& m_geometry1;
156 Strategy const& m_strategy;
157
158 visitor(Geometry1 const& geometry1, Strategy const& strategy)
159 : m_geometry1(geometry1)
160 , m_strategy(strategy)
161 {}
162
163 template <typename Geometry2>
164 result_type operator()(Geometry2 const& geometry2) const
165 {
166 return crosses
167 <
168 Geometry1,
169 Geometry2
170 >::apply(m_geometry1, geometry2, m_strategy);
171 }
172 };
173
174 template <typename Strategy>
175 static inline bool apply(Geometry1 const& geometry1,
176 variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
177 Strategy const& strategy)
178 {
179 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
180 }
181 };
182
183
184 template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)>
185 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> >
186 {
187 template <typename Strategy>
188 struct visitor: static_visitor<bool>
189 {
190 Strategy const& m_strategy;
191
192 visitor(Strategy const& strategy)
193 : m_strategy(strategy)
194 {}
195
196 template <typename Geometry1, typename Geometry2>
197 result_type operator()(Geometry1 const& geometry1,
198 Geometry2 const& geometry2) const
199 {
200 return crosses
201 <
202 Geometry1,
203 Geometry2
204 >::apply(geometry1, geometry2, m_strategy);
205 }
206 };
207
208 template <typename Strategy>
209 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
210 variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
211 Strategy const& strategy)
212 {
213 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
214 }
215 };
216
217 } // namespace resolve_variant
218
219
220 /*!
221 \brief \brief_check2{crosses}
222 \ingroup crosses
223 \tparam Geometry1 \tparam_geometry
224 \tparam Geometry2 \tparam_geometry
225 \tparam Strategy \tparam_strategy{Crosses}
226 \param geometry1 \param_geometry
227 \param geometry2 \param_geometry
228 \param strategy \param_strategy{crosses}
229 \return \return_check2{crosses}
230
231 \qbk{distinguish,with strategy}
232 \qbk{[include reference/algorithms/crosses.qbk]}
233 */
234 template <typename Geometry1, typename Geometry2, typename Strategy>
235 inline bool crosses(Geometry1 const& geometry1,
236 Geometry2 const& geometry2,
237 Strategy const& strategy)
238 {
239 return resolve_variant::crosses
240 <
241 Geometry1, Geometry2
242 >::apply(geometry1, geometry2, strategy);
243 }
244
245 /*!
246 \brief \brief_check2{crosses}
247 \ingroup crosses
248 \tparam Geometry1 \tparam_geometry
249 \tparam Geometry2 \tparam_geometry
250 \param geometry1 \param_geometry
251 \param geometry2 \param_geometry
252 \return \return_check2{crosses}
253
254 \qbk{[include reference/algorithms/crosses.qbk]}
255 */
256 template <typename Geometry1, typename Geometry2>
257 inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2)
258 {
259 return resolve_variant::crosses
260 <
261 Geometry1, Geometry2
262 >::apply(geometry1, geometry2, default_strategy());
263 }
264
265 }} // namespace boost::geometry
266
267 #endif // BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP