box.hpp 3.2 KB

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