point.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2020.
  4. // Modifications copyright (c) 2020, Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
  10. #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
  11. // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
  12. // boost::polygon::point_data -> boost::geometry::point
  13. #include <type_traits>
  14. #include <boost/polygon/polygon.hpp>
  15. #include <boost/geometry/core/access.hpp>
  16. #include <boost/geometry/core/cs.hpp>
  17. #include <boost/geometry/core/coordinate_dimension.hpp>
  18. #include <boost/geometry/core/coordinate_type.hpp>
  19. #include <boost/geometry/core/tags.hpp>
  20. namespace boost { namespace geometry
  21. {
  22. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  23. namespace traits
  24. {
  25. template <typename CoordinateType>
  26. struct tag<boost::polygon::point_data<CoordinateType> >
  27. {
  28. typedef point_tag type;
  29. };
  30. template <typename CoordinateType>
  31. struct coordinate_type<boost::polygon::point_data<CoordinateType> >
  32. {
  33. typedef CoordinateType type;
  34. };
  35. template <typename CoordinateType>
  36. struct coordinate_system<boost::polygon::point_data<CoordinateType> >
  37. {
  38. typedef cs::cartesian type;
  39. };
  40. template <typename CoordinateType>
  41. struct dimension<boost::polygon::point_data<CoordinateType> >
  42. : std::integral_constant<std::size_t, 2>
  43. {};
  44. template <typename CoordinateType>
  45. struct access<boost::polygon::point_data<CoordinateType>, 0>
  46. {
  47. typedef boost::polygon::point_data<CoordinateType> point_type;
  48. static inline CoordinateType get(point_type const& p)
  49. {
  50. return p.x();
  51. }
  52. static inline void set(point_type& p, CoordinateType const& value)
  53. {
  54. p.x(value);
  55. }
  56. };
  57. template <typename CoordinateType>
  58. struct access<boost::polygon::point_data<CoordinateType>, 1>
  59. {
  60. typedef boost::polygon::point_data<CoordinateType> point_type;
  61. static inline CoordinateType get(point_type const& p)
  62. {
  63. return p.y();
  64. }
  65. static inline void set(point_type& p, CoordinateType const& value)
  66. {
  67. p.y(value);
  68. }
  69. };
  70. } // namespace traits
  71. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  72. }} // namespace boost::geometry
  73. #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP