error when adding fillets onto a polygon

Hi all;
I'm trying to add fillets onto the four corners of a rectangle polygon. But the program reports error after I adding the fillets. Please can anyone help me to identify the mistake? Mannnnnny thanks!!!!
//Vertices of the first square
gp_Pnt E(0,10,0.0);
gp_Pnt F(0,0,0.0);
gp_Pnt G(10,0,0.0);
gp_Pnt H(10,10,0.0);
//Construction of the fist square
BRepBuilderAPI_MakeWire wireMakerb;
wireMakerb.Add(BRepBuilderAPI_MakeEdge(E, F).Edge());
wireMakerb.Add(BRepBuilderAPI_MakeEdge (F, G).Edge());
wireMakerb.Add(BRepBuilderAPI_MakeEdge(G, H).Edge());
wireMakerb.Add(BRepBuilderAPI_MakeEdge(H, E).Edge());
BRepBuilderAPI_MakeFace faceMakerb (wireMakerb.Wire());
TopoDS_Shape B = faceMakerb.Face();

BRepFilletAPI_MakeFillet afillet(B);
TopExp_Explorer ex;
for(ex.Init(B, TopAbs_EDGE); ex.More(); ex.Next())
{
TopoDS_Edge medge= TopoDS::Edge(ex.Current());
afillet.Add(medge);
}

if(afillet.Shape().IsNull()) {cout TopoDS_Shape t= afillet.Shape(); //***************HAS ERROR ON THIS LINE!

lugan2's picture

Please someone kindly help..... Many thanks!

P G's picture

If u r aware of test harness, u can use the 'chif2d' command to create 2d fillets/chamfer's.
good luck
- PG

lugan2's picture

Thanks PG, sorry I didn't see you message! I'm not using the test harness for command-input/display and I'm only using the Opencascade API to program. Do you know which function it will call when it use the 'chif2d' command to create 2d fillets/chamfer's? There is no info on internet or the documentation about this command at all. Thanks!

P G's picture

You can look into the implementation of chfi2d in the source area of OCC,
src/BRepTest_Fillet2dCommands.cxx and see the related function.
It used the API BRepFilletAPI_MakeFillet2d.

good luck

lugan2's picture

Many thanks PG! I have done it. I had tried this method before. The error was that I can't just use the TopExp_Explorer loop to go through the four edges, but have to add the fillets onto the first 3 edges and then add the fillet onto the 1st and the 3rd separately. Thank you PG!

Arjan Schouten's picture

Hello Gan Lu,

Your polygon has no thickness, it is just a planar face.
You will first have to give it a thickness, for example extruding it
with MakePrism.

Hope this helps.

lugan2's picture

Thanks very much for reply, Arjan! What I'm actually doing is trying to use it as 2D, that is build 2D shapes(with fillets) and interpret the polylines using dots and display them through Gnuplot, rather than using 3D display GUI(e.g., qt). Because my focus in only on 2D right now. Is there a simple way I could just add fillets onto the lines in 2D? Many thanks!

Sharjith Naramparambath's picture

You must actually use BRepFilletAPI_MakeFillet2d for filleting wires.

lugan2's picture

Yes, thanks Sharijith. It has been solved and I need to use BRepFilletAPI_MakeFillet2d method. Thank you

akshay gaikwad's picture

hi Sharjith Naramp,

Can you tell me, how to do 2d fillet to the wire or the edge?

Thanx