X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Fgeometry%2Falgorithms%2Fdetail%2Fdisjoint%2Finterface.hpp;fp=ceph%2Fsrc%2Fboost%2Fboost%2Fgeometry%2Falgorithms%2Fdetail%2Fdisjoint%2Finterface.hpp;h=205267db6b7b3505d17e85eb0922241e6094bafd;hb=1e59de90020f1d8d374046ef9cca56ccd4e806e2;hp=fc4aecbb03efdef1367fc3aa83ea6fa8cf5a4b7e;hpb=bd41e436e25044e8e83156060a37c23cb661c364;p=ceph.git diff --git a/ceph/src/boost/boost/geometry/algorithms/detail/disjoint/interface.hpp b/ceph/src/boost/boost/geometry/algorithms/detail/disjoint/interface.hpp index fc4aecbb0..205267db6 100644 --- a/ceph/src/boost/boost/geometry/algorithms/detail/disjoint/interface.hpp +++ b/ceph/src/boost/boost/geometry/algorithms/detail/disjoint/interface.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013-2017. -// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2021. +// Modifications copyright (c) 2013-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -23,16 +23,16 @@ #include -#include -#include -#include - #include +#include #include +#include // For backward compatibility #include -#include +#include +#include +#include namespace boost { namespace geometry @@ -41,9 +41,14 @@ namespace boost { namespace geometry namespace resolve_strategy { +template +< + typename Strategy, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> struct disjoint { - template + template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -53,13 +58,35 @@ struct disjoint Geometry1, Geometry2 >::apply(geometry1, geometry2, strategy); } +}; + +template +struct disjoint +{ + template + static inline bool apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) + { + using strategies::relate::services::strategy_converter; + + return dispatch::disjoint + < + Geometry1, Geometry2 + >::apply(geometry1, geometry2, + strategy_converter::get(strategy)); + } +}; +template <> +struct disjoint +{ template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, default_strategy) { - typedef typename strategy::disjoint::services::default_strategy + typedef typename strategies::relate::services::default_strategy < Geometry1, Geometry2 >::type strategy_type; @@ -74,13 +101,21 @@ struct disjoint } // namespace resolve_strategy -namespace resolve_variant { +namespace resolve_dynamic { -template +template +< + typename Geometry1, typename Geometry2, + bool IsDynamic = util::is_dynamic_geometry::value + || util::is_dynamic_geometry::value, + bool IsCollection = util::is_geometry_collection::value + || util::is_geometry_collection::value +> struct disjoint { template - static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) + static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, + Strategy const& strategy) { concepts::check_concepts_and_equal_dimensions < @@ -88,108 +123,60 @@ struct disjoint Geometry2 const >(); - return resolve_strategy::disjoint::apply(geometry1, geometry2, strategy); + return resolve_strategy::disjoint + < + Strategy + >::apply(geometry1, geometry2, strategy); } }; -template -struct disjoint, Geometry2> +template +struct disjoint { template - struct visitor: boost::static_visitor - { - Geometry2 const& m_geometry2; - Strategy const& m_strategy; - - visitor(Geometry2 const& geometry2, Strategy const& strategy) - : m_geometry2(geometry2) - , m_strategy(strategy) - {} - - template - bool operator()(Geometry1 const& geometry1) const - { - return disjoint::apply(geometry1, m_geometry2, m_strategy); - } - }; - - template - static inline bool apply(boost::variant const& geometry1, - Geometry2 const& geometry2, + static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - return boost::apply_visitor(visitor(geometry2, strategy), geometry1); - } -}; - -template -struct disjoint > -{ - template - struct visitor: boost::static_visitor - { - Geometry1 const& m_geometry1; - Strategy const& m_strategy; - - visitor(Geometry1 const& geometry1, Strategy const& strategy) - : m_geometry1(geometry1) - , m_strategy(strategy) - {} - - template - bool operator()(Geometry2 const& geometry2) const + bool result = true; + detail::visit([&](auto const& g1, auto const& g2) { - return disjoint::apply(m_geometry1, geometry2, m_strategy); - } - }; - - template - static inline bool apply(Geometry1 const& geometry1, - boost::variant const& geometry2, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(geometry1, strategy), geometry2); + result = disjoint + < + util::remove_cref_t, util::remove_cref_t + >::apply(g1, g2, strategy); + }, geometry1, geometry2); + return result; } }; -template -< - BOOST_VARIANT_ENUM_PARAMS(typename T1), - BOOST_VARIANT_ENUM_PARAMS(typename T2) -> -struct disjoint - < - boost::variant, - boost::variant - > +// TODO: The complexity is quadratic for two GCs +// Decrease e.g. with spatial index +template +struct disjoint { template - struct visitor: boost::static_visitor - { - Strategy const& m_strategy; - - visitor(Strategy const& strategy) - : m_strategy(strategy) - {} - - template - bool operator()(Geometry1 const& geometry1, - Geometry2 const& geometry2) const - { - return disjoint::apply(geometry1, geometry2, m_strategy); - } - }; - - template - static inline bool apply(boost::variant const& geometry1, - boost::variant const& geometry2, + static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - return boost::apply_visitor(visitor(strategy), geometry1, geometry2); + bool result = true; + detail::visit_breadth_first([&](auto const& g1) + { + detail::visit_breadth_first([&](auto const& g2) + { + result = disjoint + < + util::remove_cref_t, util::remove_cref_t + >::apply(g1, g2, strategy); + // If any of the combination intersects then the final result is not disjoint + return result; + }, geometry2); + return result; + }, geometry1); + return result; } }; -} // namespace resolve_variant +} // namespace resolve_dynamic /*! @@ -211,7 +198,7 @@ inline bool disjoint(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - return resolve_variant::disjoint + return resolve_dynamic::disjoint < Geometry1, Geometry2 >::apply(geometry1, geometry2, strategy); @@ -238,7 +225,7 @@ template inline bool disjoint(Geometry1 const& geometry1, Geometry2 const& geometry2) { - return resolve_variant::disjoint + return resolve_dynamic::disjoint < Geometry1, Geometry2 >::apply(geometry1, geometry2, default_strategy());