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_BOX_VIEW_HPP Chris@16: #define BOOST_GEOMETRY_VIEWS_BOX_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 box behave like a ring or a range Chris@16: \details Adapts a box to the Boost.Range concept, enabling the user to iterating Chris@16: box corners. The box_view is registered as a Ring Concept Chris@16: \tparam Box \tparam_geometry{Box} Chris@16: \tparam Clockwise If true, walks in clockwise direction, otherwise Chris@16: it walks in counterclockwise direction Chris@16: \ingroup views Chris@16: Chris@16: \qbk{before.synopsis, Chris@16: [heading Model of] Chris@16: [link geometry.reference.concepts.concept_ring Ring Concept] Chris@16: } Chris@16: Chris@16: \qbk{[include reference/views/box_view.qbk]} Chris@16: */ Chris@16: template Chris@101: struct box_view Chris@16: : public detail::points_view Chris@16: < Chris@101: typename geometry::point_type::type, Chris@16: 5 Chris@16: > Chris@16: { Chris@16: typedef typename geometry::point_type::type point_type; Chris@101: Chris@16: /// Constructor accepting the box to adapt Chris@16: explicit box_view(Box const& box) Chris@16: : detail::points_view(copy_policy(box)) Chris@16: {} Chris@101: Chris@101: private : Chris@101: Chris@16: class copy_policy Chris@16: { Chris@16: public : Chris@16: inline copy_policy(Box const& box) Chris@16: : m_box(box) Chris@16: {} Chris@101: Chris@16: inline void apply(point_type* points) const Chris@16: { Chris@101: // assign_box_corners_oriented requires a range Chris@101: // an alternative for this workaround would be to pass a range here, Chris@101: // e.g. use boost::array in points_view instead of c-array Chris@101: std::pair rng = std::make_pair(points, points + 5); Chris@101: detail::assign_box_corners_oriented(m_box, rng); Chris@16: points[4] = points[0]; Chris@16: } Chris@16: private : Chris@16: Box const& m_box; Chris@16: }; Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: Chris@16: // All views on boxes are handled as rings Chris@16: namespace traits Chris@16: { Chris@16: Chris@16: template Chris@16: struct tag > Chris@16: { Chris@16: typedef ring_tag type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct point_order > Chris@16: { Chris@16: static order_selector const value = counterclockwise; Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: struct point_order > Chris@16: { Chris@16: static order_selector const value = clockwise; 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_BOX_VIEW_HPP