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-2014.
9 // Modifications copyright (c) 2013-2014, 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>
43 struct check_each_ring_for_within
46 Geometry const& m_geometry;
48 inline check_each_ring_for_within(Geometry const& g)
53 template <typename Range>
54 inline void apply(Range const& range)
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) );
65 template <typename FirstGeometry, typename SecondGeometry>
66 inline bool rings_containing(FirstGeometry const& geometry1,
67 SecondGeometry const& geometry2)
69 check_each_ring_for_within<FirstGeometry> checker(geometry1);
70 geometry::detail::for_each_range(geometry2, checker);
71 return checker.not_disjoint;
76 template <typename Geometry1, typename Geometry2>
80 bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
82 if ( ! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2) )
87 // If there is no intersection of segments, they might located
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.
93 if ( rings_containing(geometry1, geometry2)
94 || rings_containing(geometry2, geometry1) )
104 }} // namespace detail::disjoint
105 #endif // DOXYGEN_NO_DETAIL
110 #ifndef DOXYGEN_NO_DISPATCH
115 template <typename Areal1, typename Areal2>
116 struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
117 : detail::disjoint::general_areal<Areal1, Areal2>
121 template <typename Areal, typename Box>
122 struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
123 : detail::disjoint::general_areal<Areal, Box>
127 } // namespace dispatch
128 #endif // DOXYGEN_NO_DISPATCH
131 }} // namespace boost::geometry
134 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP