How to join BrepFaces

I have two (or more) partially overlapping BrepFaces that are on the same surface. Now I want to create a single BrepFace containing both BrepFaces.

My two BrepFaces:

I could think of something like finding all edge intersections, trimming and creating new edges and make a new Brep from that. But this sounds like a lot of work as I cannot say for sure how many overlapping areas the BrepFaces might have.
Is there an easy way to accomplish that via RhinoCommon?

Thanks a lot!
Ray

Can you provide a gh file with internalized data?

Thanks for the reply Adwait Dake!

Sorry, not really. My file is more like a program containing 20+ files :see_no_evil:

What is your question? Maybe I can aswer that directly?

Hi @RayL,
You could first create Boolean union out of them

And then merge coplanar faces

What you have said here is what i was going to suggest:

I could think of something like finding all edge intersections, trimming and creating new edges and make a new Brep from that. But this sounds like a lot of work as I cannot say for sure how many overlapping areas the BrepFaces might have.

It is really hard to say without any file. But I would go this way:

  1. Extract BRep boundaries
  2. get boundary curves after solving intersections
  3. Project boundaries onto surface and trim the surface with said boudnaries

Thanks @Darryl_Menezes & @technostark for your suggestions.

I tried Brep.CreateBooleanUnion, but the result is:


Which I find quite strange. At least this is not the behaviour I would expect from that function. The Brep.CreateBooleanUnion results in an Array of 4 different Breps (see picture above). (These face-edges in the corners come from some other changes I did).

The Brep.MergeCoplanarFaces does really only work if the surfaces are planes and in my case with curved surfaces always fails.

Here you can see the starting point with the two Breps that shall become one face. Hope this helps:
2_open-breps.3dm (81.6 KB)

This could be a starting point:

private void RunScript(List<Brep> breps, double t, ref object A)
{
  var tol = RhinoDocument.ModelAbsoluteTolerance;
  var ubrp = Brep.CreateFromSurface(breps[0].Surfaces[0]);
  ubrp = Brep.ChangeSeam(ubrp.Faces[0], 0, t, 0.1);
  var brep = Brep.MergeBreps(breps, tol);
  A = ubrp.Split(brep.DuplicateNakedEdgeCurves(true, false), tol);
}

RayLewis.gh (43.9 KB)

Not sure if this is what you’re looking for, but it is one single brep now:

Brep_merge.gh (51.5 KB)

@Mahdiyar Thank you! This looks exactly like, what I was searching for. Is there a detailed information about the Seam-Parameter? I find the description not very precise. I would like to automate the finding of a “good” parameter value instead of trying different ones by hand. Do you have any suggestions for that?
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_ChangeSeam.htm

Thanks guys!