Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP Chris@16: #define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP Chris@16: Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Makes a segment behave like a linestring or a range Chris@101: \details Adapts a segment to the Boost.Range concept, enabling the user to Chris@16: iterate the two segment points. The segment_view is registered as a LineString Concept Chris@16: \tparam Segment \tparam_geometry{Segment} Chris@16: \ingroup views Chris@16: Chris@16: \qbk{before.synopsis, Chris@16: [heading Model of] Chris@16: [link geometry.reference.concepts.concept_linestring LineString Concept] Chris@16: } Chris@16: Chris@16: \qbk{[include reference/views/segment_view.qbk]} Chris@16: Chris@16: */ Chris@16: template Chris@16: struct segment_view Chris@16: : public detail::points_view Chris@16: < Chris@101: typename geometry::point_type::type, Chris@16: 2 Chris@16: > Chris@16: { Chris@16: typedef typename geometry::point_type::type point_type; Chris@101: Chris@16: /// Constructor accepting the segment to adapt Chris@16: explicit segment_view(Segment const& segment) Chris@16: : detail::points_view(copy_policy(segment)) Chris@16: {} Chris@101: Chris@101: private : Chris@101: Chris@16: class copy_policy Chris@16: { Chris@16: public : Chris@16: inline copy_policy(Segment const& segment) Chris@16: : m_segment(segment) Chris@16: {} Chris@101: Chris@16: inline void apply(point_type* points) const Chris@16: { Chris@16: geometry::detail::assign_point_from_index<0>(m_segment, points[0]); Chris@16: geometry::detail::assign_point_from_index<1>(m_segment, points[1]); Chris@16: } Chris@16: private : Chris@16: Segment const& m_segment; Chris@16: }; Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: Chris@16: // All segment ranges can be handled as linestrings Chris@16: namespace traits Chris@16: { Chris@16: Chris@16: template Chris@16: struct tag > Chris@16: { Chris@16: typedef linestring_tag type; Chris@16: }; Chris@16: Chris@16: } Chris@16: Chris@16: #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP