1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
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)
9 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
10 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
12 // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
13 // boost::polygon::rectangle_data -> boost::geometry::box
16 #include <boost/polygon/polygon.hpp>
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>
25 namespace boost { namespace geometry
29 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
34 template <typename CoordinateType>
35 struct tag<boost::polygon::rectangle_data<CoordinateType> >
41 template <typename CoordinateType>
42 struct point_type<boost::polygon::rectangle_data<CoordinateType> >
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;
50 template <typename CoordinateType>
53 boost::polygon::rectangle_data<CoordinateType>,
57 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
59 static inline CoordinateType get(box_type const& b)
61 return boost::polygon::xl(b);
64 static inline void set(box_type& b, CoordinateType const& value)
66 boost::polygon::xl(b, value);
71 template <typename CoordinateType>
74 boost::polygon::rectangle_data<CoordinateType>,
78 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
80 static inline CoordinateType get(box_type const& b)
82 return boost::polygon::yl(b);
85 static inline void set(box_type& b, CoordinateType const& value)
87 boost::polygon::yl(b, value);
92 template <typename CoordinateType>
95 boost::polygon::rectangle_data<CoordinateType>,
99 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
101 static inline CoordinateType get(box_type const& b)
103 return boost::polygon::xh(b);
106 static inline void set(box_type& b, CoordinateType const& value)
108 boost::polygon::xh(b, value);
113 template <typename CoordinateType>
114 struct indexed_access
116 boost::polygon::rectangle_data<CoordinateType>,
120 typedef boost::polygon::rectangle_data<CoordinateType> box_type;
122 static inline CoordinateType get(box_type const& b)
124 return boost::polygon::yh(b);
127 static inline void set(box_type& b, CoordinateType const& value)
129 boost::polygon::yh(b, value);
134 } // namespace traits
135 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
138 }} // namespace boost::geometry
141 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP