123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #ifndef BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
- #define BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
- #include <algorithm>
- #include <boost/range/begin.hpp>
- #include <boost/range/empty.hpp>
- #include <boost/range/end.hpp>
- namespace boost { namespace geometry
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail { namespace overlay
- {
- template
- <
- typename IsAcceptableTurnPredicate,
- bool AllowEmptyTurnRange = true
- >
- struct stateless_predicate_based_interrupt_policy
- {
- static bool const enabled = true;
- bool has_intersections;
-
- inline stateless_predicate_based_interrupt_policy()
- : has_intersections(false)
- {}
- template <typename Range>
- inline bool apply(Range const& range)
- {
-
- bool const has_unacceptable_turn = std::any_of(boost::begin(range), boost::end(range),
- [](auto const& turn) {
- return ! IsAcceptableTurnPredicate::apply(turn);
- });
- has_intersections = has_unacceptable_turn
- && !(AllowEmptyTurnRange && boost::empty(range));
- return has_intersections;
- }
- };
- template
- <
- typename IsAcceptableTurnPredicate,
- bool AllowEmptyTurnRange = true
- >
- struct predicate_based_interrupt_policy
- {
- static bool const enabled = true;
- bool has_intersections;
-
- IsAcceptableTurnPredicate const& m_predicate;
- inline
- predicate_based_interrupt_policy(IsAcceptableTurnPredicate const& predicate)
- : has_intersections(false)
- , m_predicate(predicate)
- {}
- template <typename Range>
- inline bool apply(Range const& range)
- {
-
- bool const has_unacceptable_turn = std::any_of(boost::begin(range),
- boost::end(range),
- [&]( auto const& turn ) {
- return ! m_predicate.apply(turn);
- });
- has_intersections = has_unacceptable_turn
- && !(AllowEmptyTurnRange && boost::empty(range));
- return has_intersections;
- }
- };
- }}
- #endif
- }}
- #endif
|