Bug in RhinoCommon Brep.Join

There seems to be a bug in Brep.Join method.

The enclosed file and python script demonstrates the problem.
Join_Error.py (1.8 KB)
join_error.3dm (46.0 KB)

The file contains a single brep and a curve that lies on the brep.

The script explodes the brep into two subobjects (brep0 and brep1) and then splits one of them using the red curve. This creates two objects (split0 and split1)
Split1 is then joined to Brep1 and at that point the bug can be seen.
Load the file and run the script to see.

I see that, and will look into why this is happening.
https://mcneel.myjetbrains.com/youtrack/issue/RH-81907

In the mean time, you can use the static function Rhino.Geometry.Brep.JoinBreps that does not have this issue:

    #brep.Join(brs[1], tol*2.1, True ) 
    breps = Rhino.Geometry.Brep.JoinBreps([brep, brs[1]], 2.1*tol)
    if (len(breps) == 1):
        brep = breps[0]

Yes, I am aware I could probably write my own version of Brep.Join that works without errors…

The script is intended to, in a simple and unambiguous way, demonstrate a bug. Its not really intended to explain what I want to accomplish.

One of the things I’m trying to use Brep.Join for is to discriminate between brep edges that have been previously joined and those that have not

Here is another version of the script and new geometry to run it on.
Join_Error2.py (1.9 KB)
breps_unjoined.3dm (48.2 KB)

In this version the script it produces the result directly without forcing the user to acknowledge each step. Also, in this version the join tolerance is set to model_tolerance*0.001 (extremely tight).
The geometry supplied is the same surfaces as before but this version surfaces are not joined. The edges between the surfaces are well within model tolerance but above the join tolerance of the script. When you run the script nothing is joined and only the unjoined Brep is returned. That is what is supposed to happen.
Now if you undo the previous result and join the two surfaces and run the script again it will work as before. It will explode the joined breps into two and one of the breps will be split and one of the splits will be joined. This time the join will work, but the edges of the split surface are still FUBAR.

Anyway thanks for looking at this.

Here’s a little more info that may help in figuring out what is happening.

I tried the scripts in Rhino6 and Rhino5. Rhino6 behaves the same as Rhino8.
In Rhino5 everything works correctly the surface joins without turning the edges inside-out. So it seems this bug was introduced in Rhino6.

Also, I should mention that in the actual code where I do this, both of the original BrepFaces (brep0 and brep1) are split and then the Brep.Join is used on one side of the splitting curve to join the faces that have edges of the same length. I only stumbled on this bug by accident when one of the faces fails to split.
In other words, the bug only happens when the edges of the two breps being joined are different lengths.

When the edges being joined are different lengths the join never messes up the edges of the Brep being joined its always the otherBrep that gets its edges garbled, but that only happens sometimes.

1 Like