]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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. | |
9 | // Modifications copyright (c) 2014 Oracle and/or its affiliates. | |
10 | ||
11 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
12 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
13 | ||
14 | // Use, modification and distribution is subject to the Boost Software License, | |
15 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
16 | // http://www.boost.org/LICENSE_1_0.txt) | |
17 | ||
18 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
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/core/access.hpp> | |
30 | ||
31 | #include <boost/geometry/geometries/concepts/check.hpp> | |
32 | ||
33 | #include <boost/geometry/algorithms/relate.hpp> | |
34 | #include <boost/geometry/algorithms/detail/relate/relate_impl.hpp> | |
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_variant | |
66 | { | |
67 | template <typename Geometry1, typename Geometry2> | |
68 | struct crosses | |
69 | { | |
70 | static inline bool | |
71 | apply( | |
72 | const Geometry1& geometry1, | |
73 | const Geometry2& geometry2) | |
74 | { | |
75 | concepts::check<Geometry1 const>(); | |
76 | concepts::check<Geometry2 const>(); | |
77 | ||
78 | return dispatch::crosses<Geometry1, Geometry2>::apply(geometry1, geometry2); | |
79 | } | |
80 | }; | |
81 | ||
82 | ||
83 | template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2> | |
84 | struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2> | |
85 | { | |
86 | struct visitor: static_visitor<bool> | |
87 | { | |
88 | Geometry2 const& m_geometry2; | |
89 | ||
90 | visitor(Geometry2 const& geometry2) | |
91 | : m_geometry2(geometry2) | |
92 | {} | |
93 | ||
94 | template <typename Geometry1> | |
95 | result_type operator()(Geometry1 const& geometry1) const | |
96 | { | |
97 | return crosses | |
98 | < | |
99 | Geometry1, | |
100 | Geometry2 | |
101 | >::apply(geometry1, m_geometry2); | |
102 | } | |
103 | }; | |
104 | ||
105 | static inline bool | |
106 | apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1, | |
107 | Geometry2 const& geometry2) | |
108 | { | |
109 | return boost::apply_visitor(visitor(geometry2), geometry1); | |
110 | } | |
111 | }; | |
112 | ||
113 | ||
114 | template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)> | |
115 | struct crosses<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> > | |
116 | { | |
117 | struct visitor: static_visitor<bool> | |
118 | { | |
119 | Geometry1 const& m_geometry1; | |
120 | ||
121 | visitor(Geometry1 const& geometry1) | |
122 | : m_geometry1(geometry1) | |
123 | {} | |
124 | ||
125 | template <typename Geometry2> | |
126 | result_type operator()(Geometry2 const& geometry2) const | |
127 | { | |
128 | return crosses | |
129 | < | |
130 | Geometry1, | |
131 | Geometry2 | |
132 | >::apply(m_geometry1, geometry2); | |
133 | } | |
134 | }; | |
135 | ||
136 | static inline bool | |
137 | apply(Geometry1 const& geometry1, | |
138 | const variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry2) | |
139 | { | |
140 | return boost::apply_visitor(visitor(geometry1), geometry2); | |
141 | } | |
142 | }; | |
143 | ||
144 | ||
145 | template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)> | |
146 | struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> > | |
147 | { | |
148 | struct visitor: static_visitor<bool> | |
149 | { | |
150 | template <typename Geometry1, typename Geometry2> | |
151 | result_type operator()(Geometry1 const& geometry1, | |
152 | Geometry2 const& geometry2) const | |
153 | { | |
154 | return crosses | |
155 | < | |
156 | Geometry1, | |
157 | Geometry2 | |
158 | >::apply(geometry1, geometry2); | |
159 | } | |
160 | }; | |
161 | ||
162 | static inline bool | |
163 | apply(const variant<BOOST_VARIANT_ENUM_PARAMS(T1)>& geometry1, | |
164 | const variant<BOOST_VARIANT_ENUM_PARAMS(T2)>& geometry2) | |
165 | { | |
166 | return boost::apply_visitor(visitor(), geometry1, geometry2); | |
167 | } | |
168 | }; | |
169 | ||
170 | } // namespace resolve_variant | |
171 | ||
172 | ||
173 | /*! | |
174 | \brief \brief_check2{crosses} | |
175 | \ingroup crosses | |
176 | \tparam Geometry1 \tparam_geometry | |
177 | \tparam Geometry2 \tparam_geometry | |
178 | \param geometry1 \param_geometry | |
179 | \param geometry2 \param_geometry | |
180 | \return \return_check2{crosses} | |
181 | ||
182 | \qbk{[include reference/algorithms/crosses.qbk]} | |
183 | */ | |
184 | template <typename Geometry1, typename Geometry2> | |
185 | inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2) | |
186 | { | |
187 | return resolve_variant::crosses<Geometry1, Geometry2>::apply(geometry1, geometry2); | |
188 | } | |
189 | ||
190 | }} // namespace boost::geometry | |
191 | ||
192 | #endif // BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP |