]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/disjoint/areal_areal.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / disjoint / areal_areal.hpp
CommitLineData
7c673cae
FG
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// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
7
8// This file was modified by Oracle on 2013-2014.
9// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
10
11// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13
14// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16
17// Use, modification and distribution is subject to the Boost Software License,
18// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19// http://www.boost.org/LICENSE_1_0.txt)
20
21#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
22#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
23
24#include <boost/geometry/core/point_type.hpp>
25
26#include <boost/geometry/algorithms/covered_by.hpp>
27#include <boost/geometry/algorithms/detail/for_each_range.hpp>
28#include <boost/geometry/algorithms/detail/point_on_border.hpp>
29
30#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
31
32
33namespace boost { namespace geometry
34{
35
36
37#ifndef DOXYGEN_NO_DETAIL
38namespace detail { namespace disjoint
39{
40
41
42template<typename Geometry>
43struct check_each_ring_for_within
44{
45 bool not_disjoint;
46 Geometry const& m_geometry;
47
48 inline check_each_ring_for_within(Geometry const& g)
49 : not_disjoint(false)
50 , m_geometry(g)
51 {}
52
53 template <typename Range>
54 inline void apply(Range const& range)
55 {
56 typename point_type<Range>::type pt;
57 not_disjoint = not_disjoint
58 || ( geometry::point_on_border(pt, range)
59 && geometry::covered_by(pt, m_geometry) );
60 }
61};
62
63
64
65template <typename FirstGeometry, typename SecondGeometry>
66inline bool rings_containing(FirstGeometry const& geometry1,
67 SecondGeometry const& geometry2)
68{
69 check_each_ring_for_within<FirstGeometry> checker(geometry1);
70 geometry::detail::for_each_range(geometry2, checker);
71 return checker.not_disjoint;
72}
73
74
75
76template <typename Geometry1, typename Geometry2>
77struct general_areal
78{
79 static inline
80 bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
81 {
82 if ( ! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2) )
83 {
84 return false;
85 }
86
87 // If there is no intersection of segments, they might located
88 // inside each other
89
90 // We check that using a point on the border (external boundary),
91 // and see if that is contained in the other geometry. And vice versa.
92
93 if ( rings_containing(geometry1, geometry2)
94 || rings_containing(geometry2, geometry1) )
95 {
96 return false;
97 }
98
99 return true;
100 }
101};
102
103
104}} // namespace detail::disjoint
105#endif // DOXYGEN_NO_DETAIL
106
107
108
109
110#ifndef DOXYGEN_NO_DISPATCH
111namespace dispatch
112{
113
114
115template <typename Areal1, typename Areal2>
116struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
117 : detail::disjoint::general_areal<Areal1, Areal2>
118{};
119
120
121template <typename Areal, typename Box>
122struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
123 : detail::disjoint::general_areal<Areal, Box>
124{};
125
126
127} // namespace dispatch
128#endif // DOXYGEN_NO_DISPATCH
129
130
131}} // namespace boost::geometry
132
133
134#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP