]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/disjoint/linear_linear.hpp
fc8e6a3511cec89bcf1ec6a4626cfb43953c775f
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / disjoint / linear_linear.hpp
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-2020.
9 // Modifications copyright (c) 2013-2020, 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/geometry/core/point_type.hpp>
28 #include <boost/geometry/core/tag.hpp>
29 #include <boost/geometry/core/tags.hpp>
30
31 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
32 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
33 #include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
34 #include <boost/geometry/algorithms/detail/overlay/segment_as_subrange.hpp>
35
36 #include <boost/geometry/policies/disjoint_interrupt_policy.hpp>
37 #include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
38
39 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
40
41
42 namespace boost { namespace geometry
43 {
44
45
46 #ifndef DOXYGEN_NO_DETAIL
47 namespace detail { namespace disjoint
48 {
49
50 template <typename Segment1, typename Segment2>
51 struct disjoint_segment
52 {
53 template <typename Strategy>
54 static inline bool apply(Segment1 const& segment1, Segment2 const& segment2,
55 Strategy const& strategy)
56 {
57 typedef typename point_type<Segment1>::type point_type;
58
59 typedef segment_intersection_points<point_type> intersection_return_type;
60
61 typedef policies::relate::segments_intersection_points
62 <
63 intersection_return_type
64 > intersection_policy;
65
66 detail::segment_as_subrange<Segment1> sub_range1(segment1);
67 detail::segment_as_subrange<Segment2> sub_range2(segment2);
68 intersection_return_type is = strategy.relate().apply(sub_range1, sub_range2,
69 intersection_policy());
70
71 return is.count == 0;
72 }
73 };
74
75
76 struct assign_disjoint_policy
77 {
78 // We want to include all points:
79 static bool const include_no_turn = true;
80 static bool const include_degenerate = true;
81 static bool const include_opposite = true;
82 static bool const include_start_turn = false;
83 };
84
85
86 template <typename Geometry1, typename Geometry2>
87 struct disjoint_linear
88 {
89 template <typename Strategy>
90 static inline bool apply(Geometry1 const& geometry1,
91 Geometry2 const& geometry2,
92 Strategy const& strategy)
93 {
94 typedef typename geometry::point_type<Geometry1>::type point_type;
95 typedef geometry::segment_ratio
96 <
97 typename coordinate_type<point_type>::type
98 > ratio_type;
99 typedef overlay::turn_info
100 <
101 point_type,
102 ratio_type,
103 typename detail::get_turns::turn_operation_type
104 <
105 Geometry1, Geometry2, ratio_type
106 >::type
107 > turn_info_type;
108
109 std::deque<turn_info_type> turns;
110
111 // Specify two policies:
112 // 1) Stop at any intersection
113 // 2) In assignment, include also degenerate points (which are normally skipped)
114 disjoint_interrupt_policy interrupt_policy;
115 dispatch::get_turns
116 <
117 typename geometry::tag<Geometry1>::type,
118 typename geometry::tag<Geometry2>::type,
119 Geometry1,
120 Geometry2,
121 overlay::do_reverse<geometry::point_order<Geometry1>::value>::value, // should be false
122 overlay::do_reverse<geometry::point_order<Geometry2>::value>::value, // should be false
123 detail::get_turns::get_turn_info_type
124 <
125 Geometry1, Geometry2, assign_disjoint_policy
126 >
127 >::apply(0, geometry1, 1, geometry2,
128 strategy, detail::no_rescale_policy(), turns, interrupt_policy);
129
130 return !interrupt_policy.has_intersections;
131 }
132 };
133
134
135 }} // namespace detail::disjoint
136 #endif // DOXYGEN_NO_DETAIL
137
138
139
140
141 #ifndef DOXYGEN_NO_DISPATCH
142 namespace dispatch
143 {
144
145
146 template <typename Linear1, typename Linear2>
147 struct disjoint<Linear1, Linear2, 2, linear_tag, linear_tag, false>
148 : detail::disjoint::disjoint_linear<Linear1, Linear2>
149 {};
150
151
152 template <typename Segment1, typename Segment2>
153 struct disjoint<Segment1, Segment2, 2, segment_tag, segment_tag, false>
154 : detail::disjoint::disjoint_segment<Segment1, Segment2>
155 {};
156
157
158 } // namespace dispatch
159 #endif // DOXYGEN_NO_DISPATCH
160
161
162 }} // namespace boost::geometry
163
164
165 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP