annotate DEPENDENCIES/generic/include/boost/geometry/views/box_view.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@16 6
Chris@16 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 9
Chris@16 10 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13
Chris@16 14 #ifndef BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
Chris@16 15 #define BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
Chris@16 16
Chris@16 17
Chris@16 18 #include <boost/range.hpp>
Chris@16 19
Chris@16 20 #include <boost/geometry/core/point_type.hpp>
Chris@16 21 #include <boost/geometry/views/detail/points_view.hpp>
Chris@16 22 #include <boost/geometry/algorithms/assign.hpp>
Chris@16 23
Chris@16 24
Chris@16 25 namespace boost { namespace geometry
Chris@16 26 {
Chris@16 27
Chris@16 28
Chris@16 29 /*!
Chris@16 30 \brief Makes a box behave like a ring or a range
Chris@16 31 \details Adapts a box to the Boost.Range concept, enabling the user to iterating
Chris@16 32 box corners. The box_view is registered as a Ring Concept
Chris@16 33 \tparam Box \tparam_geometry{Box}
Chris@16 34 \tparam Clockwise If true, walks in clockwise direction, otherwise
Chris@16 35 it walks in counterclockwise direction
Chris@16 36 \ingroup views
Chris@16 37
Chris@16 38 \qbk{before.synopsis,
Chris@16 39 [heading Model of]
Chris@16 40 [link geometry.reference.concepts.concept_ring Ring Concept]
Chris@16 41 }
Chris@16 42
Chris@16 43 \qbk{[include reference/views/box_view.qbk]}
Chris@16 44 */
Chris@16 45 template <typename Box, bool Clockwise = true>
Chris@16 46 struct box_view
Chris@16 47 : public detail::points_view
Chris@16 48 <
Chris@16 49 typename geometry::point_type<Box>::type,
Chris@16 50 5
Chris@16 51 >
Chris@16 52 {
Chris@16 53 typedef typename geometry::point_type<Box>::type point_type;
Chris@16 54
Chris@16 55 /// Constructor accepting the box to adapt
Chris@16 56 explicit box_view(Box const& box)
Chris@16 57 : detail::points_view<point_type, 5>(copy_policy(box))
Chris@16 58 {}
Chris@16 59
Chris@16 60 private :
Chris@16 61
Chris@16 62 class copy_policy
Chris@16 63 {
Chris@16 64 public :
Chris@16 65 inline copy_policy(Box const& box)
Chris@16 66 : m_box(box)
Chris@16 67 {}
Chris@16 68
Chris@16 69 inline void apply(point_type* points) const
Chris@16 70 {
Chris@16 71 detail::assign_box_corners_oriented<!Clockwise>(m_box, points);
Chris@16 72 points[4] = points[0];
Chris@16 73 }
Chris@16 74 private :
Chris@16 75 Box const& m_box;
Chris@16 76 };
Chris@16 77
Chris@16 78 };
Chris@16 79
Chris@16 80
Chris@16 81 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@16 82
Chris@16 83 // All views on boxes are handled as rings
Chris@16 84 namespace traits
Chris@16 85 {
Chris@16 86
Chris@16 87 template<typename Box, bool Clockwise>
Chris@16 88 struct tag<box_view<Box, Clockwise> >
Chris@16 89 {
Chris@16 90 typedef ring_tag type;
Chris@16 91 };
Chris@16 92
Chris@16 93 template<typename Box>
Chris@16 94 struct point_order<box_view<Box, false> >
Chris@16 95 {
Chris@16 96 static order_selector const value = counterclockwise;
Chris@16 97 };
Chris@16 98
Chris@16 99
Chris@16 100 template<typename Box>
Chris@16 101 struct point_order<box_view<Box, true> >
Chris@16 102 {
Chris@16 103 static order_selector const value = clockwise;
Chris@16 104 };
Chris@16 105
Chris@16 106 }
Chris@16 107
Chris@16 108 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@16 109
Chris@16 110
Chris@16 111 }} // namespace boost::geometry
Chris@16 112
Chris@16 113
Chris@16 114 #endif // BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP