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_DistShapeShapebounding box 方式费时;
  • 如果bouding box方式检测出来出现干涉(interference, overlap),则可以使用distance检测方式确认;



    Enjoy Reading This Article?

    Here are some more articles you might like to read next:

  • al-folio 本地部署记录(Ubuntu 24.04)
  • C++ Traits
  • 道格拉斯-普克算法(Douglas–Peucker algorithm)
  • CMake支持库收集
  • QGC代码架构解析:飞行前检查(起飞条件)