Chris@102
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@102
|
2
|
Chris@102
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@102
|
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@102
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@102
|
6 // Copyright (c) 2014 Samuel Debionne, Grenoble, France.
|
Chris@102
|
7
|
Chris@102
|
8 // This file was modified by Oracle on 2014.
|
Chris@102
|
9 // Modifications copyright (c) 2014 Oracle and/or its affiliates.
|
Chris@102
|
10
|
Chris@102
|
11 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@102
|
12 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@102
|
13
|
Chris@102
|
14 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@102
|
15 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
16 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
17
|
Chris@102
|
18 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
Chris@102
|
19
|
Chris@102
|
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
|
Chris@102
|
21 #define BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
|
Chris@102
|
22
|
Chris@102
|
23 #include <cstddef>
|
Chris@102
|
24
|
Chris@102
|
25 #include <boost/variant/apply_visitor.hpp>
|
Chris@102
|
26 #include <boost/variant/static_visitor.hpp>
|
Chris@102
|
27 #include <boost/variant/variant_fwd.hpp>
|
Chris@102
|
28
|
Chris@102
|
29 #include <boost/geometry/core/access.hpp>
|
Chris@102
|
30
|
Chris@102
|
31 #include <boost/geometry/geometries/concepts/check.hpp>
|
Chris@102
|
32
|
Chris@102
|
33 #include <boost/geometry/algorithms/detail/relate/relate.hpp>
|
Chris@102
|
34
|
Chris@102
|
35 namespace boost { namespace geometry
|
Chris@102
|
36 {
|
Chris@102
|
37
|
Chris@102
|
38 #ifndef DOXYGEN_NO_DISPATCH
|
Chris@102
|
39 namespace dispatch
|
Chris@102
|
40 {
|
Chris@102
|
41
|
Chris@102
|
42
|
Chris@102
|
43 template
|
Chris@102
|
44 <
|
Chris@102
|
45 typename Geometry1,
|
Chris@102
|
46 typename Geometry2,
|
Chris@102
|
47 typename Tag1 = typename tag<Geometry1>::type,
|
Chris@102
|
48 typename Tag2 = typename tag<Geometry2>::type
|
Chris@102
|
49 >
|
Chris@102
|
50 struct crosses
|
Chris@102
|
51 : detail::relate::relate_base
|
Chris@102
|
52 <
|
Chris@102
|
53 detail::relate::static_mask_crosses_type,
|
Chris@102
|
54 Geometry1,
|
Chris@102
|
55 Geometry2
|
Chris@102
|
56 >
|
Chris@102
|
57 {};
|
Chris@102
|
58
|
Chris@102
|
59
|
Chris@102
|
60 } // namespace dispatch
|
Chris@102
|
61 #endif // DOXYGEN_NO_DISPATCH
|
Chris@102
|
62
|
Chris@102
|
63
|
Chris@102
|
64 namespace resolve_variant
|
Chris@102
|
65 {
|
Chris@102
|
66 template <typename Geometry1, typename Geometry2>
|
Chris@102
|
67 struct crosses
|
Chris@102
|
68 {
|
Chris@102
|
69 static inline bool
|
Chris@102
|
70 apply(
|
Chris@102
|
71 const Geometry1& geometry1,
|
Chris@102
|
72 const Geometry2& geometry2)
|
Chris@102
|
73 {
|
Chris@102
|
74 concept::check<Geometry1 const>();
|
Chris@102
|
75 concept::check<Geometry2 const>();
|
Chris@102
|
76
|
Chris@102
|
77 return dispatch::crosses<Geometry1, Geometry2>::apply(geometry1, geometry2);
|
Chris@102
|
78 }
|
Chris@102
|
79 };
|
Chris@102
|
80
|
Chris@102
|
81
|
Chris@102
|
82 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
|
Chris@102
|
83 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
|
Chris@102
|
84 {
|
Chris@102
|
85 struct visitor: static_visitor<bool>
|
Chris@102
|
86 {
|
Chris@102
|
87 Geometry2 const& m_geometry2;
|
Chris@102
|
88
|
Chris@102
|
89 visitor(Geometry2 const& geometry2)
|
Chris@102
|
90 : m_geometry2(geometry2)
|
Chris@102
|
91 {}
|
Chris@102
|
92
|
Chris@102
|
93 template <typename Geometry1>
|
Chris@102
|
94 result_type operator()(Geometry1 const& geometry1) const
|
Chris@102
|
95 {
|
Chris@102
|
96 return crosses
|
Chris@102
|
97 <
|
Chris@102
|
98 Geometry1,
|
Chris@102
|
99 Geometry2
|
Chris@102
|
100 >::apply
|
Chris@102
|
101 (geometry1, m_geometry2);
|
Chris@102
|
102 }
|
Chris@102
|
103 };
|
Chris@102
|
104
|
Chris@102
|
105 static inline bool
|
Chris@102
|
106 apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
|
Chris@102
|
107 Geometry2 const& geometry2)
|
Chris@102
|
108 {
|
Chris@102
|
109 return apply_visitor(visitor(geometry2), geometry1);
|
Chris@102
|
110 }
|
Chris@102
|
111 };
|
Chris@102
|
112
|
Chris@102
|
113
|
Chris@102
|
114 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
Chris@102
|
115 struct crosses<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
Chris@102
|
116 {
|
Chris@102
|
117 struct visitor: static_visitor<bool>
|
Chris@102
|
118 {
|
Chris@102
|
119 Geometry1 const& m_geometry1;
|
Chris@102
|
120
|
Chris@102
|
121 visitor(Geometry1 const& geometry1)
|
Chris@102
|
122 : m_geometry1(geometry1)
|
Chris@102
|
123 {}
|
Chris@102
|
124
|
Chris@102
|
125 template <typename Geometry2>
|
Chris@102
|
126 result_type operator()(Geometry2 const& geometry2) const
|
Chris@102
|
127 {
|
Chris@102
|
128 return crosses
|
Chris@102
|
129 <
|
Chris@102
|
130 Geometry1,
|
Chris@102
|
131 Geometry2
|
Chris@102
|
132 >::apply
|
Chris@102
|
133 (m_geometry1, geometry2);
|
Chris@102
|
134 }
|
Chris@102
|
135 };
|
Chris@102
|
136
|
Chris@102
|
137 static inline bool
|
Chris@102
|
138 apply(
|
Chris@102
|
139 Geometry1 const& geometry1,
|
Chris@102
|
140 const variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry2)
|
Chris@102
|
141 {
|
Chris@102
|
142 return apply_visitor(visitor(geometry1), geometry2);
|
Chris@102
|
143 }
|
Chris@102
|
144 };
|
Chris@102
|
145
|
Chris@102
|
146
|
Chris@102
|
147 template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)>
|
Chris@102
|
148 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> >
|
Chris@102
|
149 {
|
Chris@102
|
150 struct visitor: static_visitor<bool>
|
Chris@102
|
151 {
|
Chris@102
|
152 template <typename Geometry1, typename Geometry2>
|
Chris@102
|
153 result_type operator()(
|
Chris@102
|
154 Geometry1 const& geometry1,
|
Chris@102
|
155 Geometry2 const& geometry2) const
|
Chris@102
|
156 {
|
Chris@102
|
157 return crosses
|
Chris@102
|
158 <
|
Chris@102
|
159 Geometry1,
|
Chris@102
|
160 Geometry2
|
Chris@102
|
161 >::apply
|
Chris@102
|
162 (geometry1, geometry2);
|
Chris@102
|
163 }
|
Chris@102
|
164 };
|
Chris@102
|
165
|
Chris@102
|
166 static inline bool
|
Chris@102
|
167 apply(
|
Chris@102
|
168 const variant<BOOST_VARIANT_ENUM_PARAMS(T1)>& geometry1,
|
Chris@102
|
169 const variant<BOOST_VARIANT_ENUM_PARAMS(T2)>& geometry2)
|
Chris@102
|
170 {
|
Chris@102
|
171 return apply_visitor(visitor(), geometry1, geometry2);
|
Chris@102
|
172 }
|
Chris@102
|
173 };
|
Chris@102
|
174
|
Chris@102
|
175 } // namespace resolve_variant
|
Chris@102
|
176
|
Chris@102
|
177
|
Chris@102
|
178 /*!
|
Chris@102
|
179 \brief \brief_check2{crosses}
|
Chris@102
|
180 \ingroup crosses
|
Chris@102
|
181 \tparam Geometry1 \tparam_geometry
|
Chris@102
|
182 \tparam Geometry2 \tparam_geometry
|
Chris@102
|
183 \param geometry1 \param_geometry
|
Chris@102
|
184 \param geometry2 \param_geometry
|
Chris@102
|
185 \return \return_check2{crosses}
|
Chris@102
|
186
|
Chris@102
|
187 \qbk{[include reference/algorithms/crosses.qbk]}
|
Chris@102
|
188 */
|
Chris@102
|
189 template <typename Geometry1, typename Geometry2>
|
Chris@102
|
190 inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2)
|
Chris@102
|
191 {
|
Chris@102
|
192 return resolve_variant::crosses<Geometry1, Geometry2>::apply(geometry1, geometry2);
|
Chris@102
|
193 }
|
Chris@102
|
194
|
Chris@102
|
195 }} // namespace boost::geometry
|
Chris@102
|
196
|
Chris@102
|
197 #endif // BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
|