annotate DEPENDENCIES/generic/include/boost/geometry/algorithms/clear.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@16 6
Chris@16 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 9
Chris@16 10 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13
Chris@16 14 #ifndef BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
Chris@16 15 #define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
Chris@16 16
Chris@16 17
Chris@16 18 #include <boost/geometry/algorithms/not_implemented.hpp>
Chris@16 19 #include <boost/geometry/core/access.hpp>
Chris@16 20 #include <boost/geometry/core/exterior_ring.hpp>
Chris@16 21 #include <boost/geometry/core/interior_rings.hpp>
Chris@16 22 #include <boost/geometry/core/mutable_range.hpp>
Chris@16 23 #include <boost/geometry/core/tag_cast.hpp>
Chris@16 24 #include <boost/geometry/geometries/concepts/check.hpp>
Chris@16 25 #include <boost/type_traits/remove_const.hpp>
Chris@16 26 #include <boost/variant/apply_visitor.hpp>
Chris@16 27 #include <boost/variant/static_visitor.hpp>
Chris@16 28 #include <boost/variant/variant_fwd.hpp>
Chris@16 29
Chris@16 30
Chris@16 31 namespace boost { namespace geometry
Chris@16 32 {
Chris@16 33
Chris@16 34 #ifndef DOXYGEN_NO_DETAIL
Chris@16 35 namespace detail { namespace clear
Chris@16 36 {
Chris@16 37
Chris@16 38 template <typename Geometry>
Chris@16 39 struct collection_clear
Chris@16 40 {
Chris@16 41 static inline void apply(Geometry& geometry)
Chris@16 42 {
Chris@16 43 traits::clear<Geometry>::apply(geometry);
Chris@16 44 }
Chris@16 45 };
Chris@16 46
Chris@16 47 template <typename Polygon>
Chris@16 48 struct polygon_clear
Chris@16 49 {
Chris@16 50 static inline void apply(Polygon& polygon)
Chris@16 51 {
Chris@16 52 traits::clear
Chris@16 53 <
Chris@16 54 typename boost::remove_reference
Chris@16 55 <
Chris@16 56 typename traits::interior_mutable_type<Polygon>::type
Chris@16 57 >::type
Chris@16 58 >::apply(interior_rings(polygon));
Chris@16 59 traits::clear
Chris@16 60 <
Chris@16 61 typename boost::remove_reference
Chris@16 62 <
Chris@16 63 typename traits::ring_mutable_type<Polygon>::type
Chris@16 64 >::type
Chris@16 65 >::apply(exterior_ring(polygon));
Chris@16 66 }
Chris@16 67 };
Chris@16 68
Chris@16 69 template <typename Geometry>
Chris@16 70 struct no_action
Chris@16 71 {
Chris@16 72 static inline void apply(Geometry& )
Chris@16 73 {
Chris@16 74 }
Chris@16 75 };
Chris@16 76
Chris@16 77
Chris@16 78 }} // namespace detail::clear
Chris@16 79 #endif // DOXYGEN_NO_DETAIL
Chris@16 80
Chris@16 81 #ifndef DOXYGEN_NO_DISPATCH
Chris@16 82 namespace dispatch
Chris@16 83 {
Chris@16 84
Chris@16 85 template
Chris@16 86 <
Chris@16 87 typename Geometry,
Chris@16 88 typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
Chris@16 89 >
Chris@16 90 struct clear: not_implemented<Tag>
Chris@16 91 {};
Chris@16 92
Chris@16 93 // Point/box/segment do not have clear. So specialize to do nothing.
Chris@16 94 template <typename Geometry>
Chris@16 95 struct clear<Geometry, point_tag>
Chris@16 96 : detail::clear::no_action<Geometry>
Chris@16 97 {};
Chris@16 98
Chris@16 99 template <typename Geometry>
Chris@16 100 struct clear<Geometry, box_tag>
Chris@16 101 : detail::clear::no_action<Geometry>
Chris@16 102 {};
Chris@16 103
Chris@16 104 template <typename Geometry>
Chris@16 105 struct clear<Geometry, segment_tag>
Chris@16 106 : detail::clear::no_action<Geometry>
Chris@16 107 {};
Chris@16 108
Chris@16 109 template <typename Geometry>
Chris@16 110 struct clear<Geometry, linestring_tag>
Chris@16 111 : detail::clear::collection_clear<Geometry>
Chris@16 112 {};
Chris@16 113
Chris@16 114 template <typename Geometry>
Chris@16 115 struct clear<Geometry, ring_tag>
Chris@16 116 : detail::clear::collection_clear<Geometry>
Chris@16 117 {};
Chris@16 118
Chris@16 119
Chris@16 120 // Polygon can (indirectly) use std for clear
Chris@16 121 template <typename Polygon>
Chris@16 122 struct clear<Polygon, polygon_tag>
Chris@16 123 : detail::clear::polygon_clear<Polygon>
Chris@16 124 {};
Chris@16 125
Chris@16 126
Chris@16 127 template <typename Geometry>
Chris@16 128 struct devarianted_clear
Chris@16 129 {
Chris@16 130 static inline void apply(Geometry& geometry)
Chris@16 131 {
Chris@16 132 clear<Geometry>::apply(geometry);
Chris@16 133 }
Chris@16 134 };
Chris@16 135
Chris@16 136 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
Chris@16 137 struct devarianted_clear<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
Chris@16 138 {
Chris@16 139 struct visitor: static_visitor<void>
Chris@16 140 {
Chris@16 141 template <typename Geometry>
Chris@16 142 inline void operator()(Geometry& geometry) const
Chris@16 143 {
Chris@16 144 clear<Geometry>::apply(geometry);
Chris@16 145 }
Chris@16 146 };
Chris@16 147
Chris@16 148 static inline void apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry)
Chris@16 149 {
Chris@16 150 apply_visitor(visitor(), geometry);
Chris@16 151 }
Chris@16 152 };
Chris@16 153
Chris@16 154
Chris@16 155 } // namespace dispatch
Chris@16 156 #endif // DOXYGEN_NO_DISPATCH
Chris@16 157
Chris@16 158
Chris@16 159 /*!
Chris@16 160 \brief Clears a linestring, ring or polygon (exterior+interiors) or multi*
Chris@16 161 \details Generic function to clear a geometry. All points will be removed from the collection or collections
Chris@16 162 making up the geometry. In most cases this is equivalent to the .clear() method of a std::vector<...>. In
Chris@16 163 the case of a polygon, this clear functionality is automatically called for the exterior ring, and for the
Chris@16 164 interior ring collection. In the case of a point, boxes and segments, nothing will happen.
Chris@16 165 \ingroup clear
Chris@16 166 \tparam Geometry \tparam_geometry
Chris@16 167 \param geometry \param_geometry which will be cleared
Chris@16 168 \note points and boxes cannot be cleared, instead they can be set to zero by "assign_zero"
Chris@16 169
Chris@16 170 \qbk{[include reference/algorithms/clear.qbk]}
Chris@16 171 */
Chris@16 172 template <typename Geometry>
Chris@16 173 inline void clear(Geometry& geometry)
Chris@16 174 {
Chris@16 175 concept::check<Geometry>();
Chris@16 176
Chris@16 177 dispatch::devarianted_clear<Geometry>::apply(geometry);
Chris@16 178 }
Chris@16 179
Chris@16 180
Chris@16 181 }} // namespace boost::geometry
Chris@16 182
Chris@16 183
Chris@16 184 #endif // BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP