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