1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
14 #include <boost/variant/apply_visitor.hpp>
15 #include <boost/variant/static_visitor.hpp>
16 #include <boost/variant/variant_fwd.hpp>
18 #include <boost/geometry/geometries/concepts/check.hpp>
20 #include <boost/geometry/algorithms/dispatch/is_simple.hpp>
21 #include <boost/geometry/core/cs.hpp>
22 #include <boost/geometry/strategies/default_strategy.hpp>
23 #include <boost/geometry/strategies/detail.hpp>
24 #include <boost/geometry/strategies/relate/services.hpp>
27 namespace boost { namespace geometry
30 namespace resolve_strategy
36 bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
40 template <typename Geometry>
41 static inline bool apply(Geometry const& geometry,
42 Strategy const& strategy)
44 return dispatch::is_simple<Geometry>::apply(geometry, strategy);
48 template <typename Strategy>
49 struct is_simple<Strategy, false>
51 template <typename Geometry>
52 static inline bool apply(Geometry const& geometry,
53 Strategy const& strategy)
55 using strategies::relate::services::strategy_converter;
56 return dispatch::is_simple
59 >::apply(geometry, strategy_converter<Strategy>::get(strategy));
64 struct is_simple<default_strategy, false>
66 template <typename Geometry>
67 static inline bool apply(Geometry const& geometry,
70 // NOTE: Currently the strategy is only used for Linear geometries
71 typedef typename strategies::relate::services::default_strategy
74 >::type strategy_type;
76 return dispatch::is_simple<Geometry>::apply(geometry, strategy_type());
80 } // namespace resolve_strategy
82 namespace resolve_variant
85 template <typename Geometry>
88 template <typename Strategy>
89 static inline bool apply(Geometry const& geometry, Strategy const& strategy)
91 concepts::check<Geometry const>();
93 return resolve_strategy::is_simple<Strategy>::apply(geometry, strategy);
97 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
98 struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
100 template <typename Strategy>
101 struct visitor : boost::static_visitor<bool>
103 Strategy const& m_strategy;
105 visitor(Strategy const& strategy)
106 : m_strategy(strategy)
109 template <typename Geometry>
110 bool operator()(Geometry const& geometry) const
112 return is_simple<Geometry>::apply(geometry, m_strategy);
116 template <typename Strategy>
118 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
119 Strategy const& strategy)
121 return boost::apply_visitor(visitor<Strategy>(strategy), geometry);
125 } // namespace resolve_variant
129 \brief \brief_check{is simple}
131 \tparam Geometry \tparam_geometry
132 \tparam Strategy \tparam_strategy{Is_simple}
133 \param geometry \param_geometry
134 \param strategy \param_strategy{is_simple}
135 \return \return_check{is simple}
137 \qbk{distinguish,with strategy}
138 \qbk{[include reference/algorithms/is_simple.qbk]}
140 template <typename Geometry, typename Strategy>
141 inline bool is_simple(Geometry const& geometry, Strategy const& strategy)
143 return resolve_variant::is_simple<Geometry>::apply(geometry, strategy);
148 \brief \brief_check{is simple}
150 \tparam Geometry \tparam_geometry
151 \param geometry \param_geometry
152 \return \return_check{is simple}
154 \qbk{[include reference/algorithms/is_simple.qbk]}
156 template <typename Geometry>
157 inline bool is_simple(Geometry const& geometry)
159 return resolve_variant::is_simple<Geometry>::apply(geometry, default_strategy());
163 }} // namespace boost::geometry
166 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP