OCC boundding box 以及 distance
bounding box 方式检测
1
2
3
4
5
6
7
8
9
10
#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 方式检测
1
2
3
4
5
#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
检测方式确认;
本文由作者按照 CC BY 4.0 进行授权