You could use TopExp_Explorer explore(*instance, TopAbs_FACE); to extract the faces from both objects and then fuse those. An alternative may be to compute the intersection (BRepAlgoAPI_Common) and sew the result with the fuse together (BRepBuilderAPI_Sewing). Hope this gives a starting point.
Archived discussion
Fuse is not merging shapes' faces
I would like to merge two cuboids such that their common faces also get merged. Currently, I am not able to get those common faces merged with the below code:
[code]
const TopoDS_Shape b1 = BRepPrimAPI_MakeBox(10, 10, 20);
const TopoDS_Shape b2 = BRepPrimAPI_MakeBox(gp_Pnt(5, 0, 0), 30, 30, 30);
const TopoDS_Shape fused = BRepAlgoAPI_Fuse(b1, b2);
[/code]
Please say how to do this.
Discussion
5 archived replies
Posts are displayed in their archived order.
Thanks Oliver,
Kindly also include an example to illustrate for a beginner.
The only code I have is the actual code I use. You can see that on github. https://github.com/WolframResearch/OpenCascadeLink/blob/master/OpenCasca... in that file look for the functions I mentioned in my answer.
It is not clear from your question what do you want to obtain. The result of fuse operation is one shell that contains faces from both arguments, some of which are splits of the original faces. This result is as on the below picture:
Archived image: 001-pic1.png
May be you want to get merged the result faces that occur to be located on the same plane? It is like on the following picture:
Archived image: 002-pic2.png
It that case all you need is just to simplify the result. For this you need to call the method SimplifyResult before getting the result:
const TopoDS_Shape b1 = BRepPrimAPI_MakeBox(10, 10, 20);
const TopoDS_Shape b2 = BRepPrimAPI_MakeBox(gp_Pnt(5, 0, 0), 30, 30, 30);
TopoDS_Shape fused;
BRepAlgoAPI_Fuse aFuse(b1, b2);
if (aFuse.IsDone())
{
aFuse.SimplifyResult();
fused = aFuse.Shape();
}
Thank Makhail,
That was very helpful. Please feel free to answer here as well: https://stackoverflow.com/questions/73680243/getting-faces-to-merge-whil....