How to secure fillet building

Hi,

I have the following code :

BRepOffsetAPI_Sewing sew;
// loop for creating faces/surfaces
for( ..... ) {
// faces/surfaces creation
...
// adding faces/surfaces to sew
sew.Add(face);
}
sew.Perform();

// create a shape from sew
TopoDS_Shape body = sew.SewedShape();

// applying fillets on edges
BRepFilletAPI_MakeFillet mkFillet(body);
TopExp_Explorer aEdgeExplorer(body , TopAbs_EDGE);
while( aEdgeExplorer.More() ) {
TopoDS_Edge aEdge = TopoDS::Edge(aEdgeExplorer.Current());
mkFillet.Add(15.0, aEdge);
aEdgeExplorer.Next();
}
body = mkFillet.Shape();

How can I secure this code? If a fillet cannot be build on Edge (ie fillet is too big for connected faces), I don't want my app crashes.

Thank you for answer.
Best regards.
thm.

Rob Bachrach's picture

Although OCC does occasionally crash, it is rare. It is usually pretty good about throwing exceptions or setting status flags where appropriate. First, you should definitely check IsDone() on your mkFillet object before retrieving the shape (this is defined in the base class BRepBuilderAPI_Command). Second, you should probably surround all your OCC code in a try...catch block.

try {
...
}
catch (Standard_Failure) {
Handle(Standard_Failure) E = Standard_Failure::Caught();
cout << E->DynamicType()->Name() << ":" << E->GetMessageString() << endl;
}