// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // 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 // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace relate { // is_generic allows dispatch::relate to generate compile-time error template struct is_generic { static const bool value = (util::is_polysegmental::value && util::is_polysegmental::value) || (util::is_point::value && util::is_polysegmental::value) || (util::is_polysegmental::value && util::is_point::value); }; }} // namespace detail::relate #endif // DOXYGEN_NO_DETAIL #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { template ::type, typename Tag2 = typename geometry::tag::type, int TopDim1 = geometry::topological_dimension::value, int TopDim2 = geometry::topological_dimension::value, bool IsGeneric = detail::relate::is_generic::value > struct relate : not_implemented {}; } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace relate { template struct interruption_enabled { static const bool value = dispatch::relate::interruption_enabled; }; template struct result_handler_type : not_implemented {}; template struct result_handler_type { typedef mask_handler < geometry::de9im::mask, interruption_enabled < Geometry1, Geometry2 >::value > type; }; template struct result_handler_type> { typedef mask_handler < std::tuple, interruption_enabled < Geometry1, Geometry2 >::value > type; }; template struct result_handler_type < Geometry1, Geometry2, geometry::de9im::static_mask > { typedef static_mask_handler < geometry::de9im::static_mask, interruption_enabled < Geometry1, Geometry2 >::value > type; }; template struct result_handler_type> { typedef static_mask_handler < util::type_sequence, interruption_enabled < Geometry1, Geometry2 >::value > type; }; }} // namespace detail::relate #endif // DOXYGEN_NO_DETAIL namespace resolve_strategy { template < typename Strategy, bool IsUmbrella = strategies::detail::is_umbrella_strategy::value > struct relate { template static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, ResultHandler & handler, Strategy const& strategy) { dispatch::relate < Geometry1, Geometry2 >::apply(geometry1, geometry2, handler, strategy); } }; template struct relate { template static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, ResultHandler & handler, Strategy const& strategy) { using strategies::relate::services::strategy_converter; dispatch::relate < Geometry1, Geometry2 >::apply(geometry1, geometry2, handler, strategy_converter::get(strategy)); } }; template <> struct relate { template static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, ResultHandler & handler, default_strategy) { typedef typename strategies::relate::services::default_strategy < Geometry1, Geometry2 >::type strategy_type; dispatch::relate < Geometry1, Geometry2 >::apply(geometry1, geometry2, handler, strategy_type()); } }; } // resolve_strategy namespace resolve_dynamic { template < typename Geometry1, typename Geometry2, typename Tag1 = typename geometry::tag::type, typename Tag2 = typename geometry::tag::type > struct relate { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Mask const& mask, Strategy const& strategy) { concepts::check(); concepts::check(); assert_dimension_equal(); typename detail::relate::result_handler_type < Geometry1, Geometry2, Mask >::type handler(mask); resolve_strategy::relate::apply(geometry1, geometry2, handler, strategy); return handler.result(); } }; template struct relate { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Mask const& mask, Strategy const& strategy) { bool result = false; traits::visit::apply([&](auto const& g1) { result = relate < util::remove_cref_t, Geometry2 >::apply(g1, geometry2, mask, strategy); }, geometry1); return result; } }; template struct relate { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Mask const& mask, Strategy const& strategy) { bool result = false; traits::visit::apply([&](auto const& g2) { result = relate < Geometry1, util::remove_cref_t >::apply(geometry1, g2, mask, strategy); }, geometry2); return result; } }; template struct relate { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Mask const& mask, Strategy const& strategy) { bool result = false; traits::visit::apply([&](auto const& g1, auto const& g2) { result = relate < util::remove_cref_t, util::remove_cref_t >::apply(g1, g2, mask, strategy); }, geometry1, geometry2); return result; } }; } // namespace resolve_dynamic /*! \brief Checks relation between a pair of geometries defined by a mask. \ingroup relate \tparam Geometry1 \tparam_geometry \tparam Geometry2 \tparam_geometry \tparam Mask An intersection model Mask type. \tparam Strategy \tparam_strategy{Relate} \param geometry1 \param_geometry \param geometry2 \param_geometry \param mask An intersection model mask object. \param strategy \param_strategy{relate} \return true if the relation is compatible with the mask, false otherwise. \qbk{distinguish,with strategy} \qbk{[include reference/algorithms/relate.qbk]} */ template inline bool relate(Geometry1 const& geometry1, Geometry2 const& geometry2, Mask const& mask, Strategy const& strategy) { return resolve_dynamic::relate < Geometry1, Geometry2 >::apply(geometry1, geometry2, mask, strategy); } /*! \brief Checks relation between a pair of geometries defined by a mask. \ingroup relate \tparam Geometry1 \tparam_geometry \tparam Geometry2 \tparam_geometry \tparam Mask An intersection model Mask type. \param geometry1 \param_geometry \param geometry2 \param_geometry \param mask An intersection model mask object. \return true if the relation is compatible with the mask, false otherwise. \qbk{[include reference/algorithms/relate.qbk]} */ template inline bool relate(Geometry1 const& geometry1, Geometry2 const& geometry2, Mask const& mask) { return resolve_dynamic::relate < Geometry1, Geometry2 >::apply(geometry1, geometry2, mask, default_strategy()); } }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP