One standard simplification would be to first compute approximate octree-tetrahedron intersections using axis-aligned bounding boxes. The resulting intersection tests are then very simple.
Then, once you've traversed to the leaf level of the tree, you can use an exact test to determine which points are contained within a given tetrahedron.
To summarise:
Form an octree T for your points X
for (all tetrahedrons ti in mesh M)
Form a minimal axis-aligned bounding-box Bi for tetrahedron ti
Traverse T from root, accumulating a list Li of all leaf nodes
that overlap with box Bi
for (all leaf nodes li in list L)
for (all points pi in leaf node li)
if (point pi is inside tetrahedron ti /*exact test*/ )
Associate point pi with tetrahedron ti
endif
endfor
endfor
endfor
This algorithm is efficient if: (i)
the points X
are well distributed within the mesh M
, and (ii)
the tetrahedrons in M
have reasonable aspect ratios.
The key to achieving good performance is to ensure that the tree-traversal step is implemented as efficiently as possible.
A point-in-tetrahedron test can be done by checking whether a given point pi
lies on the "inner" side of the 4 faces of a tetrahedron. Given a tetrahedron [i,j,k,l]
, the point pi
is on the "inner" side of the face [i,j,k]
if it lies on the same side of the plane [i,j,k]
as the "opposing" vertex l
.
These orientation tests can be performed robustly using adaptive precision arithmetic. Jonathan Shewchuk offers such an implementation here.