annotate DEPENDENCIES/generic/include/boost/geometry/algorithms/detail/intersection/interface.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@102 2
Chris@102 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4
Chris@102 5 // This file was modified by Oracle on 2014.
Chris@102 6 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
Chris@102 7
Chris@102 8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
Chris@102 9
Chris@102 10 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 13
Chris@102 14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_INTERFACE_HPP
Chris@102 15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_INTERFACE_HPP
Chris@102 16
Chris@102 17
Chris@102 18 // TODO: those headers probably may be removed
Chris@102 19 #include <boost/geometry/core/coordinate_dimension.hpp>
Chris@102 20 #include <boost/geometry/algorithms/intersects.hpp>
Chris@102 21
Chris@102 22 #include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
Chris@102 23 #include <boost/geometry/policies/robustness/get_rescale_policy.hpp>
Chris@102 24
Chris@102 25
Chris@102 26 namespace boost { namespace geometry
Chris@102 27 {
Chris@102 28
Chris@102 29
Chris@102 30 #ifndef DOXYGEN_NO_DISPATCH
Chris@102 31 namespace dispatch
Chris@102 32 {
Chris@102 33
Chris@102 34 // By default, all is forwarded to the intersection_insert-dispatcher
Chris@102 35 template
Chris@102 36 <
Chris@102 37 typename Geometry1, typename Geometry2,
Chris@102 38 typename Tag1 = typename geometry::tag<Geometry1>::type,
Chris@102 39 typename Tag2 = typename geometry::tag<Geometry2>::type,
Chris@102 40 bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
Chris@102 41 >
Chris@102 42 struct intersection
Chris@102 43 {
Chris@102 44 template <typename RobustPolicy, typename GeometryOut, typename Strategy>
Chris@102 45 static inline bool apply(Geometry1 const& geometry1,
Chris@102 46 Geometry2 const& geometry2,
Chris@102 47 RobustPolicy const& robust_policy,
Chris@102 48 GeometryOut& geometry_out,
Chris@102 49 Strategy const& strategy)
Chris@102 50 {
Chris@102 51 typedef typename boost::range_value<GeometryOut>::type OneOut;
Chris@102 52
Chris@102 53 intersection_insert
Chris@102 54 <
Chris@102 55 Geometry1, Geometry2, OneOut,
Chris@102 56 overlay_intersection
Chris@102 57 >::apply(geometry1, geometry2, robust_policy, std::back_inserter(geometry_out), strategy);
Chris@102 58
Chris@102 59 return true;
Chris@102 60 }
Chris@102 61
Chris@102 62 };
Chris@102 63
Chris@102 64
Chris@102 65 // If reversal is needed, perform it
Chris@102 66 template
Chris@102 67 <
Chris@102 68 typename Geometry1, typename Geometry2,
Chris@102 69 typename Tag1, typename Tag2
Chris@102 70 >
Chris@102 71 struct intersection
Chris@102 72 <
Chris@102 73 Geometry1, Geometry2,
Chris@102 74 Tag1, Tag2,
Chris@102 75 true
Chris@102 76 >
Chris@102 77 : intersection<Geometry2, Geometry1, Tag2, Tag1, false>
Chris@102 78 {
Chris@102 79 template <typename RobustPolicy, typename GeometryOut, typename Strategy>
Chris@102 80 static inline bool apply(
Chris@102 81 Geometry1 const& g1,
Chris@102 82 Geometry2 const& g2,
Chris@102 83 RobustPolicy const& robust_policy,
Chris@102 84 GeometryOut& out,
Chris@102 85 Strategy const& strategy)
Chris@102 86 {
Chris@102 87 return intersection<
Chris@102 88 Geometry2, Geometry1,
Chris@102 89 Tag2, Tag1,
Chris@102 90 false
Chris@102 91 >::apply(g2, g1, robust_policy, out, strategy);
Chris@102 92 }
Chris@102 93 };
Chris@102 94
Chris@102 95
Chris@102 96 } // namespace dispatch
Chris@102 97 #endif // DOXYGEN_NO_DISPATCH
Chris@102 98
Chris@102 99
Chris@102 100 namespace resolve_variant
Chris@102 101 {
Chris@102 102
Chris@102 103 template <typename Geometry1, typename Geometry2>
Chris@102 104 struct intersection
Chris@102 105 {
Chris@102 106 template <typename GeometryOut>
Chris@102 107 static inline bool
Chris@102 108 apply(
Chris@102 109 const Geometry1& geometry1,
Chris@102 110 const Geometry2& geometry2,
Chris@102 111 GeometryOut& geometry_out)
Chris@102 112 {
Chris@102 113 concept::check<Geometry1 const>();
Chris@102 114 concept::check<Geometry2 const>();
Chris@102 115
Chris@102 116 typedef typename geometry::rescale_overlay_policy_type
Chris@102 117 <
Chris@102 118 Geometry1,
Chris@102 119 Geometry2
Chris@102 120 >::type rescale_policy_type;
Chris@102 121
Chris@102 122 rescale_policy_type robust_policy
Chris@102 123 = geometry::get_rescale_policy<rescale_policy_type>(geometry1, geometry2);
Chris@102 124
Chris@102 125 typedef strategy_intersection
Chris@102 126 <
Chris@102 127 typename cs_tag<Geometry1>::type,
Chris@102 128 Geometry1,
Chris@102 129 Geometry2,
Chris@102 130 typename geometry::point_type<Geometry1>::type,
Chris@102 131 rescale_policy_type
Chris@102 132 > strategy;
Chris@102 133
Chris@102 134 return dispatch::intersection
Chris@102 135 <
Chris@102 136 Geometry1,
Chris@102 137 Geometry2
Chris@102 138 >::apply(geometry1, geometry2, robust_policy, geometry_out, strategy());
Chris@102 139 }
Chris@102 140 };
Chris@102 141
Chris@102 142
Chris@102 143 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
Chris@102 144 struct intersection<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
Chris@102 145 {
Chris@102 146 template <typename GeometryOut>
Chris@102 147 struct visitor: static_visitor<bool>
Chris@102 148 {
Chris@102 149 Geometry2 const& m_geometry2;
Chris@102 150 GeometryOut& m_geometry_out;
Chris@102 151
Chris@102 152 visitor(Geometry2 const& geometry2,
Chris@102 153 GeometryOut& geometry_out)
Chris@102 154 : m_geometry2(geometry2),
Chris@102 155 m_geometry_out(geometry_out)
Chris@102 156 {}
Chris@102 157
Chris@102 158 template <typename Geometry1>
Chris@102 159 result_type operator()(Geometry1 const& geometry1) const
Chris@102 160 {
Chris@102 161 return intersection
Chris@102 162 <
Chris@102 163 Geometry1,
Chris@102 164 Geometry2
Chris@102 165 >::template apply
Chris@102 166 <
Chris@102 167 GeometryOut
Chris@102 168 >
Chris@102 169 (geometry1, m_geometry2, m_geometry_out);
Chris@102 170 }
Chris@102 171 };
Chris@102 172
Chris@102 173 template <typename GeometryOut>
Chris@102 174 static inline bool
Chris@102 175 apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
Chris@102 176 Geometry2 const& geometry2,
Chris@102 177 GeometryOut& geometry_out)
Chris@102 178 {
Chris@102 179 return apply_visitor(visitor<GeometryOut>(geometry2, geometry_out), geometry1);
Chris@102 180 }
Chris@102 181 };
Chris@102 182
Chris@102 183
Chris@102 184 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
Chris@102 185 struct intersection<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
Chris@102 186 {
Chris@102 187 template <typename GeometryOut>
Chris@102 188 struct visitor: static_visitor<bool>
Chris@102 189 {
Chris@102 190 Geometry1 const& m_geometry1;
Chris@102 191 GeometryOut& m_geometry_out;
Chris@102 192
Chris@102 193 visitor(Geometry1 const& geometry1,
Chris@102 194 GeometryOut& geometry_out)
Chris@102 195 : m_geometry1(geometry1),
Chris@102 196 m_geometry_out(geometry_out)
Chris@102 197 {}
Chris@102 198
Chris@102 199 template <typename Geometry2>
Chris@102 200 result_type operator()(Geometry2 const& geometry2) const
Chris@102 201 {
Chris@102 202 return intersection
Chris@102 203 <
Chris@102 204 Geometry1,
Chris@102 205 Geometry2
Chris@102 206 >::template apply
Chris@102 207 <
Chris@102 208 GeometryOut
Chris@102 209 >
Chris@102 210 (m_geometry1, geometry2, m_geometry_out);
Chris@102 211 }
Chris@102 212 };
Chris@102 213
Chris@102 214 template <typename GeometryOut>
Chris@102 215 static inline bool
Chris@102 216 apply(
Chris@102 217 Geometry1 const& geometry1,
Chris@102 218 const variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry2,
Chris@102 219 GeometryOut& geometry_out)
Chris@102 220 {
Chris@102 221 return apply_visitor(visitor<GeometryOut>(geometry1, geometry_out), geometry2);
Chris@102 222 }
Chris@102 223 };
Chris@102 224
Chris@102 225
Chris@102 226 template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)>
Chris@102 227 struct intersection<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> >
Chris@102 228 {
Chris@102 229 template <typename GeometryOut>
Chris@102 230 struct visitor: static_visitor<bool>
Chris@102 231 {
Chris@102 232 GeometryOut& m_geometry_out;
Chris@102 233
Chris@102 234 visitor(GeometryOut& geometry_out)
Chris@102 235 : m_geometry_out(geometry_out)
Chris@102 236 {}
Chris@102 237
Chris@102 238 template <typename Geometry1, typename Geometry2>
Chris@102 239 result_type operator()(
Chris@102 240 Geometry1 const& geometry1,
Chris@102 241 Geometry2 const& geometry2) const
Chris@102 242 {
Chris@102 243 return intersection
Chris@102 244 <
Chris@102 245 Geometry1,
Chris@102 246 Geometry2
Chris@102 247 >::template apply
Chris@102 248 <
Chris@102 249 GeometryOut
Chris@102 250 >
Chris@102 251 (geometry1, geometry2, m_geometry_out);
Chris@102 252 }
Chris@102 253 };
Chris@102 254
Chris@102 255 template <typename GeometryOut>
Chris@102 256 static inline bool
Chris@102 257 apply(
Chris@102 258 const variant<BOOST_VARIANT_ENUM_PARAMS(T1)>& geometry1,
Chris@102 259 const variant<BOOST_VARIANT_ENUM_PARAMS(T2)>& geometry2,
Chris@102 260 GeometryOut& geometry_out)
Chris@102 261 {
Chris@102 262 return apply_visitor(visitor<GeometryOut>(geometry_out), geometry1, geometry2);
Chris@102 263 }
Chris@102 264 };
Chris@102 265
Chris@102 266 } // namespace resolve_variant
Chris@102 267
Chris@102 268
Chris@102 269 /*!
Chris@102 270 \brief \brief_calc2{intersection}
Chris@102 271 \ingroup intersection
Chris@102 272 \details \details_calc2{intersection, spatial set theoretic intersection}.
Chris@102 273 \tparam Geometry1 \tparam_geometry
Chris@102 274 \tparam Geometry2 \tparam_geometry
Chris@102 275 \tparam GeometryOut Collection of geometries (e.g. std::vector, std::deque, boost::geometry::multi*) of which
Chris@102 276 the value_type fulfills a \p_l_or_c concept, or it is the output geometry (e.g. for a box)
Chris@102 277 \param geometry1 \param_geometry
Chris@102 278 \param geometry2 \param_geometry
Chris@102 279 \param geometry_out The output geometry, either a multi_point, multi_polygon,
Chris@102 280 multi_linestring, or a box (for intersection of two boxes)
Chris@102 281
Chris@102 282 \qbk{[include reference/algorithms/intersection.qbk]}
Chris@102 283 */
Chris@102 284 template
Chris@102 285 <
Chris@102 286 typename Geometry1,
Chris@102 287 typename Geometry2,
Chris@102 288 typename GeometryOut
Chris@102 289 >
Chris@102 290 inline bool intersection(Geometry1 const& geometry1,
Chris@102 291 Geometry2 const& geometry2,
Chris@102 292 GeometryOut& geometry_out)
Chris@102 293 {
Chris@102 294 return resolve_variant::intersection
Chris@102 295 <
Chris@102 296 Geometry1,
Chris@102 297 Geometry2
Chris@102 298 >::template apply
Chris@102 299 <
Chris@102 300 GeometryOut
Chris@102 301 >
Chris@102 302 (geometry1, geometry2, geometry_out);
Chris@102 303 }
Chris@102 304
Chris@102 305
Chris@102 306 }} // namespace boost::geometry
Chris@102 307
Chris@102 308
Chris@102 309 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_INTERFACE_HPP