1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
15 #include <boost/mpl/if.hpp>
16 #include <boost/range.hpp>
18 #include <boost/geometry/algorithms/convert.hpp>
19 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
21 #include <boost/geometry/geometries/segment.hpp>
23 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
25 namespace boost { namespace geometry
29 #ifndef DOXYGEN_NO_DETAIL
30 namespace detail { namespace get_intersection_points
40 struct get_turn_without_info
42 template <typename RobustPolicy, typename OutputIterator>
43 static inline OutputIterator apply(
44 Point1 const& pi, Point1 const& pj, Point1 const& /*pk*/,
45 Point2 const& qi, Point2 const& qj, Point2 const& /*qk*/,
46 bool /*is_p_first*/, bool /*is_p_last*/,
47 bool /*is_q_first*/, bool /*is_q_last*/,
49 RobustPolicy const& robust_policy,
52 typedef intersection_strategies
54 typename cs_tag<typename TurnInfo::point_type>::type,
57 typename TurnInfo::point_type,
61 typedef typename si::segment_intersection_strategy_type strategy;
63 typedef model::referring_segment<Point1 const> segment_type1;
64 typedef model::referring_segment<Point1 const> segment_type2;
65 segment_type1 p1(pi, pj);
66 segment_type2 q1(qi, qj);
68 typedef typename geometry::robust_point_type
71 >::type robust_point_type;
73 robust_point_type pi_rob, pj_rob, qi_rob, qj_rob;
74 geometry::recalculate(pi_rob, pi, robust_policy);
75 geometry::recalculate(pj_rob, pj, robust_policy);
76 geometry::recalculate(qi_rob, qi, robust_policy);
77 geometry::recalculate(qj_rob, qj, robust_policy);
78 typename strategy::return_type result
79 = strategy::apply(p1, q1, robust_policy,
80 pi_rob, pj_rob, qi_rob, qj_rob);
82 for (std::size_t i = 0; i < result.template get<0>().count; i++)
86 geometry::convert(result.template get<0>().intersections[i], tp.point);
94 }} // namespace detail::get_intersection_points
95 #endif // DOXYGEN_NO_DETAIL
104 typename RobustPolicy,
107 inline void get_intersection_points(Geometry1 const& geometry1,
108 Geometry2 const& geometry2,
109 RobustPolicy const& robust_policy,
112 concepts::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>();
114 typedef detail::get_intersection_points::get_turn_without_info
116 typename point_type<Geometry1>::type,
117 typename point_type<Geometry2>::type,
118 typename boost::range_value<Turns>::type
121 detail::get_turns::no_interrupt_policy interrupt_policy;
125 reverse_dispatch<Geometry1, Geometry2>::type::value,
126 dispatch::get_turns_reversed
128 typename tag<Geometry1>::type,
129 typename tag<Geometry2>::type,
130 Geometry1, Geometry2,
136 typename tag<Geometry1>::type,
137 typename tag<Geometry2>::type,
138 Geometry1, Geometry2,
146 turns, interrupt_policy);
152 }} // namespace boost::geometry
154 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP