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. 12 // Modifications copyright (c) 2016 Oracle and/or its affiliates. 13 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 14 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) 18 19 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP 20 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP 21 22 #include <boost/range.hpp> 23 24 namespace boost { namespace geometry 25 { 26 27 #ifndef DOXYGEN_NO_DETAIL 28 namespace detail 29 { 30 31 32 class calculate_polygon_sum 33 { 34 template <typename ReturnType, typename Policy, typename Rings, typename Strategy> sum_interior_rings(Rings const & rings,Strategy const & strategy)35 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy) 36 { 37 ReturnType sum = ReturnType(0); 38 for (typename boost::range_iterator<Rings const>::type 39 it = boost::begin(rings); it != boost::end(rings); ++it) 40 { 41 sum += Policy::apply(*it, strategy); 42 } 43 return sum; 44 } 45 46 public : 47 template <typename ReturnType, typename Policy, typename Polygon, typename Strategy> apply(Polygon const & poly,Strategy const & strategy)48 static inline ReturnType apply(Polygon const& poly, Strategy const& strategy) 49 { 50 return Policy::apply(exterior_ring(poly), strategy) 51 + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy) 52 ; 53 } 54 }; 55 56 57 } // namespace detail 58 #endif // DOXYGEN_NO_DETAIL 59 60 }} // namespace boost::geometry 61 62 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP 63