run time error

here is the code where we try to select a face and get its bounds!

Standard_Real umin,umax,vmin,vmax;
TopoDS_Face face;
if (myAISContext->MoreSelected())
face = TopoDS::Face(myAISContext->SelectedShape());

BRepTools::UVBounds(face,umin,umax,vmin,vmax);//here the code breaks during run-time.

Roman Lygin's picture

Note sure if it is the root-cause but anyway... To make your code safe, you need to check what you get as a selected object. It may be not the face or even not the shape (TopoDS_Shape) at all.

if (!face.IsNull()) {

Hope this will be helpful.

--- - blog on Open CASCADE

Paul Jimenez's picture

Actually, it'd be also good to check in that "if" condition for myAISContext->HasSelectedShape(). As long as the face is NOT NULL, it should work (it does for me, and I actually use that a lot).