Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:06

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
0013 
0014 #include <boost/variant/apply_visitor.hpp>
0015 #include <boost/variant/static_visitor.hpp>
0016 #include <boost/variant/variant_fwd.hpp>
0017 
0018 #include <boost/geometry/geometries/concepts/check.hpp>
0019 
0020 #include <boost/geometry/algorithms/dispatch/is_simple.hpp>
0021 #include <boost/geometry/core/cs.hpp>
0022 #include <boost/geometry/strategies/default_strategy.hpp>
0023 #include <boost/geometry/strategies/detail.hpp>
0024 #include <boost/geometry/strategies/relate/services.hpp>
0025 
0026 
0027 namespace boost { namespace geometry
0028 {
0029 
0030 namespace resolve_strategy
0031 {
0032 
0033 template
0034 <
0035     typename Strategy,
0036     bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
0037 >
0038 struct is_simple
0039 {
0040     template <typename Geometry>
0041     static inline bool apply(Geometry const& geometry,
0042                              Strategy const& strategy)
0043     {
0044         return dispatch::is_simple<Geometry>::apply(geometry, strategy);
0045     }
0046 };
0047 
0048 template <typename Strategy>
0049 struct is_simple<Strategy, false>
0050 {
0051     template <typename Geometry>
0052     static inline bool apply(Geometry const& geometry,
0053                              Strategy const& strategy)
0054     {
0055         using strategies::relate::services::strategy_converter;
0056         return dispatch::is_simple
0057             <
0058                 Geometry
0059             >::apply(geometry, strategy_converter<Strategy>::get(strategy));
0060     }
0061 };
0062 
0063 template <>
0064 struct is_simple<default_strategy, false>
0065 {
0066     template <typename Geometry>
0067     static inline bool apply(Geometry const& geometry,
0068                              default_strategy)
0069     {
0070         // NOTE: Currently the strategy is only used for Linear geometries
0071         typedef typename strategies::relate::services::default_strategy
0072             <
0073                 Geometry, Geometry
0074             >::type strategy_type;
0075 
0076         return dispatch::is_simple<Geometry>::apply(geometry, strategy_type());
0077     }
0078 };
0079 
0080 } // namespace resolve_strategy
0081 
0082 namespace resolve_variant
0083 {
0084 
0085 template <typename Geometry>
0086 struct is_simple
0087 {
0088     template <typename Strategy>
0089     static inline bool apply(Geometry const& geometry, Strategy const& strategy)
0090     {
0091         concepts::check<Geometry const>();
0092 
0093         return resolve_strategy::is_simple<Strategy>::apply(geometry, strategy);
0094     }
0095 };
0096 
0097 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0098 struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
0099 {
0100     template <typename Strategy>
0101     struct visitor : boost::static_visitor<bool>
0102     {
0103         Strategy const& m_strategy;
0104 
0105         visitor(Strategy const& strategy)
0106             : m_strategy(strategy)
0107         {}
0108 
0109         template <typename Geometry>
0110         bool operator()(Geometry const& geometry) const
0111         {
0112             return is_simple<Geometry>::apply(geometry, m_strategy);
0113         }
0114     };
0115 
0116     template <typename Strategy>
0117     static inline bool
0118     apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
0119           Strategy const& strategy)
0120     {
0121         return boost::apply_visitor(visitor<Strategy>(strategy), geometry);
0122     }
0123 };
0124 
0125 } // namespace resolve_variant
0126 
0127 
0128 /*!
0129 \brief \brief_check{is simple}
0130 \ingroup is_simple
0131 \tparam Geometry \tparam_geometry
0132 \tparam Strategy \tparam_strategy{Is_simple}
0133 \param geometry \param_geometry
0134 \param strategy \param_strategy{is_simple}
0135 \return \return_check{is simple}
0136 
0137 \qbk{distinguish,with strategy}
0138 \qbk{[include reference/algorithms/is_simple.qbk]}
0139 */
0140 template <typename Geometry, typename Strategy>
0141 inline bool is_simple(Geometry const& geometry, Strategy const& strategy)
0142 {
0143     return resolve_variant::is_simple<Geometry>::apply(geometry, strategy);
0144 }
0145 
0146 
0147 /*!
0148 \brief \brief_check{is simple}
0149 \ingroup is_simple
0150 \tparam Geometry \tparam_geometry
0151 \param geometry \param_geometry
0152 \return \return_check{is simple}
0153 
0154 \qbk{[include reference/algorithms/is_simple.qbk]}
0155 */
0156 template <typename Geometry>
0157 inline bool is_simple(Geometry const& geometry)
0158 {
0159     return resolve_variant::is_simple<Geometry>::apply(geometry, default_strategy());
0160 }
0161 
0162 
0163 }} // namespace boost::geometry
0164 
0165 
0166 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP