1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2015, 2019, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11 #ifndef BOOST_GEOMETRY_TEST_CHECK_TURN_LESS_HPP
12 #define BOOST_GEOMETRY_TEST_CHECK_TURN_LESS_HPP
13
14 #include <boost/range.hpp>
15
16 #include "test_set_ops_linear_linear.hpp"
17
18
19 // check less functor for turns
20 template <typename Turns, typename Less>
verify_less_for_turns(Turns turns,Less const & less)21 inline void verify_less_for_turns(Turns turns, Less const& less)
22 {
23 typedef typename boost::range_iterator<Turns const>::type iterator_type;
24
25 if (boost::size(turns) < 2)
26 {
27 return;
28 }
29
30 iterator_type last = --boost::end(turns);
31 for (iterator_type it1 = boost::begin(turns); it1 != last; ++it1)
32 {
33 iterator_type it2 = it1;
34 ++it2;
35 for (; it2 != boost::end(turns); ++it2)
36 {
37 if (less(*it1, *it2))
38 {
39 BOOST_CHECK(! less(*it2, *it1));
40 }
41 if (less(*it2, *it1))
42 {
43 BOOST_CHECK(! less(*it1, *it2));
44 }
45 }
46 }
47 }
48
49
50 struct check_turn_less
51 {
52 template <bool EnableDegenerateTurns = true>
53 struct assign_policy
54 {
55 static bool const include_no_turn = false;
56 static bool const include_degenerate = EnableDegenerateTurns;
57 static bool const include_opposite = false;
58
59 template
60 <
61 typename Info,
62 typename Point1,
63 typename Point2,
64 typename IntersectionInfo
65 >
applycheck_turn_less::assign_policy66 static inline void apply(Info& , Point1 const& , Point2 const& ,
67 IntersectionInfo const& )
68 {
69 }
70 };
71
72 template <typename Geometry1, typename Geometry2>
applycheck_turn_less73 static inline void apply(Geometry1 const& geometry1,
74 Geometry2 const& geometry2)
75 {
76 typedef typename bg::strategy::intersection::services::default_strategy
77 <
78 typename bg::cs_tag<Geometry1>::type
79 >::type strategy_type;
80
81 typedef bg::detail::no_rescale_policy robust_policy_type;
82
83 typedef bg::detail::relate::turns::get_turns
84 <
85 Geometry1,
86 Geometry2,
87 bg::detail::get_turns::get_turn_info_type
88 <
89 Geometry1, Geometry2, assign_policy<>
90 >
91 > get_turns_type;
92
93 typedef typename get_turns_type::template turn_info_type
94 <
95 strategy_type, robust_policy_type
96 >::type turn_info;
97
98 typedef std::vector<turn_info> turns_container;
99
100 turns_container turns;
101
102 bg::detail::get_turns::no_interrupt_policy interrupt_policy;
103
104 get_turns_type::apply(turns, geometry1, geometry2,
105 interrupt_policy,
106 strategy_type(), robust_policy_type());
107
108
109 typedef bg::detail::turns::less_seg_fraction_other_op<> turn_less_type;
110
111 verify_less_for_turns(turns, turn_less_type());
112 }
113 };
114
115 #endif // BOOST_GEOMETRY_TEST_CHECK_TURN_LESS_HPP
116