]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2015, 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 | #ifndef BOOST_GEOMETRY_TEST_CHECK_TURN_LESS_HPP | |
11 | #define BOOST_GEOMETRY_TEST_CHECK_TURN_LESS_HPP | |
12 | ||
13 | #include <boost/range.hpp> | |
14 | ||
15 | #include "test_set_ops_linear_linear.hpp" | |
16 | ||
17 | ||
18 | // check less functor for turns | |
19 | template <typename Turns, typename Less> | |
20 | inline void verify_less_for_turns(Turns turns, Less const& less) | |
21 | { | |
22 | typedef typename boost::range_iterator<Turns const>::type iterator_type; | |
23 | ||
24 | if (boost::size(turns) < 2) | |
25 | { | |
26 | return; | |
27 | } | |
28 | ||
29 | iterator_type last = --boost::end(turns); | |
30 | for (iterator_type it1 = boost::begin(turns); it1 != last; ++it1) | |
31 | { | |
32 | iterator_type it2 = it1; | |
33 | ++it2; | |
34 | for (; it2 != boost::end(turns); ++it2) | |
35 | { | |
36 | if (less(*it1, *it2)) | |
37 | { | |
38 | BOOST_CHECK(! less(*it2, *it1)); | |
39 | } | |
40 | if (less(*it2, *it1)) | |
41 | { | |
42 | BOOST_CHECK(! less(*it1, *it2)); | |
43 | } | |
44 | } | |
45 | } | |
46 | } | |
47 | ||
48 | ||
49 | struct check_turn_less | |
50 | { | |
51 | template <bool EnableDegenerateTurns = true> | |
52 | struct assign_policy | |
53 | { | |
54 | static bool const include_no_turn = false; | |
55 | static bool const include_degenerate = EnableDegenerateTurns; | |
56 | static bool const include_opposite = false; | |
57 | ||
58 | template | |
59 | < | |
60 | typename Info, | |
61 | typename Point1, | |
62 | typename Point2, | |
63 | typename IntersectionInfo | |
64 | > | |
65 | static inline void apply(Info& , Point1 const& , Point2 const& , | |
66 | IntersectionInfo const& ) | |
67 | { | |
68 | } | |
69 | }; | |
70 | ||
71 | template <typename Geometry1, typename Geometry2> | |
72 | static inline void apply(Geometry1 const& geometry1, | |
73 | Geometry2 const& geometry2) | |
74 | { | |
75 | typedef bg::detail::no_rescale_policy robust_policy_type; | |
76 | ||
77 | typedef bg::detail::relate::turns::get_turns | |
78 | < | |
79 | Geometry1, | |
80 | Geometry2, | |
81 | bg::detail::get_turns::get_turn_info_type | |
82 | < | |
83 | Geometry1, Geometry2, assign_policy<> | |
84 | >, | |
85 | robust_policy_type | |
86 | > get_turns_type; | |
87 | ||
88 | typedef typename get_turns_type::turn_info turn_info; | |
89 | ||
90 | typedef std::vector<turn_info> turns_container; | |
91 | ||
92 | turns_container turns; | |
93 | ||
94 | bg::detail::get_turns::no_interrupt_policy interrupt_policy; | |
95 | ||
96 | get_turns_type::apply(turns, geometry1, geometry2, | |
97 | interrupt_policy, robust_policy_type()); | |
98 | ||
99 | ||
100 | typedef bg::detail::turns::less_seg_fraction_other_op<> turn_less_type; | |
101 | ||
102 | verify_less_for_turns(turns, turn_less_type()); | |
103 | } | |
104 | }; | |
105 | ||
106 | #endif // BOOST_GEOMETRY_TEST_CHECK_TURN_LESS_HPP |