join coplanar faces

Hi,

I've been struggling with the simple problem of merging/joining/fusing/gluing flat coplanar faces together using Python-OCC. Here is a test code:

############# Base shapes to be merged ################
f1 = BRepBuilderAPI_MakeFace(gp_Pln(0,0,1,0), 0, 20, 0, 20).Face()
f2 = BRepBuilderAPI_MakeFace(gp_Pln(0,0,1,0), -10, 10, -10, 10).Face()
f3 = BRepBuilderAPI_MakeFace(gp_Pln(0,0,1,0), -20, 0, -20, 0).Face()
############# My cheesy solution #####################
los = TopTools_ListOfShape()
los.Append(f1)
los.Append(f3)

bo = BOPAlgo_BOP()
bo.SetOperation(1)
bo.AddArgument(f1)
bo.SetTools(los)
bo.Perform()
suusd = ShapeUpgrade_UnifySameDomain(bo.Shape())
suusd.Build()

Looks like I'm shooting sparrows with a cannons. I need to process quite a large set of overlapping faces and this method is both slow and gives a bad result.

- Can I perform this operation in 2D? what is an equivalent of TopoDS_Face in 2D and can I perform boolean operations in that domain?

- Is there an elegant way of achieving this? Please note that current version of PythonOCC is based on OCC 6.9.1 and no fancy gluing option are provided for boolean operations.

Thanks in advance

 

Attachments: 
tobias559_136549's picture

Hi canaldin,

I'm very curious to know if you have found any robust/fast solution for this problem. At the moment our approach is to manually merge the edges of the various faces using ShapeAnalysis_FreeBounds_ConnectEdgesToWires and to make a new face of the resulting wire. This too is however very slow and not very robust. If you have found a more suitable solution we would therefore be very interested!

Kind regards,