• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
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.
7 
8 // This file was modified by Oracle on 2014.
9 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
10 
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 
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)
19 
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
22 
23 #include <cstddef>
24 
25 #include <boost/range.hpp>
26 
27 #include <boost/geometry/core/exterior_ring.hpp>
28 #include <boost/geometry/core/interior_rings.hpp>
29 
30 #include <boost/geometry/util/range.hpp>
31 
32 #include <boost/geometry/algorithms/detail/interior_iterator.hpp>
33 
34 
35 namespace boost { namespace geometry
36 {
37 
38 
39 #ifndef DOXYGEN_NO_DETAIL
40 namespace detail { namespace counting
41 {
42 
43 
44 template <std::size_t D>
45 struct other_count
46 {
47     template <typename Geometry>
applyboost::geometry::detail::counting::other_count48     static inline std::size_t apply(Geometry const&)
49     {
50         return D;
51     }
52 
53     template <typename Geometry>
applyboost::geometry::detail::counting::other_count54     static inline std::size_t apply(Geometry const&, bool)
55     {
56         return D;
57     }
58 };
59 
60 
61 template <typename RangeCount>
62 struct polygon_count
63 {
64     template <typename Polygon>
applyboost::geometry::detail::counting::polygon_count65     static inline std::size_t apply(Polygon const& poly)
66     {
67         std::size_t n = RangeCount::apply(exterior_ring(poly));
68 
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)
73         {
74             n += RangeCount::apply(*it);
75         }
76 
77         return n;
78     }
79 };
80 
81 
82 template <typename SingleCount>
83 struct multi_count
84 {
85     template <typename MultiGeometry>
applyboost::geometry::detail::counting::multi_count86     static inline std::size_t apply(MultiGeometry const& geometry)
87     {
88         std::size_t n = 0;
89         for (typename boost::range_iterator<MultiGeometry const>::type
90                  it = boost::begin(geometry);
91              it != boost::end(geometry);
92              ++it)
93         {
94             n += SingleCount::apply(*it);
95         }
96         return n;
97     }
98 };
99 
100 
101 }} // namespace detail::counting
102 #endif // DOXYGEN_NO_DETAIL
103 
104 }} // namespace boost::geometry
105 
106 
107 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
108