1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland.
6 // This file was modified by Oracle on 2014-2021.
7 // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates.
9 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Use, modification and distribution is subject to the Boost Software License,
13 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
14 // http://www.boost.org/LICENSE_1_0.txt)
16 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INTERSECTION_HPP
17 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INTERSECTION_HPP
21 #include <boost/geometry/core/exception.hpp>
23 #include <boost/geometry/geometries/concepts/point_concept.hpp>
24 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
25 #include <boost/geometry/geometries/segment.hpp>
27 #include <boost/geometry/arithmetic/determinant.hpp>
28 #include <boost/geometry/algorithms/detail/assign_values.hpp>
29 #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
30 #include <boost/geometry/algorithms/detail/equals/point_point.hpp>
31 #include <boost/geometry/algorithms/detail/recalculate.hpp>
33 #include <boost/geometry/util/math.hpp>
34 #include <boost/geometry/util/promote_integral.hpp>
35 #include <boost/geometry/util/select_calculation_type.hpp>
37 #include <boost/geometry/strategy/cartesian/area.hpp>
38 #include <boost/geometry/strategy/cartesian/envelope.hpp>
39 #include <boost/geometry/strategy/cartesian/expand_box.hpp>
40 #include <boost/geometry/strategy/cartesian/expand_segment.hpp>
42 #include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
43 #include <boost/geometry/strategies/cartesian/disjoint_segment_box.hpp>
44 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
45 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
46 #include <boost/geometry/strategies/cartesian/point_in_poly_winding.hpp>
47 #include <boost/geometry/strategies/covered_by.hpp>
48 #include <boost/geometry/strategies/intersection.hpp>
49 #include <boost/geometry/strategies/intersection_result.hpp>
50 #include <boost/geometry/strategies/side.hpp>
51 #include <boost/geometry/strategies/side_info.hpp>
52 #include <boost/geometry/strategies/within.hpp>
54 #include <boost/geometry/policies/robustness/rescale_policy_tags.hpp>
55 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
58 #if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS)
59 # include <boost/geometry/io/wkt/write.hpp>
63 namespace boost { namespace geometry
67 namespace strategy { namespace intersection
70 namespace detail_usage
73 // When calculating the intersection, the information of "a" or "b" can be used.
74 // Theoretically this gives equal results, but due to floating point precision
75 // there might be tiny differences. These are edge cases.
76 // This structure is to determine if "a" or "b" should be used.
77 // Prefer the segment closer to the endpoint.
78 // If both are about equally close, then prefer the longer segment
79 // To avoid hard thresholds, behavior is made fluent.
80 // Calculate comparable length indications,
81 // the longer the segment (relatively), the lower the value
82 // such that the shorter lengths are evaluated higher and will
84 template <bool IsArithmetic>
87 template <typename Ct, typename Ev>
88 static bool apply(Ct const& cla, Ct const& clb, Ev const& eva, Ev const& evb)
90 auto const clm = (std::max)(cla, clb);
96 // Relative comparible length
97 auto const rcla = Ct(1.0) - cla / clm;
98 auto const rclb = Ct(1.0) - clb / clm;
100 // Multipliers for edgevalue (ev) and relative comparible length (rcl)
101 // They determine the balance between edge value (should be larger)
102 // and segment length. In 99.9xx% of the cases there is no difference
103 // at all (if either a or b is used). Therefore the values of the
104 // constants are not sensitive for the majority of the situations.
105 // One known case is #mysql_23023665_6 (difference) which needs mev >= 2
109 return mev * eva + mrcl * rcla > mev * evb + mrcl * rclb;
113 // Specialization for non arithmetic types. They will always use "a"
117 template <typename Ct, typename Ev>
118 static bool apply(Ct const& , Ct const& , Ev const& , Ev const& )
127 \see http://mathworld.wolfram.com/Line-LineIntersection.html
131 typename CalculationType = void
133 struct cartesian_segments
135 typedef cartesian_tag cs_tag;
137 template <typename CoordinateType, typename SegmentRatio>
138 struct segment_intersection_info
141 typedef typename select_most_precise
143 CoordinateType, double
144 >::type promoted_type;
146 promoted_type comparable_length_a() const
148 return dx_a * dx_a + dy_a * dy_a;
151 promoted_type comparable_length_b() const
153 return dx_b * dx_b + dy_b * dy_b;
156 template <typename Point, typename Segment1, typename Segment2>
157 void assign_a(Point& point, Segment1 const& a, Segment2 const& ) const
159 assign(point, a, dx_a, dy_a, robust_ra);
161 template <typename Point, typename Segment1, typename Segment2>
162 void assign_b(Point& point, Segment1 const& , Segment2 const& b) const
164 assign(point, b, dx_b, dy_b, robust_rb);
167 template <typename Point, typename Segment>
168 void assign(Point& point, Segment const& segment,
169 CoordinateType const& dx, CoordinateType const& dy,
170 SegmentRatio const& ratio) const
172 // Calculate the intersection point based on segment_ratio
173 // The division, postponed until here, is done now. In case of integer this
174 // results in an integer which rounds to the nearest integer.
175 BOOST_GEOMETRY_ASSERT(ratio.denominator() != typename SegmentRatio::int_type(0));
177 typedef typename promote_integral<CoordinateType>::type calc_type;
179 calc_type const numerator
180 = boost::numeric_cast<calc_type>(ratio.numerator());
181 calc_type const denominator
182 = boost::numeric_cast<calc_type>(ratio.denominator());
183 calc_type const dx_calc = boost::numeric_cast<calc_type>(dx);
184 calc_type const dy_calc = boost::numeric_cast<calc_type>(dy);
186 set<0>(point, get<0, 0>(segment)
187 + boost::numeric_cast<CoordinateType>(
188 math::divide<calc_type>(numerator * dx_calc, denominator)));
189 set<1>(point, get<0, 1>(segment)
190 + boost::numeric_cast<CoordinateType>(
191 math::divide<calc_type>(numerator * dy_calc, denominator)));
194 template <int Index, int Dim, typename Point, typename Segment>
195 static bool exceeds_side_in_dimension(Point& p, Segment const& s)
197 // Situation a (positive)
198 // 0>-------------->1 segment
199 // * point left of segment<I> in D x or y
200 // Situation b (negative)
201 // 1<--------------<0 segment
202 // * point right of segment<I>
203 // Situation c (degenerate), return false (check other dimension)
204 auto const& c = get<Dim>(p);
205 auto const& c0 = get<Index, Dim>(s);
206 auto const& c1 = get<1 - Index, Dim>(s);
207 return c0 < c1 ? math::smaller(c, c0)
208 : c0 > c1 ? math::larger(c, c0)
212 template <int Index, typename Point, typename Segment>
213 static bool exceeds_side_of_segment(Point& p, Segment const& s)
215 return exceeds_side_in_dimension<Index, 0>(p, s)
216 || exceeds_side_in_dimension<Index, 1>(p, s);
219 template <typename Point, typename Segment>
220 static void assign_if_exceeds(Point& point, Segment const& s)
222 if (exceeds_side_of_segment<0>(point, s))
224 detail::assign_point_from_index<0>(s, point);
226 else if (exceeds_side_of_segment<1>(point, s))
228 detail::assign_point_from_index<1>(s, point);
233 template <typename Point, typename Segment1, typename Segment2>
234 void calculate(Point& point, Segment1 const& a, Segment2 const& b) const
237 = detail_usage::use_a
239 std::is_arithmetic<CoordinateType>::value
240 >::apply(comparable_length_a(), comparable_length_b(),
241 robust_ra.edge_value(), robust_rb.edge_value());
245 assign_a(point, a, b);
249 assign_b(point, a, b);
252 #if defined(BOOST_GEOMETRY_USE_RESCALING)
256 // Verify nearly collinear cases (the threshold is arbitrary
257 // but influences performance). If the intersection is located
258 // outside the segments, then it should be moved.
259 if (robust_ra.possibly_collinear(1.0e-3)
260 && robust_rb.possibly_collinear(1.0e-3))
262 // The segments are nearly collinear and because of the calculation
263 // method with very small denominator, the IP appears outside the
264 // segment(s). Correct it to the end point.
265 // Because they are nearly collinear, it doesn't really matter to
266 // to which endpoint (or it is corrected twice).
267 assign_if_exceeds(point, a);
268 assign_if_exceeds(point, b);
272 CoordinateType dx_a, dy_a;
273 CoordinateType dx_b, dy_b;
274 SegmentRatio robust_ra;
275 SegmentRatio robust_rb;
278 template <typename D, typename W, typename ResultType>
279 static inline void cramers_rule(D const& dx_a, D const& dy_a,
280 D const& dx_b, D const& dy_b, W const& wx, W const& wy,
282 ResultType& nominator, ResultType& denominator)
285 nominator = geometry::detail::determinant<ResultType>(dx_b, dy_b, wx, wy);
286 denominator = geometry::detail::determinant<ResultType>(dx_a, dy_a, dx_b, dy_b);
287 // Ratio r = nominator/denominator
288 // Collinear if denominator == 0, intersecting if 0 <= r <= 1
289 // IntersectionPoint = (x1 + r * dx_a, y1 + r * dy_a)
292 // Version for non-rescaled policies
295 typename UniqueSubRange1,
296 typename UniqueSubRange2,
299 static inline typename Policy::return_type
300 apply(UniqueSubRange1 const& range_p,
301 UniqueSubRange2 const& range_q,
302 Policy const& policy)
304 // Pass the same ranges both as normal ranges and as modelled ranges
305 return apply(range_p, range_q, policy, range_p, range_q);
308 // Version for non rescaled versions.
309 // The "modelled" parameter might be rescaled (will be removed later)
312 typename UniqueSubRange1,
313 typename UniqueSubRange2,
315 typename ModelledUniqueSubRange1,
316 typename ModelledUniqueSubRange2
318 static inline typename Policy::return_type
319 apply(UniqueSubRange1 const& range_p,
320 UniqueSubRange2 const& range_q,
321 Policy const& policy,
322 ModelledUniqueSubRange1 const& modelled_range_p,
323 ModelledUniqueSubRange2 const& modelled_range_q)
325 typedef typename UniqueSubRange1::point_type point1_type;
326 typedef typename UniqueSubRange2::point_type point2_type;
328 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point1_type>) );
329 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point2_type>) );
331 point1_type const& p1 = range_p.at(0);
332 point1_type const& p2 = range_p.at(1);
333 point2_type const& q1 = range_q.at(0);
334 point2_type const& q2 = range_q.at(1);
336 // Declare segments, currently necessary for the policies
337 // (segment_crosses, segment_colinear, degenerate, one_degenerate, etc)
338 model::referring_segment<point1_type const> const p(p1, p2);
339 model::referring_segment<point2_type const> const q(q1, q2);
341 typedef typename select_most_precise
343 typename geometry::coordinate_type<typename ModelledUniqueSubRange1::point_type>::type,
344 typename geometry::coordinate_type<typename ModelledUniqueSubRange1::point_type>::type
345 >::type modelled_coordinate_type;
347 typedef segment_ratio<modelled_coordinate_type> ratio_type;
348 segment_intersection_info
350 typename select_calculation_type<point1_type, point2_type, CalculationType>::type,
354 sinfo.dx_a = get<0>(p2) - get<0>(p1); // distance in x-dir
355 sinfo.dx_b = get<0>(q2) - get<0>(q1);
356 sinfo.dy_a = get<1>(p2) - get<1>(p1); // distance in y-dir
357 sinfo.dy_b = get<1>(q2) - get<1>(q1);
359 return unified<ratio_type>(sinfo, p, q, policy, modelled_range_p, modelled_range_q);
362 //! Returns true if two segments do not overlap.
363 //! If not, then no further calculations need to be done.
366 std::size_t Dimension,
370 static inline bool disjoint_by_range(PointP const& p1, PointP const& p2,
371 PointQ const& q1, PointQ const& q2)
373 auto minp = get<Dimension>(p1);
374 auto maxp = get<Dimension>(p2);
375 auto minq = get<Dimension>(q1);
376 auto maxq = get<Dimension>(q2);
379 std::swap(minp, maxp);
383 std::swap(minq, maxq);
386 // In this case, max(p) < min(q)
388 // <-------> <------->
389 // (and the space in between is not extremely small)
390 return math::smaller(maxp, minq) || math::smaller(maxq, minp);
393 // Implementation for either rescaled or non rescaled versions.
397 typename SegmentInfo,
401 typename UniqueSubRange1,
402 typename UniqueSubRange2
404 static inline typename Policy::return_type
405 unified(SegmentInfo& sinfo,
406 Segment1 const& p, Segment2 const& q, Policy const&,
407 UniqueSubRange1 const& range_p,
408 UniqueSubRange2 const& range_q)
410 typedef typename UniqueSubRange1::point_type point1_type;
411 typedef typename UniqueSubRange2::point_type point2_type;
412 typedef typename select_most_precise
414 typename geometry::coordinate_type<point1_type>::type,
415 typename geometry::coordinate_type<point2_type>::type
416 >::type coordinate_type;
418 point1_type const& p1 = range_p.at(0);
419 point1_type const& p2 = range_p.at(1);
420 point2_type const& q1 = range_q.at(0);
421 point2_type const& q2 = range_q.at(1);
423 bool const p_is_point = equals_point_point(p1, p2);
424 bool const q_is_point = equals_point_point(q1, q2);
426 if (p_is_point && q_is_point)
428 return equals_point_point(p1, q2)
429 ? Policy::degenerate(p, true)
434 if (disjoint_by_range<0>(p1, p2, q1, q2)
435 || disjoint_by_range<1>(p1, p2, q1, q2))
437 return Policy::disjoint();
440 using side_strategy_type
441 = typename side::services::default_strategy
442 <cartesian_tag, CalculationType>::type;
444 sides.set<0>(side_strategy_type::apply(q1, q2, p1),
445 side_strategy_type::apply(q1, q2, p2));
449 // Both points are at same side of other segment, we can leave
450 return Policy::disjoint();
453 sides.set<1>(side_strategy_type::apply(p1, p2, q1),
454 side_strategy_type::apply(p1, p2, q2));
458 // Both points are at same side of other segment, we can leave
459 return Policy::disjoint();
462 bool collinear = sides.collinear();
464 // Calculate the differences again
465 // (for rescaled version, this is different from dx_p etc)
466 coordinate_type const dx_p = get<0>(p2) - get<0>(p1);
467 coordinate_type const dx_q = get<0>(q2) - get<0>(q1);
468 coordinate_type const dy_p = get<1>(p2) - get<1>(p1);
469 coordinate_type const dy_q = get<1>(q2) - get<1>(q1);
471 // r: ratio 0-1 where intersection divides A/B
472 // (only calculated for non-collinear segments)
475 coordinate_type denominator_a, nominator_a;
476 coordinate_type denominator_b, nominator_b;
478 cramers_rule(dx_p, dy_p, dx_q, dy_q,
479 get<0>(p1) - get<0>(q1),
480 get<1>(p1) - get<1>(q1),
481 nominator_a, denominator_a);
483 cramers_rule(dx_q, dy_q, dx_p, dy_p,
484 get<0>(q1) - get<0>(p1),
485 get<1>(q1) - get<1>(p1),
486 nominator_b, denominator_b);
488 math::detail::equals_factor_policy<coordinate_type>
489 policy(dx_p, dy_p, dx_q, dy_q);
491 coordinate_type const zero = 0;
492 if (math::detail::equals_by_policy(denominator_a, zero, policy)
493 || math::detail::equals_by_policy(denominator_b, zero, policy))
495 // If this is the case, no rescaling is done for FP precision.
496 // We set it to collinear, but it indicates a robustness issue.
503 sinfo.robust_ra.assign(nominator_a, denominator_a);
504 sinfo.robust_rb.assign(nominator_b, denominator_b);
510 std::pair<bool, bool> const collinear_use_first
511 = is_x_more_significant(geometry::math::abs(dx_p),
512 geometry::math::abs(dy_p),
513 geometry::math::abs(dx_q),
514 geometry::math::abs(dy_q),
515 p_is_point, q_is_point);
517 if (collinear_use_first.second)
519 // Degenerate cases: segments of single point, lying on other segment, are not disjoint
520 // This situation is collinear too
522 if (collinear_use_first.first)
524 return relate_collinear<0, Policy, RatioType>(p, q,
526 p_is_point, q_is_point);
530 // Y direction contains larger segments (maybe dx is zero)
531 return relate_collinear<1, Policy, RatioType>(p, q,
533 p_is_point, q_is_point);
538 return Policy::segments_crosses(sides, sinfo, p, q);
542 // first is true if x is more significant
543 // second is true if the more significant difference is not 0
544 template <typename CoordinateType>
545 static inline std::pair<bool, bool>
546 is_x_more_significant(CoordinateType const& abs_dx_a,
547 CoordinateType const& abs_dy_a,
548 CoordinateType const& abs_dx_b,
549 CoordinateType const& abs_dy_b,
550 bool const a_is_point,
551 bool const b_is_point)
553 //BOOST_GEOMETRY_ASSERT_MSG(!(a_is_point && b_is_point), "both segments shouldn't be degenerated");
555 // for degenerated segments the second is always true because this function
556 // shouldn't be called if both segments were degenerated
560 return std::make_pair(abs_dx_b >= abs_dy_b, true);
564 return std::make_pair(abs_dx_a >= abs_dy_a, true);
568 CoordinateType const min_dx = (std::min)(abs_dx_a, abs_dx_b);
569 CoordinateType const min_dy = (std::min)(abs_dy_a, abs_dy_b);
570 return min_dx == min_dy ?
571 std::make_pair(true, min_dx > CoordinateType(0)) :
572 std::make_pair(min_dx > min_dy, true);
578 std::size_t Dimension,
583 typename RobustPoint1,
584 typename RobustPoint2
586 static inline typename Policy::return_type
587 relate_collinear(Segment1 const& a,
589 RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2,
590 RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2,
591 bool a_is_point, bool b_is_point)
595 return relate_one_degenerate<Policy, RatioType>(a,
596 get<Dimension>(robust_a1),
597 get<Dimension>(robust_b1), get<Dimension>(robust_b2),
602 return relate_one_degenerate<Policy, RatioType>(b,
603 get<Dimension>(robust_b1),
604 get<Dimension>(robust_a1), get<Dimension>(robust_a2),
607 return relate_collinear<Policy, RatioType>(a, b,
608 get<Dimension>(robust_a1),
609 get<Dimension>(robust_a2),
610 get<Dimension>(robust_b1),
611 get<Dimension>(robust_b2));
614 /// Relate segments known collinear
624 static inline typename Policy::return_type
625 relate_collinear(Segment1 const& a, Segment2 const& b,
626 Type1 oa_1, Type1 oa_2,
627 Type2 ob_1, Type2 ob_2)
629 // Calculate the ratios where a starts in b, b starts in a
630 // a1--------->a2 (2..7)
634 // b1 is located w.r.t. a at ratio: (5-2)/5=3/5 (on a)
635 // b2 is located w.r.t. a at ratio: (8-2)/5=6/5 (right of a)
636 // a1 is located w.r.t. b at ratio: (2-5)/3=-3/3 (left of b)
637 // a2 is located w.r.t. b at ratio: (7-5)/3=2/3 (on b)
638 // A arrives (a2 on b), B departs (b1 on a)
640 // If both are reversed:
641 // a2<---------a1 (7..2)
645 // b1 is located w.r.t. a at ratio: (8-7)/-5=-1/5 (before a starts)
646 // b2 is located w.r.t. a at ratio: (5-7)/-5=2/5 (on a)
647 // a1 is located w.r.t. b at ratio: (7-8)/-3=1/3 (on b)
648 // a2 is located w.r.t. b at ratio: (2-8)/-3=6/3 (after b ends)
650 // If both one is reversed:
651 // a1--------->a2 (2..7)
655 // b1 is located w.r.t. a at ratio: (8-2)/5=6/5 (after a ends)
656 // b2 is located w.r.t. a at ratio: (5-2)/5=3/5 (on a)
657 // a1 is located w.r.t. b at ratio: (2-8)/-3=6/3 (after b ends)
658 // a2 is located w.r.t. b at ratio: (7-8)/-3=1/3 (on b)
659 Type1 const length_a = oa_2 - oa_1; // no abs, see above
660 Type2 const length_b = ob_2 - ob_1;
662 RatioType ra_from(oa_1 - ob_1, length_b);
663 RatioType ra_to(oa_2 - ob_1, length_b);
664 RatioType rb_from(ob_1 - oa_1, length_a);
665 RatioType rb_to(ob_2 - oa_1, length_a);
667 // use absolute measure to detect endpoints intersection
668 // NOTE: it'd be possible to calculate bx_wrt_a using ax_wrt_b values
669 int const a1_wrt_b = position_value(oa_1, ob_1, ob_2);
670 int const a2_wrt_b = position_value(oa_2, ob_1, ob_2);
671 int const b1_wrt_a = position_value(ob_1, oa_1, oa_2);
672 int const b2_wrt_a = position_value(ob_2, oa_1, oa_2);
674 // fix the ratios if necessary
675 // CONSIDER: fixing ratios also in other cases, if they're inconsistent
676 // e.g. if ratio == 1 or 0 (so IP at the endpoint)
677 // but position value indicates that the IP is in the middle of the segment
678 // because one of the segments is very long
679 // In such case the ratios could be moved into the middle direction
680 // by some small value (e.g. EPS+1ULP)
683 ra_from.assign(0, 1);
684 rb_from.assign(0, 1);
686 else if (a1_wrt_b == 3)
688 ra_from.assign(1, 1);
695 rb_from.assign(1, 1);
697 else if (a2_wrt_b == 3)
703 if ((a1_wrt_b < 1 && a2_wrt_b < 1) || (a1_wrt_b > 3 && a2_wrt_b > 3))
704 //if ((ra_from.left() && ra_to.left()) || (ra_from.right() && ra_to.right()))
706 return Policy::disjoint();
709 bool const opposite = math::sign(length_a) != math::sign(length_b);
711 return Policy::segments_collinear(a, b, opposite,
712 a1_wrt_b, a2_wrt_b, b1_wrt_a, b2_wrt_a,
713 ra_from, ra_to, rb_from, rb_to);
716 /// Relate segments where one is degenerate
721 typename DegenerateSegment,
725 static inline typename Policy::return_type
726 relate_one_degenerate(DegenerateSegment const& degenerate_segment,
727 Type1 d, Type2 s1, Type2 s2,
730 // Calculate the ratios where ds starts in s
731 // a1--------->a2 (2..6)
733 // Ratio: (4-2)/(6-2)
734 RatioType const ratio(d - s1, s2 - s1);
736 if (!ratio.on_segment())
738 return Policy::disjoint();
741 return Policy::one_degenerate(degenerate_segment, ratio, a_degenerate);
744 template <typename ProjCoord1, typename ProjCoord2>
745 static inline int position_value(ProjCoord1 const& ca1,
746 ProjCoord2 const& cb1,
747 ProjCoord2 const& cb2)
751 return math::equals(ca1, cb1) ? 1
752 : math::equals(ca1, cb2) ? 3
762 template <typename Point1, typename Point2>
763 static inline bool equals_point_point(Point1 const& point1, Point2 const& point2)
765 return strategy::within::cartesian_point_point::apply(point1, point2);
770 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
774 template <typename CalculationType>
775 struct default_strategy<cartesian_tag, CalculationType>
777 typedef cartesian_segments<CalculationType> type;
780 } // namespace services
781 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
784 }} // namespace strategy::intersection
789 namespace within { namespace services
792 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
793 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, linear_tag, cartesian_tag, cartesian_tag>
795 typedef strategy::intersection::cartesian_segments<> type;
798 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
799 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, polygonal_tag, cartesian_tag, cartesian_tag>
801 typedef strategy::intersection::cartesian_segments<> type;
804 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
805 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, linear_tag, cartesian_tag, cartesian_tag>
807 typedef strategy::intersection::cartesian_segments<> type;
810 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
811 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, polygonal_tag, cartesian_tag, cartesian_tag>
813 typedef strategy::intersection::cartesian_segments<> type;
816 }} // within::services
818 namespace covered_by { namespace services
821 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
822 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, linear_tag, cartesian_tag, cartesian_tag>
824 typedef strategy::intersection::cartesian_segments<> type;
827 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
828 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, polygonal_tag, cartesian_tag, cartesian_tag>
830 typedef strategy::intersection::cartesian_segments<> type;
833 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
834 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, linear_tag, cartesian_tag, cartesian_tag>
836 typedef strategy::intersection::cartesian_segments<> type;
839 template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2>
840 struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, polygonal_tag, cartesian_tag, cartesian_tag>
842 typedef strategy::intersection::cartesian_segments<> type;
845 }} // within::services
849 }} // namespace boost::geometry
852 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INTERSECTION_HPP