使用类

  • Bnd_Box:3维包围盒
  • BRepBndLib: 计算TopoDS_Shape包围盒,并加入Bnd_Box。

示例代码

#include "BRepPrimAPI_MakeBox.hxx"
#include "BRepPrimAPI_MakeSphere.hxx"
#include "BRepBndLib.hxx"
#include "Bnd_Box.hxx"
#include <iostream>

void TestBndBox()
{
TopoDS_Shape aBoxShape = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 6, 6, 6).Shape();
TopoDS_Shape aSphereShape = BRepPrimAPI_MakeSphere(gp_Pnt(5, 5, 5), 3.0).Shape();

Bnd_Box aBound;
BRepBndLib::Add(aBoxShape, aBound);
BRepBndLib::Add(aSphereShape, aBound);

Standard_Real theXmin;
Standard_Real theYmin;
Standard_Real theZmin;
Standard_Real theXmax;
Standard_Real theYmax;
Standard_Real theZmax;
aBound.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);

std::cout << "min corner(" << theXmin << "," << theYmin << "," << theZmin << ")" << std::endl;
std::cout << "max corner(" << theXmax << "," << theYmax << "," << theZmax << ")" << std::endl;

}

运行截图

OpenCascade笔记:计算TopoDS_Shape包围盒_OpenCascade