interior_rings.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
  11. #define BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
  12. #include <cstddef>
  13. #include <boost/mpl/assert.hpp>
  14. #include <boost/range/value_type.hpp>
  15. #include <boost/type_traits/remove_const.hpp>
  16. #include <boost/geometry/core/tag.hpp>
  17. #include <boost/geometry/core/tags.hpp>
  18. #include <boost/geometry/core/interior_type.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. namespace traits
  22. {
  23. /*!
  24. \brief Traits class defining access to interior_rings of a polygon
  25. \details defines access (const and non const) to interior ring
  26. \ingroup traits
  27. \par Geometries:
  28. - polygon
  29. \par Specializations should provide:
  30. - static inline INTERIOR& get(POLY&)
  31. - static inline const INTERIOR& get(POLY const&)
  32. \tparam Geometry geometry
  33. */
  34. template <typename Geometry>
  35. struct interior_rings
  36. {
  37. BOOST_MPL_ASSERT_MSG
  38. (
  39. false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  40. , (types<Geometry>)
  41. );
  42. };
  43. } // namespace traits
  44. #ifndef DOXYGEN_NO_DISPATCH
  45. namespace core_dispatch
  46. {
  47. template
  48. <
  49. typename GeometryTag,
  50. typename Geometry
  51. >
  52. struct interior_rings {};
  53. template <typename Polygon>
  54. struct interior_rings<polygon_tag, Polygon>
  55. {
  56. static inline
  57. typename geometry::interior_return_type<Polygon>::type
  58. apply(Polygon& polygon)
  59. {
  60. return traits::interior_rings
  61. <
  62. typename boost::remove_const<Polygon>::type
  63. >::get(polygon);
  64. }
  65. };
  66. template <typename MultiPolygon>
  67. struct interior_type<multi_polygon_tag, MultiPolygon>
  68. {
  69. typedef typename core_dispatch::interior_type
  70. <
  71. polygon_tag,
  72. typename boost::range_value<MultiPolygon>::type
  73. >::type type;
  74. };
  75. } // namespace core_dispatch
  76. #endif
  77. /*!
  78. \brief Function to get the interior rings of a polygon (non const version)
  79. \ingroup interior_rings
  80. \note OGC compliance: instead of InteriorRingN
  81. \tparam Polygon polygon type
  82. \param polygon the polygon to get the interior rings from
  83. \return the interior rings (possibly a reference)
  84. */
  85. template <typename Polygon>
  86. inline typename interior_return_type<Polygon>::type interior_rings(Polygon& polygon)
  87. {
  88. return core_dispatch::interior_rings
  89. <
  90. typename tag<Polygon>::type,
  91. Polygon
  92. >::apply(polygon);
  93. }
  94. /*!
  95. \brief Function to get the interior rings of a polygon (const version)
  96. \ingroup interior_rings
  97. \note OGC compliance: instead of InteriorRingN
  98. \tparam Polygon polygon type
  99. \param polygon the polygon to get the interior rings from
  100. \return the interior rings (possibly a const reference)
  101. \qbk{distinguish,const version}
  102. */
  103. template <typename Polygon>
  104. inline typename interior_return_type<Polygon const>::type interior_rings(
  105. Polygon const& polygon)
  106. {
  107. return core_dispatch::interior_rings
  108. <
  109. typename tag<Polygon>::type,
  110. Polygon const
  111. >::apply(polygon);
  112. }
  113. }} // namespace boost::geometry
  114. #endif // BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP