Wrong bounding box dimensions

Hi,

I noticed an error when I used it to do some calculations with the bounding box information of a shape.

result
X Y Z
CAD Assistant Min: -95.7296 mm, 29.6258 mm, -26.7835 mm
CAS Assistant Max: 0.384177 mm, 120.021 mm, 69.2307 mm

My code Min: -95.3497 30.0011 -26.4022
My code Max: 0.00350084 119.641 68.8494

my code:

    Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(readerDoc->Main());

    TDF_LabelSequence shapes;
    shapeTool->GetShapes(shapes);

    TDF_LabelSequence freeShapes;
    shapeTool->GetFreeShapes(freeShapes);

    qDebug() << "GetShapes():" << shapes.Length() << "GetFreeShapes():" << freeShapes.Length();


    TDF_Label rootLabel = freeShapes.Value(1);
    TopoDS_Shape shape = shapeTool->GetShape(rootLabel);
    TopoDS_Iterator iterator(shape, true, true);

    qDebug() << "Root boundry box ....";
    Bnd_Box box;
    box.SetGap(0);
    BRepBndLib::Add( shape, box);
    Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
    box.Get(xmin, ymin, zmin, xmax, ymax, zmax);

    qDebug() << "Bnd box-> Min" << xmin << ymin << zmin;
    qDebug() << "Bnd box-> Max" << xmax << ymax << zmax;

Do you have any idea about this?

Kirill Gavrilov's picture

BRepBndLib::Add() doesn't compute an exact bounding box, but a rough bounding >= shape. BRepBndLib::Add() by default (see last argument) uses triangulation data stored in the shape, so that the result will depend on the presence of triangulation and on it's quality (meshing parameters).

If you don't call BRepMesh in your code at all (and do not display shapes in AIS_InteractiveContext), then it is not surprise that bounding could different from CAD Assistant (and even if you do - your meshing parameters might be different).