@@ -476,6 +476,42 @@ struct intersects<SegmentTag, SegmentTag, Segment, Segment>
476
476
}
477
477
};
478
478
479
+ template <typename Segment, typename Box>
480
+ struct intersects <SegmentTag, BoxTag, Segment, Box>
481
+ {
482
+ KOKKOS_FUNCTION static constexpr bool apply (Segment const &segment,
483
+ Box const &box)
484
+ {
485
+ static_assert (GeometryTraits::dimension_v<Segment> == 2 );
486
+
487
+ if (Details::intersects (segment.a , box) ||
488
+ Details::intersects (segment.b , box))
489
+ return true ;
490
+
491
+ using Point = std::decay_t <decltype (box.minCorner ())>;
492
+
493
+ auto const &bottom_left = box.minCorner ();
494
+ auto const &top_right = box.maxCorner ();
495
+ auto const top_left = Point {bottom_left[0 ], top_right[1 ]};
496
+ auto const bottom_right = Point {top_right[0 ], bottom_left[1 ]};
497
+
498
+ return Details::intersects (segment, Segment{bottom_left, top_left}) ||
499
+ Details::intersects (segment, Segment{bottom_left, bottom_right}) ||
500
+ Details::intersects (segment, Segment{top_right, top_left}) ||
501
+ Details::intersects (segment, Segment{top_right, bottom_right});
502
+ }
503
+ };
504
+
505
+ template <typename Box, typename Segment>
506
+ struct intersects <BoxTag, SegmentTag, Box, Segment>
507
+ {
508
+ KOKKOS_FUNCTION static constexpr bool apply (Box const &box,
509
+ Segment const &segment)
510
+ {
511
+ return Details::intersects (segment, box);
512
+ }
513
+ };
514
+
479
515
} // namespace Dispatch
480
516
481
517
} // namespace ArborX::Details
0 commit comments