The solution I found was the following (though not sure if this is the optimal one):
In the callback function of the collision check
- First read the IDs of the triangles
id1 = a.handle() - coll_Triangles.begin();
id2 = b.handle() - coll_Triangles.begin();
- Check if triangles are degenerate (if true, return)
a.handle()->is_degenerate()
- Check the vertices-ID of the triangles. If they share a vertex-ID, return
this is obvious, not pseudocode here :)
- Only if the above hold true, do the actual intersection test between triangles
CGAL::do_intersect( *(a.handle()), *(b.handle())
- If the last command returns true, then you have two non-adjacent triangles colliding. Congratulations :)
The do_intersect has to happen as the last step, after all other tests, otherwise the computational load is quite big and in vain.
Another possible speedup is to use half-open instead of closed boxes. I found that during greedy checks between all triangle pairs this leads to a speedup (~50%), but I assume that this could lead to missing some collisions (e.g. in the case of touch).
CGAL::Box_intersection_d::HALF_OPEN
CGAL::Box_intersection_d::CLOSED