closed_clockwise_view.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 2014-2021.
  6. // Modifications copyright (c) 2014-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_DETAIL_CLOSED_CLOCKWISE_VIEW_HPP
  15. #define BOOST_GEOMETRY_VIEWS_DETAIL_CLOSED_CLOCKWISE_VIEW_HPP
  16. #include <type_traits>
  17. #include <boost/range/begin.hpp>
  18. #include <boost/range/end.hpp>
  19. #include <boost/range/iterator.hpp>
  20. #include <boost/geometry/views/closeable_view.hpp>
  21. #include <boost/geometry/views/reversible_view.hpp>
  22. #include <boost/geometry/util/order_as_direction.hpp>
  23. #include <boost/geometry/util/type_traits_std.hpp>
  24. namespace boost { namespace geometry
  25. {
  26. #ifndef DOXYGEN_NO_DETAIL
  27. namespace detail
  28. {
  29. template
  30. <
  31. typename Range,
  32. closure_selector Closure = geometry::closure<Range>::value,
  33. order_selector Order = geometry::point_order<Range>::value
  34. >
  35. struct closed_clockwise_view
  36. {
  37. using closed_view = detail::closed_view<Range const, Closure>;
  38. using view = detail::clockwise_view<closed_view const, Order>;
  39. explicit inline closed_clockwise_view(Range const& r)
  40. : m_view(closed_view(r))
  41. {}
  42. using iterator = typename boost::range_iterator<view const>::type;
  43. using const_iterator = typename boost::range_iterator<view const>::type;
  44. inline const_iterator begin() const { return boost::begin(m_view); }
  45. inline const_iterator end() const { return boost::end(m_view); }
  46. private:
  47. view m_view;
  48. };
  49. } // namespace detail
  50. #endif // DOXYGEN_NO_DETAIL
  51. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  52. namespace traits
  53. {
  54. template <typename Range, closure_selector Closure, order_selector Order>
  55. struct tag<geometry::detail::closed_clockwise_view<Range, Closure, Order> >
  56. : geometry::tag<Range>
  57. {};
  58. template <typename Range, closure_selector Closure, order_selector Order>
  59. struct point_order<geometry::detail::closed_clockwise_view<Range, Closure, Order> >
  60. {
  61. static const order_selector value = clockwise;
  62. };
  63. template <typename Range, closure_selector Closure, order_selector Order>
  64. struct closure<geometry::detail::closed_clockwise_view<Range, Closure, Order> >
  65. {
  66. static const closure_selector value = closed;
  67. };
  68. } // namespace traits
  69. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  70. }} // namespace boost::geometry
  71. #endif // BOOST_GEOMETRY_VIEWS_DETAIL_CLOSED_CLOCKWISE_VIEW_HPP