]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/is_simple/interface.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / is_simple / interface.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2017, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP
13
14 #include <boost/variant/apply_visitor.hpp>
15 #include <boost/variant/static_visitor.hpp>
16 #include <boost/variant/variant_fwd.hpp>
17
18 #include <boost/geometry/geometries/concepts/check.hpp>
19
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/intersection.hpp>
24
25
26 namespace boost { namespace geometry
27 {
28
29 namespace resolve_strategy
30 {
31
32 struct is_simple
33 {
34 template <typename Geometry, typename Strategy>
35 static inline bool apply(Geometry const& geometry,
36 Strategy const& strategy)
37 {
38 return dispatch::is_simple<Geometry>::apply(geometry, strategy);
39 }
40
41 template <typename Geometry>
42 static inline bool apply(Geometry const& geometry,
43 default_strategy)
44 {
45 // NOTE: Currently the strategy is only used for Linear geometries
46 typedef typename strategy::intersection::services::default_strategy
47 <
48 typename cs_tag<Geometry>::type
49 >::type strategy_type;
50
51 return dispatch::is_simple<Geometry>::apply(geometry, strategy_type());
52 }
53 };
54
55 } // namespace resolve_strategy
56
57 namespace resolve_variant
58 {
59
60 template <typename Geometry>
61 struct is_simple
62 {
63 template <typename Strategy>
64 static inline bool apply(Geometry const& geometry, Strategy const& strategy)
65 {
66 concepts::check<Geometry const>();
67
68 return resolve_strategy::is_simple::apply(geometry, strategy);
69 }
70 };
71
72 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
73 struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
74 {
75 template <typename Strategy>
76 struct visitor : boost::static_visitor<bool>
77 {
78 Strategy const& m_strategy;
79
80 visitor(Strategy const& strategy)
81 : m_strategy(strategy)
82 {}
83
84 template <typename Geometry>
85 bool operator()(Geometry const& geometry) const
86 {
87 return is_simple<Geometry>::apply(geometry, m_strategy);
88 }
89 };
90
91 template <typename Strategy>
92 static inline bool
93 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
94 Strategy const& strategy)
95 {
96 return boost::apply_visitor(visitor<Strategy>(strategy), geometry);
97 }
98 };
99
100 } // namespace resolve_variant
101
102
103 /*!
104 \brief \brief_check{is simple}
105 \ingroup is_simple
106 \tparam Geometry \tparam_geometry
107 \tparam Strategy \tparam_strategy{Is_simple}
108 \param geometry \param_geometry
109 \param strategy \param_strategy{is_simple}
110 \return \return_check{is simple}
111
112 \qbk{distinguish,with strategy}
113 \qbk{[include reference/algorithms/is_simple.qbk]}
114 */
115 template <typename Geometry, typename Strategy>
116 inline bool is_simple(Geometry const& geometry, Strategy const& strategy)
117 {
118 return resolve_variant::is_simple<Geometry>::apply(geometry, strategy);
119 }
120
121
122 /*!
123 \brief \brief_check{is simple}
124 \ingroup is_simple
125 \tparam Geometry \tparam_geometry
126 \param geometry \param_geometry
127 \return \return_check{is simple}
128
129 \qbk{[include reference/algorithms/is_simple.qbk]}
130 */
131 template <typename Geometry>
132 inline bool is_simple(Geometry const& geometry)
133 {
134 return resolve_variant::is_simple<Geometry>::apply(geometry, default_strategy());
135 }
136
137
138 }} // namespace boost::geometry
139
140
141 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_INTERFACE_HPP