]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | ||
20effc67 TL |
5 | // This file was modified by Oracle on 2017-2020. |
6 | // Modifications copyright (c) 2017-2020 Oracle and/or its affiliates. | |
b32b8144 FG |
7 | |
8 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
9 | ||
7c673cae FG |
10 | // Use, modification and distribution is subject to the Boost Software License, |
11 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 | // http://www.boost.org/LICENSE_1_0.txt) | |
13 | ||
14 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP | |
15 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP | |
16 | ||
17 | ||
18 | #include <cstddef> | |
20effc67 | 19 | #include <type_traits> |
7c673cae | 20 | |
20effc67 | 21 | #include <boost/range/value_type.hpp> |
7c673cae FG |
22 | |
23 | #include <boost/geometry/algorithms/convert.hpp> | |
24 | #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp> | |
92f5a8d4 | 25 | #include <boost/geometry/policies/robustness/rescale_policy_tags.hpp> |
7c673cae FG |
26 | |
27 | #include <boost/geometry/geometries/segment.hpp> | |
28 | ||
7c673cae FG |
29 | namespace boost { namespace geometry |
30 | { | |
31 | ||
32 | ||
33 | #ifndef DOXYGEN_NO_DETAIL | |
34 | namespace detail { namespace get_intersection_points | |
35 | { | |
36 | ||
37 | ||
38 | template | |
39 | < | |
40 | typename Point1, | |
41 | typename Point2, | |
42 | typename TurnInfo | |
43 | > | |
44 | struct get_turn_without_info | |
45 | { | |
92f5a8d4 TL |
46 | template |
47 | < | |
48 | typename UniqueSubRange1, | |
49 | typename UniqueSubRange2, | |
50 | typename Strategy, | |
51 | typename RobustPolicy, | |
52 | typename OutputIterator | |
53 | > | |
54 | static inline OutputIterator apply(UniqueSubRange1 const& range_p, | |
55 | UniqueSubRange2 const& range_q, | |
7c673cae | 56 | TurnInfo const& , |
b32b8144 | 57 | Strategy const& strategy, |
92f5a8d4 | 58 | RobustPolicy const& , |
7c673cae FG |
59 | OutputIterator out) |
60 | { | |
92f5a8d4 | 61 | // Make sure this is only called with no rescaling |
20effc67 | 62 | BOOST_STATIC_ASSERT((std::is_same |
92f5a8d4 TL |
63 | < |
64 | no_rescale_policy_tag, | |
65 | typename rescale_policy_type<RobustPolicy>::type | |
66 | >::value)); | |
67 | ||
b32b8144 | 68 | typedef typename TurnInfo::point_type turn_point_type; |
7c673cae | 69 | |
b32b8144 FG |
70 | typedef policies::relate::segments_intersection_points |
71 | < | |
92f5a8d4 | 72 | segment_intersection_points<turn_point_type> |
b32b8144 | 73 | > policy_type; |
7c673cae | 74 | |
92f5a8d4 TL |
75 | typename policy_type::return_type const result |
76 | = strategy.apply(range_p, range_q, policy_type()); | |
7c673cae | 77 | |
b32b8144 | 78 | for (std::size_t i = 0; i < result.count; i++) |
7c673cae | 79 | { |
7c673cae | 80 | TurnInfo tp; |
b32b8144 | 81 | geometry::convert(result.intersections[i], tp.point); |
7c673cae FG |
82 | *out++ = tp; |
83 | } | |
84 | ||
85 | return out; | |
86 | } | |
87 | }; | |
88 | ||
89 | }} // namespace detail::get_intersection_points | |
90 | #endif // DOXYGEN_NO_DETAIL | |
91 | ||
92 | ||
93 | ||
94 | ||
95 | template | |
96 | < | |
97 | typename Geometry1, | |
98 | typename Geometry2, | |
99 | typename RobustPolicy, | |
b32b8144 FG |
100 | typename Turns, |
101 | typename Strategy | |
7c673cae FG |
102 | > |
103 | inline void get_intersection_points(Geometry1 const& geometry1, | |
104 | Geometry2 const& geometry2, | |
105 | RobustPolicy const& robust_policy, | |
b32b8144 FG |
106 | Turns& turns, |
107 | Strategy const& strategy) | |
7c673cae FG |
108 | { |
109 | concepts::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>(); | |
110 | ||
111 | typedef detail::get_intersection_points::get_turn_without_info | |
112 | < | |
113 | typename point_type<Geometry1>::type, | |
114 | typename point_type<Geometry2>::type, | |
115 | typename boost::range_value<Turns>::type | |
116 | > TurnPolicy; | |
117 | ||
118 | detail::get_turns::no_interrupt_policy interrupt_policy; | |
119 | ||
20effc67 | 120 | std::conditional_t |
7c673cae FG |
121 | < |
122 | reverse_dispatch<Geometry1, Geometry2>::type::value, | |
123 | dispatch::get_turns_reversed | |
124 | < | |
125 | typename tag<Geometry1>::type, | |
126 | typename tag<Geometry2>::type, | |
127 | Geometry1, Geometry2, | |
128 | false, false, | |
129 | TurnPolicy | |
130 | >, | |
131 | dispatch::get_turns | |
132 | < | |
133 | typename tag<Geometry1>::type, | |
134 | typename tag<Geometry2>::type, | |
135 | Geometry1, Geometry2, | |
136 | false, false, | |
137 | TurnPolicy | |
138 | > | |
20effc67 TL |
139 | >::apply(0, geometry1, |
140 | 1, geometry2, | |
141 | strategy, | |
142 | robust_policy, | |
143 | turns, interrupt_policy); | |
7c673cae FG |
144 | } |
145 | ||
146 | ||
147 | ||
148 | ||
149 | }} // namespace boost::geometry | |
150 | ||
151 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP |