# 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

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`

http://developer.rhino3d.com/api/RhinoCommonWin/html/T_Rhino_Geometry_Brep.htm

Hi Heinz,

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

– Dale

Voilà!

brep_outerloop_collinear_curves.3dm (175.7 KB)

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! the face supplied is resulting from a MergeCoplanarFaces operation.

best regards, heinz

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.

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

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsDuplicateBorder.cs

– Dale

thanks a lot, @menno and @dale