
Tue, 03/23/2021 - 15:46
Hi,
I'm trying to create a simple shape which is essentially a square with one of the corners replaced by and arc of a circle. Whenever I try to draw the output it's not being displayed correctly. I'm working from the Qt bottle sample code and I've essentially replaced the contents of the MakeBottle function in order to build my own model.
To summarise I'm creating 2d features using GCE2d_MakeSegment and GCE2d_MakeCircle. I then use the following constructor to place the 2d objects on BRepBuilderAPI::Plane():
BRepBuilderAPI_MakeEdge (const Handle< Geom2d_Curve > &L, const Handle< Geom_Surface > &S)
I create a wire from the edges and a face. Here is a small code snippet recreating my issue:
BRepBuilderAPI_MakeWire wire;
TopoDS_Edge e1, e2, e3, e4, e5;
e1 = BRepBuilderAPI_MakeEdge(GCE2d_MakeSegment(gp_Pnt2d(0, 0), gp_Pnt2d(10, 0)).Value(), BRepBuilderAPI::Plane());
e2 = BRepBuilderAPI_MakeEdge(GCE2d_MakeSegment(gp_Pnt2d(10, 0), gp_Pnt2d(10, 10)).Value(), BRepBuilderAPI::Plane());
e3 = BRepBuilderAPI_MakeEdge(GCE2d_MakeSegment(gp_Pnt2d(10, 10), gp_Pnt2d(5, 10)).Value(), BRepBuilderAPI::Plane());
e4 = BRepBuilderAPI_MakeEdge(GCE2d_MakeCircle(gp_Pnt2d(5, 5), 5).Value(), BRepBuilderAPI::Plane(), M_PI/2.0, M_PI);
e5 = BRepBuilderAPI_MakeEdge(GCE2d_MakeSegment(gp_Pnt2d(0, 5), gp_Pnt2d(0,0)).Value(), BRepBuilderAPI::Plane());
wire.Add(e1);
wire.Add(e2);
wire.Add(e3);
wire.Add(e4);
wire.Add(e5);
TopoDS_Face face = BRepBuilderAPI_MakeFace(BRepBuilderAPI::Plane(), wire);
return face
My first attachment shows the output in the window. As you can see, rather than there being an arc in the top left corner there is more of a chamfer.
When I replace the line which creates the face to this:
TopoDS_Face face = BRepBuilderAPI_MakeFace(BRepBuilderAPI::Plane()->Pln(), wire);
I wouldn't expect the output to change however I now get the output shown in my second attachment. This time the edge is drawn correctly but the face is no longer drawn.
Can anyone explain what I'm doing wrong?
I'm using Windows 10, Visual Studio 2019,and version 7.5.0 of opencascade.
EDIT: I've just tried editing the above code to use the 3d primitives rather than 2d and the code works just fine. I'm guessing that I'm incorrectly handling the 2d case but I can't see what the issue would be.
Thanks,
David