I'm writing a tool path solver and in a tight loop I need to test if a tool intersects a sheet body. The current function I have is
public static bool DoesIntersection(this IBody2 bodyA, IBody2 bodyB)
//!!!!We need to copy the bodies because IGetIntersectionEdgeCount is destsructive!!!!
var bodyACopy = (Body2) bodyA.Copy();
var bodyBCopy = (Body2) bodyB.Copy();
return bodyACopy.IGetIntersectionEdgeCount(bodyBCopy) > 0;
The only useful API function I can find is IGetIntersectionEdgeCount. There is also 2016 SOLIDWORKS API Help - GetIntersectionEdges Method (IBody2)
but this has basically the same behaviour as GetIntersectionEdgeCount.
The above functions are slow. They find all the intersection edges and then modify the bodies with these new edges. I would like a function that returns immediately if it knows an intersection will exist but doesn't need to actually calculate it.
I've considered tessellating the two bodies bodies to a high resolution and then shove all the triangles into some kind of binary space tree which can give me fast intersection tests. I'd prefer not to have to build this if not necessary.
( And yes I'm running the API calls on the correct thread to maximize performance )