annotate DEPENDENCIES/generic/include/boost/geometry/algorithms/reverse.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_REVERSE_HPP
Chris@16 15 #define BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP
Chris@16 16
Chris@16 17 #include <algorithm>
Chris@16 18
Chris@16 19 #include <boost/range.hpp>
Chris@16 20 #include <boost/typeof/typeof.hpp>
Chris@16 21
Chris@16 22 #include <boost/geometry/core/interior_rings.hpp>
Chris@16 23 #include <boost/geometry/geometries/concepts/check.hpp>
Chris@16 24
Chris@16 25
Chris@16 26 namespace boost { namespace geometry
Chris@16 27 {
Chris@16 28
Chris@16 29
Chris@16 30 #ifndef DOXYGEN_NO_DETAIL
Chris@16 31 namespace detail { namespace reverse
Chris@16 32 {
Chris@16 33
Chris@16 34
Chris@16 35 struct range_reverse
Chris@16 36 {
Chris@16 37 template <typename Range>
Chris@16 38 static inline void apply(Range& range)
Chris@16 39 {
Chris@16 40 std::reverse(boost::begin(range), boost::end(range));
Chris@16 41 }
Chris@16 42 };
Chris@16 43
Chris@16 44
Chris@16 45 struct polygon_reverse: private range_reverse
Chris@16 46 {
Chris@16 47 template <typename Polygon>
Chris@16 48 static inline void apply(Polygon& polygon)
Chris@16 49 {
Chris@16 50 typedef typename geometry::ring_type<Polygon>::type ring_type;
Chris@16 51
Chris@16 52 range_reverse::apply(exterior_ring(polygon));
Chris@16 53
Chris@16 54 typename interior_return_type<Polygon>::type rings
Chris@16 55 = interior_rings(polygon);
Chris@16 56 for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
Chris@16 57 {
Chris@16 58 range_reverse::apply(*it);
Chris@16 59 }
Chris@16 60 }
Chris@16 61 };
Chris@16 62
Chris@16 63
Chris@16 64 }} // namespace detail::reverse
Chris@16 65 #endif // DOXYGEN_NO_DETAIL
Chris@16 66
Chris@16 67
Chris@16 68 #ifndef DOXYGEN_NO_DISPATCH
Chris@16 69 namespace dispatch
Chris@16 70 {
Chris@16 71
Chris@16 72
Chris@16 73 template <typename Geometry, typename Tag = typename tag<Geometry>::type>
Chris@16 74 struct reverse
Chris@16 75 {
Chris@16 76 static inline void apply(Geometry&)
Chris@16 77 {}
Chris@16 78 };
Chris@16 79
Chris@16 80
Chris@16 81 template <typename Ring>
Chris@16 82 struct reverse<Ring, ring_tag>
Chris@16 83 : detail::reverse::range_reverse
Chris@16 84 {};
Chris@16 85
Chris@16 86
Chris@16 87 template <typename LineString>
Chris@16 88 struct reverse<LineString, linestring_tag>
Chris@16 89 : detail::reverse::range_reverse
Chris@16 90 {};
Chris@16 91
Chris@16 92
Chris@16 93 template <typename Polygon>
Chris@16 94 struct reverse<Polygon, polygon_tag>
Chris@16 95 : detail::reverse::polygon_reverse
Chris@16 96 {};
Chris@16 97
Chris@16 98
Chris@16 99 } // namespace dispatch
Chris@16 100 #endif
Chris@16 101
Chris@16 102
Chris@16 103 /*!
Chris@16 104 \brief Reverses the points within a geometry
Chris@16 105 \details Generic function to reverse a geometry. It resembles the std::reverse
Chris@16 106 functionality, but it takes the geometry type into account. Only for a ring
Chris@16 107 or for a linestring it is the same as the std::reverse.
Chris@16 108 \ingroup reverse
Chris@16 109 \tparam Geometry \tparam_geometry
Chris@16 110 \param geometry \param_geometry which will be reversed
Chris@16 111
Chris@16 112 \qbk{[include reference/algorithms/reverse.qbk]}
Chris@16 113 */
Chris@16 114 template <typename Geometry>
Chris@16 115 inline void reverse(Geometry& geometry)
Chris@16 116 {
Chris@16 117 concept::check<Geometry>();
Chris@16 118
Chris@16 119 dispatch::reverse<Geometry>::apply(geometry);
Chris@16 120 }
Chris@16 121
Chris@16 122 }} // namespace boost::geometry
Chris@16 123
Chris@16 124
Chris@16 125 #endif // BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP