point.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_POINT_HPP
  7. #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
  8. // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
  9. // boost::polygon::point_data -> boost::geometry::point
  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::point_data<CoordinateType> >
  23. {
  24. typedef point_tag type;
  25. };
  26. template <typename CoordinateType>
  27. struct coordinate_type<boost::polygon::point_data<CoordinateType> >
  28. {
  29. typedef CoordinateType type;
  30. };
  31. template <typename CoordinateType>
  32. struct coordinate_system<boost::polygon::point_data<CoordinateType> >
  33. {
  34. typedef cs::cartesian type;
  35. };
  36. template <typename CoordinateType>
  37. struct dimension<boost::polygon::point_data<CoordinateType> >
  38. : boost::mpl::int_<2>
  39. {};
  40. template <typename CoordinateType>
  41. struct access<boost::polygon::point_data<CoordinateType>, 0>
  42. {
  43. typedef boost::polygon::point_data<CoordinateType> point_type;
  44. static inline CoordinateType get(point_type const& p)
  45. {
  46. return p.x();
  47. }
  48. static inline void set(point_type& p, CoordinateType const& value)
  49. {
  50. p.x(value);
  51. }
  52. };
  53. template <typename CoordinateType>
  54. struct access<boost::polygon::point_data<CoordinateType>, 1>
  55. {
  56. typedef boost::polygon::point_data<CoordinateType> point_type;
  57. static inline CoordinateType get(point_type const& p)
  58. {
  59. return p.y();
  60. }
  61. static inline void set(point_type& p, CoordinateType const& value)
  62. {
  63. p.y(value);
  64. }
  65. };
  66. } // namespace traits
  67. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  68. }} // namespace boost::geometry
  69. #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP