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_GEOMETRIES_RING_HPP
|
Chris@16
|
15 #define BOOST_GEOMETRY_GEOMETRIES_RING_HPP
|
Chris@16
|
16
|
Chris@16
|
17 #include <memory>
|
Chris@16
|
18 #include <vector>
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/concept/assert.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/geometry/core/closure.hpp>
|
Chris@16
|
23 #include <boost/geometry/core/point_order.hpp>
|
Chris@16
|
24 #include <boost/geometry/core/tag.hpp>
|
Chris@16
|
25 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/geometry/geometries/concepts/point_concept.hpp>
|
Chris@16
|
28
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost { namespace geometry
|
Chris@16
|
31 {
|
Chris@16
|
32
|
Chris@16
|
33 namespace model
|
Chris@16
|
34 {
|
Chris@16
|
35 /*!
|
Chris@16
|
36 \brief A ring (aka linear ring) is a closed line which should not be selfintersecting
|
Chris@16
|
37 \ingroup geometries
|
Chris@16
|
38 \tparam Point point type
|
Chris@16
|
39 \tparam ClockWise true for clockwise direction,
|
Chris@16
|
40 false for CounterClockWise direction
|
Chris@16
|
41 \tparam Closed true for closed polygons (last point == first point),
|
Chris@16
|
42 false open points
|
Chris@16
|
43 \tparam Container container type, for example std::vector, std::deque
|
Chris@16
|
44 \tparam Allocator container-allocator-type
|
Chris@16
|
45
|
Chris@16
|
46 \qbk{before.synopsis,
|
Chris@16
|
47 [heading Model of]
|
Chris@16
|
48 [link geometry.reference.concepts.concept_ring Ring Concept]
|
Chris@16
|
49 }
|
Chris@16
|
50 */
|
Chris@16
|
51 template
|
Chris@16
|
52 <
|
Chris@16
|
53 typename Point,
|
Chris@16
|
54 bool ClockWise = true, bool Closed = true,
|
Chris@16
|
55 template<typename, typename> class Container = std::vector,
|
Chris@16
|
56 template<typename> class Allocator = std::allocator
|
Chris@16
|
57 >
|
Chris@16
|
58 class ring : public Container<Point, Allocator<Point> >
|
Chris@16
|
59 {
|
Chris@16
|
60 BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
|
Chris@16
|
61
|
Chris@16
|
62 typedef Container<Point, Allocator<Point> > base_type;
|
Chris@16
|
63
|
Chris@16
|
64 public :
|
Chris@16
|
65 /// \constructor_default{ring}
|
Chris@16
|
66 inline ring()
|
Chris@16
|
67 : base_type()
|
Chris@16
|
68 {}
|
Chris@16
|
69
|
Chris@16
|
70 /// \constructor_begin_end{ring}
|
Chris@16
|
71 template <typename Iterator>
|
Chris@16
|
72 inline ring(Iterator begin, Iterator end)
|
Chris@16
|
73 : base_type(begin, end)
|
Chris@16
|
74 {}
|
Chris@16
|
75 };
|
Chris@16
|
76
|
Chris@16
|
77 } // namespace model
|
Chris@16
|
78
|
Chris@16
|
79
|
Chris@16
|
80 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
Chris@16
|
81 namespace traits
|
Chris@16
|
82 {
|
Chris@16
|
83
|
Chris@16
|
84 template
|
Chris@16
|
85 <
|
Chris@16
|
86 typename Point,
|
Chris@16
|
87 bool ClockWise, bool Closed,
|
Chris@16
|
88 template<typename, typename> class Container,
|
Chris@16
|
89 template<typename> class Allocator
|
Chris@16
|
90 >
|
Chris@16
|
91 struct tag<model::ring<Point, ClockWise, Closed, Container, Allocator> >
|
Chris@16
|
92 {
|
Chris@16
|
93 typedef ring_tag type;
|
Chris@16
|
94 };
|
Chris@16
|
95
|
Chris@16
|
96
|
Chris@16
|
97 template
|
Chris@16
|
98 <
|
Chris@16
|
99 typename Point,
|
Chris@16
|
100 bool Closed,
|
Chris@16
|
101 template<typename, typename> class Container,
|
Chris@16
|
102 template<typename> class Allocator
|
Chris@16
|
103 >
|
Chris@16
|
104 struct point_order<model::ring<Point, false, Closed, Container, Allocator> >
|
Chris@16
|
105 {
|
Chris@16
|
106 static const order_selector value = counterclockwise;
|
Chris@16
|
107 };
|
Chris@16
|
108
|
Chris@16
|
109
|
Chris@16
|
110 template
|
Chris@16
|
111 <
|
Chris@16
|
112 typename Point,
|
Chris@16
|
113 bool Closed,
|
Chris@16
|
114 template<typename, typename> class Container,
|
Chris@16
|
115 template<typename> class Allocator
|
Chris@16
|
116 >
|
Chris@16
|
117 struct point_order<model::ring<Point, true, Closed, Container, Allocator> >
|
Chris@16
|
118 {
|
Chris@16
|
119 static const order_selector value = clockwise;
|
Chris@16
|
120 };
|
Chris@16
|
121
|
Chris@16
|
122 template
|
Chris@16
|
123 <
|
Chris@16
|
124 typename Point,
|
Chris@16
|
125 bool PointOrder,
|
Chris@16
|
126 template<typename, typename> class Container,
|
Chris@16
|
127 template<typename> class Allocator
|
Chris@16
|
128 >
|
Chris@16
|
129 struct closure<model::ring<Point, PointOrder, true, Container, Allocator> >
|
Chris@16
|
130 {
|
Chris@16
|
131 static const closure_selector value = closed;
|
Chris@16
|
132 };
|
Chris@16
|
133
|
Chris@16
|
134 template
|
Chris@16
|
135 <
|
Chris@16
|
136 typename Point,
|
Chris@16
|
137 bool PointOrder,
|
Chris@16
|
138 template<typename, typename> class Container,
|
Chris@16
|
139 template<typename> class Allocator
|
Chris@16
|
140 >
|
Chris@16
|
141 struct closure<model::ring<Point, PointOrder, false, Container, Allocator> >
|
Chris@16
|
142 {
|
Chris@16
|
143 static const closure_selector value = open;
|
Chris@16
|
144 };
|
Chris@16
|
145
|
Chris@16
|
146
|
Chris@16
|
147 } // namespace traits
|
Chris@16
|
148 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
Chris@16
|
149
|
Chris@16
|
150
|
Chris@16
|
151 }} // namespace boost::geometry
|
Chris@16
|
152
|
Chris@16
|
153 #endif // BOOST_GEOMETRY_GEOMETRIES_RING_HPP
|