1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
13 #include <boost/range.hpp>
15 #include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
18 namespace boost { namespace geometry
22 #ifndef DOXYGEN_NO_DETAIL
23 namespace detail { namespace overlay
29 typename IsAcceptableTurnPredicate,
30 bool AllowEmptyTurnRange = true // by default, allow an empty turn range
32 struct stateless_predicate_based_interrupt_policy
34 static bool const enabled = true;
35 bool has_intersections; // set to true if there is at least one
38 inline stateless_predicate_based_interrupt_policy()
39 : has_intersections(false)
42 template <typename Range>
43 inline bool apply(Range const& range)
45 // if there is at least one unacceptable turn in the range, return false
46 has_intersections = !detail::check_iterator_range
48 IsAcceptableTurnPredicate,
50 >::apply(boost::begin(range), boost::end(range));
52 return has_intersections;
61 typename IsAcceptableTurnPredicate,
62 bool AllowEmptyTurnRange = true // by default, allow an empty turn range
64 struct predicate_based_interrupt_policy
66 static bool const enabled = true;
67 bool has_intersections; // set to true if there is at least one
69 IsAcceptableTurnPredicate const& m_predicate;
72 predicate_based_interrupt_policy(IsAcceptableTurnPredicate const& predicate)
73 : has_intersections(false)
74 , m_predicate(predicate)
77 template <typename Range>
78 inline bool apply(Range const& range)
80 // if there is at least one unacceptable turn in the range, return false
81 has_intersections = !detail::check_iterator_range
83 IsAcceptableTurnPredicate,
85 >::apply(boost::begin(range), boost::end(range), m_predicate);
87 return has_intersections;
94 }} // namespace detail::overlay
95 #endif // DOXYGEN_NO_DETAIL
98 }} // namespace boost::geometry
101 #endif // BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP