File indexing completed on 2025-09-18 08:42:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP
0013
0014 #include <vector>
0015
0016 #include <boost/core/ignore_unused.hpp>
0017 #include <boost/range/empty.hpp>
0018
0019 #include <boost/geometry/algorithms/detail/is_valid/is_acceptable_turn.hpp>
0020 #include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
0021 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
0022 #include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
0023 #include <boost/geometry/algorithms/validity_failure_type.hpp>
0024
0025 #include <boost/geometry/core/assert.hpp>
0026 #include <boost/geometry/core/point_type.hpp>
0027
0028 #include <boost/geometry/policies/predicate_based_interrupt_policy.hpp>
0029
0030 namespace boost { namespace geometry
0031 {
0032
0033
0034 #ifndef DOXYGEN_NO_DETAIL
0035 namespace detail { namespace is_valid
0036 {
0037
0038
0039 template
0040 <
0041 typename Geometry,
0042 typename CSTag
0043 >
0044 class has_valid_self_turns
0045 {
0046 private:
0047 using point_type = point_type_t<Geometry>;
0048
0049 public:
0050 using turn_type = detail::overlay::turn_info
0051 <
0052 point_type,
0053 typename segment_ratio_type<point_type>::type
0054 >;
0055
0056
0057 template <typename Turns, typename VisitPolicy, typename Strategy>
0058 static inline bool apply(Geometry const& geometry,
0059 Turns& turns,
0060 VisitPolicy& visitor,
0061 Strategy const& strategy)
0062 {
0063 boost::ignore_unused(visitor);
0064
0065 detail::overlay::stateless_predicate_based_interrupt_policy
0066 <
0067 is_acceptable_turn<Geometry>
0068 > interrupt_policy;
0069
0070
0071 detail::self_get_turn_points::self_turns
0072 <
0073 false, detail::overlay::assign_null_policy
0074 >(geometry, strategy, turns, interrupt_policy,
0075 0, true);
0076
0077 if (interrupt_policy.has_intersections)
0078 {
0079 BOOST_GEOMETRY_ASSERT(! boost::empty(turns));
0080 return visitor.template apply<failure_self_intersections>(turns);
0081 }
0082 else
0083 {
0084 return visitor.template apply<no_failure>();
0085 }
0086 }
0087
0088
0089 template <typename VisitPolicy, typename Strategy>
0090 static inline bool apply(Geometry const& geometry, VisitPolicy& visitor, Strategy const& strategy)
0091 {
0092 std::vector<turn_type> turns;
0093 return apply(geometry, turns, visitor, strategy);
0094 }
0095 };
0096
0097
0098 }}
0099 #endif
0100
0101 }}
0102
0103 #endif