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_VIEWS_CLOSEABLE_VIEW_HPP
|
Chris@16
|
15 #define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/range.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/geometry/core/closure.hpp>
|
Chris@16
|
21 #include <boost/geometry/core/ring_type.hpp>
|
Chris@16
|
22 #include <boost/geometry/core/tag.hpp>
|
Chris@16
|
23 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
24 #include <boost/geometry/iterators/closing_iterator.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #include <boost/geometry/views/identity_view.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost { namespace geometry
|
Chris@16
|
29 {
|
Chris@16
|
30
|
Chris@16
|
31 // Silence warning C4512: assignment operator could not be generated
|
Chris@16
|
32 #if defined(_MSC_VER)
|
Chris@101
|
33 #pragma warning(push)
|
Chris@16
|
34 #pragma warning(disable : 4512)
|
Chris@16
|
35 #endif
|
Chris@16
|
36
|
Chris@16
|
37 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
38
|
Chris@16
|
39 namespace detail
|
Chris@16
|
40 {
|
Chris@16
|
41
|
Chris@16
|
42 template <typename Range>
|
Chris@16
|
43 struct closing_view
|
Chris@16
|
44 {
|
Chris@16
|
45 // Keep this explicit, important for nested views/ranges
|
Chris@16
|
46 explicit inline closing_view(Range& r)
|
Chris@16
|
47 : m_range(r)
|
Chris@16
|
48 {}
|
Chris@16
|
49
|
Chris@16
|
50 typedef closing_iterator<Range> iterator;
|
Chris@16
|
51 typedef closing_iterator<Range const> const_iterator;
|
Chris@16
|
52
|
Chris@16
|
53 inline const_iterator begin() const { return const_iterator(m_range); }
|
Chris@16
|
54 inline const_iterator end() const { return const_iterator(m_range, true); }
|
Chris@16
|
55
|
Chris@16
|
56 inline iterator begin() { return iterator(m_range); }
|
Chris@16
|
57 inline iterator end() { return iterator(m_range, true); }
|
Chris@16
|
58 private :
|
Chris@16
|
59 Range& m_range;
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 }
|
Chris@16
|
63
|
Chris@16
|
64 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
65
|
Chris@16
|
66
|
Chris@16
|
67 /*!
|
Chris@16
|
68 \brief View on a range, either closing it or leaving it as it is
|
Chris@16
|
69 \details The closeable_view is used internally by the library to handle all rings,
|
Chris@101
|
70 either closed or open, the same way. The default method is closed, all
|
Chris@16
|
71 algorithms process rings as if they are closed. Therefore, if they are opened,
|
Chris@16
|
72 a view is created which closes them.
|
Chris@16
|
73 The closeable_view might be used by library users, but its main purpose is
|
Chris@16
|
74 internally.
|
Chris@16
|
75 \tparam Range Original range
|
Chris@16
|
76 \tparam Close Specifies if it the range is closed, if so, nothing will happen.
|
Chris@16
|
77 If it is open, it will iterate the first point after the last point.
|
Chris@16
|
78 \ingroup views
|
Chris@16
|
79 */
|
Chris@16
|
80 template <typename Range, closure_selector Close>
|
Chris@16
|
81 struct closeable_view {};
|
Chris@16
|
82
|
Chris@16
|
83
|
Chris@16
|
84 #ifndef DOXYGEN_NO_SPECIALIZATIONS
|
Chris@16
|
85
|
Chris@16
|
86 template <typename Range>
|
Chris@16
|
87 struct closeable_view<Range, closed>
|
Chris@16
|
88 {
|
Chris@16
|
89 typedef identity_view<Range> type;
|
Chris@16
|
90 };
|
Chris@16
|
91
|
Chris@16
|
92
|
Chris@16
|
93 template <typename Range>
|
Chris@16
|
94 struct closeable_view<Range, open>
|
Chris@16
|
95 {
|
Chris@16
|
96 typedef detail::closing_view<Range> type;
|
Chris@16
|
97 };
|
Chris@16
|
98
|
Chris@16
|
99 #endif // DOXYGEN_NO_SPECIALIZATIONS
|
Chris@16
|
100
|
Chris@16
|
101
|
Chris@16
|
102 #if defined(_MSC_VER)
|
Chris@16
|
103 #pragma warning(pop)
|
Chris@16
|
104 #endif
|
Chris@16
|
105
|
Chris@16
|
106 }} // namespace boost::geometry
|
Chris@16
|
107
|
Chris@16
|
108
|
Chris@16
|
109 #endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
|