1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
10 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
12 // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
13 // boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
14 // hole_iterator -> returning ring_proxy's instead of normal polygon_data
16 #include <boost/polygon/polygon.hpp>
18 #include <boost/iterator.hpp>
19 #include <boost/iterator/iterator_facade.hpp>
22 namespace boost { namespace geometry
25 namespace adapt { namespace bp
29 template <typename Polygon, typename RingProxy>
31 : public ::boost::iterator_facade
33 hole_iterator<Polygon, RingProxy>,
34 RingProxy, // value type
35 boost::forward_traversal_tag,
36 RingProxy // reference type
40 typedef typename boost::polygon::polygon_with_holes_traits
43 >::iterator_holes_type ith_type;
45 explicit inline hole_iterator(Polygon& polygon, ith_type const it)
51 typedef std::ptrdiff_t difference_type;
54 friend class boost::iterator_core_access;
56 inline RingProxy dereference() const
58 return RingProxy(m_polygon, this->m_base);
61 inline void increment() { ++m_base; }
62 inline void decrement() { --m_base; }
63 inline void advance(difference_type n)
65 for (int i = 0; i < n; i++)
71 inline bool equal(hole_iterator<Polygon, RingProxy> const& other) const
73 return this->m_base == other.m_base;
83 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP