]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/calculate_sum.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / calculate_sum.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
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.
7
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10
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
15
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)
19
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
22
23 #include <boost/range/begin.hpp>
24 #include <boost/range/end.hpp>
25
26 namespace boost { namespace geometry
27 {
28
29 #ifndef DOXYGEN_NO_DETAIL
30 namespace detail
31 {
32
33
34 class calculate_polygon_sum
35 {
36 template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
37 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
38 {
39 ReturnType sum = ReturnType(0);
40 for (typename boost::range_iterator<Rings const>::type
41 it = boost::begin(rings); it != boost::end(rings); ++it)
42 {
43 sum += Policy::apply(*it, strategy);
44 }
45 return sum;
46 }
47
48 public :
49 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
50 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
51 {
52 return Policy::apply(exterior_ring(poly), strategy)
53 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
54 ;
55 }
56 };
57
58
59 } // namespace detail
60 #endif // DOXYGEN_NO_DETAIL
61
62 }} // namespace boost::geometry
63
64 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP