]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/calculate_sum.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / include / 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 // 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)
14
15 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
16 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
17
18 #include <boost/range.hpp>
19
20 namespace boost { namespace geometry
21 {
22
23 #ifndef DOXYGEN_NO_DETAIL
24 namespace detail
25 {
26
27
28 class calculate_polygon_sum
29 {
30 template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
31 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
32 {
33 ReturnType sum = ReturnType();
34 for (typename boost::range_iterator<Rings const>::type
35 it = boost::begin(rings); it != boost::end(rings); ++it)
36 {
37 sum += Policy::apply(*it, strategy);
38 }
39 return sum;
40 }
41
42 public :
43 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
44 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
45 {
46 return Policy::apply(exterior_ring(poly), strategy)
47 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
48 ;
49 }
50 };
51
52
53 } // namespace detail
54 #endif // DOXYGEN_NO_DETAIL
55
56 }} // namespace boost::geometry
57
58 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP