|
Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
|
Chris@16
|
2
|
|
Chris@16
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
|
Chris@16
|
4
|
|
Chris@16
|
5 // Use, modification and distribution is subject to the Boost Software License,
|
|
Chris@16
|
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
|
Chris@16
|
8
|
|
Chris@16
|
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
|
|
Chris@16
|
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
|
|
Chris@16
|
11
|
|
Chris@16
|
12
|
|
Chris@16
|
13 #include <boost/assert.hpp>
|
|
Chris@16
|
14 #include <boost/range.hpp>
|
|
Chris@16
|
15
|
|
Chris@16
|
16
|
|
Chris@16
|
17 #include <boost/geometry/core/tags.hpp>
|
|
Chris@16
|
18 #include <boost/geometry/core/exterior_ring.hpp>
|
|
Chris@16
|
19 #include <boost/geometry/core/interior_rings.hpp>
|
|
Chris@16
|
20 #include <boost/geometry/algorithms/detail/ring_identifier.hpp>
|
|
Chris@16
|
21
|
|
Chris@16
|
22
|
|
Chris@16
|
23 namespace boost { namespace geometry
|
|
Chris@16
|
24 {
|
|
Chris@16
|
25
|
|
Chris@16
|
26
|
|
Chris@16
|
27 #ifndef DOXYGEN_NO_DETAIL
|
|
Chris@16
|
28 namespace detail { namespace overlay
|
|
Chris@16
|
29 {
|
|
Chris@16
|
30
|
|
Chris@16
|
31
|
|
Chris@16
|
32 template<typename Tag>
|
|
Chris@16
|
33 struct get_ring
|
|
Chris@16
|
34 {};
|
|
Chris@16
|
35
|
|
Chris@16
|
36 // A container of rings (multi-ring but that does not exist)
|
|
Chris@16
|
37 // gets the "void" tag and is dispatched here.
|
|
Chris@16
|
38 template<>
|
|
Chris@16
|
39 struct get_ring<void>
|
|
Chris@16
|
40 {
|
|
Chris@16
|
41 template<typename Container>
|
|
Chris@16
|
42 static inline typename boost::range_value<Container>::type const&
|
|
Chris@16
|
43 apply(ring_identifier const& id, Container const& container)
|
|
Chris@16
|
44 {
|
|
Chris@16
|
45 return container[id.multi_index];
|
|
Chris@16
|
46 }
|
|
Chris@16
|
47 };
|
|
Chris@16
|
48
|
|
Chris@16
|
49
|
|
Chris@16
|
50
|
|
Chris@16
|
51
|
|
Chris@16
|
52 template<>
|
|
Chris@16
|
53 struct get_ring<ring_tag>
|
|
Chris@16
|
54 {
|
|
Chris@16
|
55 template<typename Ring>
|
|
Chris@16
|
56 static inline Ring const& apply(ring_identifier const& , Ring const& ring)
|
|
Chris@16
|
57 {
|
|
Chris@16
|
58 return ring;
|
|
Chris@16
|
59 }
|
|
Chris@16
|
60 };
|
|
Chris@16
|
61
|
|
Chris@16
|
62
|
|
Chris@16
|
63 template<>
|
|
Chris@16
|
64 struct get_ring<box_tag>
|
|
Chris@16
|
65 {
|
|
Chris@16
|
66 template<typename Box>
|
|
Chris@16
|
67 static inline Box const& apply(ring_identifier const& ,
|
|
Chris@16
|
68 Box const& box)
|
|
Chris@16
|
69 {
|
|
Chris@16
|
70 return box;
|
|
Chris@16
|
71 }
|
|
Chris@16
|
72 };
|
|
Chris@16
|
73
|
|
Chris@16
|
74
|
|
Chris@16
|
75 template<>
|
|
Chris@16
|
76 struct get_ring<polygon_tag>
|
|
Chris@16
|
77 {
|
|
Chris@16
|
78 template<typename Polygon>
|
|
Chris@16
|
79 static inline typename ring_return_type<Polygon const>::type const apply(
|
|
Chris@16
|
80 ring_identifier const& id,
|
|
Chris@16
|
81 Polygon const& polygon)
|
|
Chris@16
|
82 {
|
|
Chris@16
|
83 BOOST_ASSERT
|
|
Chris@16
|
84 (
|
|
Chris@16
|
85 id.ring_index >= -1
|
|
Chris@16
|
86 && id.ring_index < int(boost::size(interior_rings(polygon)))
|
|
Chris@16
|
87 );
|
|
Chris@16
|
88 return id.ring_index < 0
|
|
Chris@16
|
89 ? exterior_ring(polygon)
|
|
Chris@16
|
90 : interior_rings(polygon)[id.ring_index];
|
|
Chris@16
|
91 }
|
|
Chris@16
|
92 };
|
|
Chris@16
|
93
|
|
Chris@16
|
94
|
|
Chris@16
|
95 }} // namespace detail::overlay
|
|
Chris@16
|
96 #endif // DOXYGEN_NO_DETAIL
|
|
Chris@16
|
97
|
|
Chris@16
|
98
|
|
Chris@16
|
99 }} // namespace boost::geometry
|
|
Chris@16
|
100
|
|
Chris@16
|
101
|
|
Chris@16
|
102 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
|