File indexing completed on 2025-01-18 09:35:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
0020 #define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
0021
0022
0023 #include <type_traits>
0024
0025 #include <boost/geometry/algorithms/not_implemented.hpp>
0026 #include <boost/geometry/core/exterior_ring.hpp>
0027 #include <boost/geometry/core/interior_rings.hpp>
0028 #include <boost/geometry/core/mutable_range.hpp>
0029 #include <boost/geometry/core/tag_cast.hpp>
0030 #include <boost/geometry/core/tags.hpp>
0031 #include <boost/geometry/core/visit.hpp>
0032 #include <boost/geometry/geometries/adapted/boost_variant.hpp> // for backward compatibility
0033 #include <boost/geometry/geometries/concepts/check.hpp>
0034
0035
0036 namespace boost { namespace geometry
0037 {
0038
0039 #ifndef DOXYGEN_NO_DETAIL
0040 namespace detail { namespace clear
0041 {
0042
0043 template <typename Geometry>
0044 struct collection_clear
0045 {
0046 static inline void apply(Geometry& geometry)
0047 {
0048 traits::clear<Geometry>::apply(geometry);
0049 }
0050 };
0051
0052 template <typename Polygon>
0053 struct polygon_clear
0054 {
0055 static inline void apply(Polygon& polygon)
0056 {
0057 traits::clear
0058 <
0059 typename std::remove_reference
0060 <
0061 typename traits::interior_mutable_type<Polygon>::type
0062 >::type
0063 >::apply(interior_rings(polygon));
0064 traits::clear
0065 <
0066 typename std::remove_reference
0067 <
0068 typename traits::ring_mutable_type<Polygon>::type
0069 >::type
0070 >::apply(exterior_ring(polygon));
0071 }
0072 };
0073
0074 template <typename Geometry>
0075 struct no_action
0076 {
0077 static inline void apply(Geometry& )
0078 {
0079 }
0080 };
0081
0082
0083 }}
0084 #endif
0085
0086 #ifndef DOXYGEN_NO_DISPATCH
0087 namespace dispatch
0088 {
0089
0090 template
0091 <
0092 typename Geometry,
0093 typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
0094 >
0095 struct clear: not_implemented<Tag>
0096 {};
0097
0098
0099 template <typename Geometry>
0100 struct clear<Geometry, point_tag>
0101 : detail::clear::no_action<Geometry>
0102 {};
0103
0104 template <typename Geometry>
0105 struct clear<Geometry, box_tag>
0106 : detail::clear::no_action<Geometry>
0107 {};
0108
0109 template <typename Geometry>
0110 struct clear<Geometry, segment_tag>
0111 : detail::clear::no_action<Geometry>
0112 {};
0113
0114 template <typename Geometry>
0115 struct clear<Geometry, linestring_tag>
0116 : detail::clear::collection_clear<Geometry>
0117 {};
0118
0119 template <typename Geometry>
0120 struct clear<Geometry, ring_tag>
0121 : detail::clear::collection_clear<Geometry>
0122 {};
0123
0124
0125
0126 template <typename Polygon>
0127 struct clear<Polygon, polygon_tag>
0128 : detail::clear::polygon_clear<Polygon>
0129 {};
0130
0131
0132 template <typename Geometry>
0133 struct clear<Geometry, multi_tag>
0134 : detail::clear::collection_clear<Geometry>
0135 {};
0136
0137
0138 template <typename Geometry>
0139 struct clear<Geometry, dynamic_geometry_tag>
0140 {
0141 static void apply(Geometry& geometry)
0142 {
0143 traits::visit<Geometry>::apply([](auto & g)
0144 {
0145 clear<std::remove_reference_t<decltype(g)>>::apply(g);
0146 }, geometry);
0147 }
0148 };
0149
0150
0151 template <typename Geometry>
0152 struct clear<Geometry, geometry_collection_tag>
0153 {
0154 static void apply(Geometry& geometry)
0155 {
0156 traits::clear<Geometry>::apply(geometry);
0157 }
0158 };
0159
0160
0161 }
0162 #endif
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 template <typename Geometry>
0179 inline void clear(Geometry& geometry)
0180 {
0181 concepts::check<Geometry>();
0182
0183 dispatch::clear<Geometry>::apply(geometry);
0184 }
0185
0186
0187 }}
0188
0189
0190 #endif