Merge pull request #7704 from sloriot/Mesh_3-PCMD_in_domain_bug

Fix Is_in_domain potential infinite loop

# Conflicts:
#	Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h
This commit is contained in:
Laurent Rineau 2023-09-13 16:16:23 +02:00
commit 3cf928a4c7
1 changed files with 10 additions and 7 deletions

View File

@ -528,9 +528,9 @@ public:
return r_domain_.bounding_aabb_tree_ptr()-> return r_domain_.bounding_aabb_tree_ptr()->
first_intersected_primitive(ray); first_intersected_primitive(ray);
} }
#define CGAL_USE_ALL_INTERSECTIONS 0
#if USE_ALL_INTERSECTIONS #if CGAL_USE_ALL_INTERSECTIONS
std::optional<AABB_primitive_id> shoot_a_ray_2(const Ray_3 ray) const { std::optional<AABB_primitive_id> shoot_a_ray_2(const Ray_3& ray) const {
const Point_3& p = ray.source(); const Point_3& p = ray.source();
typedef typename AABB_tree:: typedef typename AABB_tree::
template Intersection_and_primitive_id<Ray_3>::Type Inter_and_prim; template Intersection_and_primitive_id<Ray_3>::Type Inter_and_prim;
@ -556,7 +556,7 @@ public:
return it->second; return it->second;
} }
} }
#endif // USE_ALL_INTERSECTIONS #endif // CGAL_USE_ALL_INTERSECTIONS
Subdomain operator()(const Point_3& p) const { Subdomain operator()(const Point_3& p) const {
if(r_domain_.bounding_aabb_tree_ptr() == 0) return Subdomain(); if(r_domain_.bounding_aabb_tree_ptr() == 0) return Subdomain();
@ -578,8 +578,7 @@ public:
const Ray_3 ray_shot = ray(p, vector(CGAL::ORIGIN,*random_point)); const Ray_3 ray_shot = ray(p, vector(CGAL::ORIGIN,*random_point));
#define USE_ALL_INTERSECTIONS 0 #if CGAL_USE_ALL_INTERSECTIONS
#if USE_ALL_INTERSECTIONS
std::optional<AABB_primitive_id> opt = shoot_a_ray_2(ray_shot); std::optional<AABB_primitive_id> opt = shoot_a_ray_2(ray_shot);
#else // first_intersected_primitive #else // first_intersected_primitive
std::optional<AABB_primitive_id> opt = shoot_a_ray_1(ray_shot); std::optional<AABB_primitive_id> opt = shoot_a_ray_1(ray_shot);
@ -617,7 +616,11 @@ public:
return pair.second == 0 ? return pair.second == 0 ?
Subdomain() : Subdomain() :
Subdomain(Subdomain_index(pair.second)); Subdomain(Subdomain_index(pair.second));
default: /* COPLANAR */ continue; // loop default: /* COPLANAR */
if (!triangle.has_on(p))
continue; // loop
else
return Subdomain(Subdomain_index((std::max)(pair.first,pair.second))); // make a canonical choice
} // end switch on the orientation } // end switch on the orientation
} // opt } // opt
} // end while(true) } // end while(true)