reversible_view.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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-2023.
  6. // Modifications copyright (c) 2020-2023 Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
  15. #define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
  16. #include <boost/version.hpp>
  17. #include <boost/range/adaptor/reversed.hpp>
  18. #include <boost/geometry/core/closure.hpp>
  19. #include <boost/geometry/core/point_order.hpp>
  20. #include <boost/geometry/core/ring_type.hpp>
  21. #include <boost/geometry/core/tag.hpp>
  22. #include <boost/geometry/core/tags.hpp>
  23. #include <boost/geometry/util/order_as_direction.hpp>
  24. #include <boost/geometry/views/identity_view.hpp>
  25. namespace boost { namespace geometry
  26. {
  27. #ifndef DOXYGEN_NO_DETAIL
  28. namespace detail
  29. {
  30. template
  31. <
  32. typename Range,
  33. order_selector Order = geometry::point_order<Range>::value
  34. >
  35. struct clockwise_view
  36. : identity_view<Range>
  37. {
  38. explicit inline clockwise_view(Range& r)
  39. : identity_view<Range>(r)
  40. {}
  41. };
  42. template <typename Range>
  43. struct clockwise_view<Range, counterclockwise>
  44. : boost::reversed_range<Range>
  45. {
  46. explicit inline clockwise_view(Range& r)
  47. : boost::reversed_range<Range>(r)
  48. {}
  49. };
  50. } // namespace detail
  51. #endif // DOXYGEN_NO_DETAIL
  52. /*!
  53. \brief View on a range, reversing direction if necessary
  54. \tparam Range original range
  55. \tparam Direction direction of iteration
  56. \ingroup views
  57. */
  58. template <typename Range, iterate_direction Direction>
  59. struct reversible_view {};
  60. #ifndef DOXYGEN_NO_SPECIALIZATIONS
  61. template <typename Range>
  62. struct reversible_view<Range, iterate_forward>
  63. {
  64. using type = identity_view<Range>;
  65. };
  66. template <typename Range>
  67. struct reversible_view<Range, iterate_reverse>
  68. {
  69. using type = boost::reversed_range<Range>;
  70. };
  71. #endif // DOXYGEN_NO_SPECIALIZATIONS
  72. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  73. namespace traits
  74. {
  75. template <typename Range, order_selector Order>
  76. struct tag<geometry::detail::clockwise_view<Range, Order> >
  77. : geometry::tag<Range>
  78. {};
  79. template <typename Range, order_selector Order>
  80. struct point_order<geometry::detail::clockwise_view<Range, Order> >
  81. {
  82. static const order_selector value = clockwise;
  83. };
  84. template <typename Range, order_selector Order>
  85. struct closure<geometry::detail::clockwise_view<Range, Order> >
  86. : geometry::closure<Range>
  87. {};
  88. } // namespace traits
  89. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  90. }} // namespace boost::geometry
  91. #endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP