1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
8 // This file was modified by Oracle on 2014.
9 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
25 #include <boost/range.hpp>
27 #include <boost/geometry/core/exterior_ring.hpp>
28 #include <boost/geometry/core/interior_rings.hpp>
30 #include <boost/geometry/util/range.hpp>
32 #include <boost/geometry/algorithms/detail/interior_iterator.hpp>
35 namespace boost { namespace geometry
39 #ifndef DOXYGEN_NO_DETAIL
40 namespace detail { namespace counting
44 template <std::size_t D>
47 template <typename Geometry>
48 static inline std::size_t apply(Geometry const&)
53 template <typename Geometry>
54 static inline std::size_t apply(Geometry const&, bool)
61 template <typename RangeCount>
64 template <typename Polygon>
65 static inline std::size_t apply(Polygon const& poly)
67 std::size_t n = RangeCount::apply(exterior_ring(poly));
69 typename interior_return_type<Polygon const>::type
70 rings = interior_rings(poly);
71 for (typename detail::interior_iterator<Polygon const>::type
72 it = boost::begin(rings); it != boost::end(rings); ++it)
74 n += RangeCount::apply(*it);
82 template <typename SingleCount>
85 template <typename MultiGeometry>
86 static inline std::size_t apply(MultiGeometry const& geometry)
89 for (typename boost::range_iterator<MultiGeometry const>::type
90 it = boost::begin(geometry);
91 it != boost::end(geometry);
94 n += SingleCount::apply(*it);
101 }} // namespace detail::counting
102 #endif // DOXYGEN_NO_DETAIL
104 }} // namespace boost::geometry
107 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP