error control for BRepFilletAPI_MakeFillet

I have the following code to build a fillet on an edge of a shape:

1. BRepFilletAPI_Make_Fillet mkFillet(aShape);
2. mkFillet.Add(radius, aEdge);
3. mkFillet.Build();
4. newShape=mkFillet.Shape();

If for some reason, the information in step 2 is wrong, it crashes on step 3. How can I detect the error on step 2, so that it won't reach step 3?

Thanks.

Sean

sergey zaritchny's picture

Hi Sean,
You may check whether the specified Edge belongs to the context shape.
If not - it is wrong parameter. Also you may protect step 3 with try/catch.
Regards

seanliu's picture

Hi Sergey:
Thank you for your reply.
The edge belongs to the context shape. When I said "the information in step 2 is wrong", I meant the edge cannot be used to build a fillet. For example, the edge is an neutral edge (meaning it is not convex or concave).
Also, could you explain more about "Also you may protect step 3 with try/catch"?

Thanks in advance.

Sean

sergey zaritchny's picture

Hi Sean,
1.Sorry, probably I didn't understand your idea.
The mentioned is not convex or concave (according you).
Do you mean ordinary linear edge?
In any case the requirement is single: the edge should belong to the context shape.
2. step 3 (fillet building) may be protected with ordinary C++
try { mkFillet.Build(); ...} catch {} construction to catch exception.
Regards

seanliu's picture

Hi Sergey:
Sorry for being not clear. Attached please find the picture to show the edge is selected and it crashes in mkFillet.Build().

Thanks again.

Sean

Attachments: 
sergey zaritchny's picture

Hi,
Ok. It is clear. You mean seam edge.
If you will check it in debug mode you will get message like next:
"... Standard_Failure: There are no suitable edges for chamfer or fillet"
Algorithm identified that list of suitable edges is empty.
It is not a bug. It is expected reaction of the algorithm to wrong conditions.
Regards

seanliu's picture

Hi Sergey:
That's a great hint. Thank you so much.
Is there a way that I can get this message after mkFillet.Add(radius, aEdge)is called so that I can stop the program?

Thanks again.

Sean

sergey zaritchny's picture

Hi Sean,
It is better detect a problem before than it will appear.
Avoid adding seam edges to fillet function.
ShapeAnalysis package may help you.
Regards

seanliu's picture

Hi Sergey:
Great! Thank you so much.

Sean