Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:50:14

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2014-2022.
0008 // Modifications copyright (c) 2014-2022 Oracle and/or its affiliates.
0009 
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
0018 
0019 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAPS_INTERFACE_HPP
0020 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAPS_INTERFACE_HPP
0021 
0022 
0023 #include <cstddef>
0024 
0025 #include <boost/geometry/algorithms/not_implemented.hpp>
0026 
0027 #include <boost/geometry/geometries/adapted/boost_variant.hpp>
0028 #include <boost/geometry/geometries/concepts/check.hpp>
0029 
0030 #include <boost/geometry/algorithms/detail/relate/relate_impl.hpp>
0031 
0032 #include <boost/geometry/strategies/default_strategy.hpp>
0033 #include <boost/geometry/strategies/detail.hpp>
0034 #include <boost/geometry/strategies/relate/services.hpp>
0035 
0036 
0037 namespace boost { namespace geometry
0038 {
0039 
0040 #ifndef DOXYGEN_NO_DISPATCH
0041 namespace dispatch
0042 {
0043 
0044 
0045 template
0046 <
0047     typename Geometry1,
0048     typename Geometry2,
0049     typename Tag1 = tag_t<Geometry1>,
0050     typename Tag2 = tag_t<Geometry2>
0051 >
0052 struct overlaps
0053     : detail::relate::relate_impl
0054         <
0055             detail::de9im::static_mask_overlaps_type,
0056             Geometry1,
0057             Geometry2
0058         >
0059 {};
0060 
0061 
0062 } // namespace dispatch
0063 #endif // DOXYGEN_NO_DISPATCH
0064 
0065 
0066 namespace resolve_strategy
0067 {
0068 
0069 template
0070 <
0071     typename Strategy,
0072     bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
0073 >
0074 struct overlaps
0075 {
0076     template <typename Geometry1, typename Geometry2>
0077     static inline bool apply(Geometry1 const& geometry1,
0078                              Geometry2 const& geometry2,
0079                              Strategy const& strategy)
0080     {
0081         return dispatch::overlaps
0082             <
0083                 Geometry1, Geometry2
0084             >::apply(geometry1, geometry2, strategy);
0085     }
0086 };
0087 
0088 template <typename Strategy>
0089 struct overlaps<Strategy, false>
0090 {
0091     template <typename Geometry1, typename Geometry2>
0092     static inline bool apply(Geometry1 const& geometry1,
0093                              Geometry2 const& geometry2,
0094                              Strategy const& strategy)
0095     {
0096         using strategies::relate::services::strategy_converter;
0097         return dispatch::overlaps
0098             <
0099                 Geometry1, Geometry2
0100             >::apply(geometry1, geometry2,
0101                      strategy_converter<Strategy>::get(strategy));
0102     }
0103 };
0104 
0105 template <>
0106 struct overlaps<default_strategy, false>
0107 {
0108     template <typename Geometry1, typename Geometry2>
0109     static inline bool apply(Geometry1 const& geometry1,
0110                              Geometry2 const& geometry2,
0111                              default_strategy)
0112     {
0113         typedef typename strategies::relate::services::default_strategy
0114             <
0115                 Geometry1, Geometry2
0116             >::type strategy_type;
0117 
0118         return dispatch::overlaps
0119             <
0120                 Geometry1, Geometry2
0121             >::apply(geometry1, geometry2, strategy_type());
0122     }
0123 };
0124 
0125 } // namespace resolve_strategy
0126 
0127 
0128 namespace resolve_dynamic
0129 {
0130 
0131 template
0132 <
0133     typename Geometry1, typename Geometry2,
0134     typename Tag1 = geometry::tag_t<Geometry1>,
0135     typename Tag2 = geometry::tag_t<Geometry2>
0136 >
0137 struct overlaps
0138 {
0139     template <typename Strategy>
0140     static inline bool apply(Geometry1 const& geometry1,
0141                              Geometry2 const& geometry2,
0142                              Strategy const& strategy)
0143     {
0144         return resolve_strategy::overlaps
0145             <
0146                 Strategy
0147             >::apply(geometry1, geometry2, strategy);
0148     }
0149 };
0150 
0151 
0152 template <typename DynamicGeometry1, typename Geometry2, typename Tag2>
0153 struct overlaps<DynamicGeometry1, Geometry2, dynamic_geometry_tag, Tag2>
0154 {
0155     template <typename Strategy>
0156     static inline bool apply(DynamicGeometry1 const& geometry1,
0157                              Geometry2 const& geometry2,
0158                              Strategy const& strategy)
0159     {
0160         bool result = false;
0161         traits::visit<DynamicGeometry1>::apply([&](auto const& g1)
0162         {
0163             result = resolve_strategy::overlaps
0164                 <
0165                     Strategy
0166                 >::apply(g1, geometry2, strategy);
0167         }, geometry1);
0168         return result;
0169     }
0170 };
0171 
0172 
0173 template <typename Geometry1, typename DynamicGeometry2, typename Tag1>
0174 struct overlaps<Geometry1, DynamicGeometry2, Tag1, dynamic_geometry_tag>
0175 {
0176     template <typename Strategy>
0177     static inline bool apply(Geometry1 const& geometry1,
0178                              DynamicGeometry2 const& geometry2,
0179                              Strategy const& strategy)
0180     {
0181         bool result = false;
0182         traits::visit<DynamicGeometry2>::apply([&](auto const& g2)
0183         {
0184             result = resolve_strategy::overlaps
0185                 <
0186                     Strategy
0187                 >::apply(geometry1, g2, strategy);
0188         }, geometry2);
0189         return result;
0190     }
0191 };
0192 
0193 
0194 template <typename DynamicGeometry1, typename DynamicGeometry2>
0195 struct overlaps<DynamicGeometry1, DynamicGeometry2, dynamic_geometry_tag, dynamic_geometry_tag>
0196 {
0197     template <typename Strategy>
0198     static inline bool apply(DynamicGeometry1 const& geometry1,
0199                              DynamicGeometry2 const& geometry2,
0200                              Strategy const& strategy)
0201     {
0202         bool result = false;
0203         traits::visit<DynamicGeometry1, DynamicGeometry2>::apply([&](auto const& g1, auto const& g2)
0204         {
0205             result = resolve_strategy::overlaps
0206                 <
0207                     Strategy
0208                 >::apply(g1, g2, strategy);
0209         }, geometry1, geometry2);
0210         return result;
0211     }
0212 };
0213 
0214 
0215 } // namespace resolve_dynamic
0216 
0217 
0218 /*!
0219 \brief \brief_check2{overlap}
0220 \ingroup overlaps
0221 \tparam Geometry1 \tparam_geometry
0222 \tparam Geometry2 \tparam_geometry
0223 \tparam Strategy \tparam_strategy{Overlaps}
0224 \param geometry1 \param_geometry
0225 \param geometry2 \param_geometry
0226 \param strategy \param_strategy{overlaps}
0227 \return \return_check2{overlap}
0228 
0229 \qbk{distinguish,with strategy}
0230 \qbk{[include reference/algorithms/overlaps.qbk]}
0231 */
0232 template <typename Geometry1, typename Geometry2, typename Strategy>
0233 inline bool overlaps(Geometry1 const& geometry1,
0234                      Geometry2 const& geometry2,
0235                      Strategy const& strategy)
0236 {
0237     concepts::check<Geometry1 const>();
0238     concepts::check<Geometry2 const>();
0239 
0240     return resolve_dynamic::overlaps
0241         <
0242             Geometry1, Geometry2
0243         >::apply(geometry1, geometry2, strategy);
0244 }
0245 
0246 /*!
0247 \brief \brief_check2{overlap}
0248 \ingroup overlaps
0249 \tparam Geometry1 \tparam_geometry
0250 \tparam Geometry2 \tparam_geometry
0251 \param geometry1 \param_geometry
0252 \param geometry2 \param_geometry
0253 \return \return_check2{overlap}
0254 
0255 \qbk{[include reference/algorithms/overlaps.qbk]}
0256 \qbk{
0257 [heading Examples]
0258 [overlaps]
0259 [overlaps_output]
0260 }
0261 */
0262 template <typename Geometry1, typename Geometry2>
0263 inline bool overlaps(Geometry1 const& geometry1, Geometry2 const& geometry2)
0264 {
0265     concepts::check<Geometry1 const>();
0266     concepts::check<Geometry2 const>();
0267 
0268     return resolve_dynamic::overlaps
0269         <
0270             Geometry1, Geometry2
0271         >::apply(geometry1, geometry2, default_strategy());
0272 }
0273 
0274 }} // namespace boost::geometry
0275 
0276 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAPS_INTERFACE_HPP