]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / disjoint / linear_segment_or_box.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-2021.
9 // Modifications copyright (c) 2013-2021, 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_SEGMENT_OR_BOX_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
23
24
25 #include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
26 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
27 #include <boost/geometry/algorithms/not_implemented.hpp>
28 #include <boost/geometry/core/closure.hpp>
29 #include <boost/geometry/geometries/segment.hpp>
30 #include <boost/geometry/util/range.hpp>
31 #include <boost/geometry/views/closeable_view.hpp>
32
33
34 namespace boost { namespace geometry
35 {
36
37
38 #ifndef DOXYGEN_NO_DETAIL
39 namespace detail { namespace disjoint
40 {
41
42
43 template
44 <
45 typename SegmentOrBox,
46 typename Tag = typename tag<SegmentOrBox>::type
47 >
48 struct disjoint_point_segment_or_box
49 : not_implemented<Tag>
50 {};
51
52 template <typename Segment>
53 struct disjoint_point_segment_or_box<Segment, segment_tag>
54 {
55 template <typename Point, typename Strategy>
56 static inline bool apply(Point const& point, Segment const& segment, Strategy const& strategy)
57 {
58 return dispatch::disjoint
59 <
60 Point, Segment
61 >::apply(point, segment, strategy);
62 }
63 };
64
65 template <typename Box>
66 struct disjoint_point_segment_or_box<Box, box_tag>
67 {
68 template <typename Point, typename Strategy>
69 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
70 {
71 return dispatch::disjoint
72 <
73 Point, Box
74 >::apply(point, box, strategy);
75 }
76 };
77
78
79 template <typename Range, typename SegmentOrBox>
80 struct disjoint_range_segment_or_box
81 {
82 template <typename Strategy>
83 static inline bool apply(Range const& range,
84 SegmentOrBox const& segment_or_box,
85 Strategy const& strategy)
86 {
87 using point_type = typename point_type<Range>::type;
88 using range_segment = typename geometry::model::referring_segment<point_type const>;
89
90 detail::closed_view<Range const> const view(range);
91
92 auto const count = ::boost::size(view);
93
94 if ( count == 0 )
95 {
96 return false;
97 }
98 else if ( count == 1 )
99 {
100 return disjoint_point_segment_or_box
101 <
102 SegmentOrBox
103 >::apply(range::front(view), segment_or_box, strategy);
104 }
105 else
106 {
107 auto it0 = ::boost::begin(view);
108 auto it1 = ::boost::begin(view) + 1;
109 auto const last = ::boost::end(view);
110
111 for ( ; it1 != last ; ++it0, ++it1 )
112 {
113 point_type const& p0 = *it0;
114 point_type const& p1 = *it1;
115 range_segment rng_segment(p0, p1);
116 if ( !dispatch::disjoint
117 <
118 range_segment, SegmentOrBox
119 >::apply(rng_segment, segment_or_box, strategy) )
120 {
121 return false;
122 }
123 }
124 return true;
125 }
126 }
127 };
128
129
130
131
132 template
133 <
134 typename Linear,
135 typename SegmentOrBox,
136 typename Tag = typename tag<Linear>::type
137 >
138 struct disjoint_linear_segment_or_box
139 : not_implemented<Linear, SegmentOrBox>
140 {};
141
142
143 template <typename Linestring, typename SegmentOrBox>
144 struct disjoint_linear_segment_or_box<Linestring, SegmentOrBox, linestring_tag>
145 : disjoint_range_segment_or_box<Linestring, SegmentOrBox>
146 {};
147
148
149 template <typename MultiLinestring, typename SegmentOrBox>
150 struct disjoint_linear_segment_or_box
151 <
152 MultiLinestring, SegmentOrBox, multi_linestring_tag
153 > : multirange_constant_size_geometry<MultiLinestring, SegmentOrBox>
154 {};
155
156
157 }} // namespace detail::disjoint
158 #endif // DOXYGEN_NO_DETAIL
159
160
161 #ifndef DOXYGEN_NO_DISPATCH
162 namespace dispatch
163 {
164
165
166 template <typename Linear, typename Segment>
167 struct disjoint<Linear, Segment, 2, linear_tag, segment_tag, false>
168 : detail::disjoint::disjoint_linear_segment_or_box<Linear, Segment>
169 {};
170
171
172 template <typename Linear, typename Box, std::size_t DimensionCount>
173 struct disjoint<Linear, Box, DimensionCount, linear_tag, box_tag, false>
174 : detail::disjoint::disjoint_linear_segment_or_box<Linear, Box>
175 {};
176
177
178 } // namespace dispatch
179 #endif // DOXYGEN_NO_DISPATCH
180
181
182 }} // namespace boost::geometry
183
184
185 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP