Adding specific code for Tet + Bbox_3 do_intersect as it should be ok for Bbox_3 to degenerate.

Adding specific code for Tet + Bbox_3 do_intersect as it should be ok for Bbox_3 to degenerate. 

The previous code failed in case Bbox_3 is degenerate. 

I use the result = result || predicate(); to keep the maybe inside result. 
If certain the code returns early. 
I also avoid the %4 as this is a slow operation, but not sure that this is worth compared to the rest.
This commit is contained in:
Michael Hemmer 2020-06-03 16:58:49 +02:00 committed by GitHub
parent 97123fc3c7
commit bbf26e22ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 15 deletions

View File

@ -161,23 +161,30 @@ do_intersect(const typename K::Tetrahedron_3 &tet,
}
template <class K>
inline
typename K::Boolean
do_intersect(const typename K::Tetrahedron_3 &tet,
const CGAL::Bbox_3 &bb,
const K & k)
{
return do_intersect_tetrahedron_bounded(bb, tet, typename K::Point_3(bb.xmin(), bb.ymin(), bb.zmin()), k);
inline typename K::Boolean do_intersect(const typename K::Tetrahedron_3 &tet,
const CGAL::Bbox_3 &bb, const K &k) {
// Swap arguments.
return do_intersect(bb, tet, k);
}
template <class K>
inline
typename K::Boolean
do_intersect(const CGAL::Bbox_3 &bb,
const typename K::Tetrahedron_3 &tet,
const K & k)
{
return do_intersect_tetrahedron_bounded(bb, tet, typename K::Point_3(bb.xmin(), bb.ymin(), bb.zmin()), k);
// BBox_3 sphecific code since it's ok for BBox_3 to degenerate.
template <class K>
inline typename K::Boolean do_intersect(const CGAL::Bbox_3 &aabb,
const typename K::Tetrahedron_3 &tet,
const K &k) {
using Tr = CGAL::Triangle_3<K>;
typename K::Boolean result = do_intersect(aabb, Tr(tet[0], tet[1], tet[2]), k);
if (certainly(result)) return result;
result = result || do_intersect(aabb, Tr(tet[1], tet[2], tet[3]), k);
if (certainly(result)) return result;
result = result || do_intersect(aabb, Tr(tet[2], tet[3], tet[0]), k);
if (certainly(result)) return result;
result = result || do_intersect(aabb, Tr(tet[3], tet[0], tet[1]), k);
if (certainly(result)) return result;
result = result ||
k.has_on_bounded_side_3_object()(
tet, typename K::Point_3(aabb.xmin(), aabb.ymin(), aabb.zmin()));
return result;
}
} // namespace internal