all_custom_polygon.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_POLYGON_HPP
  8. #define GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_POLYGON_HPP
  9. #include <cstddef>
  10. #include <boost/range.hpp>
  11. #include <boost/geometry/core/mutable_range.hpp>
  12. #include <boost/geometry/core/tag.hpp>
  13. #include <boost/geometry/core/tags.hpp>
  14. #include <test_geometries/all_custom_container.hpp>
  15. #include <test_geometries/all_custom_ring.hpp>
  16. template <typename P>
  17. class all_custom_polygon
  18. {
  19. public :
  20. typedef all_custom_ring<P> custom_ring_type;
  21. typedef all_custom_container<custom_ring_type> custom_int_type;
  22. custom_ring_type& custom_ext() { return m_ext; }
  23. custom_int_type& custom_int() { return m_int; }
  24. custom_ring_type const& custom_ext() const { return m_ext; }
  25. custom_int_type const& custom_int() const { return m_int; }
  26. private :
  27. custom_ring_type m_ext;
  28. custom_int_type m_int;
  29. };
  30. namespace boost { namespace geometry
  31. {
  32. namespace traits
  33. {
  34. template <typename Point>
  35. struct tag<all_custom_polygon<Point> >
  36. {
  37. typedef polygon_tag type;
  38. };
  39. template <typename Point>
  40. struct ring_const_type<all_custom_polygon<Point> >
  41. {
  42. typedef typename all_custom_polygon<Point>::custom_ring_type const& type;
  43. };
  44. template <typename Point>
  45. struct ring_mutable_type<all_custom_polygon<Point> >
  46. {
  47. typedef typename all_custom_polygon<Point>::custom_ring_type& type;
  48. };
  49. template <typename Point>
  50. struct interior_const_type<all_custom_polygon<Point> >
  51. {
  52. typedef typename all_custom_polygon<Point>::custom_int_type const& type;
  53. };
  54. template <typename Point>
  55. struct interior_mutable_type<all_custom_polygon<Point> >
  56. {
  57. typedef typename all_custom_polygon<Point>::custom_int_type& type;
  58. };
  59. template <typename Point>
  60. struct exterior_ring<all_custom_polygon<Point> >
  61. {
  62. typedef all_custom_polygon<Point> polygon_type;
  63. typedef typename polygon_type::custom_ring_type ring_type;
  64. static inline ring_type& get(polygon_type& p)
  65. {
  66. return p.custom_ext();
  67. }
  68. static inline ring_type const& get(polygon_type const& p)
  69. {
  70. return p.custom_ext();
  71. }
  72. };
  73. template <typename Point>
  74. struct interior_rings<all_custom_polygon<Point> >
  75. {
  76. typedef all_custom_polygon<Point> polygon_type;
  77. typedef typename polygon_type::custom_int_type int_type;
  78. static inline int_type& get(polygon_type& p)
  79. {
  80. return p.custom_int();
  81. }
  82. static inline int_type const& get(polygon_type const& p)
  83. {
  84. return p.custom_int();
  85. }
  86. };
  87. } // namespace traits
  88. }} // namespace boost::geometry
  89. #endif // GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_POLYGON_HPP