1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
8 // This file was modified by Oracle on 2013-2017.
9 // Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
21 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
26 #include <boost/variant/apply_visitor.hpp>
27 #include <boost/variant/static_visitor.hpp>
28 #include <boost/variant/variant_fwd.hpp>
30 #include <boost/geometry/algorithms/detail/relate/interface.hpp>
31 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
33 #include <boost/geometry/geometries/concepts/check.hpp>
35 #include <boost/geometry/strategies/disjoint.hpp>
38 namespace boost { namespace geometry
41 namespace resolve_strategy
46 template <typename Geometry1, typename Geometry2, typename Strategy>
47 static inline bool apply(Geometry1 const& geometry1,
48 Geometry2 const& geometry2,
49 Strategy const& strategy)
51 return dispatch::disjoint
54 >::apply(geometry1, geometry2, strategy);
57 template <typename Geometry1, typename Geometry2>
58 static inline bool apply(Geometry1 const& geometry1,
59 Geometry2 const& geometry2,
62 typedef typename strategy::disjoint::services::default_strategy
65 >::type strategy_type;
67 return dispatch::disjoint
70 >::apply(geometry1, geometry2, strategy_type());
74 } // namespace resolve_strategy
77 namespace resolve_variant {
79 template <typename Geometry1, typename Geometry2>
82 template <typename Strategy>
83 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
85 concepts::check_concepts_and_equal_dimensions
91 return resolve_strategy::disjoint::apply(geometry1, geometry2, strategy);
95 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
96 struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
98 template <typename Strategy>
99 struct visitor: boost::static_visitor<bool>
101 Geometry2 const& m_geometry2;
102 Strategy const& m_strategy;
104 visitor(Geometry2 const& geometry2, Strategy const& strategy)
105 : m_geometry2(geometry2)
106 , m_strategy(strategy)
109 template <typename Geometry1>
110 bool operator()(Geometry1 const& geometry1) const
112 return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2, m_strategy);
116 template <typename Strategy>
117 static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
118 Geometry2 const& geometry2,
119 Strategy const& strategy)
121 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
125 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
126 struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
128 template <typename Strategy>
129 struct visitor: boost::static_visitor<bool>
131 Geometry1 const& m_geometry1;
132 Strategy const& m_strategy;
134 visitor(Geometry1 const& geometry1, Strategy const& strategy)
135 : m_geometry1(geometry1)
136 , m_strategy(strategy)
139 template <typename Geometry2>
140 bool operator()(Geometry2 const& geometry2) const
142 return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2, m_strategy);
146 template <typename Strategy>
147 static inline bool apply(Geometry1 const& geometry1,
148 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
149 Strategy const& strategy)
151 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
157 BOOST_VARIANT_ENUM_PARAMS(typename T1),
158 BOOST_VARIANT_ENUM_PARAMS(typename T2)
162 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
163 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
166 template <typename Strategy>
167 struct visitor: boost::static_visitor<bool>
169 Strategy const& m_strategy;
171 visitor(Strategy const& strategy)
172 : m_strategy(strategy)
175 template <typename Geometry1, typename Geometry2>
176 bool operator()(Geometry1 const& geometry1,
177 Geometry2 const& geometry2) const
179 return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2, m_strategy);
183 template <typename Strategy>
184 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)
188 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
192 } // namespace resolve_variant
196 \brief \brief_check2{are 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}
206 \qbk{distinguish,with strategy}
207 \qbk{[include reference/algorithms/disjoint.qbk]}
209 template <typename Geometry1, typename Geometry2, typename Strategy>
210 inline bool disjoint(Geometry1 const& geometry1,
211 Geometry2 const& geometry2,
212 Strategy const& strategy)
214 return resolve_variant::disjoint
217 >::apply(geometry1, geometry2, strategy);
222 \brief \brief_check2{are 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}
230 \qbk{[include reference/algorithms/disjoint.qbk]}
237 template <typename Geometry1, typename Geometry2>
238 inline bool disjoint(Geometry1 const& geometry1,
239 Geometry2 const& geometry2)
241 return resolve_variant::disjoint
244 >::apply(geometry1, geometry2, default_strategy());
248 }} // namespace boost::geometry
251 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP