• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2019-2019 Barend Gehrels, Amsterdam, the Netherlands.
4 
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_AS_SUBRANGE_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_AS_SUBRANGE_HPP
11 
12 
13 #include <cstddef>
14 #include <map>
15 
16 #include <boost/geometry/core/access.hpp>
17 
18 namespace boost { namespace geometry
19 {
20 
21 #ifndef DOXYGEN_NO_DETAIL
22 namespace detail
23 {
24 
25 template <typename Segment>
26 struct segment_as_subrange
27 {
segment_as_subrangeboost::geometry::detail::segment_as_subrange28     segment_as_subrange(Segment const& s)
29         : m_segment(s)
30     {
31         geometry::set<0>(m_p1, geometry::get<0, 0>(m_segment));
32         geometry::set<1>(m_p1, geometry::get<0, 1>(m_segment));
33         geometry::set<0>(m_p2, geometry::get<1, 0>(m_segment));
34         geometry::set<1>(m_p2, geometry::get<1, 1>(m_segment));
35     }
36 
37     typedef typename geometry::point_type<Segment>::type point_type;
38 
atboost::geometry::detail::segment_as_subrange39     point_type const& at(std::size_t index) const
40     {
41         return index == 0 ? m_p1 : m_p2;
42     }
43 
is_last_segmentboost::geometry::detail::segment_as_subrange44     static inline bool is_last_segment()
45     {
46         return true;
47     }
48 
49     point_type m_p1, m_p2;
50 
51     Segment const& m_segment;
52 };
53 
54 } // namespace detail
55 #endif // DOXYGEN_NO_DETAIL
56 
57 }} // namespace boost::geometry
58 
59 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_AS_SUBRANGE_HPP
60