Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:20

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