• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
6 // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
7 
8 // This file was modified by Oracle on 2013-2017.
9 // Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
10 
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 
17 // Use, modification and distribution is subject to the Boost Software License,
18 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
20 
21 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
23 
24 #include <cstddef>
25 
26 #include <boost/variant/apply_visitor.hpp>
27 #include <boost/variant/static_visitor.hpp>
28 #include <boost/variant/variant_fwd.hpp>
29 
30 #include <boost/geometry/algorithms/detail/relate/interface.hpp>
31 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
32 
33 #include <boost/geometry/geometries/concepts/check.hpp>
34 
35 #include <boost/geometry/strategies/disjoint.hpp>
36 
37 
38 namespace boost { namespace geometry
39 {
40 
41 namespace resolve_strategy
42 {
43 
44 struct disjoint
45 {
46     template <typename Geometry1, typename Geometry2, typename Strategy>
applyboost::geometry::resolve_strategy::disjoint47     static inline bool apply(Geometry1 const& geometry1,
48                              Geometry2 const& geometry2,
49                              Strategy const& strategy)
50     {
51         return dispatch::disjoint
52                 <
53                     Geometry1, Geometry2
54                 >::apply(geometry1, geometry2, strategy);
55     }
56 
57     template <typename Geometry1, typename Geometry2>
applyboost::geometry::resolve_strategy::disjoint58     static inline bool apply(Geometry1 const& geometry1,
59                              Geometry2 const& geometry2,
60                              default_strategy)
61     {
62         typedef typename strategy::disjoint::services::default_strategy
63             <
64                 Geometry1, Geometry2
65             >::type strategy_type;
66 
67         return dispatch::disjoint
68                 <
69                     Geometry1, Geometry2
70                 >::apply(geometry1, geometry2, strategy_type());
71     }
72 };
73 
74 } // namespace resolve_strategy
75 
76 
77 namespace resolve_variant {
78 
79 template <typename Geometry1, typename Geometry2>
80 struct disjoint
81 {
82     template <typename Strategy>
applyboost::geometry::resolve_variant::disjoint83     static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
84     {
85         concepts::check_concepts_and_equal_dimensions
86             <
87                 Geometry1 const,
88                 Geometry2 const
89             >();
90 
91         return resolve_strategy::disjoint::apply(geometry1, geometry2, strategy);
92     }
93 };
94 
95 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
96 struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
97 {
98     template <typename Strategy>
99     struct visitor: boost::static_visitor<bool>
100     {
101         Geometry2 const& m_geometry2;
102         Strategy const& m_strategy;
103 
visitorboost::geometry::resolve_variant::disjoint::visitor104         visitor(Geometry2 const& geometry2, Strategy const& strategy)
105             : m_geometry2(geometry2)
106             , m_strategy(strategy)
107         {}
108 
109         template <typename Geometry1>
operator ()boost::geometry::resolve_variant::disjoint::visitor110         bool operator()(Geometry1 const& geometry1) const
111         {
112             return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2, m_strategy);
113         }
114     };
115 
116     template <typename Strategy>
applyboost::geometry::resolve_variant::disjoint117     static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
118                              Geometry2 const& geometry2,
119                              Strategy const& strategy)
120     {
121         return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
122     }
123 };
124 
125 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
126 struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
127 {
128     template <typename Strategy>
129     struct visitor: boost::static_visitor<bool>
130     {
131         Geometry1 const& m_geometry1;
132         Strategy const& m_strategy;
133 
visitorboost::geometry::resolve_variant::disjoint::visitor134         visitor(Geometry1 const& geometry1, Strategy const& strategy)
135             : m_geometry1(geometry1)
136             , m_strategy(strategy)
137         {}
138 
139         template <typename Geometry2>
operator ()boost::geometry::resolve_variant::disjoint::visitor140         bool operator()(Geometry2 const& geometry2) const
141         {
142             return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2, m_strategy);
143         }
144     };
145 
146     template <typename Strategy>
applyboost::geometry::resolve_variant::disjoint147     static inline bool apply(Geometry1 const& geometry1,
148                              boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
149                              Strategy const& strategy)
150     {
151         return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
152     }
153 };
154 
155 template
156 <
157     BOOST_VARIANT_ENUM_PARAMS(typename T1),
158     BOOST_VARIANT_ENUM_PARAMS(typename T2)
159 >
160 struct disjoint
161     <
162         boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
163         boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
164     >
165 {
166     template <typename Strategy>
167     struct visitor: boost::static_visitor<bool>
168     {
169         Strategy const& m_strategy;
170 
visitorboost::geometry::resolve_variant::disjoint::visitor171         visitor(Strategy const& strategy)
172             : m_strategy(strategy)
173         {}
174 
175         template <typename Geometry1, typename Geometry2>
operator ()boost::geometry::resolve_variant::disjoint::visitor176         bool operator()(Geometry1 const& geometry1,
177                         Geometry2 const& geometry2) const
178         {
179             return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2, m_strategy);
180         }
181     };
182 
183     template <typename Strategy>
applyboost::geometry::resolve_variant::disjoint184     static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
185                              boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
186                              Strategy const& strategy)
187     {
188         return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
189     }
190 };
191 
192 } // namespace resolve_variant
193 
194 
195 /*!
196 \brief \brief_check2{are disjoint}
197 \ingroup disjoint
198 \tparam Geometry1 \tparam_geometry
199 \tparam Geometry2 \tparam_geometry
200 \tparam Strategy \tparam_strategy{Disjoint}
201 \param geometry1 \param_geometry
202 \param geometry2 \param_geometry
203 \param strategy \param_strategy{disjoint}
204 \return \return_check2{are disjoint}
205 
206 \qbk{distinguish,with strategy}
207 \qbk{[include reference/algorithms/disjoint.qbk]}
208 */
209 template <typename Geometry1, typename Geometry2, typename Strategy>
disjoint(Geometry1 const & geometry1,Geometry2 const & geometry2,Strategy const & strategy)210 inline bool disjoint(Geometry1 const& geometry1,
211                      Geometry2 const& geometry2,
212                      Strategy const& strategy)
213 {
214     return resolve_variant::disjoint
215             <
216                 Geometry1, Geometry2
217             >::apply(geometry1, geometry2, strategy);
218 }
219 
220 
221 /*!
222 \brief \brief_check2{are disjoint}
223 \ingroup disjoint
224 \tparam Geometry1 \tparam_geometry
225 \tparam Geometry2 \tparam_geometry
226 \param geometry1 \param_geometry
227 \param geometry2 \param_geometry
228 \return \return_check2{are disjoint}
229 
230 \qbk{[include reference/algorithms/disjoint.qbk]}
231 \qbk{
232 [heading Examples]
233 [disjoint]
234 [disjoint_output]
235 }
236 */
237 template <typename Geometry1, typename Geometry2>
disjoint(Geometry1 const & geometry1,Geometry2 const & geometry2)238 inline bool disjoint(Geometry1 const& geometry1,
239                      Geometry2 const& geometry2)
240 {
241     return resolve_variant::disjoint
242             <
243                 Geometry1, Geometry2
244             >::apply(geometry1, geometry2, default_strategy());
245 }
246 
247 
248 }} // namespace boost::geometry
249 
250 
251 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
252