File indexing completed on 2025-12-15 09:50:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
0011 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
0012
0013
0014 #include <array>
0015
0016 #include <boost/geometry/core/coordinate_type.hpp>
0017 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
0018 #include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
0019 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
0020 #include <boost/geometry/policies/robustness/segment_ratio.hpp>
0021
0022 namespace boost { namespace geometry
0023 {
0024
0025 #ifndef DOXYGEN_NO_DETAIL
0026 namespace detail { namespace overlay
0027 {
0028
0029 enum method_type
0030 {
0031 method_none,
0032 method_disjoint,
0033 method_crosses,
0034 method_touch,
0035 method_touch_interior,
0036 method_collinear,
0037 method_equal,
0038 method_start,
0039 method_error
0040 };
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 template <typename Point, typename SegmentRatio>
0052 struct turn_operation
0053 {
0054 using segment_ratio_type = SegmentRatio;
0055
0056 operation_type operation;
0057 segment_identifier seg_id;
0058 segment_ratio_type fraction;
0059
0060 using comparable_distance_type = coordinate_type_t<Point>;
0061 comparable_distance_type remaining_distance;
0062
0063 inline turn_operation()
0064 : operation(operation_none)
0065 , remaining_distance(0)
0066 {}
0067 };
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 template
0080 <
0081 typename Point,
0082 typename SegmentRatio = geometry::segment_ratio<coordinate_type_t<Point>>,
0083 typename Operation = turn_operation<Point, SegmentRatio>,
0084 typename Container = std::array<Operation, 2>
0085 >
0086 struct turn_info
0087 {
0088 using point_type = Point;
0089 using segment_ratio_type = SegmentRatio;
0090 using turn_operation_type = Operation;
0091 using container_type = Container;
0092
0093 Point point;
0094 method_type method;
0095 bool touch_only;
0096 signed_size_type cluster_id;
0097 bool discarded;
0098 bool has_colocated_both;
0099
0100 Container operations;
0101
0102 inline turn_info()
0103 : method(method_none)
0104 , touch_only(false)
0105 , cluster_id(-1)
0106 , discarded(false)
0107 , has_colocated_both(false)
0108 {}
0109
0110 inline bool both(operation_type type) const
0111 {
0112 return has12(type, type);
0113 }
0114
0115 inline bool has(operation_type type) const
0116 {
0117 return this->operations[0].operation == type
0118 || this->operations[1].operation == type;
0119 }
0120
0121 inline bool combination(operation_type type1, operation_type type2) const
0122 {
0123 return has12(type1, type2) || has12(type2, type1);
0124 }
0125
0126 inline bool blocked() const
0127 {
0128 return both(operation_blocked);
0129 }
0130 inline bool opposite() const
0131 {
0132 return both(operation_opposite);
0133 }
0134 inline bool any_blocked() const
0135 {
0136 return has(operation_blocked);
0137 }
0138 inline bool is_clustered() const
0139 {
0140 return cluster_id > 0;
0141 }
0142 inline bool is_self() const
0143 {
0144 return operations[0].seg_id.source_index
0145 == operations[1].seg_id.source_index;
0146 }
0147
0148 private :
0149 inline bool has12(operation_type type1, operation_type type2) const
0150 {
0151 return this->operations[0].operation == type1
0152 && this->operations[1].operation == type2
0153 ;
0154 }
0155
0156 };
0157
0158
0159 }}
0160 #endif
0161
0162
0163 }}
0164
0165
0166 #endif