1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
8 // This file was modified by Oracle on 2013-2017.
9 // Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
21 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
24 #include <boost/geometry/core/point_type.hpp>
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>
30 #include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
33 namespace boost { namespace geometry
37 #ifndef DOXYGEN_NO_DETAIL
38 namespace detail { namespace disjoint
42 template <typename Geometry, typename Tag = typename tag<Geometry>::type>
43 struct check_each_ring_for_within_call_covered_by
46 \tparam Strategy point_in_geometry strategy
48 template <typename Point, typename Strategy>
49 static inline bool apply(Point const& p, Geometry const& g, Strategy const& strategy)
51 return geometry::covered_by(p, g, strategy);
55 template <typename Geometry>
56 struct check_each_ring_for_within_call_covered_by<Geometry, box_tag>
58 template <typename Point, typename Strategy>
59 static inline bool apply(Point const& p, Geometry const& g, Strategy const& )
61 return geometry::covered_by(p, g);
67 \tparam Strategy point_in_geometry strategy
69 template<typename Geometry, typename Strategy>
70 struct check_each_ring_for_within
73 Geometry const& m_geometry;
74 Strategy const& m_strategy;
76 inline check_each_ring_for_within(Geometry const& g,
77 Strategy const& strategy)
80 , m_strategy(strategy)
83 template <typename Range>
84 inline void apply(Range const& range)
86 typename point_type<Range>::type pt;
87 not_disjoint = not_disjoint
88 || ( geometry::point_on_border(pt, range)
89 && check_each_ring_for_within_call_covered_by
92 >::apply(pt, m_geometry, m_strategy) );
98 \tparam Strategy point_in_geometry strategy
100 template <typename FirstGeometry, typename SecondGeometry, typename Strategy>
101 inline bool rings_containing(FirstGeometry const& geometry1,
102 SecondGeometry const& geometry2,
103 Strategy const& strategy)
105 check_each_ring_for_within
107 FirstGeometry, Strategy
108 > checker(geometry1, strategy);
109 geometry::detail::for_each_range(geometry2, checker);
110 return checker.not_disjoint;
115 template <typename Geometry1, typename Geometry2>
119 \tparam Strategy relate (segments intersection) strategy
121 template <typename Strategy>
122 static inline bool apply(Geometry1 const& geometry1,
123 Geometry2 const& geometry2,
124 Strategy const& strategy)
126 if ( ! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy) )
131 // If there is no intersection of segments, they might located
134 // We check that using a point on the border (external boundary),
135 // and see if that is contained in the other geometry. And vice versa.
137 if ( rings_containing(geometry1, geometry2,
138 strategy.template get_point_in_geometry_strategy<Geometry2, Geometry1>())
139 || rings_containing(geometry2, geometry1,
140 strategy.template get_point_in_geometry_strategy<Geometry1, Geometry2>()) )
150 }} // namespace detail::disjoint
151 #endif // DOXYGEN_NO_DETAIL
156 #ifndef DOXYGEN_NO_DISPATCH
161 template <typename Areal1, typename Areal2>
162 struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
163 : detail::disjoint::general_areal<Areal1, Areal2>
167 template <typename Areal, typename Box>
168 struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
169 : detail::disjoint::general_areal<Areal, Box>
173 } // namespace dispatch
174 #endif // DOXYGEN_NO_DISPATCH
177 }} // namespace boost::geometry
180 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP