Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/policies/relate/de9im.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_DE9IM_HPP | |
10 #define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DE9IM_HPP | |
11 | |
12 | |
13 #include <boost/geometry/strategies/intersection_result.hpp> | |
14 #include <boost/geometry/util/math.hpp> | |
15 #include <boost/geometry/util/select_coordinate_type.hpp> | |
16 | |
17 | |
18 namespace boost { namespace geometry | |
19 { | |
20 | |
21 namespace policies { namespace relate | |
22 { | |
23 | |
24 | |
25 template <typename S1, typename S2> | |
26 struct segments_de9im | |
27 { | |
28 typedef de9im_segment return_type; | |
29 typedef S1 segment_type1; | |
30 typedef S2 segment_type2; | |
31 typedef typename select_coordinate_type<S1, S2>::type coordinate_type; | |
32 | |
33 static inline return_type rays_intersect(bool on_segment, | |
34 double ra, double rb, | |
35 coordinate_type const& dx1, coordinate_type const& dy1, | |
36 coordinate_type const& dx2, coordinate_type const& dy2, | |
37 coordinate_type const& wx, coordinate_type const& wy, | |
38 S1 const& s1, S2 const& s2) | |
39 { | |
40 if(on_segment) | |
41 { | |
42 // 0 <= ra <= 1 and 0 <= rb <= 1 | |
43 // Now check if one of them is 0 or 1, these are "touch" cases | |
44 bool a = math::equals(ra, 0.0) || math::equals(ra, 1.0); | |
45 bool b = math::equals(rb, 0.0) || math::equals(rb, 1.0); | |
46 if (a && b) | |
47 { | |
48 // Touch boundary/boundary: i-i == -1, i-b == -1, b-b == 0 | |
49 // Opposite: if both are equal they touch in opposite direction | |
50 return de9im_segment(ra,rb, | |
51 -1, -1, 1, | |
52 -1, 0, 0, | |
53 1, 0, 2, false, math::equals(ra,rb)); | |
54 } | |
55 else if (a || b) | |
56 { | |
57 // Touch boundary/interior: i-i == -1, i-b == -1 or 0, b-b == -1 | |
58 int A = a ? 0 : -1; | |
59 int B = b ? 0 : -1; | |
60 return de9im_segment(ra,rb, | |
61 -1, B, 1, | |
62 A, -1, 0, | |
63 1, 0, 2); | |
64 } | |
65 | |
66 // Intersects: i-i == 0, i-b == -1, i-e == 1 | |
67 return de9im_segment(ra,rb, | |
68 0, -1, 1, | |
69 -1, -1, 0, | |
70 1, 0, 2); | |
71 } | |
72 | |
73 // Not on segment, disjoint | |
74 return de9im_segment(ra,rb, | |
75 -1, -1, 1, | |
76 -1, -1, 0, | |
77 1, 0, 2); | |
78 } | |
79 | |
80 static inline return_type collinear_touch(coordinate_type const& x, | |
81 coordinate_type const& y, bool opposite, char) | |
82 { | |
83 return de9im_segment(0,0, | |
84 -1, -1, 1, | |
85 -1, 0, 0, | |
86 1, 0, 2, | |
87 true, opposite); | |
88 } | |
89 | |
90 template <typename S> | |
91 static inline return_type collinear_interior_boundary_intersect(S const& s, | |
92 bool a_within_b, bool opposite) | |
93 { | |
94 return a_within_b | |
95 ? de9im_segment(0,0, | |
96 1, -1, -1, | |
97 0, 0, -1, | |
98 1, 0, 2, | |
99 true, opposite) | |
100 : de9im_segment(0,0, | |
101 1, 0, 1, | |
102 -1, 0, 0, | |
103 -1, -1, 2, | |
104 true, opposite); | |
105 } | |
106 | |
107 | |
108 | |
109 static inline return_type collinear_a_in_b(S1 const& s, bool opposite) | |
110 { | |
111 return de9im_segment(0,0, | |
112 1, -1, -1, | |
113 0, -1, -1, | |
114 1, 0, 2, | |
115 true, opposite); | |
116 } | |
117 static inline return_type collinear_b_in_a(S2 const& s, bool opposite) | |
118 { | |
119 return de9im_segment(0,0, | |
120 1, 0, 1, | |
121 -1, -1, 0, | |
122 -1, -1, 2, | |
123 true, opposite); | |
124 } | |
125 | |
126 static inline return_type collinear_overlaps( | |
127 coordinate_type const& x1, coordinate_type const& y1, | |
128 coordinate_type const& x2, coordinate_type const& y2, bool opposite) | |
129 { | |
130 return de9im_segment(0,0, | |
131 1, 0, 1, | |
132 0, -1, 0, | |
133 1, 0, 2, | |
134 true, opposite); | |
135 } | |
136 | |
137 static inline return_type segment_equal(S1 const& s, bool opposite) | |
138 { | |
139 return de9im_segment(0,0, | |
140 1, -1, -1, | |
141 -1, 0, -1, | |
142 -1, -1, 2, | |
143 true, opposite); | |
144 } | |
145 | |
146 static inline return_type degenerate(S1 const& segment, bool a_degenerate) | |
147 { | |
148 return a_degenerate | |
149 ? de9im_segment(0,0, | |
150 0, -1, -1, | |
151 -1, -1, -1, | |
152 1, 0, 2, | |
153 false, false, false, true) | |
154 : de9im_segment(0,0, | |
155 0, -1, 1, | |
156 -1, -1, 0, | |
157 -1, -1, 2, | |
158 false, false, false, true); | |
159 } | |
160 | |
161 static inline return_type collinear_disjoint() | |
162 { | |
163 return de9im_segment(0,0, | |
164 -1, -1, 1, | |
165 -1, -1, 0, | |
166 1, 0, 2, | |
167 true); | |
168 } | |
169 | |
170 }; | |
171 | |
172 | |
173 }} // namespace policies::relate | |
174 | |
175 }} // namespace boost::geometry | |
176 | |
177 #endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DE9IM_HPP |