comparison DEPENDENCIES/generic/include/boost/geometry/views/box_view.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
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_BOX_VIEW_HPP
15 #define BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
16
17
18 #include <boost/range.hpp>
19
20 #include <boost/geometry/core/point_type.hpp>
21 #include <boost/geometry/views/detail/points_view.hpp>
22 #include <boost/geometry/algorithms/assign.hpp>
23
24
25 namespace boost { namespace geometry
26 {
27
28
29 /*!
30 \brief Makes a box behave like a ring or a range
31 \details Adapts a box to the Boost.Range concept, enabling the user to iterating
32 box corners. The box_view is registered as a Ring Concept
33 \tparam Box \tparam_geometry{Box}
34 \tparam Clockwise If true, walks in clockwise direction, otherwise
35 it walks in counterclockwise direction
36 \ingroup views
37
38 \qbk{before.synopsis,
39 [heading Model of]
40 [link geometry.reference.concepts.concept_ring Ring Concept]
41 }
42
43 \qbk{[include reference/views/box_view.qbk]}
44 */
45 template <typename Box, bool Clockwise = true>
46 struct box_view
47 : public detail::points_view
48 <
49 typename geometry::point_type<Box>::type,
50 5
51 >
52 {
53 typedef typename geometry::point_type<Box>::type point_type;
54
55 /// Constructor accepting the box to adapt
56 explicit box_view(Box const& box)
57 : detail::points_view<point_type, 5>(copy_policy(box))
58 {}
59
60 private :
61
62 class copy_policy
63 {
64 public :
65 inline copy_policy(Box const& box)
66 : m_box(box)
67 {}
68
69 inline void apply(point_type* points) const
70 {
71 detail::assign_box_corners_oriented<!Clockwise>(m_box, points);
72 points[4] = points[0];
73 }
74 private :
75 Box const& m_box;
76 };
77
78 };
79
80
81 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
82
83 // All views on boxes are handled as rings
84 namespace traits
85 {
86
87 template<typename Box, bool Clockwise>
88 struct tag<box_view<Box, Clockwise> >
89 {
90 typedef ring_tag type;
91 };
92
93 template<typename Box>
94 struct point_order<box_view<Box, false> >
95 {
96 static order_selector const value = counterclockwise;
97 };
98
99
100 template<typename Box>
101 struct point_order<box_view<Box, true> >
102 {
103 static order_selector const value = clockwise;
104 };
105
106 }
107
108 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
109
110
111 }} // namespace boost::geometry
112
113
114 #endif // BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP