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 // This file was modified by Oracle on 2016.
12 // Modifications copyright (c) 2016 Oracle and/or its affiliates.
13 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
20 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
22 #include <boost/range.hpp>
24 namespace boost { namespace geometry
27 #ifndef DOXYGEN_NO_DETAIL
32 class calculate_polygon_sum
34 template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
35 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
37 ReturnType sum = ReturnType(0);
38 for (typename boost::range_iterator<Rings const>::type
39 it = boost::begin(rings); it != boost::end(rings); ++it)
41 sum += Policy::apply(*it, strategy);
47 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
48 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
50 return Policy::apply(exterior_ring(poly), strategy)
51 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
58 #endif // DOXYGEN_NO_DETAIL
60 }} // namespace boost::geometry
62 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP