Chris@102
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@102
|
2
|
Chris@102
|
3 // Copyright (c) 2014, Oracle and/or its affiliates.
|
Chris@102
|
4
|
Chris@102
|
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
Chris@102
|
6
|
Chris@102
|
7 // Licensed under the Boost Software License version 1.0.
|
Chris@102
|
8 // http://www.boost.org/users/license.html
|
Chris@102
|
9
|
Chris@102
|
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
|
Chris@102
|
11 #define BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
|
Chris@102
|
12
|
Chris@102
|
13 #include <boost/range.hpp>
|
Chris@102
|
14
|
Chris@102
|
15 #include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
Chris@102
|
16
|
Chris@102
|
17
|
Chris@102
|
18 namespace boost { namespace geometry
|
Chris@102
|
19 {
|
Chris@102
|
20
|
Chris@102
|
21
|
Chris@102
|
22 #ifndef DOXYGEN_NO_DETAIL
|
Chris@102
|
23 namespace detail { namespace overlay
|
Chris@102
|
24 {
|
Chris@102
|
25
|
Chris@102
|
26
|
Chris@102
|
27 template
|
Chris@102
|
28 <
|
Chris@102
|
29 typename IsAcceptableTurnPredicate,
|
Chris@102
|
30 bool AllowEmptyTurnRange = true // by default, allow an empty turn range
|
Chris@102
|
31 >
|
Chris@102
|
32 struct stateless_predicate_based_interrupt_policy
|
Chris@102
|
33 {
|
Chris@102
|
34 static bool const enabled = true;
|
Chris@102
|
35 bool has_intersections; // set to true if there is at least one
|
Chris@102
|
36 // unacceptable turn
|
Chris@102
|
37
|
Chris@102
|
38 inline stateless_predicate_based_interrupt_policy()
|
Chris@102
|
39 : has_intersections(false)
|
Chris@102
|
40 {}
|
Chris@102
|
41
|
Chris@102
|
42 template <typename Range>
|
Chris@102
|
43 inline bool apply(Range const& range)
|
Chris@102
|
44 {
|
Chris@102
|
45 // if there is at least one unacceptable turn in the range, return false
|
Chris@102
|
46 has_intersections = !detail::check_iterator_range
|
Chris@102
|
47 <
|
Chris@102
|
48 IsAcceptableTurnPredicate,
|
Chris@102
|
49 AllowEmptyTurnRange
|
Chris@102
|
50 >::apply(boost::begin(range), boost::end(range));
|
Chris@102
|
51
|
Chris@102
|
52 return has_intersections;
|
Chris@102
|
53 }
|
Chris@102
|
54 };
|
Chris@102
|
55
|
Chris@102
|
56
|
Chris@102
|
57
|
Chris@102
|
58
|
Chris@102
|
59 template
|
Chris@102
|
60 <
|
Chris@102
|
61 typename IsAcceptableTurnPredicate,
|
Chris@102
|
62 bool AllowEmptyTurnRange = true // by default, allow an empty turn range
|
Chris@102
|
63 >
|
Chris@102
|
64 struct predicate_based_interrupt_policy
|
Chris@102
|
65 {
|
Chris@102
|
66 static bool const enabled = true;
|
Chris@102
|
67 bool has_intersections; // set to true if there is at least one
|
Chris@102
|
68 // unacceptable turn
|
Chris@102
|
69 IsAcceptableTurnPredicate const& m_predicate;
|
Chris@102
|
70
|
Chris@102
|
71 inline
|
Chris@102
|
72 predicate_based_interrupt_policy(IsAcceptableTurnPredicate const& predicate)
|
Chris@102
|
73 : has_intersections(false)
|
Chris@102
|
74 , m_predicate(predicate)
|
Chris@102
|
75 {}
|
Chris@102
|
76
|
Chris@102
|
77 template <typename Range>
|
Chris@102
|
78 inline bool apply(Range const& range)
|
Chris@102
|
79 {
|
Chris@102
|
80 // if there is at least one unacceptable turn in the range, return false
|
Chris@102
|
81 has_intersections = !detail::check_iterator_range
|
Chris@102
|
82 <
|
Chris@102
|
83 IsAcceptableTurnPredicate,
|
Chris@102
|
84 AllowEmptyTurnRange
|
Chris@102
|
85 >::apply(boost::begin(range), boost::end(range), m_predicate);
|
Chris@102
|
86
|
Chris@102
|
87 return has_intersections;
|
Chris@102
|
88 }
|
Chris@102
|
89 };
|
Chris@102
|
90
|
Chris@102
|
91
|
Chris@102
|
92
|
Chris@102
|
93
|
Chris@102
|
94 }} // namespace detail::overlay
|
Chris@102
|
95 #endif // DOXYGEN_NO_DETAIL
|
Chris@102
|
96
|
Chris@102
|
97
|
Chris@102
|
98 }} // namespace boost::geometry
|
Chris@102
|
99
|
Chris@102
|
100
|
Chris@102
|
101 #endif // BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
|