Chris@102
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@102
|
2
|
Chris@102
|
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@102
|
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
Chris@102
|
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
Chris@102
|
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
|
Chris@102
|
7
|
Chris@102
|
8 // This file was modified by Oracle on 2014.
|
Chris@102
|
9 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
Chris@102
|
10
|
Chris@102
|
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
Chris@102
|
12
|
Chris@102
|
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@102
|
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@102
|
15
|
Chris@102
|
16 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@102
|
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
18 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
19
|
Chris@102
|
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
|
Chris@102
|
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
|
Chris@102
|
22
|
Chris@102
|
23 #include <cstddef>
|
Chris@102
|
24
|
Chris@102
|
25 #include <boost/range.hpp>
|
Chris@102
|
26
|
Chris@102
|
27 #include <boost/geometry/core/exterior_ring.hpp>
|
Chris@102
|
28 #include <boost/geometry/core/interior_rings.hpp>
|
Chris@102
|
29
|
Chris@102
|
30 #include <boost/geometry/util/range.hpp>
|
Chris@102
|
31
|
Chris@102
|
32 #include <boost/geometry/algorithms/detail/interior_iterator.hpp>
|
Chris@102
|
33
|
Chris@102
|
34
|
Chris@102
|
35 namespace boost { namespace geometry
|
Chris@102
|
36 {
|
Chris@102
|
37
|
Chris@102
|
38
|
Chris@102
|
39 #ifndef DOXYGEN_NO_DETAIL
|
Chris@102
|
40 namespace detail { namespace counting
|
Chris@102
|
41 {
|
Chris@102
|
42
|
Chris@102
|
43
|
Chris@102
|
44 template <std::size_t D>
|
Chris@102
|
45 struct other_count
|
Chris@102
|
46 {
|
Chris@102
|
47 template <typename Geometry>
|
Chris@102
|
48 static inline std::size_t apply(Geometry const&)
|
Chris@102
|
49 {
|
Chris@102
|
50 return D;
|
Chris@102
|
51 }
|
Chris@102
|
52
|
Chris@102
|
53 template <typename Geometry>
|
Chris@102
|
54 static inline std::size_t apply(Geometry const&, bool)
|
Chris@102
|
55 {
|
Chris@102
|
56 return D;
|
Chris@102
|
57 }
|
Chris@102
|
58 };
|
Chris@102
|
59
|
Chris@102
|
60
|
Chris@102
|
61 template <typename RangeCount>
|
Chris@102
|
62 struct polygon_count
|
Chris@102
|
63 {
|
Chris@102
|
64 template <typename Polygon>
|
Chris@102
|
65 static inline std::size_t apply(Polygon const& poly)
|
Chris@102
|
66 {
|
Chris@102
|
67 std::size_t n = RangeCount::apply(exterior_ring(poly));
|
Chris@102
|
68
|
Chris@102
|
69 typename interior_return_type<Polygon const>::type
|
Chris@102
|
70 rings = interior_rings(poly);
|
Chris@102
|
71 for (typename detail::interior_iterator<Polygon const>::type
|
Chris@102
|
72 it = boost::begin(rings); it != boost::end(rings); ++it)
|
Chris@102
|
73 {
|
Chris@102
|
74 n += RangeCount::apply(*it);
|
Chris@102
|
75 }
|
Chris@102
|
76
|
Chris@102
|
77 return n;
|
Chris@102
|
78 }
|
Chris@102
|
79 };
|
Chris@102
|
80
|
Chris@102
|
81
|
Chris@102
|
82 template <typename SingleCount>
|
Chris@102
|
83 struct multi_count
|
Chris@102
|
84 {
|
Chris@102
|
85 template <typename MultiGeometry>
|
Chris@102
|
86 static inline std::size_t apply(MultiGeometry const& geometry)
|
Chris@102
|
87 {
|
Chris@102
|
88 std::size_t n = 0;
|
Chris@102
|
89 for (typename boost::range_iterator<MultiGeometry const>::type
|
Chris@102
|
90 it = boost::begin(geometry);
|
Chris@102
|
91 it != boost::end(geometry);
|
Chris@102
|
92 ++it)
|
Chris@102
|
93 {
|
Chris@102
|
94 n += SingleCount::apply(*it);
|
Chris@102
|
95 }
|
Chris@102
|
96 return n;
|
Chris@102
|
97 }
|
Chris@102
|
98 };
|
Chris@102
|
99
|
Chris@102
|
100
|
Chris@102
|
101 }} // namespace detail::counting
|
Chris@102
|
102 #endif // DOXYGEN_NO_DETAIL
|
Chris@102
|
103
|
Chris@102
|
104 }} // namespace boost::geometry
|
Chris@102
|
105
|
Chris@102
|
106
|
Chris@102
|
107 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
|