calculate_sum.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // This file was modified by Oracle on 2016.
  9. // Modifications copyright (c) 2016 Oracle and/or its affiliates.
  10. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  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. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
  15. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
  16. #include <boost/range.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. #ifndef DOXYGEN_NO_DETAIL
  20. namespace detail
  21. {
  22. class calculate_polygon_sum
  23. {
  24. template <typename ReturnType, typename Policy, typename Rings, typename Strategy>
  25. static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
  26. {
  27. ReturnType sum = ReturnType(0);
  28. for (typename boost::range_iterator<Rings const>::type
  29. it = boost::begin(rings); it != boost::end(rings); ++it)
  30. {
  31. sum += Policy::apply(*it, strategy);
  32. }
  33. return sum;
  34. }
  35. public :
  36. template <typename ReturnType, typename Policy, typename Polygon, typename Strategy>
  37. static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
  38. {
  39. return Policy::apply(exterior_ring(poly), strategy)
  40. + sum_interior_rings<ReturnType, Policy>(interior_rings(poly), strategy)
  41. ;
  42. }
  43. };
  44. } // namespace detail
  45. #endif // DOXYGEN_NO_DETAIL
  46. }} // namespace boost::geometry
  47. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP