File indexing completed on 2025-01-18 09:35:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
0022 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
0023
0024 #include <boost/geometry/core/point_type.hpp>
0025
0026 #include <boost/geometry/algorithms/detail/covered_by/implementation.hpp>
0027 #include <boost/geometry/algorithms/detail/for_each_range.hpp>
0028 #include <boost/geometry/algorithms/detail/point_on_border.hpp>
0029
0030 #include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
0031 #include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
0032
0033 #include <boost/geometry/geometries/helper_geometry.hpp>
0034
0035 #include <boost/geometry/algorithms/for_each.hpp>
0036
0037
0038 namespace boost { namespace geometry
0039 {
0040
0041
0042 #ifndef DOXYGEN_NO_DETAIL
0043 namespace detail { namespace disjoint
0044 {
0045
0046 template <typename Geometry1, typename Geometry2, typename Strategy>
0047 inline bool point_on_border_covered_by(Geometry1 const& geometry1,
0048 Geometry2 const& geometry2,
0049 Strategy const& strategy)
0050 {
0051 using point_type = typename geometry::point_type<Geometry1>::type;
0052 typename helper_geometry<point_type>::type pt;
0053 return geometry::point_on_border(pt, geometry1)
0054 && geometry::covered_by(pt, geometry2, strategy);
0055 }
0056
0057
0058
0059
0060
0061 template <typename Geometry1, typename Geometry2, typename Strategy>
0062 inline bool rings_containing(Geometry1 const& geometry1,
0063 Geometry2 const& geometry2,
0064 Strategy const& strategy)
0065 {
0066 return geometry::detail::any_range_of(geometry2, [&](auto const& range)
0067 {
0068 return point_on_border_covered_by(range, geometry1, strategy);
0069 });
0070 }
0071
0072
0073
0074 template <typename Geometry1, typename Geometry2>
0075 struct areal_areal
0076 {
0077
0078
0079
0080 template <typename Strategy>
0081 static inline bool apply(Geometry1 const& geometry1,
0082 Geometry2 const& geometry2,
0083 Strategy const& strategy)
0084 {
0085 if ( ! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy) )
0086 {
0087 return false;
0088 }
0089
0090
0091
0092
0093
0094
0095
0096 if ( rings_containing(geometry1, geometry2, strategy)
0097 || rings_containing(geometry2, geometry1, strategy) )
0098 {
0099 return false;
0100 }
0101
0102 return true;
0103 }
0104 };
0105
0106
0107 template <typename Areal, typename Box>
0108 struct areal_box
0109 {
0110
0111
0112
0113 template <typename Strategy>
0114 static inline bool apply(Areal const& areal,
0115 Box const& box,
0116 Strategy const& strategy)
0117 {
0118 if (! geometry::all_segments_of(areal, [&](auto const& s)
0119 {
0120 return disjoint_segment_box::apply(s, box, strategy);
0121 }) )
0122 {
0123 return false;
0124 }
0125
0126
0127
0128
0129 if ( point_on_border_covered_by(box, areal, strategy) )
0130 {
0131 return false;
0132 }
0133
0134 return true;
0135 }
0136 };
0137
0138
0139 }}
0140 #endif
0141
0142
0143
0144
0145 #ifndef DOXYGEN_NO_DISPATCH
0146 namespace dispatch
0147 {
0148
0149
0150 template <typename Areal1, typename Areal2>
0151 struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
0152 : detail::disjoint::areal_areal<Areal1, Areal2>
0153 {};
0154
0155
0156 template <typename Areal, typename Box>
0157 struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
0158 : detail::disjoint::areal_box<Areal, Box>
0159 {};
0160
0161
0162 }
0163 #endif
0164
0165
0166 }}
0167
0168
0169 #endif