polygon.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_POLYGON_HPP
  7. #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
  8. // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
  9. // boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
  10. #include <boost/polygon/polygon.hpp>
  11. #include <boost/geometry/core/tags.hpp>
  12. #include <boost/geometry/core/ring_type.hpp>
  13. #include <boost/geometry/core/exterior_ring.hpp>
  14. #include <boost/geometry/core/interior_rings.hpp>
  15. #include <boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp>
  16. #include <boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp>
  17. #include <boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  21. namespace traits
  22. {
  23. template <typename CoordinateType>
  24. struct tag<boost::polygon::polygon_with_holes_data<CoordinateType> >
  25. {
  26. typedef polygon_tag type;
  27. };
  28. template <typename CoordinateType>
  29. struct ring_const_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
  30. {
  31. typedef adapt::bp::ring_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> const> type;
  32. };
  33. template <typename CoordinateType>
  34. struct ring_mutable_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
  35. {
  36. typedef adapt::bp::ring_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> > type;
  37. };
  38. template <typename CoordinateType>
  39. struct interior_const_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
  40. {
  41. typedef adapt::bp::holes_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> const> type;
  42. };
  43. template <typename CoordinateType>
  44. struct interior_mutable_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
  45. {
  46. typedef adapt::bp::holes_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> > type;
  47. };
  48. template <typename CoordinateType>
  49. struct exterior_ring<boost::polygon::polygon_with_holes_data<CoordinateType> >
  50. {
  51. typedef boost::polygon::polygon_with_holes_data<CoordinateType> polygon_type;
  52. typedef adapt::bp::ring_proxy<polygon_type> proxy;
  53. typedef adapt::bp::ring_proxy<polygon_type const> const_proxy;
  54. static inline proxy get(polygon_type& p)
  55. {
  56. return proxy(p);
  57. }
  58. static inline const_proxy get(polygon_type const& p)
  59. {
  60. return const_proxy(p);
  61. }
  62. };
  63. template <typename CoordinateType>
  64. struct interior_rings<boost::polygon::polygon_with_holes_data<CoordinateType> >
  65. {
  66. typedef boost::polygon::polygon_with_holes_data<CoordinateType> polygon_type;
  67. typedef adapt::bp::holes_proxy<polygon_type> proxy;
  68. typedef adapt::bp::holes_proxy<polygon_type const> const_proxy;
  69. static inline proxy get(polygon_type& p)
  70. {
  71. return proxy(p);
  72. }
  73. static inline const_proxy get(polygon_type const& p)
  74. {
  75. return const_proxy(p);
  76. }
  77. };
  78. } // namespace traits
  79. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  80. }} // namespace boost::geometry
  81. #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP