]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/views/segment_view.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / views / segment_view.hpp
CommitLineData
7c673cae
FG
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// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#ifndef BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
15#define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
16
17
18#include <boost/range.hpp>
19
20#include <boost/geometry/core/point_type.hpp>
21#include <boost/geometry/views/detail/points_view.hpp>
22#include <boost/geometry/algorithms/assign.hpp>
23
24
25namespace boost { namespace geometry
26{
27
28
29/*!
30\brief Makes a segment behave like a linestring or a range
31\details Adapts a segment to the Boost.Range concept, enabling the user to
32 iterate the two segment points. The segment_view is registered as a LineString Concept
33\tparam Segment \tparam_geometry{Segment}
34\ingroup views
35
36\qbk{before.synopsis,
37[heading Model of]
38[link geometry.reference.concepts.concept_linestring LineString Concept]
39}
40
41\qbk{[include reference/views/segment_view.qbk]}
42
43*/
44template <typename Segment>
45struct segment_view
46 : public detail::points_view
47 <
48 typename geometry::point_type<Segment>::type,
49 2
50 >
51{
52 typedef typename geometry::point_type<Segment>::type point_type;
53
54 /// Constructor accepting the segment to adapt
55 explicit segment_view(Segment const& segment)
56 : detail::points_view<point_type, 2>(copy_policy(segment))
57 {}
58
59private :
60
61 class copy_policy
62 {
63 public :
64 inline copy_policy(Segment const& segment)
65 : m_segment(segment)
66 {}
67
68 inline void apply(point_type* points) const
69 {
70 geometry::detail::assign_point_from_index<0>(m_segment, points[0]);
71 geometry::detail::assign_point_from_index<1>(m_segment, points[1]);
72 }
73 private :
74 Segment const& m_segment;
75 };
76
77};
78
79
80#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
81
82// All segment ranges can be handled as linestrings
83namespace traits
84{
85
86template<typename Segment>
87struct tag<segment_view<Segment> >
88{
89 typedef linestring_tag type;
90};
91
92}
93
94#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
95
96
97}} // namespace boost::geometry
98
99
100#endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP