• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9 
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13 
14 #ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
15 #define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
16 
17 
18 #include <boost/range.hpp>
19 
20 #include <boost/geometry/core/closure.hpp>
21 #include <boost/geometry/core/ring_type.hpp>
22 #include <boost/geometry/core/tag.hpp>
23 #include <boost/geometry/core/tags.hpp>
24 #include <boost/geometry/iterators/closing_iterator.hpp>
25 
26 #include <boost/geometry/views/identity_view.hpp>
27 
28 namespace boost { namespace geometry
29 {
30 
31 // Silence warning C4512: assignment operator could not be generated
32 #if defined(_MSC_VER)
33 #pragma warning(push)
34 #pragma warning(disable : 4512)
35 #endif
36 
37 #ifndef DOXYGEN_NO_DETAIL
38 
39 namespace detail
40 {
41 
42 template <typename Range>
43 struct closing_view
44 {
45     // Keep this explicit, important for nested views/ranges
closing_viewboost::geometry::detail::closing_view46     explicit inline closing_view(Range& r)
47         : m_range(r)
48     {}
49 
50     typedef closing_iterator<Range> iterator;
51     typedef closing_iterator<Range const> const_iterator;
52 
beginboost::geometry::detail::closing_view53     inline const_iterator begin() const { return const_iterator(m_range); }
endboost::geometry::detail::closing_view54     inline const_iterator end() const { return const_iterator(m_range, true); }
55 
beginboost::geometry::detail::closing_view56     inline iterator begin() { return iterator(m_range); }
endboost::geometry::detail::closing_view57     inline iterator end() { return iterator(m_range, true); }
58 private :
59     Range& m_range;
60 };
61 
62 }
63 
64 #endif // DOXYGEN_NO_DETAIL
65 
66 
67 /*!
68 \brief View on a range, either closing it or leaving it as it is
69 \details The closeable_view is used internally by the library to handle all rings,
70     either closed or open, the same way. The default method is closed, all
71     algorithms process rings as if they are closed. Therefore, if they are opened,
72     a view is created which closes them.
73     The closeable_view might be used by library users, but its main purpose is
74     internally.
75 \tparam Range Original range
76 \tparam Close Specifies if it the range is closed, if so, nothing will happen.
77     If it is open, it will iterate the first point after the last point.
78 \ingroup views
79 */
80 template <typename Range, closure_selector Close>
81 struct closeable_view {};
82 
83 
84 #ifndef DOXYGEN_NO_SPECIALIZATIONS
85 
86 template <typename Range>
87 struct closeable_view<Range, closed>
88 {
89     typedef identity_view<Range> type;
90 };
91 
92 
93 template <typename Range>
94 struct closeable_view<Range, open>
95 {
96     typedef detail::closing_view<Range> type;
97 };
98 
99 #endif // DOXYGEN_NO_SPECIALIZATIONS
100 
101 
102 #if defined(_MSC_VER)
103 #pragma warning(pop)
104 #endif
105 
106 }} // namespace boost::geometry
107 
108 
109 #endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
110