1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
8 // This file was modified by Oracle on 2014, 2017.
9 // Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
25 #include <boost/variant/apply_visitor.hpp>
26 #include <boost/variant/static_visitor.hpp>
27 #include <boost/variant/variant_fwd.hpp>
29 #include <boost/geometry/algorithms/relate.hpp>
30 #include <boost/geometry/algorithms/detail/relate/relate_impl.hpp>
31 #include <boost/geometry/core/access.hpp>
32 #include <boost/geometry/geometries/concepts/check.hpp>
33 #include <boost/geometry/strategies/default_strategy.hpp>
36 namespace boost { namespace geometry
39 #ifndef DOXYGEN_NO_DISPATCH
48 typename Tag1 = typename tag<Geometry1>::type,
49 typename Tag2 = typename tag<Geometry2>::type
52 : detail::relate::relate_impl
54 detail::de9im::static_mask_crosses_type,
61 } // namespace dispatch
62 #endif // DOXYGEN_NO_DISPATCH
65 namespace resolve_strategy
70 template <typename Geometry1, typename Geometry2, typename Strategy>
71 static inline bool apply(Geometry1 const& geometry1,
72 Geometry2 const& geometry2,
73 Strategy const& strategy)
75 concepts::check<Geometry1 const>();
76 concepts::check<Geometry2 const>();
78 return dispatch::crosses<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy);
81 template <typename Geometry1, typename Geometry2>
82 static inline bool apply(Geometry1 const& geometry1,
83 Geometry2 const& geometry2,
86 typedef typename strategy::relate::services::default_strategy
90 >::type strategy_type;
92 return apply(geometry1, geometry2, strategy_type());
96 } // namespace resolve_strategy
99 namespace resolve_variant
101 template <typename Geometry1, typename Geometry2>
104 template <typename Strategy>
105 static inline bool apply(Geometry1 const& geometry1,
106 Geometry2 const& geometry2,
107 Strategy const& strategy)
109 return resolve_strategy::crosses::apply(geometry1, geometry2, strategy);
114 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
115 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
117 template <typename Strategy>
118 struct visitor: static_visitor<bool>
120 Geometry2 const& m_geometry2;
121 Strategy const& m_strategy;
123 visitor(Geometry2 const& geometry2, Strategy const& strategy)
124 : m_geometry2(geometry2)
125 , m_strategy(strategy)
128 template <typename Geometry1>
129 result_type operator()(Geometry1 const& geometry1) const
135 >::apply(geometry1, m_geometry2, m_strategy);
139 template <typename Strategy>
140 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
141 Geometry2 const& geometry2,
142 Strategy const& strategy)
144 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
149 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
150 struct crosses<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
152 template <typename Strategy>
153 struct visitor: static_visitor<bool>
155 Geometry1 const& m_geometry1;
156 Strategy const& m_strategy;
158 visitor(Geometry1 const& geometry1, Strategy const& strategy)
159 : m_geometry1(geometry1)
160 , m_strategy(strategy)
163 template <typename Geometry2>
164 result_type operator()(Geometry2 const& geometry2) const
170 >::apply(m_geometry1, geometry2, m_strategy);
174 template <typename Strategy>
175 static inline bool apply(Geometry1 const& geometry1,
176 variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
177 Strategy const& strategy)
179 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
184 template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)>
185 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> >
187 template <typename Strategy>
188 struct visitor: static_visitor<bool>
190 Strategy const& m_strategy;
192 visitor(Strategy const& strategy)
193 : m_strategy(strategy)
196 template <typename Geometry1, typename Geometry2>
197 result_type operator()(Geometry1 const& geometry1,
198 Geometry2 const& geometry2) const
204 >::apply(geometry1, geometry2, m_strategy);
208 template <typename Strategy>
209 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
210 variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
211 Strategy const& strategy)
213 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
217 } // namespace resolve_variant
221 \brief \brief_check2{crosses}
223 \tparam Geometry1 \tparam_geometry
224 \tparam Geometry2 \tparam_geometry
225 \tparam Strategy \tparam_strategy{Crosses}
226 \param geometry1 \param_geometry
227 \param geometry2 \param_geometry
228 \param strategy \param_strategy{crosses}
229 \return \return_check2{crosses}
231 \qbk{distinguish,with strategy}
232 \qbk{[include reference/algorithms/crosses.qbk]}
234 template <typename Geometry1, typename Geometry2, typename Strategy>
235 inline bool crosses(Geometry1 const& geometry1,
236 Geometry2 const& geometry2,
237 Strategy const& strategy)
239 return resolve_variant::crosses
242 >::apply(geometry1, geometry2, strategy);
246 \brief \brief_check2{crosses}
248 \tparam Geometry1 \tparam_geometry
249 \tparam Geometry2 \tparam_geometry
250 \param geometry1 \param_geometry
251 \param geometry2 \param_geometry
252 \return \return_check2{crosses}
254 \qbk{[include reference/algorithms/crosses.qbk]}
256 template <typename Geometry1, typename Geometry2>
257 inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2)
259 return resolve_variant::crosses
262 >::apply(geometry1, geometry2, default_strategy());
265 }} // namespace boost::geometry
267 #endif // BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP