Union two planar faces

Is there a way in occ to make a union between two adjacent planar faces and get only one face?
I used "BRepAlgoAPI_Fuse" but it does not result in a single face.. it only makes a shell containing two faces..

David Egan's picture

you can merge the faces into a sewed shape and then use the ShapeTool to find the edges which are connected to only one face (ie on a boundary. )Assuming simply connected you can take these edges, and make a wire and then a planar face.

Prs3d_ShapeTool Tool(SewedShape);

for (Tool.InitCurve();Tool.MoreCurve();Tool.NextCurve())
{
const TopoDS_Edge& E = Tool.GetCurve();
Standard_Integer neighbour = Tool.Neighbours();
// etc add edge to wire if neighbour ==1 ...

Guilherme Praciano Karst Caminha's picture

Hello,

Many thanks for you answer. Although OP didn't answer, I'd like to thank you.

Here's the complete working code for what I've done based on your answer. Since my two coplanar faces woudn't necessarily just touch each other (they could have parts inside of each other), I've used fuser instead of sewer to join them.

BRepAlgoAPI_Fuse Fused_face(face,it->face);

Prs3d_ShapeTool Tool(Fused_face.Shape());
BRepBuilderAPI_MakeWire mkwire;
for (Tool.InitCurve();Tool.MoreCurve();Tool.NextCurve())
{
const TopoDS_Edge& E = Tool.GetCurve();
Standard_Integer neighbour = Tool.Neighbours();
cout << neighbour << endl;
if(neighbour == 1) {
mkwire.Add(E);
}
}
mkwire.Build();
face = BRepBuilderAPI_MakeFace(TopoDS::Wire(mkwire.Shape()));