File indexing completed on 2025-01-18 09:35:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
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 }
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 }
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
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
0149
0150
0151
0152
0153
0154
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 }}
0164
0165
0166 #endif