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

source code of boost/libs/geometry/include/boost/geometry/geometries/ring.hpp