]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. | |
5 | // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. | |
6 | // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. | |
7 | ||
8 | // This file was modified by Oracle on 2013-2014. | |
9 | // Modifications copyright (c) 2013-2014, Oracle and/or its affiliates. | |
10 | ||
11 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
12 | // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle | |
13 | ||
14 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
15 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
16 | ||
17 | // Use, modification and distribution is subject to the Boost Software License, | |
18 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
19 | // http://www.boost.org/LICENSE_1_0.txt) | |
20 | ||
21 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP | |
22 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP | |
23 | ||
24 | #include <cstddef> | |
25 | #include <deque> | |
26 | ||
27 | #include <boost/range.hpp> | |
28 | #include <boost/geometry/util/range.hpp> | |
29 | ||
30 | #include <boost/geometry/core/point_type.hpp> | |
31 | #include <boost/geometry/core/tag.hpp> | |
32 | #include <boost/geometry/core/tags.hpp> | |
33 | ||
34 | #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp> | |
35 | #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp> | |
36 | #include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp> | |
37 | ||
38 | #include <boost/geometry/policies/disjoint_interrupt_policy.hpp> | |
39 | #include <boost/geometry/policies/robustness/no_rescale_policy.hpp> | |
40 | #include <boost/geometry/policies/robustness/segment_ratio_type.hpp> | |
41 | ||
42 | #include <boost/geometry/algorithms/dispatch/disjoint.hpp> | |
43 | ||
44 | ||
45 | namespace boost { namespace geometry | |
46 | { | |
47 | ||
48 | ||
49 | #ifndef DOXYGEN_NO_DETAIL | |
50 | namespace detail { namespace disjoint | |
51 | { | |
52 | ||
53 | template <typename Segment1, typename Segment2> | |
54 | struct disjoint_segment | |
55 | { | |
56 | static inline bool apply(Segment1 const& segment1, Segment2 const& segment2) | |
57 | { | |
58 | typedef typename point_type<Segment1>::type point_type; | |
59 | ||
60 | // We don't need to rescale to detect disjointness | |
61 | typedef no_rescale_policy rescale_policy_type; | |
62 | rescale_policy_type robust_policy; | |
63 | ||
64 | typedef segment_intersection_points | |
65 | < | |
66 | point_type, | |
67 | typename segment_ratio_type | |
68 | < | |
69 | point_type, | |
70 | rescale_policy_type | |
71 | >::type | |
72 | > intersection_return_type; | |
73 | ||
74 | intersection_return_type is | |
75 | = strategy::intersection::relate_cartesian_segments | |
76 | < | |
77 | policies::relate::segments_intersection_points | |
78 | < | |
79 | intersection_return_type | |
80 | > | |
81 | >::apply(segment1, segment2, robust_policy); | |
82 | ||
83 | return is.count == 0; | |
84 | } | |
85 | }; | |
86 | ||
87 | ||
88 | struct assign_disjoint_policy | |
89 | { | |
90 | // We want to include all points: | |
91 | static bool const include_no_turn = true; | |
92 | static bool const include_degenerate = true; | |
93 | static bool const include_opposite = true; | |
94 | ||
95 | // We don't assign extra info: | |
96 | template | |
97 | < | |
98 | typename Info, | |
99 | typename Point1, | |
100 | typename Point2, | |
101 | typename IntersectionInfo | |
102 | > | |
103 | static inline void apply(Info& , Point1 const& , Point2 const&, | |
104 | IntersectionInfo const&) | |
105 | {} | |
106 | }; | |
107 | ||
108 | ||
109 | template <typename Geometry1, typename Geometry2> | |
110 | struct disjoint_linear | |
111 | { | |
112 | static inline | |
113 | bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2) | |
114 | { | |
115 | typedef typename geometry::point_type<Geometry1>::type point_type; | |
116 | typedef detail::no_rescale_policy rescale_policy_type; | |
117 | typedef typename geometry::segment_ratio_type | |
118 | < | |
119 | point_type, rescale_policy_type | |
120 | >::type segment_ratio_type; | |
121 | typedef overlay::turn_info | |
122 | < | |
123 | point_type, | |
124 | segment_ratio_type, | |
125 | typename detail::get_turns::turn_operation_type | |
126 | < | |
127 | Geometry1, Geometry2, segment_ratio_type | |
128 | >::type | |
129 | > turn_info_type; | |
130 | ||
131 | std::deque<turn_info_type> turns; | |
132 | ||
133 | // Specify two policies: | |
134 | // 1) Stop at any intersection | |
135 | // 2) In assignment, include also degenerate points (which are normally skipped) | |
136 | disjoint_interrupt_policy interrupt_policy; | |
137 | dispatch::get_turns | |
138 | < | |
139 | typename geometry::tag<Geometry1>::type, | |
140 | typename geometry::tag<Geometry2>::type, | |
141 | Geometry1, | |
142 | Geometry2, | |
143 | overlay::do_reverse<geometry::point_order<Geometry1>::value>::value, // should be false | |
144 | overlay::do_reverse<geometry::point_order<Geometry2>::value>::value, // should be false | |
145 | detail::get_turns::get_turn_info_type | |
146 | < | |
147 | Geometry1, Geometry2, assign_disjoint_policy | |
148 | > | |
149 | >::apply(0, geometry1, 1, geometry2, | |
150 | rescale_policy_type(), turns, interrupt_policy); | |
151 | ||
152 | return !interrupt_policy.has_intersections; | |
153 | } | |
154 | }; | |
155 | ||
156 | ||
157 | }} // namespace detail::disjoint | |
158 | #endif // DOXYGEN_NO_DETAIL | |
159 | ||
160 | ||
161 | ||
162 | ||
163 | #ifndef DOXYGEN_NO_DISPATCH | |
164 | namespace dispatch | |
165 | { | |
166 | ||
167 | ||
168 | template <typename Linear1, typename Linear2> | |
169 | struct disjoint<Linear1, Linear2, 2, linear_tag, linear_tag, false> | |
170 | : detail::disjoint::disjoint_linear<Linear1, Linear2> | |
171 | {}; | |
172 | ||
173 | ||
174 | template <typename Segment1, typename Segment2> | |
175 | struct disjoint<Segment1, Segment2, 2, segment_tag, segment_tag, false> | |
176 | : detail::disjoint::disjoint_segment<Segment1, Segment2> | |
177 | {}; | |
178 | ||
179 | ||
180 | } // namespace dispatch | |
181 | #endif // DOXYGEN_NO_DISPATCH | |
182 | ||
183 | ||
184 | }} // namespace boost::geometry | |
185 | ||
186 | ||
187 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP |