]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/overlay/turn_info.hpp
import new upstream nautilus stable release 14.2.8
[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 #include <boost/geometry/policies/robustness/segment_ratio.hpp>
20
21 namespace boost { namespace geometry
22 {
23
24 #ifndef DOXYGEN_NO_DETAIL
25 namespace detail { namespace overlay
26 {
27
28 enum method_type
29 {
30 method_none,
31 method_disjoint,
32 method_crosses,
33 method_touch,
34 method_touch_interior,
35 method_collinear,
36 method_equal,
37 method_error
38 };
39
40
41 /*!
42 \brief Turn operation: operation
43 \details Information necessary for traversal phase (a phase
44 of the overlay process). The information is gathered during the
45 get_turns (segment intersection) phase.
46 The class is to be included in the turn_info class, either direct
47 or a derived or similar class with more (e.g. enrichment) information.
48 */
49 template <typename Point, typename SegmentRatio>
50 struct turn_operation
51 {
52 typedef SegmentRatio segment_ratio_type;
53
54 operation_type operation;
55 segment_identifier seg_id;
56 SegmentRatio fraction;
57
58 typedef typename coordinate_type<Point>::type comparable_distance_type;
59 comparable_distance_type remaining_distance;
60
61 inline turn_operation()
62 : operation(operation_none)
63 , remaining_distance(0)
64 {}
65 };
66
67
68 /*!
69 \brief Turn information: intersection point, method, and turn information
70 \details Information necessary for traversal phase (a phase
71 of the overlay process). The information is gathered during the
72 get_turns (segment intersection) phase.
73 \tparam Point point type of intersection point
74 \tparam Operation gives classes opportunity to add additional info
75 \tparam Container gives classes opportunity to define how operations are stored
76 */
77 template
78 <
79 typename Point,
80 typename SegmentRatio = geometry::segment_ratio<typename coordinate_type<Point>::type>,
81 typename Operation = turn_operation<Point, SegmentRatio>,
82 typename Container = boost::array<Operation, 2>
83 >
84 struct turn_info
85 {
86 typedef Point point_type;
87 typedef SegmentRatio segment_ratio_type;
88 typedef Operation turn_operation_type;
89 typedef Container container_type;
90
91 Point point;
92 method_type method;
93 bool touch_only; // True in case of method touch(interior) and lines do not cross
94 signed_size_type cluster_id; // For multiple turns on same location, > 0. Else -1. 0 is unused.
95 bool discarded;
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