Bounding boxes of trimmed surfaces

I'm trying to find the bounding box of a trimmed surface. I have tried iShape->BoundingBox(), BRepBndLib::Add and BndLib_AddSurface::Add but none of them seem to return the correct result.

Does anyone know of a more accurate method of finding a bounding box?


Rob Bachrach's picture

I thought BRepBndLib (and more to the point,
Bnd_Box) was inaccurate as well until I discovered
the SetGap function. Bnd_Box automatically adds
a small gap around the actual bounding box and
pads the result. All you need to do is to
call SetGap(0.0) AFTER you've added your surfaces
to the box (not before). This should return an
accurate result.

n-southall's picture


I found that to achieve an accurate bounding box, I had to set the Gap parameter to a large amount and then subtract it from the bounds afterwards:

Bnd_Box myBox;
BRepBndLib::Add (myShape, myBox );

double rGap = 1000.0;


myBox.Get(m_rXMin, m_rYMin, m_rZMin, m_rXMax, m_rYMax, m_rZMax);

// remove the gap from each result;
m_rXMin += rGap;
m_rYMin += rGap;
m_rZMin += rGap;
m_rXMax -= rGap;
m_rYMax -= rGap;
m_rZMax -= rGap;

Hope this helps,


Mark English's picture

What I should have added is that the data for the surfaces which I am having trouble with are imported through the IGES reader, if that offers any clues.