From ceec0d938b3b7547f78a7bdffebef372d3fc8487 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 8 Jun 2022 21:57:51 +0200 Subject: [PATCH] [within] Add support for GC --- .../algorithms/detail/equals/interface.hpp | 5 +- .../detail/relate/implementation_gc.hpp | 3 + .../detail/within/implementation.hpp | 26 ++- .../algorithms/detail/within/interface.hpp | 151 +++++++----------- 4 files changed, 81 insertions(+), 104 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/equals/interface.hpp b/include/boost/geometry/algorithms/detail/equals/interface.hpp index c4146e6d1..f0c443843 100644 --- a/include/boost/geometry/algorithms/detail/equals/interface.hpp +++ b/include/boost/geometry/algorithms/detail/equals/interface.hpp @@ -23,15 +23,12 @@ #include -#include -#include -#include - #include #include #include #include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp b/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp index 8bb752fef..f1ed75a9c 100644 --- a/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp +++ b/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp @@ -166,6 +166,7 @@ struct relate(tuple2), boost::get<2>(tuple1), mls2_diff_mpo1); mls1_t mls1_diff_mpo2; @@ -191,6 +192,7 @@ struct relate(tuple2), boost::get<2>(tuple1), mls2_inters_mpo1); if (! geometry::is_empty(mls2_inters_mpo1)) @@ -217,6 +219,7 @@ struct relate(tuple1), boost::get<2>(tuple2), mls1_inters_mpo2); if (! geometry::is_empty(mls1_inters_mpo2)) diff --git a/include/boost/geometry/algorithms/detail/within/implementation.hpp b/include/boost/geometry/algorithms/detail/within/implementation.hpp index c49592f94..de5c3c4b4 100644 --- a/include/boost/geometry/algorithms/detail/within/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/within/implementation.hpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -68,11 +70,12 @@ struct use_relate template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - typedef typename detail::de9im::static_mask_within_type + return detail::relate::relate_impl < - Geometry1, Geometry2 - >::type within_mask; - return geometry::relate(geometry1, geometry2, within_mask(), strategy); + detail::de9im::static_mask_within_type, + Geometry1, + Geometry2 + >::apply(geometry1, geometry2, strategy); } }; @@ -291,6 +294,21 @@ struct within +struct within + : detail::within::use_relate +{}; + +template +struct within + : detail::within::use_relate +{}; + +template +struct within + : detail::within::use_relate +{}; + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH diff --git a/include/boost/geometry/algorithms/detail/within/interface.hpp b/include/boost/geometry/algorithms/detail/within/interface.hpp index 1a10ca84d..572e0e5c9 100644 --- a/include/boost/geometry/algorithms/detail/within/interface.hpp +++ b/include/boost/geometry/algorithms/detail/within/interface.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2013-2021. -// Modifications copyright (c) 2013-2021 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2022. +// Modifications copyright (c) 2013-2022 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library @@ -21,16 +21,14 @@ #include -#include -#include -#include - #include #include #include +#include #include + #include #include #include @@ -126,10 +124,15 @@ struct within } // namespace resolve_strategy -namespace resolve_variant +namespace resolve_dynamic { -template +template +< + typename Geometry1, typename Geometry2, + typename Tag1 = typename geometry::tag::type, + typename Tag2 = typename geometry::tag::type +> struct within { template @@ -148,110 +151,66 @@ struct within } }; -template -struct within, Geometry2> +template +struct within { template - struct visitor: boost::static_visitor + static inline bool apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { - 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 + bool result = false; + traits::visit::apply([&](auto const& g1) { - return within::apply(geometry1, - m_geometry2, - m_strategy); - } - }; - - template - static inline bool - apply(boost::variant const& geometry1, - Geometry2 const& geometry2, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(geometry2, strategy), - geometry1); + result = within + < + util::remove_cref_t, + Geometry2 + >::apply(g1, geometry2, strategy); + }, geometry1); + return result; } }; -template -struct within > +template +struct within { template - struct visitor: boost::static_visitor + static inline bool apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { - 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 = false; + traits::visit::apply([&](auto const& g2) { - return within::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 = within + < + Geometry1, + util::remove_cref_t + >::apply(geometry1, g2, strategy); + }, geometry2); + return result; } }; -template < - BOOST_VARIANT_ENUM_PARAMS(typename T1), - BOOST_VARIANT_ENUM_PARAMS(typename T2) -> -struct within< - boost::variant, - boost::variant -> +template +struct within { template - struct visitor: boost::static_visitor + static inline bool apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { - Strategy const& m_strategy; - - visitor(Strategy const& strategy): m_strategy(strategy) {} - - template - bool operator()(Geometry1 const& geometry1, - Geometry2 const& geometry2) const + bool result = false; + traits::visit::apply([&](auto const& g1, auto const& g2) { - return within::apply(geometry1, - geometry2, - m_strategy); - } - }; - - template - static inline bool - apply(boost::variant const& geometry1, - boost::variant const& geometry2, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(strategy), - geometry1, - geometry2); + result = within + < + util::remove_cref_t, + util::remove_cref_t + >::apply(g1, g2, strategy); + }, geometry1, geometry2); + return result; } }; @@ -282,7 +241,7 @@ struct within< template inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2) { - return resolve_variant::within + return resolve_dynamic::within < Geometry1, Geometry2 @@ -320,7 +279,7 @@ inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - return resolve_variant::within + return resolve_dynamic::within < Geometry1, Geometry2