How to convert Bnd_Box to TopoDS_Shape

Hi . I want to convert Bnd_Box to TopoDS_Shape .

How do this? Is there any class that have that function?

Kirill Gavrilov's picture

Bnd_Box (AABB) is not a shape, so it is unclear what kind of shape you expect to see (solid? lines?).

Solid could be created using BRepPrimAPI_MakeBox class (Bnd_OBB has a constructor from Bnd_Box), as done by Draw Harness command bounding:

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);
}
youngbin son's picture

Thank you.