Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:35:16

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2020-2023.
0009 // Modifications copyright (c) 2020-2023, Oracle and/or its affiliates.
0010 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0011 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0012 
0013 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0014 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0015 
0016 // Use, modification and distribution is subject to the Boost Software License,
0017 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0018 // http://www.boost.org/LICENSE_1_0.txt)
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 }} // namespace detail::clear
0085 #endif // DOXYGEN_NO_DETAIL
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 // Point/box/segment do not have clear. So specialize to do nothing.
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 // Polygon can (indirectly) use std for clear
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 } // namespace dispatch
0163 #endif // DOXYGEN_NO_DISPATCH
0164 
0165 
0166 /*!
0167 \brief Clears a linestring, ring or polygon (exterior+interiors) or multi*
0168 \details Generic function to clear a geometry. All points will be removed from the collection or collections
0169     making up the geometry. In most cases this is equivalent to the .clear() method of a std::vector<...>. In
0170     the case of a polygon, this clear functionality is automatically called for the exterior ring, and for the
0171     interior ring collection. In the case of a point, boxes and segments, nothing will happen.
0172 \ingroup clear
0173 \tparam Geometry \tparam_geometry
0174 \param geometry \param_geometry which will be cleared
0175 \note points and boxes cannot be cleared, instead they can be set to zero by "assign_zero"
0176 
0177 \qbk{[include reference/algorithms/clear.qbk]}
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 }} // namespace boost::geometry
0189 
0190 
0191 #endif // BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP