exterior_ring.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP
  14. #define BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP
  15. #include <type_traits>
  16. #include <boost/geometry/core/ring_type.hpp>
  17. #include <boost/geometry/core/static_assert.hpp>
  18. #include <boost/geometry/core/tag.hpp>
  19. #include <boost/geometry/core/tags.hpp>
  20. namespace boost { namespace geometry
  21. {
  22. namespace traits
  23. {
  24. /*!
  25. \brief Traits class defining access to exterior_ring of a polygon
  26. \details Should define const and non const access
  27. \ingroup traits
  28. \tparam Polygon the polygon type
  29. \par Geometries:
  30. - polygon
  31. \par Specializations should provide:
  32. - static inline RING& get(POLY& )
  33. - static inline RING const& get(POLY const& )
  34. */
  35. template <typename Polygon>
  36. struct exterior_ring
  37. {
  38. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  39. "Not implemented for this Polygon type.",
  40. Polygon);
  41. };
  42. } // namespace traits
  43. #ifndef DOXYGEN_NO_DISPATCH
  44. namespace core_dispatch
  45. {
  46. template <typename Tag, typename Geometry>
  47. struct exterior_ring
  48. {
  49. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  50. "Not implemented for this Geometry type.",
  51. Tag, Geometry);
  52. };
  53. template <typename Polygon>
  54. struct exterior_ring<polygon_tag, Polygon>
  55. {
  56. static
  57. typename geometry::ring_return_type<Polygon>::type
  58. apply(Polygon& polygon)
  59. {
  60. return traits::exterior_ring
  61. <
  62. typename std::remove_const<Polygon>::type
  63. >::get(polygon);
  64. }
  65. };
  66. } // namespace core_dispatch
  67. #endif // DOXYGEN_NO_DISPATCH
  68. /*!
  69. \brief Function to get the exterior_ring ring of a polygon
  70. \ingroup exterior_ring
  71. \note OGC compliance: instead of ExteriorRing
  72. \tparam Polygon polygon type
  73. \param polygon the polygon to get the exterior ring from
  74. \return a reference to the exterior ring
  75. */
  76. template <typename Polygon>
  77. inline typename ring_return_type<Polygon>::type exterior_ring(Polygon& polygon)
  78. {
  79. return core_dispatch::exterior_ring
  80. <
  81. typename tag<Polygon>::type,
  82. Polygon
  83. >::apply(polygon);
  84. }
  85. /*!
  86. \brief Function to get the exterior ring of a polygon (const version)
  87. \ingroup exterior_ring
  88. \note OGC compliance: instead of ExteriorRing
  89. \tparam Polygon polygon type
  90. \param polygon the polygon to get the exterior ring from
  91. \return a const reference to the exterior ring
  92. \qbk{distinguish,const version}
  93. */
  94. template <typename Polygon>
  95. inline typename ring_return_type<Polygon const>::type exterior_ring(
  96. Polygon const& polygon)
  97. {
  98. return core_dispatch::exterior_ring
  99. <
  100. typename tag<Polygon>::type,
  101. Polygon const
  102. >::apply(polygon);
  103. }
  104. }} // namespace boost::geometry
  105. #endif // BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP