annotate DEPENDENCIES/generic/include/boost/geometry/geometries/adapted/boost_polygon/ring.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 4
Chris@16 5 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
Chris@16 10 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
Chris@16 11
Chris@16 12 // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
Chris@16 13 // boost::polygon::polygon_data -> boost::geometry::ring
Chris@16 14
Chris@16 15 #include <cstddef>
Chris@16 16 #include <boost/polygon/polygon.hpp>
Chris@16 17
Chris@16 18 #include <boost/geometry/core/access.hpp>
Chris@16 19 #include <boost/geometry/core/cs.hpp>
Chris@16 20 #include <boost/geometry/core/coordinate_dimension.hpp>
Chris@16 21 #include <boost/geometry/core/coordinate_type.hpp>
Chris@16 22 #include <boost/geometry/core/mutable_range.hpp>
Chris@16 23 #include <boost/geometry/core/tags.hpp>
Chris@16 24
Chris@16 25
Chris@16 26 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@16 27
Chris@16 28 namespace boost { namespace geometry
Chris@16 29 {
Chris@16 30
Chris@16 31 namespace traits
Chris@16 32 {
Chris@16 33
Chris@16 34 template <typename CoordinateType>
Chris@16 35 struct tag<boost::polygon::polygon_data<CoordinateType> >
Chris@16 36 {
Chris@16 37 typedef ring_tag type;
Chris@16 38 };
Chris@16 39
Chris@16 40 template <typename CoordinateType>
Chris@16 41 struct clear<boost::polygon::polygon_data<CoordinateType> >
Chris@16 42 {
Chris@16 43 static inline void apply(boost::polygon::polygon_data<CoordinateType>& data)
Chris@16 44 {
Chris@16 45 // There is no "clear" function but we can assign
Chris@16 46 // a newly (and therefore empty) constructed polygon
Chris@16 47 boost::polygon::assign(data, boost::polygon::polygon_data<CoordinateType>());
Chris@16 48 }
Chris@16 49 };
Chris@16 50
Chris@16 51 template <typename CoordinateType>
Chris@16 52 struct push_back<boost::polygon::polygon_data<CoordinateType> >
Chris@16 53 {
Chris@16 54 typedef boost::polygon::point_data<CoordinateType> point_type;
Chris@16 55
Chris@16 56 static inline void apply(boost::polygon::polygon_data<CoordinateType>& data,
Chris@16 57 point_type const& point)
Chris@16 58 {
Chris@16 59 // Boost.Polygon's polygons are not appendable. So create a temporary vector,
Chris@16 60 // add a record and set it to the original. Of course: this is not efficient.
Chris@16 61 // But there seems no other way (without using a wrapper)
Chris@16 62 std::vector<point_type> temporary_vector
Chris@16 63 (
Chris@16 64 boost::polygon::begin_points(data),
Chris@16 65 boost::polygon::end_points(data)
Chris@16 66 );
Chris@16 67 temporary_vector.push_back(point);
Chris@16 68 data.set(temporary_vector.begin(), temporary_vector.end());
Chris@16 69 }
Chris@16 70 };
Chris@16 71
Chris@101 72 template <typename CoordinateType>
Chris@101 73 struct resize<boost::polygon::polygon_data<CoordinateType> >
Chris@101 74 {
Chris@101 75 typedef boost::polygon::point_data<CoordinateType> point_type;
Chris@16 76
Chris@101 77 static inline void apply(boost::polygon::polygon_data<CoordinateType>& data,
Chris@101 78 std::size_t new_size)
Chris@101 79 {
Chris@101 80 // Boost.Polygon's polygons are not resizable. So create a temporary vector,
Chris@101 81 // resize it and set it to the original. Of course: this is not efficient.
Chris@101 82 // But there seems no other way (without using a wrapper)
Chris@101 83 std::vector<point_type> temporary_vector
Chris@101 84 (
Chris@101 85 boost::polygon::begin_points(data),
Chris@101 86 boost::polygon::end_points(data)
Chris@101 87 );
Chris@101 88 temporary_vector.resize(new_size);
Chris@101 89 data.set(temporary_vector.begin(), temporary_vector.end());
Chris@101 90 }
Chris@101 91 };
Chris@16 92
Chris@16 93
Chris@16 94 } // namespace traits
Chris@16 95
Chris@16 96 }} // namespace boost::geometry
Chris@16 97
Chris@16 98
Chris@16 99 // Adapt Boost.Polygon's polygon_data to Boost.Range
Chris@16 100 // This just translates to
Chris@16 101 // polygon_data.begin() and polygon_data.end()
Chris@16 102 namespace boost
Chris@16 103 {
Chris@16 104 template<typename CoordinateType>
Chris@16 105 struct range_mutable_iterator<boost::polygon::polygon_data<CoordinateType> >
Chris@16 106 {
Chris@16 107 typedef typename boost::polygon::polygon_traits
Chris@16 108 <
Chris@16 109 boost::polygon::polygon_data<CoordinateType>
Chris@16 110 >::iterator_type type;
Chris@16 111 };
Chris@16 112
Chris@16 113 template<typename CoordinateType>
Chris@16 114 struct range_const_iterator<boost::polygon::polygon_data<CoordinateType> >
Chris@16 115 {
Chris@16 116 typedef typename boost::polygon::polygon_traits
Chris@16 117 <
Chris@16 118 boost::polygon::polygon_data<CoordinateType>
Chris@16 119 >::iterator_type type;
Chris@16 120 };
Chris@16 121
Chris@16 122 template<typename CoordinateType>
Chris@16 123 struct range_size<boost::polygon::polygon_data<CoordinateType> >
Chris@16 124 {
Chris@16 125 typedef std::size_t type;
Chris@16 126 };
Chris@16 127
Chris@16 128 } // namespace boost
Chris@16 129
Chris@16 130
Chris@16 131 // Support Boost.Polygon's polygon_data for Boost.Range ADP
Chris@16 132 namespace boost { namespace polygon
Chris@16 133 {
Chris@16 134
Chris@16 135 template<typename CoordinateType>
Chris@16 136 inline typename polygon_traits
Chris@16 137 <
Chris@16 138 polygon_data<CoordinateType>
Chris@16 139 >::iterator_type range_begin(polygon_data<CoordinateType>& polygon)
Chris@16 140 {
Chris@16 141 return polygon.begin();
Chris@16 142 }
Chris@16 143
Chris@16 144 template<typename CoordinateType>
Chris@16 145 inline typename polygon_traits
Chris@16 146 <
Chris@16 147 polygon_data<CoordinateType>
Chris@16 148 >::iterator_type range_begin(polygon_data<CoordinateType> const& polygon)
Chris@16 149 {
Chris@16 150 return polygon.begin();
Chris@16 151 }
Chris@16 152
Chris@16 153 template<typename CoordinateType>
Chris@16 154 inline typename polygon_traits
Chris@16 155 <
Chris@16 156 polygon_data<CoordinateType>
Chris@16 157 >::iterator_type range_end(polygon_data<CoordinateType>& polygon)
Chris@16 158 {
Chris@16 159 return polygon.end();
Chris@16 160 }
Chris@16 161
Chris@16 162 template<typename CoordinateType>
Chris@16 163 inline typename polygon_traits
Chris@16 164 <
Chris@16 165 polygon_data<CoordinateType>
Chris@16 166 >::iterator_type range_end(polygon_data<CoordinateType> const& polygon)
Chris@16 167 {
Chris@16 168 return polygon.end();
Chris@16 169 }
Chris@16 170
Chris@16 171 template<typename CoordinateType>
Chris@16 172 inline std::size_t range_calculate_size(polygon_data<CoordinateType> const& polygon)
Chris@16 173 {
Chris@16 174 return polygon.size();
Chris@16 175 }
Chris@16 176
Chris@16 177 }}
Chris@16 178
Chris@16 179 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@16 180
Chris@16 181
Chris@16 182 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP