From 0879232f8e036073cca9f62384df3b7af11a4d44 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 17 Sep 2025 10:14:07 +0300 Subject: [PATCH] Fixed drawing with a bounding box --- .../include/CGAL/Arr_linear_traits_2.h | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h index 36ca18b980b..83d1c99229b 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_linear_traits_2.h @@ -1582,24 +1582,25 @@ public: { using Approx_pnt = Approximate_point_2; using Approx_seg = Approximate_kernel::Segment_2; + using Approx_ray = Approximate_kernel::Ray_2; + using Approx_lin = Approximate_kernel::Line_2; auto xmin = bbox.xmin(); auto ymin = bbox.ymin(); auto xmax = bbox.xmax(); auto ymax = bbox.ymax(); Approximate_kernel::Iso_rectangle_2 rect(xmin, ymin, xmax, ymax); - auto xs = CGAL::to_double(xcv.source().x()); - auto ys = CGAL::to_double(xcv.source().y()); - auto xt = CGAL::to_double(xcv.target().x()); - auto yt = CGAL::to_double(xcv.target().y()); if (xcv.is_ray()) { - using Approx_ray = Approximate_kernel::Ray_2; - Approx_ray ray(Approx_pnt(xs, ys), Approx_pnt(xt, yt)); - const auto result = CGAL::intersection(rect, ray); + auto ray = xcv.ray(); + Kernel kernel; + auto construct_vertex = kernel.construct_point_on_2_object(); + Approx_pnt s = this->operator()(construct_vertex(ray, 0)); + Approx_pnt t = this->operator()(construct_vertex(ray, 1)); + const auto result = CGAL::intersection(rect, Approx_ray(s, t)); if (! result) return oi; if (const auto* res_seg = std::get_if(&*result)) { - *oi++ = res_seg->source(); - *oi++ = res_seg->target(); + *oi++ = l2r ? res_seg->min() : res_seg->max(); + *oi++ = l2r ? res_seg->max() : res_seg->min(); return oi; } const auto* res_pnt = std::get_if(&*result); @@ -1608,14 +1609,17 @@ public: return oi; } if (xcv.is_line()) { - using Approx_lin = Approximate_kernel::Line_2; - Approx_lin line(Approx_pnt(xs, ys), Approx_pnt(xt, yt)); - const auto result = CGAL::intersection(rect, line); + const Line_2 & supp_line = xcv.supp_line(); + Approx_lin approx_supp_line( + CGAL::to_double(supp_line.a()), + CGAL::to_double(supp_line.b()), + CGAL::to_double(supp_line.c())); + const auto result = CGAL::intersection(rect, approx_supp_line); if (! result) return oi; if (const auto* res_seg = std::get_if(&*result)) { - *oi++ = res_seg->source(); - *oi++ = res_seg->target(); + *oi++ = l2r ? res_seg->min() : res_seg->max(); + *oi++ = l2r ? res_seg->max() : res_seg->min(); return oi; } const auto* res_pnt = std::get_if(&*result); @@ -1623,13 +1627,13 @@ public: *oi++ = *res_pnt; return oi; } - Approx_seg seg(Approx_pnt(xs, ys), Approx_pnt(xt, yt)); + Approx_seg seg(this->operator()(xcv.source()), this->operator()(xcv.target())); const auto result = CGAL::intersection(rect, seg); if (! result) return oi; if (const auto* res_seg = std::get_if(&*result)) { - *oi++ = res_seg->source(); - *oi++ = res_seg->target(); + *oi++ = l2r ? res_seg->min() : res_seg->max(); + *oi++ = l2r ? res_seg->max() : res_seg->min(); return oi; } const auto* res_pnt = std::get_if(&*result);