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