Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:54

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2020-2021.
0008 // Modifications copyright (c) 2020-2021 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0012 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
0019 #define BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
0020 
0021 
0022 #include <array>
0023 
0024 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
0025 #include <boost/geometry/core/point_order.hpp>
0026 #include <boost/geometry/core/point_type.hpp>
0027 #include <boost/geometry/core/tag.hpp>
0028 
0029 
0030 namespace boost { namespace geometry
0031 {
0032 
0033 // NOTE: This is equivalent to the previous implementation with detail::points_view.
0034 //       Technically this should not be called a view because it owns the elements.
0035 //       It's also not a borrowed_range because of dangling iterators after the
0036 //       destruction.
0037 //       It's a container or more specifically a ring of some sort, e.g. static_ring.
0038 // NOTE: It would be possible to implement a borrowed_range or a view.
0039 //       The iterators would have to store copies of points.
0040 //       Another possibility is to store the original Box or reference/pointer
0041 //       to Box and index. But then the reference would be the value type
0042 //       so technically they would be InputIterators not RandomAccessIterators.
0043 // NOTE: This object can not represent a Box correctly in all coordinates systems.
0044 //       It's correct only in cartesian CS so maybe it should be removed entirely.
0045 
0046 
0047 /*!
0048 \brief Makes a box behave like a ring or a range
0049 \details Adapts a box to the Boost.Range concept, enabling the user to iterating
0050     box corners. The box_view is registered as a Ring Concept
0051 \tparam Box \tparam_geometry{Box}
0052 \tparam Clockwise If true, walks in clockwise direction, otherwise
0053     it walks in counterclockwise direction
0054 \ingroup views
0055 
0056 \qbk{before.synopsis,
0057 [heading Model of]
0058 [link geometry.reference.concepts.concept_ring Ring Concept]
0059 }
0060 
0061 \qbk{[include reference/views/box_view.qbk]}
0062 */
0063 template <typename Box, bool Clockwise = true>
0064 struct box_view
0065 {
0066     using array_t = std::array<typename geometry::point_type<Box>::type, 5>;
0067 
0068     using iterator = typename array_t::const_iterator;
0069     using const_iterator = typename array_t::const_iterator;
0070 
0071     /// Constructor accepting the box to adapt
0072     explicit box_view(Box const& box)
0073     {
0074         detail::assign_box_corners_oriented<!Clockwise>(box, m_array);
0075         m_array[4] = m_array[0];
0076     }
0077 
0078     const_iterator begin() const noexcept { return m_array.begin(); }
0079     const_iterator end() const noexcept { return m_array.end(); }
0080 
0081 private:
0082     array_t m_array;
0083 };
0084 
0085 
0086 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0087 
0088 // All views on boxes are handled as rings
0089 namespace traits
0090 {
0091 
0092 template<typename Box, bool Clockwise>
0093 struct tag<box_view<Box, Clockwise> >
0094 {
0095     typedef ring_tag type;
0096 };
0097 
0098 template<typename Box>
0099 struct point_order<box_view<Box, false> >
0100 {
0101     static order_selector const value = counterclockwise;
0102 };
0103 
0104 
0105 template<typename Box>
0106 struct point_order<box_view<Box, true> >
0107 {
0108     static order_selector const value = clockwise;
0109 };
0110 
0111 }
0112 
0113 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0114 
0115 
0116 }} // namespace boost::geometry
0117 
0118 
0119 #endif // BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP