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