• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3 
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 #ifndef GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_POLYGON_HPP
11 #define GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_POLYGON_HPP
12 
13 #include <cstddef>
14 
15 #include <boost/range.hpp>
16 
17 
18 #include <boost/geometry/core/mutable_range.hpp>
19 #include <boost/geometry/core/tag.hpp>
20 #include <boost/geometry/core/tags.hpp>
21 
22 #include <test_geometries/all_custom_container.hpp>
23 #include <test_geometries/all_custom_ring.hpp>
24 
25 
26 template <typename P>
27 class all_custom_polygon
28 {
29 public :
30     typedef all_custom_ring<P> custom_ring_type;
31     typedef all_custom_container<custom_ring_type> custom_int_type;
32 
custom_ext()33     custom_ring_type& custom_ext() { return m_ext; }
custom_int()34     custom_int_type& custom_int() { return m_int; }
35 
custom_ext() const36     custom_ring_type const& custom_ext() const { return m_ext; }
custom_int() const37     custom_int_type const& custom_int() const { return m_int; }
38 
39 private :
40     custom_ring_type m_ext;
41     custom_int_type m_int;
42 };
43 
44 
45 
46 namespace boost { namespace geometry
47 {
48 
49 namespace traits
50 {
51 
52 
53 
54 template <typename Point>
55 struct tag<all_custom_polygon<Point> >
56 {
57     typedef polygon_tag type;
58 };
59 
60 template <typename Point>
61 struct ring_const_type<all_custom_polygon<Point> >
62 {
63     typedef typename all_custom_polygon<Point>::custom_ring_type const& type;
64 };
65 
66 template <typename Point>
67 struct ring_mutable_type<all_custom_polygon<Point> >
68 {
69     typedef typename all_custom_polygon<Point>::custom_ring_type& type;
70 };
71 
72 
73 template <typename Point>
74 struct interior_const_type<all_custom_polygon<Point> >
75 {
76     typedef typename all_custom_polygon<Point>::custom_int_type const& type;
77 };
78 
79 template <typename Point>
80 struct interior_mutable_type<all_custom_polygon<Point> >
81 {
82     typedef typename all_custom_polygon<Point>::custom_int_type& type;
83 };
84 
85 
86 
87 template <typename Point>
88 struct exterior_ring<all_custom_polygon<Point> >
89 {
90     typedef all_custom_polygon<Point> polygon_type;
91     typedef typename polygon_type::custom_ring_type ring_type;
92 
getboost::geometry::traits::exterior_ring93     static inline ring_type& get(polygon_type& p)
94     {
95         return p.custom_ext();
96     }
97 
getboost::geometry::traits::exterior_ring98     static inline ring_type const& get(polygon_type const& p)
99     {
100         return p.custom_ext();
101     }
102 };
103 
104 template <typename Point>
105 struct interior_rings<all_custom_polygon<Point> >
106 {
107     typedef all_custom_polygon<Point> polygon_type;
108     typedef typename polygon_type::custom_int_type int_type;
109 
getboost::geometry::traits::interior_rings110     static inline int_type& get(polygon_type& p)
111     {
112         return p.custom_int();
113     }
114 
getboost::geometry::traits::interior_rings115     static inline int_type const& get(polygon_type const& p)
116     {
117         return p.custom_int();
118     }
119 };
120 
121 
122 } // namespace traits
123 
124 }} // namespace boost::geometry
125 
126 
127 
128 
129 
130 #endif // GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_POLYGON_HPP
131