Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@101
|
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@101
|
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
Chris@101
|
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
Chris@101
|
6
|
Chris@101
|
7 // This file was modified by Oracle on 2013-2014.
|
Chris@101
|
8 // Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
|
Chris@101
|
9
|
Chris@101
|
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
Chris@16
|
11
|
Chris@16
|
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
14
|
Chris@16
|
15 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
17 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
18
|
Chris@16
|
19 #ifndef BOOST_GEOMETRY_ALGORITHMS_INTERSECTS_HPP
|
Chris@16
|
20 #define BOOST_GEOMETRY_ALGORITHMS_INTERSECTS_HPP
|
Chris@16
|
21
|
Chris@16
|
22
|
Chris@16
|
23 #include <deque>
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/geometry/geometries/concepts/check.hpp>
|
Chris@16
|
26 #include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
|
Chris@16
|
27 #include <boost/geometry/algorithms/disjoint.hpp>
|
Chris@16
|
28
|
Chris@101
|
29 #include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
|
Chris@101
|
30 #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
|
Chris@101
|
31
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost { namespace geometry
|
Chris@16
|
34 {
|
Chris@16
|
35
|
Chris@16
|
36 /*!
|
Chris@16
|
37 \brief \brief_check{has at least one intersection (crossing or self-tangency)}
|
Chris@16
|
38 \note This function can be called for one geometry (self-intersection) and
|
Chris@16
|
39 also for two geometries (intersection)
|
Chris@16
|
40 \ingroup intersects
|
Chris@16
|
41 \tparam Geometry \tparam_geometry
|
Chris@16
|
42 \param geometry \param_geometry
|
Chris@16
|
43 \return \return_check{is self-intersecting}
|
Chris@16
|
44
|
Chris@16
|
45 \qbk{distinguish,one geometry}
|
Chris@16
|
46 \qbk{[def __one_parameter__]}
|
Chris@16
|
47 \qbk{[include reference/algorithms/intersects.qbk]}
|
Chris@16
|
48 */
|
Chris@16
|
49 template <typename Geometry>
|
Chris@16
|
50 inline bool intersects(Geometry const& geometry)
|
Chris@16
|
51 {
|
Chris@16
|
52 concept::check<Geometry const>();
|
Chris@16
|
53
|
Chris@101
|
54 typedef typename geometry::point_type<Geometry>::type point_type;
|
Chris@101
|
55 typedef detail::no_rescale_policy rescale_policy_type;
|
Chris@16
|
56
|
Chris@16
|
57 typedef detail::overlay::turn_info
|
Chris@16
|
58 <
|
Chris@101
|
59 point_type,
|
Chris@101
|
60 typename segment_ratio_type<point_type, rescale_policy_type>::type
|
Chris@16
|
61 > turn_info;
|
Chris@101
|
62
|
Chris@16
|
63 std::deque<turn_info> turns;
|
Chris@16
|
64
|
Chris@16
|
65 typedef detail::overlay::get_turn_info
|
Chris@16
|
66 <
|
Chris@16
|
67 detail::overlay::assign_null_policy
|
Chris@101
|
68 > turn_policy;
|
Chris@101
|
69
|
Chris@101
|
70 rescale_policy_type robust_policy;
|
Chris@16
|
71
|
Chris@16
|
72 detail::disjoint::disjoint_interrupt_policy policy;
|
Chris@16
|
73 detail::self_get_turn_points::get_turns
|
Chris@101
|
74 <
|
Chris@101
|
75 turn_policy
|
Chris@101
|
76 >::apply(geometry, robust_policy, turns, policy);
|
Chris@16
|
77 return policy.has_intersections;
|
Chris@16
|
78 }
|
Chris@16
|
79
|
Chris@16
|
80
|
Chris@16
|
81 /*!
|
Chris@16
|
82 \brief \brief_check2{have at least one intersection}
|
Chris@16
|
83 \ingroup intersects
|
Chris@16
|
84 \tparam Geometry1 \tparam_geometry
|
Chris@16
|
85 \tparam Geometry2 \tparam_geometry
|
Chris@16
|
86 \param geometry1 \param_geometry
|
Chris@16
|
87 \param geometry2 \param_geometry
|
Chris@16
|
88 \return \return_check2{intersect each other}
|
Chris@16
|
89
|
Chris@16
|
90 \qbk{distinguish,two geometries}
|
Chris@16
|
91 \qbk{[include reference/algorithms/intersects.qbk]}
|
Chris@16
|
92 */
|
Chris@16
|
93 template <typename Geometry1, typename Geometry2>
|
Chris@16
|
94 inline bool intersects(Geometry1 const& geometry1, Geometry2 const& geometry2)
|
Chris@16
|
95 {
|
Chris@16
|
96 concept::check<Geometry1 const>();
|
Chris@16
|
97 concept::check<Geometry2 const>();
|
Chris@16
|
98
|
Chris@16
|
99 return ! geometry::disjoint(geometry1, geometry2);
|
Chris@16
|
100 }
|
Chris@16
|
101
|
Chris@16
|
102
|
Chris@16
|
103
|
Chris@16
|
104 }} // namespace boost::geometry
|
Chris@16
|
105
|
Chris@16
|
106 #endif // BOOST_GEOMETRY_ALGORITHMS_INTERSECTS_HPP
|