1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 6 7 // This file was modified by Oracle on 2014. 8 // Modifications copyright (c) 2014 Oracle and/or its affiliates. 9 10 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 11 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 12 13 // Use, modification and distribution is subject to the Boost Software License, 14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 15 // http://www.boost.org/LICENSE_1_0.txt) 16 17 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 18 19 #ifndef BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP 20 #define BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP 21 22 23 #include <boost/range/begin.hpp> 24 #include <boost/range/end.hpp> 25 #include <boost/range/iterator.hpp> 26 #include <boost/mpl/if.hpp> 27 #include <boost/type_traits/is_const.hpp> 28 #include <boost/geometry/views/detail/range_type.hpp> 29 #include <boost/geometry/views/reversible_view.hpp> 30 #include <boost/geometry/views/closeable_view.hpp> 31 #include <boost/geometry/util/order_as_direction.hpp> 32 33 namespace boost { namespace geometry { 34 35 36 #ifndef DOXYGEN_NO_DETAIL 37 38 namespace detail { 39 40 template <typename Geometry> 41 struct normalized_view 42 { 43 static const bool is_const = boost::is_const<Geometry>::value; 44 45 //typedef typename ring_type<Geometry>::type ring_type; 46 47 typedef typename detail::range_type<Geometry>::type range_type; 48 49 typedef typename 50 boost::mpl::if_c 51 < 52 is_const, 53 range_type const, 54 range_type 55 >::type range; 56 57 typedef typename 58 reversible_view 59 < 60 range, 61 order_as_direction 62 < 63 geometry::point_order<Geometry>::value 64 >::value 65 >::type reversible_type; 66 67 typedef typename 68 boost::mpl::if_c 69 < 70 is_const, 71 reversible_type const, 72 reversible_type 73 >::type reversible; 74 75 typedef typename 76 closeable_view 77 < 78 reversible, 79 geometry::closure<Geometry>::value 80 >::type closeable_type; 81 82 typedef typename 83 boost::mpl::if_c 84 < 85 is_const, 86 closeable_type const, 87 closeable_type 88 >::type closeable; 89 normalized_viewboost::geometry::detail::normalized_view90 explicit inline normalized_view(range & r) 91 : m_reversible(r) 92 , m_closeable(m_reversible) 93 {} 94 95 typedef typename boost::range_iterator<closeable>::type iterator; 96 typedef typename boost::range_const_iterator<closeable>::type const_iterator; 97 beginboost::geometry::detail::normalized_view98 inline const_iterator begin() const { return boost::begin(m_closeable); } endboost::geometry::detail::normalized_view99 inline const_iterator end() const { return boost::end(m_closeable); } 100 beginboost::geometry::detail::normalized_view101 inline iterator begin() { return boost::begin(m_closeable); } endboost::geometry::detail::normalized_view102 inline iterator end() { return boost::end(m_closeable); } 103 104 private: 105 reversible_type m_reversible; 106 closeable_type m_closeable; 107 }; 108 109 } // namespace detail 110 111 #endif // DOXYGEN_NO_DETAIL 112 113 114 }} // namespace boost::geometry 115 116 117 #endif // BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP 118