File indexing completed on 2025-01-18 09:35:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_IS_ACCEPTABLE_TURN_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_IS_ACCEPTABLE_TURN_HPP
0013
0014 #include <boost/range/value_type.hpp>
0015
0016 #include <boost/geometry/core/point_order.hpp>
0017 #include <boost/geometry/core/tag.hpp>
0018 #include <boost/geometry/core/tags.hpp>
0019
0020 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
0021
0022
0023 namespace boost { namespace geometry
0024 {
0025
0026
0027 #ifndef DOXYGEN_NO_DETAIL
0028 namespace detail { namespace is_valid
0029 {
0030
0031
0032 template
0033 <
0034 typename Geometry,
0035 order_selector Order = geometry::point_order<Geometry>::value,
0036 typename Tag = typename tag<Geometry>::type
0037 >
0038 struct acceptable_operation
0039 {};
0040
0041 template <typename Polygon>
0042 struct acceptable_operation<Polygon, counterclockwise, polygon_tag>
0043 {
0044 static const detail::overlay::operation_type value =
0045 detail::overlay::operation_union;
0046 };
0047
0048 template <typename Polygon>
0049 struct acceptable_operation<Polygon, clockwise, polygon_tag>
0050 {
0051 static const detail::overlay::operation_type value =
0052 detail::overlay::operation_intersection;
0053 };
0054
0055 template <typename MultiPolygon>
0056 struct acceptable_operation<MultiPolygon, counterclockwise, multi_polygon_tag>
0057 {
0058 static const detail::overlay::operation_type value =
0059 detail::overlay::operation_intersection;
0060 };
0061
0062 template <typename MultiPolygon>
0063 struct acceptable_operation<MultiPolygon, clockwise, multi_polygon_tag>
0064 {
0065 static const detail::overlay::operation_type value =
0066 detail::overlay::operation_union;
0067 };
0068
0069
0070
0071
0072 template <typename Geometry, typename Tag = typename tag<Geometry>::type>
0073 struct is_acceptable_turn
0074 {};
0075
0076 template <typename Ring>
0077 struct is_acceptable_turn<Ring, ring_tag>
0078 {
0079 template <typename Turn>
0080 static inline bool apply(Turn const&)
0081 {
0082 return false;
0083 }
0084 };
0085
0086 template <typename Polygon>
0087 class is_acceptable_turn<Polygon, polygon_tag>
0088 {
0089 protected:
0090 template <typename Turn, typename Method, typename Operation>
0091 static inline bool check_turn(Turn const& turn,
0092 Method method,
0093 Operation operation)
0094 {
0095 return turn.method == method
0096 && turn.operations[0].operation == operation
0097 && turn.operations[1].operation == operation;
0098 }
0099
0100
0101 public:
0102 template <typename Turn>
0103 static inline bool apply(Turn const& turn)
0104 {
0105 using namespace detail::overlay;
0106
0107 if ( turn.operations[0].seg_id.ring_index
0108 == turn.operations[1].seg_id.ring_index )
0109 {
0110 return false;
0111 }
0112
0113 operation_type const op = acceptable_operation<Polygon>::value;
0114
0115 return check_turn(turn, method_touch_interior, op)
0116 || check_turn(turn, method_touch, op)
0117 ;
0118 }
0119 };
0120
0121 template <typename MultiPolygon>
0122 class is_acceptable_turn<MultiPolygon, multi_polygon_tag>
0123 : is_acceptable_turn<typename boost::range_value<MultiPolygon>::type>
0124 {
0125 private:
0126 typedef typename boost::range_value<MultiPolygon>::type polygon;
0127 typedef is_acceptable_turn<polygon> base;
0128
0129 public:
0130 template <typename Turn>
0131 static inline bool apply(Turn const& turn)
0132 {
0133 using namespace detail::overlay;
0134
0135 if ( turn.operations[0].seg_id.multi_index
0136 == turn.operations[1].seg_id.multi_index )
0137 {
0138 return base::apply(turn);
0139 }
0140
0141 operation_type const op = acceptable_operation<MultiPolygon>::value;
0142 if ( base::check_turn(turn, method_touch_interior, op)
0143 || base::check_turn(turn, method_touch, op))
0144 {
0145 return true;
0146 }
0147
0148
0149
0150 return (turn.method == method_touch
0151 || turn.method == method_touch_interior)
0152 && turn.touch_only;
0153 }
0154 };
0155
0156
0157 }}
0158 #endif
0159
0160 }}
0161
0162 #endif