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-2020.
12 // Modifications copyright (c) 2016-2020 Oracle and/or its affiliates.
13 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
14 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
23 #include <boost/range/begin.hpp>
24 #include <boost/range/end.hpp>
26 namespace boost { namespace geometry
29 #ifndef DOXYGEN_NO_DETAIL
34 class calculate_polygon_sum
36 template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
37 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
39 ReturnType sum = ReturnType(0);
40 for (typename boost::range_iterator<Rings const>::type
41 it = boost::begin(rings); it != boost::end(rings); ++it)
43 sum += Policy::apply(*it, strategy);
49 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
50 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
52 return Policy::apply(exterior_ring(poly), strategy)
53 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
60 #endif // DOXYGEN_NO_DETAIL
62 }} // namespace boost::geometry
64 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP