Disjoint faces when creating a shell with a BSpline edge

I am trying to connect two faces into a shell:

  • A horizontal semi-circular face with 2 edges: one from a straight line (simply connecting 2 vertices), another from a Geom_BSplineCurve. Both have the same vertices at their ends.
  • A rectangular vertical face. The bottom edge is the straight edge (hence shared) from the above face.

I found that the resulting shell has both faces disjoint, and the vertices and edges are duplicated. Does anyone know why this happens, and how I can connect these faces correctly?

The code can be found below. Otherwise the source code as well as a screenshot of the shell is attached. I use OCCT 7.2.0.

Thank you,
Nicholas

gp_Pnt pTop_0(0.0, 0.0, 10.0);
gp_Pnt pTop_1(10.0, 0.0, 10.0);
gp_Pnt pTop_2(10.0, 10.0, 10.0);
gp_Pnt pTop_3(0.0, 10.0, 10.0);

gp_Pnt pBottom_0(0.0, 0.0, 0.0);
gp_Pnt pBottom_1(10.0, 0.0, 0.0);
gp_Pnt pBottom_2(10.0, 10.0, 0.0);
gp_Pnt pBottom_3(0.0, 10.0, 0.0);

TopoDS_Vertex vTop_0 = BRepBuilderAPI_MakeVertex(pTop_0);
TopoDS_Vertex vTop_3 = BRepBuilderAPI_MakeVertex(pTop_3);

TopoDS_Vertex vBottom_0 = BRepBuilderAPI_MakeVertex(pBottom_0);
TopoDS_Vertex vBottom_3 = BRepBuilderAPI_MakeVertex(pBottom_3);

TColgp_Array1OfPnt bottomPoles(0, 3);
bottomPoles.SetValue(0, pBottom_0);
bottomPoles.SetValue(1, pBottom_1);
bottomPoles.SetValue(2, pBottom_2);
bottomPoles.SetValue(3, pBottom_3);

TColStd_Array1OfReal weights(0, 3);
weights.SetValue(0, 1);
weights.SetValue(1, 1);
weights.SetValue(2, 1);
weights.SetValue(3, 1);

TColStd_Array1OfReal knots(0, 1);
knots.SetValue(0, 0);
knots.SetValue(1, 1);

TColStd_Array1OfInteger multiplicities(0, 1);
multiplicities.SetValue(0, 4);
multiplicities.SetValue(1, 4);

Handle(Geom_BSplineCurve) frontBottomCurve = new Geom_BSplineCurve(bottomPoles, weights, knots, multiplicities, 3, false, false);

TopoDS_Edge frontBottomEdge = BRepBuilderAPI_MakeEdge(frontBottomCurve);
TopoDS_Edge backTopEdge = BRepBuilderAPI_MakeEdge(vTop_0, vTop_3);
TopoDS_Edge backBottomEdge = BRepBuilderAPI_MakeEdge(vBottom_0, vBottom_3);
TopoDS_Edge e0 = BRepBuilderAPI_MakeEdge(vBottom_0, vTop_0);
TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(vBottom_3, vTop_3);

TopoDS_Wire bottomWire = BRepBuilderAPI_MakeWire(frontBottomEdge, backBottomEdge);
TopoDS_Wire backWire_planar = BRepBuilderAPI_MakeWire(backTopEdge, e0, backBottomEdge, e3);

TopoDS_Face bottomFace = BRepBuilderAPI_MakeFace(bottomWire);
TopoDS_Face backFace_planar = BRepBuilderAPI_MakeFace(backWire_planar);

TopoDS_Shell shell;
BRep_Builder aBuilder;
aBuilder.MakeShell(shell);
aBuilder.Add(shell, bottomFace);
aBuilder.Add(shell, backFace_planar);

 

Nicholas MW's picture

Sorry, i just realised that I should be using BRepBuilderAPI_Sewing instead. The code below works as intended.

BRepBuilderAPI_Sewing sewing;
sewing.Add(bottomFace);
sewing.Add(backFace_planar);
sewing.Perform();