1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | |
3 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. |
4 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. |
5 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. |
6 | |
7 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
8 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. |
9 | |
10 | // Use, modification and distribution is subject to the Boost Software License, |
11 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
12 | // http://www.boost.org/LICENSE_1_0.txt) |
13 | |
14 | |
15 | #ifndef BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP |
16 | #define BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP |
17 | |
18 | |
19 | #include <boost/mpl/assert.hpp> |
20 | #include <boost/type_traits/remove_const.hpp> |
21 | |
22 | |
23 | #include <boost/geometry/core/ring_type.hpp> |
24 | #include <boost/geometry/core/tag.hpp> |
25 | #include <boost/geometry/core/tags.hpp> |
26 | #include <boost/geometry/util/add_const_if_c.hpp> |
27 | |
28 | |
29 | namespace boost { namespace geometry |
30 | { |
31 | |
32 | namespace traits |
33 | { |
34 | |
35 | |
36 | /*! |
37 | \brief Traits class defining access to exterior_ring of a polygon |
38 | \details Should define const and non const access |
39 | \ingroup traits |
40 | \tparam Polygon the polygon type |
41 | \par Geometries: |
42 | - polygon |
43 | \par Specializations should provide: |
44 | - static inline RING& get(POLY& ) |
45 | - static inline RING const& get(POLY const& ) |
46 | */ |
47 | template <typename Polygon> |
48 | struct exterior_ring |
49 | { |
50 | BOOST_MPL_ASSERT_MSG |
51 | ( |
52 | false, NOT_IMPLEMENTED_FOR_THIS_POLYGON_TYPE |
53 | , (types<Polygon>) |
54 | ); |
55 | }; |
56 | |
57 | |
58 | } // namespace traits |
59 | |
60 | |
61 | #ifndef DOXYGEN_NO_DISPATCH |
62 | namespace core_dispatch |
63 | { |
64 | |
65 | |
66 | template <typename Tag, typename Geometry> |
67 | struct exterior_ring |
68 | { |
69 | BOOST_MPL_ASSERT_MSG |
70 | ( |
71 | false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE |
72 | , (types<Geometry>) |
73 | ); |
74 | }; |
75 | |
76 | |
77 | template <typename Polygon> |
78 | struct exterior_ring<polygon_tag, Polygon> |
79 | { |
80 | static |
81 | typename geometry::ring_return_type<Polygon>::type |
82 | apply(typename add_const_if_c |
83 | < |
84 | boost::is_const<Polygon>::type::value, |
85 | Polygon |
86 | >::type& polygon) |
87 | { |
88 | return traits::exterior_ring |
89 | < |
90 | typename boost::remove_const<Polygon>::type |
91 | >::get(polygon); |
92 | } |
93 | }; |
94 | |
95 | |
96 | } // namespace core_dispatch |
97 | #endif // DOXYGEN_NO_DISPATCH |
98 | |
99 | |
100 | /*! |
101 | \brief Function to get the exterior_ring ring of a polygon |
102 | \ingroup exterior_ring |
103 | \note OGC compliance: instead of ExteriorRing |
104 | \tparam Polygon polygon type |
105 | \param polygon the polygon to get the exterior ring from |
106 | \return a reference to the exterior ring |
107 | */ |
108 | template <typename Polygon> |
109 | inline typename ring_return_type<Polygon>::type exterior_ring(Polygon& polygon) |
110 | { |
111 | return core_dispatch::exterior_ring |
112 | < |
113 | typename tag<Polygon>::type, |
114 | Polygon |
115 | >::apply(polygon); |
116 | } |
117 | |
118 | |
119 | /*! |
120 | \brief Function to get the exterior ring of a polygon (const version) |
121 | \ingroup exterior_ring |
122 | \note OGC compliance: instead of ExteriorRing |
123 | \tparam Polygon polygon type |
124 | \param polygon the polygon to get the exterior ring from |
125 | \return a const reference to the exterior ring |
126 | |
127 | \qbk{distinguish,const version} |
128 | */ |
129 | template <typename Polygon> |
130 | inline typename ring_return_type<Polygon const>::type exterior_ring( |
131 | Polygon const& polygon) |
132 | { |
133 | return core_dispatch::exterior_ring |
134 | < |
135 | typename tag<Polygon>::type, |
136 | Polygon const |
137 | >::apply(polygon); |
138 | } |
139 | |
140 | |
141 | }} // namespace boost::geometry |
142 | |
143 | |
144 | #endif // BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP |
145 | |