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.
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
16 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
18 #include <boost/range.hpp>
20 namespace boost { namespace geometry
23 #ifndef DOXYGEN_NO_DETAIL
28 class calculate_polygon_sum
30 template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
31 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
33 ReturnType sum = ReturnType();
34 for (typename boost::range_iterator<Rings const>::type
35 it = boost::begin(rings); it != boost::end(rings); ++it)
37 sum += Policy::apply(*it, strategy);
43 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
44 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
46 return Policy::apply(exterior_ring(poly), strategy)
47 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
54 #endif // DOXYGEN_NO_DETAIL
56 }} // namespace boost::geometry
58 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP