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_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
18 #include <boost/mpl/assert.hpp>
19 #include <boost/concept/requires.hpp>
20 #include <boost/range.hpp>
21 #include <boost/type_traits/is_const.hpp>
22 #include <boost/type_traits/remove_const.hpp>
24 #include <boost/geometry/core/tag.hpp>
25 #include <boost/geometry/core/tag_cast.hpp>
26 #include <boost/geometry/core/tags.hpp>
28 #include <boost/geometry/util/add_const_if_c.hpp>
29 #include <boost/geometry/views/box_view.hpp>
32 namespace boost { namespace geometry
36 #ifndef DOXYGEN_NO_DETAIL
37 namespace detail { namespace for_each
41 template <typename Range, typename Actor>
44 static inline void apply(Range & range, Actor & actor)
51 template <typename Polygon, typename Actor>
52 struct fe_range_polygon
54 static inline void apply(Polygon & polygon, Actor & actor)
56 actor.apply(exterior_ring(polygon));
58 // TODO: If some flag says true, also do the inner rings.
59 // for convex hull, it's not necessary
63 template <typename Box, typename Actor>
66 static inline void apply(Box & box, Actor & actor)
68 actor.apply(box_view<typename boost::remove_const<Box>::type>(box));
72 template <typename Multi, typename Actor, typename SinglePolicy>
75 static inline void apply(Multi & multi, Actor & actor)
77 for ( typename boost::range_iterator<Multi>::type
78 it = boost::begin(multi); it != boost::end(multi); ++it)
80 SinglePolicy::apply(*it, actor);
85 }} // namespace detail::for_each
86 #endif // DOXYGEN_NO_DETAIL
89 #ifndef DOXYGEN_NO_DISPATCH
98 typename Tag = typename tag<Geometry>::type
100 struct for_each_range
104 false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
110 template <typename Linestring, typename Actor>
111 struct for_each_range<Linestring, Actor, linestring_tag>
112 : detail::for_each::fe_range_range<Linestring, Actor>
116 template <typename Ring, typename Actor>
117 struct for_each_range<Ring, Actor, ring_tag>
118 : detail::for_each::fe_range_range<Ring, Actor>
122 template <typename Polygon, typename Actor>
123 struct for_each_range<Polygon, Actor, polygon_tag>
124 : detail::for_each::fe_range_polygon<Polygon, Actor>
128 template <typename Box, typename Actor>
129 struct for_each_range<Box, Actor, box_tag>
130 : detail::for_each::fe_range_box<Box, Actor>
134 template <typename MultiPoint, typename Actor>
135 struct for_each_range<MultiPoint, Actor, multi_point_tag>
136 : detail::for_each::fe_range_range<MultiPoint, Actor>
140 template <typename Geometry, typename Actor>
141 struct for_each_range<Geometry, Actor, multi_linestring_tag>
142 : detail::for_each::fe_range_multi
146 detail::for_each::fe_range_range
148 typename add_const_if_c
150 boost::is_const<Geometry>::value,
151 typename boost::range_value<Geometry>::type
159 template <typename Geometry, typename Actor>
160 struct for_each_range<Geometry, Actor, multi_polygon_tag>
161 : detail::for_each::fe_range_multi
165 detail::for_each::fe_range_polygon
167 typename add_const_if_c
169 boost::is_const<Geometry>::value,
170 typename boost::range_value<Geometry>::type
178 } // namespace dispatch
179 #endif // DOXYGEN_NO_DISPATCH
184 template <typename Geometry, typename Actor>
185 inline void for_each_range(Geometry const& geometry, Actor & actor)
187 dispatch::for_each_range
191 >::apply(geometry, actor);
198 }} // namespace boost::geometry
201 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP