Brep: Merge Collinear Loop Curves?


Hey guys,

I am using BrepFace.OuterLoop.To3dCurve().DuplicateSegments() on a rectangular Brep face (U and V: degree 1 / CV count 2).

Even though I’d expect 4 linear curves as a result, for some BrepFaces (i think it’s those which result from a MergeCoplanarFaces operation) i keep getting more than that.

Brep.Optimize() doesn’t do the trick.

Is there a way to merge such collinear loop curves for Breps?

Best regards, Heinz

(Menno Deij - van Rijswijk) #2

I’m not sure, but have you tried to cull unused objects?
Check the link below and look for functions starting with Cull...

Probably use one or more of CullUnusedCurves{2d|3d}, CullUnusedEdges, CullUnusedLoops

(Dale Fugier) #3

Hi Heinz,

Can one you post a model that contains such an object?

– Dale


Voilà! :wink:

brep_outerloop_collinear_curves.3dm (175.7 KB)

(Menno Deij - van Rijswijk) #5

One of the edges is a polycurve. You can see this when you use the List command. I don’t know how that happened, what is the origin of this BRep?

What you could do, for this specific case, is to split the outerloop at G1 discontinuities, like so:

ObjRef sRef;
RhinoGet.GetOneObject("Brep", false, ObjectType.Brep, out sRef);

Brep b = sRef.Brep();
foreach (var f in b.Faces)
    var ol = f.OuterLoop.To3dCurve();
    double t0 = ol.Domain.T0;
    double t1 = ol.Domain.T1;
    double t;
    List<double> ts = new List<double>();
    while(ol.GetNextDiscontinuity(Continuity.G1_locus_continuous, t0, t1, out t))
        t0 = t;
    Curve[] segs = ol.Split(ts);

    foreach (var seg in segs)

return Result.Success;


hey menno, thanks a lot, your code works for me! :slight_smile: the face supplied is resulting from a MergeCoplanarFaces operation.

best regards, heinz

(Menno Deij - van Rijswijk) #7

the face supplied is resulting from a MergeCoplanarFaces operation

Ah, that explains the polycurve as an edge. Both edges are then “merged” into a polycurve, containing the previous edges in one curve.

(Dale Fugier) #8

Duplicating the naked edges might be an easy way to go.

– Dale


thanks a lot, @menno and @dale :wink: