Here's the issue: suppose I want to find whether a point is inside or outside a 3D shape (or right on the surface). Theoretically, I can just extend a ray from that point in any direction, and count how many times it intersects with any triangles. If the number is even, then it was outside (because it must cross in then out each time), and if it's odd, then it's inside (because it must cross once to get out, then an even number of times after that).
The problem is this: first of all, suppose that it crosses through at an edge between 2 triangles to enter or exit the shape. It would count twice, because it's intersecting both polygons. Or suppose it intersects at a vertex, then it will count for however many triangles share that vertex.
Also, suppose I just graze an edge of the boundary of the 3D shape, so it only intersects once to go all the way through, when I'm expecting it to intersect twice. Actually, in the case of grazing an edge, that would work, because it would count twice, but if the previous problem were fixed, it would cause this to only count once, producing a new problem. And if it intersects a vertex, all bets are off!
So what's the right way to do this?