How to Convert Bnd_Box to TopoDS_Shape?

jianbaoxia

CAD master
Hi Bros, I get an Bnd_Box of a solid, I try to convert Bnd_Box to TopoDS_Shape. Is there a easy tool to do this. The BRepPrimAPI_MakeBox seems doesn't word.
 

jianbaoxia

CAD master
this code can work.
Code:
TopoDS_Solid ConvertBndToShape(const Bnd_OBB& theBox)
{
    const gp_Pnt aBaryCenter = theBox.Center();
    const gp_XYZ aXDir = theBox.XDirection(), aYDir = theBox.YDirection(), aZDir = theBox.ZDirection();
    Standard_Real aHalfX = theBox.XHSize(), aHalfY = theBox.YHSize(), aHalfZ = theBox.ZHSize();

    gp_Ax2 anAxes(aBaryCenter, aZDir, aXDir);
    anAxes.SetLocation(aBaryCenter.XYZ() - aHalfX * aXDir - aHalfY * aYDir - aHalfZ * aZDir);
    return BRepPrimAPI_MakeBox(anAxes, 2.0 * aHalfX, 2.0 * aHalfY, 2.0 * aHalfZ);
}
 
Top