Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@101
|
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
|
Chris@16
|
7
|
Chris@16
|
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
10
|
Chris@16
|
11 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
13 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
|
Chris@16
|
16 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/range.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace geometry
|
Chris@16
|
21 {
|
Chris@16
|
22
|
Chris@16
|
23 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
24 namespace detail
|
Chris@16
|
25 {
|
Chris@16
|
26
|
Chris@16
|
27
|
Chris@16
|
28 class calculate_polygon_sum
|
Chris@16
|
29 {
|
Chris@16
|
30 template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
|
Chris@16
|
31 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
|
Chris@16
|
32 {
|
Chris@16
|
33 ReturnType sum = ReturnType();
|
Chris@101
|
34 for (typename boost::range_iterator<Rings const>::type
|
Chris@101
|
35 it = boost::begin(rings); it != boost::end(rings); ++it)
|
Chris@16
|
36 {
|
Chris@16
|
37 sum += Policy::apply(*it, strategy);
|
Chris@16
|
38 }
|
Chris@16
|
39 return sum;
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 public :
|
Chris@16
|
43 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
|
Chris@16
|
44 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
|
Chris@16
|
45 {
|
Chris@16
|
46 return Policy::apply(exterior_ring(poly), strategy)
|
Chris@16
|
47 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
|
Chris@16
|
48 ;
|
Chris@16
|
49 }
|
Chris@16
|
50 };
|
Chris@16
|
51
|
Chris@16
|
52
|
Chris@16
|
53 } // namespace detail
|
Chris@16
|
54 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
55
|
Chris@16
|
56 }} // namespace boost::geometry
|
Chris@16
|
57
|
Chris@16
|
58 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
|