From 39c0a9fb33ca2f253dd8db7ed6ba04f5fae90d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 26 Jun 2023 17:11:15 +0200 Subject: [PATCH] Fix returning no intersection for a ray with spawn in a triangle --- .../Mesh_3/Robust_intersection_traits_3.h | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h index 944916523a0..4df259b6486 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h @@ -418,14 +418,14 @@ tr_intersection(const typename K::Triangle_3 &t, typedef typename K::Point_3 Point_3; - typename K::Construct_vertex_3 vertex_on = - k.construct_vertex_3_object(); - + typename K::Do_intersect_3 do_intersect = + k.do_intersect_3_object(); typename K::Orientation_3 orientation = k.orientation_3_object(); - typename K::Construct_point_on_3 point_on = k.construct_point_on_3_object(); + typename K::Construct_vertex_3 vertex_on = + k.construct_vertex_3_object(); typename Mesh_3::Vector_plane_orientation_3_static_filter vector_plane_orient; @@ -439,17 +439,24 @@ tr_intersection(const typename K::Triangle_3 &t, const Point_3& q = point_on(r,1); const Orientation ray_direction = vector_plane_orient(p, q, a, b, c); - - if(ray_direction == COPLANAR) return result_type(); + if(ray_direction == COPLANAR) + return result_type(); const Orientation abcp = orientation(a,b,c,p); + if(abcp == COPLANAR) // p belongs to the triangle's supporting plane + { + if(do_intersect(t, p)) + return result_type(p); + else + return result_type(); + } - if(abcp == COPLANAR) return result_type(); // p belongs to the triangle's - // supporting plane - - if(ray_direction == abcp) return result_type(); - // The ray lies entirely in one of the two open halfspaces defined by the - // triangle's supporting plane. + if(ray_direction == abcp) + { + // The ray lies entirely in one of the two open halfspaces defined by the + // triangle's supporting plane. + return result_type(); + } // Here we know that the ray crosses the plane (abc)