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@101
|
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
|
Chris@16
|
7
|
Chris@16
|
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
10
|
Chris@16
|
11 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
13 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_RING_HPP
|
Chris@16
|
16 #define BOOST_GEOMETRY_GEOMETRIES_RING_HPP
|
Chris@16
|
17
|
Chris@16
|
18 #include <memory>
|
Chris@16
|
19 #include <vector>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/concept/assert.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/geometry/core/closure.hpp>
|
Chris@16
|
24 #include <boost/geometry/core/point_order.hpp>
|
Chris@16
|
25 #include <boost/geometry/core/tag.hpp>
|
Chris@16
|
26 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 #include <boost/geometry/geometries/concepts/point_concept.hpp>
|
Chris@16
|
29
|
Chris@101
|
30 #ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST
|
Chris@101
|
31 #include <boost/config.hpp>
|
Chris@101
|
32 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
|
Chris@101
|
33 #include <initializer_list>
|
Chris@101
|
34 #endif
|
Chris@101
|
35 #endif
|
Chris@16
|
36
|
Chris@16
|
37 namespace boost { namespace geometry
|
Chris@16
|
38 {
|
Chris@16
|
39
|
Chris@16
|
40 namespace model
|
Chris@16
|
41 {
|
Chris@16
|
42 /*!
|
Chris@16
|
43 \brief A ring (aka linear ring) is a closed line which should not be selfintersecting
|
Chris@16
|
44 \ingroup geometries
|
Chris@16
|
45 \tparam Point point type
|
Chris@16
|
46 \tparam ClockWise true for clockwise direction,
|
Chris@16
|
47 false for CounterClockWise direction
|
Chris@16
|
48 \tparam Closed true for closed polygons (last point == first point),
|
Chris@16
|
49 false open points
|
Chris@16
|
50 \tparam Container container type, for example std::vector, std::deque
|
Chris@16
|
51 \tparam Allocator container-allocator-type
|
Chris@16
|
52
|
Chris@16
|
53 \qbk{before.synopsis,
|
Chris@16
|
54 [heading Model of]
|
Chris@16
|
55 [link geometry.reference.concepts.concept_ring Ring Concept]
|
Chris@16
|
56 }
|
Chris@16
|
57 */
|
Chris@16
|
58 template
|
Chris@16
|
59 <
|
Chris@16
|
60 typename Point,
|
Chris@16
|
61 bool ClockWise = true, bool Closed = true,
|
Chris@16
|
62 template<typename, typename> class Container = std::vector,
|
Chris@16
|
63 template<typename> class Allocator = std::allocator
|
Chris@16
|
64 >
|
Chris@16
|
65 class ring : public Container<Point, Allocator<Point> >
|
Chris@16
|
66 {
|
Chris@16
|
67 BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
|
Chris@16
|
68
|
Chris@16
|
69 typedef Container<Point, Allocator<Point> > base_type;
|
Chris@16
|
70
|
Chris@16
|
71 public :
|
Chris@16
|
72 /// \constructor_default{ring}
|
Chris@16
|
73 inline ring()
|
Chris@16
|
74 : base_type()
|
Chris@16
|
75 {}
|
Chris@16
|
76
|
Chris@16
|
77 /// \constructor_begin_end{ring}
|
Chris@16
|
78 template <typename Iterator>
|
Chris@16
|
79 inline ring(Iterator begin, Iterator end)
|
Chris@16
|
80 : base_type(begin, end)
|
Chris@16
|
81 {}
|
Chris@101
|
82
|
Chris@101
|
83 #ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST
|
Chris@101
|
84 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
|
Chris@101
|
85
|
Chris@101
|
86 /// \constructor_initializer_list{ring}
|
Chris@101
|
87 inline ring(std::initializer_list<Point> l)
|
Chris@101
|
88 : base_type(l.begin(), l.end())
|
Chris@101
|
89 {}
|
Chris@101
|
90
|
Chris@101
|
91 // Commented out for now in order to support Boost.Assign
|
Chris@101
|
92 // Without this assignment operator first the object should be created
|
Chris@101
|
93 // from initializer list, then it shoudl be moved.
|
Chris@101
|
94 //// Without this workaround in MSVC the assignment operator is ambiguous
|
Chris@101
|
95 //#ifndef BOOST_MSVC
|
Chris@101
|
96 // /// \assignment_initializer_list{ring}
|
Chris@101
|
97 // inline ring & operator=(std::initializer_list<Point> l)
|
Chris@101
|
98 // {
|
Chris@101
|
99 // base_type::assign(l.begin(), l.end());
|
Chris@101
|
100 // return *this;
|
Chris@101
|
101 // }
|
Chris@101
|
102 //#endif
|
Chris@101
|
103
|
Chris@101
|
104 #endif
|
Chris@101
|
105 #endif
|
Chris@16
|
106 };
|
Chris@16
|
107
|
Chris@16
|
108 } // namespace model
|
Chris@16
|
109
|
Chris@16
|
110
|
Chris@16
|
111 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
Chris@16
|
112 namespace traits
|
Chris@16
|
113 {
|
Chris@16
|
114
|
Chris@16
|
115 template
|
Chris@16
|
116 <
|
Chris@16
|
117 typename Point,
|
Chris@16
|
118 bool ClockWise, bool Closed,
|
Chris@16
|
119 template<typename, typename> class Container,
|
Chris@16
|
120 template<typename> class Allocator
|
Chris@16
|
121 >
|
Chris@16
|
122 struct tag<model::ring<Point, ClockWise, Closed, Container, Allocator> >
|
Chris@16
|
123 {
|
Chris@16
|
124 typedef ring_tag type;
|
Chris@16
|
125 };
|
Chris@16
|
126
|
Chris@16
|
127
|
Chris@16
|
128 template
|
Chris@16
|
129 <
|
Chris@16
|
130 typename Point,
|
Chris@16
|
131 bool Closed,
|
Chris@16
|
132 template<typename, typename> class Container,
|
Chris@16
|
133 template<typename> class Allocator
|
Chris@16
|
134 >
|
Chris@16
|
135 struct point_order<model::ring<Point, false, Closed, Container, Allocator> >
|
Chris@16
|
136 {
|
Chris@16
|
137 static const order_selector value = counterclockwise;
|
Chris@16
|
138 };
|
Chris@16
|
139
|
Chris@16
|
140
|
Chris@16
|
141 template
|
Chris@16
|
142 <
|
Chris@16
|
143 typename Point,
|
Chris@16
|
144 bool Closed,
|
Chris@16
|
145 template<typename, typename> class Container,
|
Chris@16
|
146 template<typename> class Allocator
|
Chris@16
|
147 >
|
Chris@16
|
148 struct point_order<model::ring<Point, true, Closed, Container, Allocator> >
|
Chris@16
|
149 {
|
Chris@16
|
150 static const order_selector value = clockwise;
|
Chris@16
|
151 };
|
Chris@16
|
152
|
Chris@16
|
153 template
|
Chris@16
|
154 <
|
Chris@16
|
155 typename Point,
|
Chris@16
|
156 bool PointOrder,
|
Chris@16
|
157 template<typename, typename> class Container,
|
Chris@16
|
158 template<typename> class Allocator
|
Chris@16
|
159 >
|
Chris@16
|
160 struct closure<model::ring<Point, PointOrder, true, Container, Allocator> >
|
Chris@16
|
161 {
|
Chris@16
|
162 static const closure_selector value = closed;
|
Chris@16
|
163 };
|
Chris@16
|
164
|
Chris@16
|
165 template
|
Chris@16
|
166 <
|
Chris@16
|
167 typename Point,
|
Chris@16
|
168 bool PointOrder,
|
Chris@16
|
169 template<typename, typename> class Container,
|
Chris@16
|
170 template<typename> class Allocator
|
Chris@16
|
171 >
|
Chris@16
|
172 struct closure<model::ring<Point, PointOrder, false, Container, Allocator> >
|
Chris@16
|
173 {
|
Chris@16
|
174 static const closure_selector value = open;
|
Chris@16
|
175 };
|
Chris@16
|
176
|
Chris@16
|
177
|
Chris@16
|
178 } // namespace traits
|
Chris@16
|
179 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
Chris@16
|
180
|
Chris@16
|
181
|
Chris@16
|
182 }} // namespace boost::geometry
|
Chris@16
|
183
|
Chris@16
|
184 #endif // BOOST_GEOMETRY_GEOMETRIES_RING_HPP
|