OCC boundding box 以及 distance
bounding box 方式检测
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
TopoDS_Shape shape1, shape2; // Assume these shapes are already defined
Bnd_Box boundingBox1, boundingBox2;
BRepBndLib::Add(shape1, boundingBox1);
BRepBndLib::Add(shape2, boundingBox2);
bool isInterfering = !boundingBox1.IsOut(boundingBox2);
distance 方式检测
#include <BRepExtrema_DistShapeShape.hxx>
BRepExtrema_DistShapeShape distShapeShape(shape1, shape2);
Standard_Real minDistance = distShapeShape.Value();
bool isInterfering = (minDistance <= Precision::Confusion());
-
BRepExtrema_DistShapeShape比bounding box方式费时; - 如果
bouding box方式检测出来出现干涉(interference, overlap),则可以使用distance检测方式确认;
Enjoy Reading This Article?
Here are some more articles you might like to read next: