
Wed, 08/09/2023 - 12:09
When using the BRepAlgoAPI_Fuse operation on a circle and a square, I get the desired fused outcome, but the shape consists of two separate faces. The first being the full circle, and the second being the square minus the circle.
Is it possible to get only one face, so that I dont get the internal edge going between the two intersections of the fused shape?
CODE:
TopoDS_Face Face() {
TopoDS_Edge line = Line(gp_Pnt(0, 0, 0), gp_Pnt(8, 0, 0));
TopoDS_Edge line2 = Line(gp_Pnt(8, 0, 0), gp_Pnt(8, 8, 0));
TopoDS_Edge line3 = Line(gp_Pnt(8, 8, 0), gp_Pnt(0, 8, 0));
TopoDS_Edge line4 = Line(gp_Pnt(0, 8, 0), gp_Pnt(0, 0, 0));
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(line, line2, line3, line4);
BRepBuilderAPI_MakeFace makeFace(wire, true);
return makeFace.Face();
}
TopoDS_Shape Circle() {
gp_Pnt centerPt(9, 9, 0);
gp_Dir dir(0, 0, -1);
gp_Ax2 ax2(centerPt, dir);
gp_Circ circ(ax2, 4);
Geom_Curve* curve = new Geom_Circle(circ);
BRepBuilderAPI_MakeEdge maker(curve);
BRepBuilderAPI_MakeWire wire(maker.Edge());
BRepBuilderAPI_MakeFace face(wire.Wire());
return face.Face();
}
TopoDS_Shape Fuse(TopoDS_Shape face1, TopoDS_Shape face2) {
BRepAlgoAPI_Fuse fuse(face1, face2);
fuse.SimplifyResult();
return fuse.Shape();
}
Wed, 08/09/2023 - 22:14
SimplifyResult must do the job. If it does not it is an error. BTW, without simplifying there must be 3 faces in the result.
Thu, 08/10/2023 - 11:29
Thanks for your reply.
Yeah I think it is strange behaviour. I tried another example where I have a parabolic shaped face merged with a square face. This also results in two distinct faces, when I am using SimplifyResult. Each being the original face I tried to fuse. Yet the fuse seems to work alright I guess since the whole desired shape is included in the compound.
TopoDS_Shape ParabolaFace() {
gp_Pnt pt1(0, 8, 0);
gp_Pnt pt2(8, 8, 0);
gp_Pnt centerPt(4, 13, 0);
gp_Vec vec(pt1, pt2);
gp_Dir dir(0, 0, 1);
gp_Dir dir2(0, -1, 0);
gp_Ax2 ax2(centerPt, dir, dir2);
gp_Parab parab(ax2, 0.8);
Handle(Geom_TrimmedCurve) aArcOfParabola = GC_MakeArcOfParabola(parab, pt1, pt2, true);
BRepBuilderAPI_MakeEdge maker(aArcOfParabola);
TopoDS_Shape shape = maker.Shape();
Handle(Geom_TrimmedCurve) segment = GC_MakeSegment(pt1, pt2);
BRepBuilderAPI_MakeEdge edge(segment);
BRepBuilderAPI_MakeWire wire(maker.Edge(), edge.Edge());
BRepBuilderAPI_MakeFace face(wire.Wire());
return face.Face();
}
Thu, 08/10/2023 - 19:24
I was able to reproduce your problem from your first example. There is definitely a bug in ShapeUpgrade_UnifySameDomain. It has to do with the face normals. The construction of your rectangular face results in a face normal of (0.0,0.0,1.0). Your circular face is constructed with the opposite normal of (0.0,0.0,-1.0). ShapeUpgrade_UnifySameDomain considers these same domain, but then doesn't handle it correctly. If you use (0.0,0.0,1.0) for the normal of your circular face, then you get the expected results.
Mon, 08/14/2023 - 10:44
Thank you! works now:)