comparison DEPENDENCIES/generic/include/boost/geometry/policies/relate/tupled.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
12 12
13 #include <string> 13 #include <string>
14 14
15 #include <boost/tuple/tuple.hpp> 15 #include <boost/tuple/tuple.hpp>
16 #include <boost/geometry/strategies/side_info.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 17
20 namespace boost { namespace geometry 18 namespace boost { namespace geometry
21 { 19 {
22 20
23 namespace policies { namespace relate 21 namespace policies { namespace relate
24 { 22 {
25 23
26 24
27 // "tupled" to return intersection results together. 25 // "tupled" to return intersection results together.
28 // Now with two, with some meta-programming and derivations it can also be three (or more) 26 // 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> 27 template <typename Policy1, typename Policy2>
30 struct segments_tupled 28 struct segments_tupled
31 { 29 {
32 typedef boost::tuple 30 typedef boost::tuple
33 < 31 <
34 typename Policy1::return_type, 32 typename Policy1::return_type,
35 typename Policy2::return_type 33 typename Policy2::return_type
36 > return_type; 34 > return_type;
37 35
38 // Take segments of first policy, they should be equal 36 template <typename Segment1, typename Segment2, typename SegmentIntersectionInfo>
39 typedef typename Policy1::segment_type1 segment_type1; 37 static inline return_type segments_crosses(side_info const& sides,
40 typedef typename Policy1::segment_type2 segment_type2; 38 SegmentIntersectionInfo const& sinfo,
41 39 Segment1 const& s1, Segment2 const& s2)
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 { 40 {
59 return boost::make_tuple 41 return boost::make_tuple
60 ( 42 (
61 Policy1::segments_intersect(sides, r, 43 Policy1::segments_crosses(sides, sinfo, s1, s2),
62 dx1, dy1, dx2, dy2, s1, s2), 44 Policy2::segments_crosses(sides, sinfo, s1, s2)
63 Policy2::segments_intersect(sides, r,
64 dx1, dy1, dx2, dy2, s1, s2)
65 ); 45 );
66 } 46 }
67 47
68 static inline return_type collinear_touch(coordinate_type const& x, 48 template <typename Segment1, typename Segment2, typename Ratio>
69 coordinate_type const& y, int arrival_a, int arrival_b) 49 static inline return_type segments_collinear(
50 Segment1 const& segment1, Segment2 const& segment2,
51 bool opposite,
52 int pa1, int pa2, int pb1, int pb2,
53 Ratio const& ra1, Ratio const& ra2,
54 Ratio const& rb1, Ratio const& rb2)
70 { 55 {
71 return boost::make_tuple 56 return boost::make_tuple
72 ( 57 (
73 Policy1::collinear_touch(x, y, arrival_a, arrival_b), 58 Policy1::segments_collinear(segment1, segment2,
74 Policy2::collinear_touch(x, y, arrival_a, arrival_b) 59 opposite,
60 pa1, pa2, pb1, pb2,
61 ra1, ra2, rb1, rb2),
62 Policy2::segments_collinear(segment1, segment2,
63 opposite,
64 pa1, pa2, pb1, pb2,
65 ra1, ra2, rb1, rb2)
75 ); 66 );
76 } 67 }
77 68
78 template <typename S> 69 template <typename Segment>
79 static inline return_type collinear_interior_boundary_intersect(S const& segment, 70 static inline return_type degenerate(Segment 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) 71 bool a_degenerate)
134 { 72 {
135 return boost::make_tuple 73 return boost::make_tuple
136 ( 74 (
137 Policy1::degenerate(segment, a_degenerate), 75 Policy1::degenerate(segment, a_degenerate),
138 Policy2::degenerate(segment, a_degenerate) 76 Policy2::degenerate(segment, a_degenerate)
77 );
78 }
79
80 template <typename Segment, typename Ratio>
81 static inline return_type one_degenerate(Segment const& segment,
82 Ratio const& ratio,
83 bool a_degenerate)
84 {
85 return boost::make_tuple
86 (
87 Policy1::one_degenerate(segment, ratio, a_degenerate),
88 Policy2::one_degenerate(segment, ratio, a_degenerate)
139 ); 89 );
140 } 90 }
141 91
142 static inline return_type disjoint() 92 static inline return_type disjoint()
143 { 93 {
155 Policy1::error(msg), 105 Policy1::error(msg),
156 Policy2::error(msg) 106 Policy2::error(msg)
157 ); 107 );
158 } 108 }
159 109
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 }; 110 };
170 111
171 }} // namespace policies::relate 112 }} // namespace policies::relate
172 113
173 }} // namespace boost::geometry 114 }} // namespace boost::geometry