File indexing completed on 2025-01-18 09:35:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
0013 #define BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
0014
0015 #include <algorithm>
0016
0017 #include <boost/range/begin.hpp>
0018 #include <boost/range/empty.hpp>
0019 #include <boost/range/end.hpp>
0020
0021
0022 namespace boost { namespace geometry
0023 {
0024
0025
0026 #ifndef DOXYGEN_NO_DETAIL
0027 namespace detail { namespace overlay
0028 {
0029
0030
0031 template
0032 <
0033 typename IsAcceptableTurnPredicate,
0034 bool AllowEmptyTurnRange = true
0035 >
0036 struct stateless_predicate_based_interrupt_policy
0037 {
0038 static bool const enabled = true;
0039 bool has_intersections;
0040
0041
0042 inline stateless_predicate_based_interrupt_policy()
0043 : has_intersections(false)
0044 {}
0045
0046 template <typename Range>
0047 inline bool apply(Range const& range)
0048 {
0049
0050 bool const has_unacceptable_turn = std::any_of(boost::begin(range), boost::end(range),
0051 [](auto const& turn) {
0052 return ! IsAcceptableTurnPredicate::apply(turn);
0053 });
0054
0055 has_intersections = has_unacceptable_turn
0056 && !(AllowEmptyTurnRange && boost::empty(range));
0057
0058 return has_intersections;
0059 }
0060 };
0061
0062
0063
0064
0065 template
0066 <
0067 typename IsAcceptableTurnPredicate,
0068 bool AllowEmptyTurnRange = true
0069 >
0070 struct predicate_based_interrupt_policy
0071 {
0072 static bool const enabled = true;
0073 bool has_intersections;
0074
0075 IsAcceptableTurnPredicate const& m_predicate;
0076
0077 inline
0078 predicate_based_interrupt_policy(IsAcceptableTurnPredicate const& predicate)
0079 : has_intersections(false)
0080 , m_predicate(predicate)
0081 {}
0082
0083 template <typename Range>
0084 inline bool apply(Range const& range)
0085 {
0086
0087 bool const has_unacceptable_turn = std::any_of(boost::begin(range),
0088 boost::end(range),
0089 [&]( auto const& turn ) {
0090 return ! m_predicate.apply(turn);
0091 });
0092
0093 has_intersections = has_unacceptable_turn
0094 && !(AllowEmptyTurnRange && boost::empty(range));
0095
0096 return has_intersections;
0097 }
0098 };
0099
0100
0101
0102
0103 }}
0104 #endif
0105
0106
0107 }}
0108
0109
0110 #endif