]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
18 | namespace boost { namespace geometry | |
19 | { | |
20 | ||
21 | namespace policies { namespace relate | |
22 | { | |
23 | ||
24 | ||
25 | // "tupled" to return intersection results together. | |
26 | // Now with two, with some meta-programming and derivations it can also be three (or more) | |
27 | template <typename Policy1, typename Policy2> | |
28 | struct segments_tupled | |
29 | { | |
30 | typedef boost::tuple | |
31 | < | |
32 | typename Policy1::return_type, | |
33 | typename Policy2::return_type | |
34 | > return_type; | |
35 | ||
36 | template <typename Segment1, typename Segment2, typename SegmentIntersectionInfo> | |
37 | static inline return_type segments_crosses(side_info const& sides, | |
38 | SegmentIntersectionInfo const& sinfo, | |
39 | Segment1 const& s1, Segment2 const& s2) | |
40 | { | |
41 | return boost::make_tuple | |
42 | ( | |
43 | Policy1::segments_crosses(sides, sinfo, s1, s2), | |
44 | Policy2::segments_crosses(sides, sinfo, s1, s2) | |
45 | ); | |
46 | } | |
47 | ||
48 | template <typename Segment1, typename Segment2, typename Ratio> | |
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) | |
55 | { | |
56 | return boost::make_tuple | |
57 | ( | |
58 | Policy1::segments_collinear(segment1, segment2, | |
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) | |
66 | ); | |
67 | } | |
68 | ||
69 | template <typename Segment> | |
70 | static inline return_type degenerate(Segment const& segment, | |
71 | bool a_degenerate) | |
72 | { | |
73 | return boost::make_tuple | |
74 | ( | |
75 | Policy1::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) | |
89 | ); | |
90 | } | |
91 | ||
92 | static inline return_type disjoint() | |
93 | { | |
94 | return boost::make_tuple | |
95 | ( | |
96 | Policy1::disjoint(), | |
97 | Policy2::disjoint() | |
98 | ); | |
99 | } | |
100 | ||
101 | static inline return_type error(std::string const& msg) | |
102 | { | |
103 | return boost::make_tuple | |
104 | ( | |
105 | Policy1::error(msg), | |
106 | Policy2::error(msg) | |
107 | ); | |
108 | } | |
109 | ||
110 | }; | |
111 | ||
112 | }} // namespace policies::relate | |
113 | ||
114 | }} // namespace boost::geometry | |
115 | ||
116 | #endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP |