Fuse method does not work for edges

Hello, I think i have an understanding issue here, but when i try to fuse to two edges together like this, the result still has two edges. 

Do i use the fuse algorithm in a wrong way, or do i have to do something else?

pt1 = OCC.gp.gp_Pnt(0,0,0)
pt2 = OCC.gp.gp_Pnt(3,0,0)
pt3 = OCC.gp.gp_Pnt(1,0,0)
pt4 = OCC.gp.gp_Pnt(5,0,0)

edge1 = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge(pt1,pt2).Edge()
edge2 = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge(pt3,pt4).Edge()

fuse = OCC.BRepAlgoAPI.BRepAlgoAPI_Fuse(edge1, edge2).Shape()

edges = []
exp = OCC.TopExp.TopExp_Explorer(fuse, OCC.TopAbs.TopAbs_EDGE)
while exp.More():
    edge = OCC.TopoDS.topods.Edge(exp.Current())
return edges

results in two edges, I need one.

unif = OCC.ShapeUpgrade.ShapeUpgrade_UnifySameDomain(fuse)

even results in three edges :)

Any help is appreciated!


Martin Melbourne's picture

Okay, I solved it using:

BRepLib_FuseEdges(BRepAlgoAPI_Fuse(edge1, edge2).Shape())

though i don't yet understand why the normal boolean fuse does not just unify the two edges.




does the same, are there any differences, or advantages to using one of the methods, or is there a better one? Basically I need do fuse edges that can be fuse (i.e. I would check for common and unify them if common has been found, to get one edge)


BRepAlgoAPI_Fuse(edge1, edge2) only fuses the edges into one edge if they have exactly the same coordinates

Forum supervisor's picture

Dear Martin,

As you can see from Draw script below, an operation of merging 2 your edges properly produces a shape with 3 edges, what can be joined to a wire and unified to a shape with 1 edge.

vertex v1 0 0 0   vertex v2 3 0 0   vertex v3 1 0 0   vertex v4 5 0 0

edge e1 v1 v2   edge e2 v3 v4

bfuse r e1 e2

nbs r

# EDGE      : 3

eval wire w [explode r e]

unifysamedom result w

don result

nbs result

# EDGE      : 1

Best regards,

Forum supervisor

Martin Melbourne's picture

Thanks for your help, can you explaine to me what the other two methods (BRepLib_FuseEdges and TopOpeBRepTool_FuseEdges) do, and where they differ from your solution? 

Martin Melbourne's picture

Your Solution does not seem to work for me :/

pt1 = OCC.gp.gp_Pnt(0,0,0)
pt2 = OCC.gp.gp_Pnt(3,0,0)
pt3 = OCC.gp.gp_Pnt(1,0,0)
pt4 = OCC.gp.gp_Pnt(3,0,0)

edge1 = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge(pt1,pt2).Edge()
edge2 = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge(pt3,pt4).Edge()

wire = OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire()

unif = OCC.ShapeUpgrade.ShapeUpgrade_UnifySameDomain(wire.Shape())


The result are still 2 edges

Eugeny's picture

This solution does not work because you've missed the step in which the edges are fused (bfuse r e1 e2). The unification algorithm works only on topologically shared objects, i.e. the edges should be connected.

Martin Melbourne's picture