1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
14 #ifndef BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
15 #define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
18 #include <boost/range.hpp>
20 #include <boost/geometry/core/point_type.hpp>
21 #include <boost/geometry/views/detail/points_view.hpp>
22 #include <boost/geometry/algorithms/assign.hpp>
25 namespace boost { namespace geometry
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}
38 [link geometry.reference.concepts.concept_linestring LineString Concept]
41 \qbk{[include reference/views/segment_view.qbk]}
44 template <typename Segment>
46 : public detail::points_view
48 typename geometry::point_type<Segment>::type,
52 typedef typename geometry::point_type<Segment>::type point_type;
54 /// Constructor accepting the segment to adapt
55 explicit segment_view(Segment const& segment)
56 : detail::points_view<point_type, 2>(copy_policy(segment))
64 inline copy_policy(Segment const& segment)
68 inline void apply(point_type* points) const
70 geometry::detail::assign_point_from_index<0>(m_segment, points[0]);
71 geometry::detail::assign_point_from_index<1>(m_segment, points[1]);
74 Segment const& m_segment;
80 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
82 // All segment ranges can be handled as linestrings
86 template<typename Segment>
87 struct tag<segment_view<Segment> >
89 typedef linestring_tag type;
94 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
97 }} // namespace boost::geometry
100 #endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP