Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
4
|
Chris@16
|
5 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
|
Chris@16
|
10 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
|
Chris@16
|
11
|
Chris@16
|
12 // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
|
Chris@16
|
13 // boost::polygon::rectangle_data -> boost::geometry::box
|
Chris@16
|
14
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/polygon/polygon.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/geometry/core/access.hpp>
|
Chris@16
|
19 #include <boost/geometry/core/cs.hpp>
|
Chris@16
|
20 #include <boost/geometry/core/coordinate_dimension.hpp>
|
Chris@16
|
21 #include <boost/geometry/core/coordinate_type.hpp>
|
Chris@16
|
22 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
23
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost { namespace geometry
|
Chris@16
|
26 {
|
Chris@16
|
27
|
Chris@16
|
28
|
Chris@16
|
29 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
Chris@16
|
30 namespace traits
|
Chris@16
|
31 {
|
Chris@16
|
32
|
Chris@16
|
33
|
Chris@16
|
34 template <typename CoordinateType>
|
Chris@16
|
35 struct tag<boost::polygon::rectangle_data<CoordinateType> >
|
Chris@16
|
36 {
|
Chris@16
|
37 typedef box_tag type;
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40
|
Chris@16
|
41 template <typename CoordinateType>
|
Chris@16
|
42 struct point_type<boost::polygon::rectangle_data<CoordinateType> >
|
Chris@16
|
43 {
|
Chris@16
|
44 // Not sure what to do here. Boost.Polygon's rectangle does NOT define its
|
Chris@16
|
45 // point_type (but uses it...)
|
Chris@16
|
46 typedef boost::polygon::point_data<CoordinateType> type;
|
Chris@16
|
47 };
|
Chris@16
|
48
|
Chris@16
|
49
|
Chris@16
|
50 template <typename CoordinateType>
|
Chris@16
|
51 struct indexed_access
|
Chris@16
|
52 <
|
Chris@16
|
53 boost::polygon::rectangle_data<CoordinateType>,
|
Chris@16
|
54 min_corner, 0
|
Chris@16
|
55 >
|
Chris@16
|
56 {
|
Chris@16
|
57 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
|
Chris@16
|
58
|
Chris@16
|
59 static inline CoordinateType get(box_type const& b)
|
Chris@16
|
60 {
|
Chris@16
|
61 return boost::polygon::xl(b);
|
Chris@16
|
62 }
|
Chris@16
|
63
|
Chris@16
|
64 static inline void set(box_type& b, CoordinateType const& value)
|
Chris@16
|
65 {
|
Chris@16
|
66 boost::polygon::xl(b, value);
|
Chris@16
|
67 }
|
Chris@16
|
68 };
|
Chris@16
|
69
|
Chris@16
|
70
|
Chris@16
|
71 template <typename CoordinateType>
|
Chris@16
|
72 struct indexed_access
|
Chris@16
|
73 <
|
Chris@16
|
74 boost::polygon::rectangle_data<CoordinateType>,
|
Chris@16
|
75 min_corner, 1
|
Chris@16
|
76 >
|
Chris@16
|
77 {
|
Chris@16
|
78 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
|
Chris@16
|
79
|
Chris@16
|
80 static inline CoordinateType get(box_type const& b)
|
Chris@16
|
81 {
|
Chris@16
|
82 return boost::polygon::yl(b);
|
Chris@16
|
83 }
|
Chris@16
|
84
|
Chris@16
|
85 static inline void set(box_type& b, CoordinateType const& value)
|
Chris@16
|
86 {
|
Chris@16
|
87 boost::polygon::yl(b, value);
|
Chris@16
|
88 }
|
Chris@16
|
89 };
|
Chris@16
|
90
|
Chris@16
|
91
|
Chris@16
|
92 template <typename CoordinateType>
|
Chris@16
|
93 struct indexed_access
|
Chris@16
|
94 <
|
Chris@16
|
95 boost::polygon::rectangle_data<CoordinateType>,
|
Chris@16
|
96 max_corner, 0
|
Chris@16
|
97 >
|
Chris@16
|
98 {
|
Chris@16
|
99 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
|
Chris@16
|
100
|
Chris@16
|
101 static inline CoordinateType get(box_type const& b)
|
Chris@16
|
102 {
|
Chris@16
|
103 return boost::polygon::xh(b);
|
Chris@16
|
104 }
|
Chris@16
|
105
|
Chris@16
|
106 static inline void set(box_type& b, CoordinateType const& value)
|
Chris@16
|
107 {
|
Chris@16
|
108 boost::polygon::xh(b, value);
|
Chris@16
|
109 }
|
Chris@16
|
110 };
|
Chris@16
|
111
|
Chris@16
|
112
|
Chris@16
|
113 template <typename CoordinateType>
|
Chris@16
|
114 struct indexed_access
|
Chris@16
|
115 <
|
Chris@16
|
116 boost::polygon::rectangle_data<CoordinateType>,
|
Chris@16
|
117 max_corner, 1
|
Chris@16
|
118 >
|
Chris@16
|
119 {
|
Chris@16
|
120 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
|
Chris@16
|
121
|
Chris@16
|
122 static inline CoordinateType get(box_type const& b)
|
Chris@16
|
123 {
|
Chris@16
|
124 return boost::polygon::yh(b);
|
Chris@16
|
125 }
|
Chris@16
|
126
|
Chris@16
|
127 static inline void set(box_type& b, CoordinateType const& value)
|
Chris@16
|
128 {
|
Chris@16
|
129 boost::polygon::yh(b, value);
|
Chris@16
|
130 }
|
Chris@16
|
131 };
|
Chris@16
|
132
|
Chris@16
|
133
|
Chris@16
|
134 } // namespace traits
|
Chris@16
|
135 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
Chris@16
|
136
|
Chris@16
|
137
|
Chris@16
|
138 }} // namespace boost::geometry
|
Chris@16
|
139
|
Chris@16
|
140
|
Chris@16
|
141 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
|