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