1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2017.
6 // Modifications copyright (c) 2017 Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
20 #include <boost/mpl/if.hpp>
21 #include <boost/range.hpp>
23 #include <boost/geometry/algorithms/convert.hpp>
24 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
26 #include <boost/geometry/geometries/segment.hpp>
28 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
30 namespace boost { namespace geometry
34 #ifndef DOXYGEN_NO_DETAIL
35 namespace detail { namespace get_intersection_points
45 struct get_turn_without_info
47 template <typename Strategy, typename RobustPolicy, typename OutputIterator>
48 static inline OutputIterator apply(
49 Point1 const& pi, Point1 const& pj, Point1 const& /*pk*/,
50 Point2 const& qi, Point2 const& qj, Point2 const& /*qk*/,
51 bool /*is_p_first*/, bool /*is_p_last*/,
52 bool /*is_q_first*/, bool /*is_q_last*/,
54 Strategy const& strategy,
55 RobustPolicy const& robust_policy,
58 typedef typename TurnInfo::point_type turn_point_type;
60 typedef policies::relate::segments_intersection_points
62 segment_intersection_points
65 typename geometry::segment_ratio_type
67 turn_point_type, RobustPolicy
72 typedef model::referring_segment<Point1 const> segment_type1;
73 typedef model::referring_segment<Point2 const> segment_type2;
74 segment_type1 p1(pi, pj);
75 segment_type2 q1(qi, qj);
77 typedef typename geometry::robust_point_type
80 >::type robust_point_type;
82 robust_point_type pi_rob, pj_rob, qi_rob, qj_rob;
83 geometry::recalculate(pi_rob, pi, robust_policy);
84 geometry::recalculate(pj_rob, pj, robust_policy);
85 geometry::recalculate(qi_rob, qi, robust_policy);
86 geometry::recalculate(qj_rob, qj, robust_policy);
87 typename policy_type::return_type result
88 = strategy.apply(p1, q1, policy_type(), robust_policy,
89 pi_rob, pj_rob, qi_rob, qj_rob);
91 for (std::size_t i = 0; i < result.count; i++)
94 geometry::convert(result.intersections[i], tp.point);
102 }} // namespace detail::get_intersection_points
103 #endif // DOXYGEN_NO_DETAIL
112 typename RobustPolicy,
116 inline void get_intersection_points(Geometry1 const& geometry1,
117 Geometry2 const& geometry2,
118 RobustPolicy const& robust_policy,
120 Strategy const& strategy)
122 concepts::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>();
124 typedef detail::get_intersection_points::get_turn_without_info
126 typename point_type<Geometry1>::type,
127 typename point_type<Geometry2>::type,
128 typename boost::range_value<Turns>::type
131 detail::get_turns::no_interrupt_policy interrupt_policy;
135 reverse_dispatch<Geometry1, Geometry2>::type::value,
136 dispatch::get_turns_reversed
138 typename tag<Geometry1>::type,
139 typename tag<Geometry2>::type,
140 Geometry1, Geometry2,
146 typename tag<Geometry1>::type,
147 typename tag<Geometry2>::type,
148 Geometry1, Geometry2,
157 turns, interrupt_policy);
163 }} // namespace boost::geometry
165 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP