1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_RING_HPP
16 #define BOOST_GEOMETRY_GEOMETRIES_RING_HPP
21 #include <boost/concept/assert.hpp>
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>
28 #include <boost/geometry/geometries/concepts/point_concept.hpp>
30 #include <boost/config.hpp>
31 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
32 #include <initializer_list>
35 namespace boost { namespace geometry
41 \brief A ring (aka linear ring) is a closed line which should not be selfintersecting
43 \tparam Point point type
44 \tparam ClockWise true for clockwise direction,
45 false for CounterClockWise direction
46 \tparam Closed true for closed polygons (last point == first point),
48 \tparam Container container type, for example std::vector, std::deque
49 \tparam Allocator container-allocator-type
51 \qbk{[include reference/geometries/ring.qbk]}
54 [link geometry.reference.concepts.concept_ring Ring Concept]
60 bool ClockWise = true, bool Closed = true,
61 template<typename, typename> class Container = std::vector,
62 template<typename> class Allocator = std::allocator
64 class ring : public Container<Point, Allocator<Point> >
66 BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
68 typedef Container<Point, Allocator<Point> > base_type;
71 /// \constructor_default{ring}
76 /// \constructor_begin_end{ring}
77 template <typename Iterator>
78 inline ring(Iterator begin, Iterator end)
79 : base_type(begin, end)
82 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
84 /// \constructor_initializer_list{ring}
85 inline ring(std::initializer_list<Point> l)
86 : base_type(l.begin(), l.end())
89 // Commented out for now in order to support Boost.Assign
90 // Without this assignment operator first the object should be created
91 // from initializer list, then it shoudl be moved.
92 //// Without this workaround in MSVC the assignment operator is ambiguous
94 // /// \assignment_initializer_list{ring}
95 // inline ring & operator=(std::initializer_list<Point> l)
97 // base_type::assign(l.begin(), l.end());
108 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
115 bool ClockWise, bool Closed,
116 template<typename, typename> class Container,
117 template<typename> class Allocator
119 struct tag<model::ring<Point, ClockWise, Closed, Container, Allocator> >
121 typedef ring_tag type;
129 template<typename, typename> class Container,
130 template<typename> class Allocator
132 struct point_order<model::ring<Point, false, Closed, Container, Allocator> >
134 static const order_selector value = counterclockwise;
142 template<typename, typename> class Container,
143 template<typename> class Allocator
145 struct point_order<model::ring<Point, true, Closed, Container, Allocator> >
147 static const order_selector value = clockwise;
154 template<typename, typename> class Container,
155 template<typename> class Allocator
157 struct closure<model::ring<Point, PointOrder, true, Container, Allocator> >
159 static const closure_selector value = closed;
166 template<typename, typename> class Container,
167 template<typename> class Allocator
169 struct closure<model::ring<Point, PointOrder, false, Container, Allocator> >
171 static const closure_selector value = open;
175 } // namespace traits
176 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
179 }} // namespace boost::geometry
181 #endif // BOOST_GEOMETRY_GEOMETRIES_RING_HPP