]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / turns / filter_continue_turns.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014, Oracle and/or its affiliates.
4
5 // Licensed under the Boost Software License version 1.0.
6 // http://www.boost.org/users/license.html
7
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
9
10
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_FILTER_CONTINUE_TURNS_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_FILTER_CONTINUE_TURNS_HPP
13
14 #include <algorithm>
15 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
16
17 namespace boost { namespace geometry
18 {
19
20 namespace detail { namespace turns
21 {
22
23
24 template <typename Turns, bool Enable>
25 struct filter_continue_turns
26 {
27 static inline void apply(Turns&) {}
28 };
29
30
31 template <typename Turns>
32 class filter_continue_turns<Turns, true>
33 {
34 private:
35 class IsContinueTurn
36 {
37 private:
38 template <typename Operation>
39 inline bool is_continue_or_opposite(Operation const& operation) const
40 {
41 return operation == detail::overlay::operation_continue
42 || operation == detail::overlay::operation_opposite;
43 }
44
45 public:
46 template <typename Turn>
47 bool operator()(Turn const& turn) const
48 {
49 if ( turn.method != detail::overlay::method_collinear
50 && turn.method != detail::overlay::method_equal )
51 {
52 return false;
53 }
54
55 return is_continue_or_opposite(turn.operations[0].operation)
56 && is_continue_or_opposite(turn.operations[1].operation);
57 }
58 };
59
60
61 public:
62 static inline void apply(Turns& turns)
63 {
64 turns.erase( std::remove_if(turns.begin(), turns.end(),
65 IsContinueTurn()),
66 turns.end()
67 );
68 }
69 };
70
71
72 }} // namespace detail::turns
73
74 }} // namespect boost::geometry
75
76
77
78 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_FILTER_CONTINUE_TURNS_HPP