Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/algorithms/unique.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | |
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | |
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
9 | |
10 // Use, modification and distribution is subject to the Boost Software License, | |
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 // http://www.boost.org/LICENSE_1_0.txt) | |
13 | |
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP | |
15 #define BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP | |
16 | |
17 #include <algorithm> | |
18 | |
19 #include <boost/range.hpp> | |
20 #include <boost/typeof/typeof.hpp> | |
21 | |
22 #include <boost/geometry/core/interior_rings.hpp> | |
23 #include <boost/geometry/core/mutable_range.hpp> | |
24 #include <boost/geometry/geometries/concepts/check.hpp> | |
25 #include <boost/geometry/policies/compare.hpp> | |
26 | |
27 | |
28 namespace boost { namespace geometry | |
29 { | |
30 | |
31 | |
32 #ifndef DOXYGEN_NO_DETAIL | |
33 namespace detail { namespace unique | |
34 { | |
35 | |
36 | |
37 struct range_unique | |
38 { | |
39 template <typename Range, typename ComparePolicy> | |
40 static inline void apply(Range& range, ComparePolicy const& policy) | |
41 { | |
42 typename boost::range_iterator<Range>::type it | |
43 = std::unique | |
44 ( | |
45 boost::begin(range), | |
46 boost::end(range), | |
47 policy | |
48 ); | |
49 | |
50 traits::resize<Range>::apply(range, it - boost::begin(range)); | |
51 } | |
52 }; | |
53 | |
54 | |
55 struct polygon_unique | |
56 { | |
57 template <typename Polygon, typename ComparePolicy> | |
58 static inline void apply(Polygon& polygon, ComparePolicy const& policy) | |
59 { | |
60 range_unique::apply(exterior_ring(polygon), policy); | |
61 | |
62 typename interior_return_type<Polygon>::type rings | |
63 = interior_rings(polygon); | |
64 for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) | |
65 { | |
66 range_unique::apply(*it, policy); | |
67 } | |
68 } | |
69 }; | |
70 | |
71 | |
72 | |
73 }} // namespace detail::unique | |
74 #endif // DOXYGEN_NO_DETAIL | |
75 | |
76 | |
77 | |
78 #ifndef DOXYGEN_NO_DISPATCH | |
79 namespace dispatch | |
80 { | |
81 | |
82 | |
83 template | |
84 < | |
85 typename Geometry, | |
86 typename Tag = typename tag<Geometry>::type | |
87 > | |
88 struct unique | |
89 { | |
90 template <typename ComparePolicy> | |
91 static inline void apply(Geometry&, ComparePolicy const& ) | |
92 {} | |
93 }; | |
94 | |
95 | |
96 template <typename Ring> | |
97 struct unique<Ring, ring_tag> | |
98 : detail::unique::range_unique | |
99 {}; | |
100 | |
101 | |
102 template <typename LineString> | |
103 struct unique<LineString, linestring_tag> | |
104 : detail::unique::range_unique | |
105 {}; | |
106 | |
107 | |
108 template <typename Polygon> | |
109 struct unique<Polygon, polygon_tag> | |
110 : detail::unique::polygon_unique | |
111 {}; | |
112 | |
113 | |
114 } // namespace dispatch | |
115 #endif | |
116 | |
117 | |
118 /*! | |
119 \brief \brief_calc{minimal set} | |
120 \ingroup unique | |
121 \details \details_calc{unique,minimal set (where duplicate consecutive points are removed)}. | |
122 \tparam Geometry \tparam_geometry | |
123 \param geometry \param_geometry which will be made unique | |
124 | |
125 \qbk{[include reference/algorithms/unique.qbk]} | |
126 */ | |
127 template <typename Geometry> | |
128 inline void unique(Geometry& geometry) | |
129 { | |
130 concept::check<Geometry>(); | |
131 | |
132 // Default strategy is the default point-comparison policy | |
133 typedef geometry::equal_to | |
134 < | |
135 typename geometry::point_type<Geometry>::type | |
136 > policy; | |
137 | |
138 | |
139 dispatch::unique<Geometry>::apply(geometry, policy()); | |
140 } | |
141 | |
142 }} // namespace boost::geometry | |
143 | |
144 | |
145 #endif // BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP |