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