|
||||
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_SEGMENT_VIEW_HPP 0019 #define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP 0020 0021 0022 #include <array> 0023 0024 #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp> 0025 #include <boost/geometry/core/point_type.hpp> 0026 #include <boost/geometry/core/tag.hpp> 0027 0028 0029 namespace boost { namespace geometry 0030 { 0031 0032 // NOTE: This is equivalent to the previous implementation with detail::points_view. 0033 // Technically this should not be called a view because it owns the elements. 0034 // It's also not a borrowed_range because of dangling iterators after the 0035 // destruction. 0036 // It's a container or more specifically a linestring of some sort, e.g. static_linestring. 0037 // NOTE: It would be possible to implement a borrowed_range or a view. 0038 // The iterators would have to store copies of points. 0039 // Another possibility is to store the original Segment or reference/pointer 0040 // to Segment and index. But then the reference would be the value type 0041 // so technically they would be InputIterators not RandomAccessIterators. 0042 0043 0044 /*! 0045 \brief Makes a segment behave like a linestring or a range 0046 \details Adapts a segment to the Boost.Range concept, enabling the user to 0047 iterate the two segment points. The segment_view is registered as a LineString Concept 0048 \tparam Segment \tparam_geometry{Segment} 0049 \ingroup views 0050 0051 \qbk{before.synopsis, 0052 [heading Model of] 0053 [link geometry.reference.concepts.concept_linestring LineString Concept] 0054 } 0055 0056 \qbk{[include reference/views/segment_view.qbk]} 0057 0058 */ 0059 template <typename Segment> 0060 struct segment_view 0061 { 0062 using array_t = std::array<typename geometry::point_type<Segment>::type, 2>; 0063 0064 using iterator = typename array_t::const_iterator; 0065 using const_iterator = typename array_t::const_iterator; 0066 0067 /// Constructor accepting the segment to adapt 0068 explicit segment_view(Segment const& segment) 0069 { 0070 geometry::detail::assign_point_from_index<0>(segment, m_array[0]); 0071 geometry::detail::assign_point_from_index<1>(segment, m_array[1]); 0072 } 0073 0074 const_iterator begin() const noexcept { return m_array.begin(); } 0075 const_iterator end() const noexcept { return m_array.end(); } 0076 0077 private: 0078 array_t m_array; 0079 }; 0080 0081 0082 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS 0083 0084 // All segment ranges can be handled as linestrings 0085 namespace traits 0086 { 0087 0088 template<typename Segment> 0089 struct tag<segment_view<Segment> > 0090 { 0091 typedef linestring_tag type; 0092 }; 0093 0094 } 0095 0096 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS 0097 0098 0099 }} // namespace boost::geometry 0100 0101 0102 #endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |