Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/policies/relate/tupled.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | |
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | |
5 // Use, modification and distribution is subject to the Boost Software License, | |
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 // http://www.boost.org/LICENSE_1_0.txt) | |
8 | |
9 #ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP | |
10 #define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP | |
11 | |
12 | |
13 #include <string> | |
14 | |
15 #include <boost/tuple/tuple.hpp> | |
16 #include <boost/geometry/strategies/side_info.hpp> | |
17 #include <boost/geometry/util/select_calculation_type.hpp> | |
18 #include <boost/geometry/util/select_most_precise.hpp> | |
19 | |
20 namespace boost { namespace geometry | |
21 { | |
22 | |
23 namespace policies { namespace relate | |
24 { | |
25 | |
26 | |
27 // "tupled" to return intersection results together. | |
28 // Now with two, with some meta-programming and derivations it can also be three (or more) | |
29 template <typename Policy1, typename Policy2, typename CalculationType = void> | |
30 struct segments_tupled | |
31 { | |
32 typedef boost::tuple | |
33 < | |
34 typename Policy1::return_type, | |
35 typename Policy2::return_type | |
36 > return_type; | |
37 | |
38 // Take segments of first policy, they should be equal | |
39 typedef typename Policy1::segment_type1 segment_type1; | |
40 typedef typename Policy1::segment_type2 segment_type2; | |
41 | |
42 typedef typename select_calculation_type | |
43 < | |
44 segment_type1, | |
45 segment_type2, | |
46 CalculationType | |
47 >::type coordinate_type; | |
48 | |
49 // Get the same type, but at least a double | |
50 typedef typename select_most_precise<coordinate_type, double>::type rtype; | |
51 | |
52 template <typename R> | |
53 static inline return_type segments_intersect(side_info const& sides, | |
54 R const& r, | |
55 coordinate_type const& dx1, coordinate_type const& dy1, | |
56 coordinate_type const& dx2, coordinate_type const& dy2, | |
57 segment_type1 const& s1, segment_type2 const& s2) | |
58 { | |
59 return boost::make_tuple | |
60 ( | |
61 Policy1::segments_intersect(sides, r, | |
62 dx1, dy1, dx2, dy2, s1, s2), | |
63 Policy2::segments_intersect(sides, r, | |
64 dx1, dy1, dx2, dy2, s1, s2) | |
65 ); | |
66 } | |
67 | |
68 static inline return_type collinear_touch(coordinate_type const& x, | |
69 coordinate_type const& y, int arrival_a, int arrival_b) | |
70 { | |
71 return boost::make_tuple | |
72 ( | |
73 Policy1::collinear_touch(x, y, arrival_a, arrival_b), | |
74 Policy2::collinear_touch(x, y, arrival_a, arrival_b) | |
75 ); | |
76 } | |
77 | |
78 template <typename S> | |
79 static inline return_type collinear_interior_boundary_intersect(S const& segment, | |
80 bool a_within_b, | |
81 int arrival_a, int arrival_b, bool opposite) | |
82 { | |
83 return boost::make_tuple | |
84 ( | |
85 Policy1::collinear_interior_boundary_intersect(segment, a_within_b, arrival_a, arrival_b, opposite), | |
86 Policy2::collinear_interior_boundary_intersect(segment, a_within_b, arrival_a, arrival_b, opposite) | |
87 ); | |
88 } | |
89 | |
90 static inline return_type collinear_a_in_b(segment_type1 const& segment, | |
91 bool opposite) | |
92 { | |
93 return boost::make_tuple | |
94 ( | |
95 Policy1::collinear_a_in_b(segment, opposite), | |
96 Policy2::collinear_a_in_b(segment, opposite) | |
97 ); | |
98 } | |
99 static inline return_type collinear_b_in_a(segment_type2 const& segment, | |
100 bool opposite) | |
101 { | |
102 return boost::make_tuple | |
103 ( | |
104 Policy1::collinear_b_in_a(segment, opposite), | |
105 Policy2::collinear_b_in_a(segment, opposite) | |
106 ); | |
107 } | |
108 | |
109 | |
110 static inline return_type collinear_overlaps( | |
111 coordinate_type const& x1, coordinate_type const& y1, | |
112 coordinate_type const& x2, coordinate_type const& y2, | |
113 int arrival_a, int arrival_b, bool opposite) | |
114 { | |
115 return boost::make_tuple | |
116 ( | |
117 Policy1::collinear_overlaps(x1, y1, x2, y2, arrival_a, arrival_b, opposite), | |
118 Policy2::collinear_overlaps(x1, y1, x2, y2, arrival_a, arrival_b, opposite) | |
119 ); | |
120 } | |
121 | |
122 static inline return_type segment_equal(segment_type1 const& s, | |
123 bool opposite) | |
124 { | |
125 return boost::make_tuple | |
126 ( | |
127 Policy1::segment_equal(s, opposite), | |
128 Policy2::segment_equal(s, opposite) | |
129 ); | |
130 } | |
131 | |
132 static inline return_type degenerate(segment_type1 const& segment, | |
133 bool a_degenerate) | |
134 { | |
135 return boost::make_tuple | |
136 ( | |
137 Policy1::degenerate(segment, a_degenerate), | |
138 Policy2::degenerate(segment, a_degenerate) | |
139 ); | |
140 } | |
141 | |
142 static inline return_type disjoint() | |
143 { | |
144 return boost::make_tuple | |
145 ( | |
146 Policy1::disjoint(), | |
147 Policy2::disjoint() | |
148 ); | |
149 } | |
150 | |
151 static inline return_type error(std::string const& msg) | |
152 { | |
153 return boost::make_tuple | |
154 ( | |
155 Policy1::error(msg), | |
156 Policy2::error(msg) | |
157 ); | |
158 } | |
159 | |
160 static inline return_type collinear_disjoint() | |
161 { | |
162 return boost::make_tuple | |
163 ( | |
164 Policy1::collinear_disjoint(), | |
165 Policy2::collinear_disjoint() | |
166 ); | |
167 } | |
168 | |
169 }; | |
170 | |
171 }} // namespace policies::relate | |
172 | |
173 }} // namespace boost::geometry | |
174 | |
175 #endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP |