normalized_view.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.
  6. // Modifications copyright (c) 2014 Oracle and/or its affiliates.
  7. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  8. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  9. // Use, modification and distribution is subject to the Boost Software License,
  10. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt)
  12. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  13. #ifndef BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP
  14. #define BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP
  15. #include <boost/range/begin.hpp>
  16. #include <boost/range/end.hpp>
  17. #include <boost/range/iterator.hpp>
  18. #include <boost/mpl/if.hpp>
  19. #include <boost/type_traits/is_const.hpp>
  20. #include <boost/geometry/views/detail/range_type.hpp>
  21. #include <boost/geometry/views/reversible_view.hpp>
  22. #include <boost/geometry/views/closeable_view.hpp>
  23. #include <boost/geometry/util/order_as_direction.hpp>
  24. namespace boost { namespace geometry {
  25. #ifndef DOXYGEN_NO_DETAIL
  26. namespace detail {
  27. template <typename Geometry>
  28. struct normalized_view
  29. {
  30. static const bool is_const = boost::is_const<Geometry>::value;
  31. //typedef typename ring_type<Geometry>::type ring_type;
  32. typedef typename detail::range_type<Geometry>::type range_type;
  33. typedef typename
  34. boost::mpl::if_c
  35. <
  36. is_const,
  37. range_type const,
  38. range_type
  39. >::type range;
  40. typedef typename
  41. reversible_view
  42. <
  43. range,
  44. order_as_direction
  45. <
  46. geometry::point_order<Geometry>::value
  47. >::value
  48. >::type reversible_type;
  49. typedef typename
  50. boost::mpl::if_c
  51. <
  52. is_const,
  53. reversible_type const,
  54. reversible_type
  55. >::type reversible;
  56. typedef typename
  57. closeable_view
  58. <
  59. reversible,
  60. geometry::closure<Geometry>::value
  61. >::type closeable_type;
  62. typedef typename
  63. boost::mpl::if_c
  64. <
  65. is_const,
  66. closeable_type const,
  67. closeable_type
  68. >::type closeable;
  69. explicit inline normalized_view(range & r)
  70. : m_reversible(r)
  71. , m_closeable(m_reversible)
  72. {}
  73. typedef typename boost::range_iterator<closeable>::type iterator;
  74. typedef typename boost::range_const_iterator<closeable>::type const_iterator;
  75. inline const_iterator begin() const { return boost::begin(m_closeable); }
  76. inline const_iterator end() const { return boost::end(m_closeable); }
  77. inline iterator begin() { return boost::begin(m_closeable); }
  78. inline iterator end() { return boost::end(m_closeable); }
  79. private:
  80. reversible_type m_reversible;
  81. closeable_type m_closeable;
  82. };
  83. } // namespace detail
  84. #endif // DOXYGEN_NO_DETAIL
  85. }} // namespace boost::geometry
  86. #endif // BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP