]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/overlay/turn_info.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / overlay / turn_info.hpp
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_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
11
12
13 #include <boost/array.hpp>
14
15 #include <boost/geometry/core/coordinate_type.hpp>
16 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
17 #include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
18 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
19
20 namespace boost { namespace geometry
21 {
22
23 #ifndef DOXYGEN_NO_DETAIL
24 namespace detail { namespace overlay
25 {
26
27 enum method_type
28 {
29 method_none,
30 method_disjoint,
31 method_crosses,
32 method_touch,
33 method_touch_interior,
34 method_collinear,
35 method_equal,
36 method_error
37 };
38
39
40 /*!
41 \brief Turn operation: operation
42 \details Information necessary for traversal phase (a phase
43 of the overlay process). The information is gathered during the
44 get_turns (segment intersection) phase.
45 The class is to be included in the turn_info class, either direct
46 or a derived or similar class with more (e.g. enrichment) information.
47 */
48 template <typename Point, typename SegmentRatio>
49 struct turn_operation
50 {
51 typedef SegmentRatio segment_ratio_type;
52
53 operation_type operation;
54 segment_identifier seg_id;
55 SegmentRatio fraction;
56
57 typedef typename coordinate_type<Point>::type comparable_distance_type;
58 comparable_distance_type remaining_distance;
59
60 inline turn_operation()
61 : operation(operation_none)
62 , remaining_distance(0)
63 {}
64 };
65
66
67 /*!
68 \brief Turn information: intersection point, method, and turn information
69 \details Information necessary for traversal phase (a phase
70 of the overlay process). The information is gathered during the
71 get_turns (segment intersection) phase.
72 \tparam Point point type of intersection point
73 \tparam Operation gives classes opportunity to add additional info
74 \tparam Container gives classes opportunity to define how operations are stored
75 */
76 template
77 <
78 typename Point,
79 typename SegmentRatio,
80 typename Operation = turn_operation<Point, SegmentRatio>,
81 typename Container = boost::array<Operation, 2>
82 >
83 struct turn_info
84 {
85 typedef Point point_type;
86 typedef SegmentRatio segment_ratio_type;
87 typedef Operation turn_operation_type;
88 typedef Container container_type;
89
90 Point point;
91 method_type method;
92 bool touch_only; // True in case of method touch(interior) and lines do not cross
93 signed_size_type cluster_id; // For multiple turns on same location, > 0. Else -1. 0 is unused.
94 bool discarded;
95
96 bool has_colocated_both; // Colocated with a uu turn (for union) or ii (other)
97
98 Container operations;
99
100 inline turn_info()
101 : method(method_none)
102 , touch_only(false)
103 , cluster_id(-1)
104 , discarded(false)
105 , has_colocated_both(false)
106 {}
107
108 inline bool both(operation_type type) const
109 {
110 return has12(type, type);
111 }
112
113 inline bool has(operation_type type) const
114 {
115 return this->operations[0].operation == type
116 || this->operations[1].operation == type;
117 }
118
119 inline bool combination(operation_type type1, operation_type type2) const
120 {
121 return has12(type1, type2) || has12(type2, type1);
122 }
123
124 inline bool blocked() const
125 {
126 return both(operation_blocked);
127 }
128 inline bool opposite() const
129 {
130 return both(operation_opposite);
131 }
132 inline bool any_blocked() const
133 {
134 return has(operation_blocked);
135 }
136 inline bool is_clustered() const
137 {
138 return cluster_id > 0;
139 }
140
141 private :
142 inline bool has12(operation_type type1, operation_type type2) const
143 {
144 return this->operations[0].operation == type1
145 && this->operations[1].operation == type2
146 ;
147 }
148
149 };
150
151
152 }} // namespace detail::overlay
153 #endif //DOXYGEN_NO_DETAIL
154
155
156 }} // namespace boost::geometry
157
158
159 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP