From b090cd8c22bc44facc627d145f0c221d65d64ffc Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 10 Nov 2025 16:40:02 +0100 Subject: [PATCH] setting Has_static_filters for Epeck to true fixing static filter for Sphere_3 Iso_cuboid_3 intersection --- .../internal/Static_filters/Do_intersect_3.h | 27 +++++-------------- Filtered_kernel/include/CGAL/Lazy_kernel.h | 6 +---- .../test/Filtered_kernel/Static_filters.cpp | 14 ---------- .../Iso_cuboid_3_Sphere_3_do_intersect.h | 6 +++++ 4 files changed, 14 insertions(+), 39 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Filtered_kernel/internal/Static_filters/Do_intersect_3.h b/Filtered_kernel/include/CGAL/Filtered_kernel/internal/Static_filters/Do_intersect_3.h index 220ff50f273..3e1e5bf83d1 100644 --- a/Filtered_kernel/include/CGAL/Filtered_kernel/internal/Static_filters/Do_intersect_3.h +++ b/Filtered_kernel/include/CGAL/Filtered_kernel/internal/Static_filters/Do_intersect_3.h @@ -774,23 +774,9 @@ public: // If the center is inside the box, check the distance to the closest box face and the furthest corner. if (distance == 0) { - double dx = (std::min)(bxmax - scx, scx - bxmin); - double dy = (std::min)(bymax - scy, scy - bymin); - double dz = (std::min)(bzmax - scz, scz - bzmin); - - // Distance to closest box face - distance = (std::min)(dx, (std::min)(dy, dz)) - ssr; - - if ((distance < 3.33558365626356687717e-147) || (distance > 1.67597599124282407923e+153)) { - CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - return Base::operator()(s, b); - } - - eps = 1.99986535548615598560e-15 * (std::max)(ssr, distance); - - // Is the sphere fully contained in the box? - if (distance > eps) - return false; + double dx = (std::max)(bxmax - scx, scx - bxmin); + double dy = (std::max)(bymax - scy, scy - bymin); + double dz = (std::max)(bzmax - scz, scz - bzmin); dx = square(dx); dy = square(dy); @@ -804,13 +790,14 @@ public: eps = 1.99986535548615598560e-15 * (std::max)((std::max)(ssr, dx), (std::max)(dy, dz)); - double outer_distance = dx + dy + dz - ssr; + distance = dx + dy + dz - ssr; // Is the box fully contained in the sphere? - if (outer_distance > eps) + if (distance > eps) return false; - if (distance < eps && outer_distance < eps) + // Does the box intersect the sphere or is the sphere fully contained in the box? + if (distance < -eps) return true; } diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 819ed0fa8ee..963914ff71e 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -84,11 +84,7 @@ public: #ifdef CGAL_NO_STATIC_FILTERS_FOR_LAZY_KERNEL enum { Has_static_filters = false }; #else - // @fixme, this should be 'true' but it's broken because EPIC_predicate_if_convertible - // assumes the static filtered predicate and the (non-static) filtered predicate - // have the same signature, which is not always the case, for example in - // Do_intersect_3(Sphere_3, Bbox_3, *bool*) - enum { Has_static_filters = false }; + enum { Has_static_filters = true }; #endif // Types diff --git a/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp b/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp index 87f18075700..342688c29be 100644 --- a/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp +++ b/Filtered_kernel/test/Filtered_kernel/Static_filters.cpp @@ -309,20 +309,6 @@ int main(int argc, char **argv) assert( !CGAL::Epick::Has_static_filters); #endif - #ifdef CGAL_DONT_USE_LAZY_KERNEL - #ifdef CGAL_NO_STATIC_FILTERS - assert( !CGAL::Epeck::Has_static_filters); - #else - assert( CGAL::Epeck::Has_static_filters); - #endif - #else - #ifdef CGAL_LAZY_KERNEL_USE_STATIC_FILTERS_BY_DEFAULT - assert( CGAL::Epeck::Has_static_filters); - #else - assert( !CGAL::Epeck::Has_static_filters); - #endif - #endif - assert( K2::Has_static_filters); assert(! K4::Has_static_filters); diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h index f09eaa71c08..b2da7a54bca 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Iso_cuboid_3_Sphere_3_do_intersect.h @@ -82,12 +82,18 @@ do_intersect_sphere_box_3(const typename K::Sphere_3& sphere, { d = to_FT(bzmin) - to_FT(center.z()); d = square(d); + if (certainly(d > sr)) + return false; + distance += d; } else if(compare(center.z(), bzmax) == LARGER) { d = to_FT(center.z()) - to_FT(bzmax); d = square(d); + if (certainly(d > sr)) + return false; + distance += d; } // Note that with the way the distance above is computed, the distance is '0'