[RhinoCommon] BrepFace.TrimAwareIsoCurve does not work on domain boundaries

No matter what I do, when extracting trim-aware isocurves on the face edge, the result is null.

BrepFace bf; // defined elsewhere
Interval iv = bf.Domain(0);
int dir = 1;
Curve[] crv = bf.TrimAwareIsoCurve(dir, iv.T0); // null
crv = bf.TrimAwareIsoCurve((dir+1)%2, iv.T0); // also null, I never know what is what with dir and value 

I guess, I need to find out which of the edges correspond to the desired iso-curves and go with that, but that is error prone.

Ok, I did some more research into this problem and I found this:

  1. on an untrimmed BRep it works (see plane in attached document), but on a trimmed BRep it does not work (see trimmed cylinder in attached document).
  2. Adding or subtracting RhinoMath.ZeroTolerance to the parameter values of the domain boundaries works in both cases.

I have to wonder about this odd behavior, especially as the cylinder boundaries give exactly the same curves with the code below (SelDup works).

trim_aware_isocurve_problem.3dm (35.4 KB)

public Result RunCommand(RhinoDoc doc, RunMode mode)
    ObjRef bRef;
    Result res = RhinoGet.GetOneObject("brep", false, ObjectType.Brep, out bRef);
    if (res != Result.Success) return res;
    Brep b = bRef.Brep();

    Interval u = b.Faces[0].Domain(0);
    Interval v = b.Faces[0].Domain(1);

    double delta = RhinoMath.ZeroTolerance;
    // double delta = 0.0; // this does not work

    Curve[] tu0 = b.Faces[0].TrimAwareIsoCurve(1, u.T0 + delta);
    Curve[] tu1 = b.Faces[0].TrimAwareIsoCurve(1, u.T1 - delta);

    Curve[] tv0 = b.Faces[0].TrimAwareIsoCurve(0, v.T0 + delta);
    Curve[] tv1 = b.Faces[0].TrimAwareIsoCurve(0, v.T1 - delta);

    foreach (var a in new[] {tu0, tu1, tv0, tv1}.Where(a => null != a))
        foreach (var c in a.Where(c => c != null))

    return Result.Success;

Hi Menno,

The attached file seems to work with your code.

Remember, Brep.Faces[face_index].Domain(dir) returns the domain of the untrimmed surface, If the specified parameters to BrepFace.TrimAwareIsoCurve fall on the inactive portion of the surface, then no curve(s) will be returned. This is the case of the trimmed cylinder in your document.

trimmed_plane.3dm (42.7 KB)

– Dale

Hi @dale, thanks for looking into this.

Please run the code with the delta parameter set to 0.0, not to 1e-12. The problem shows itself with delta value of 0.0. The solution is to provide a non-zero value for delta, like 1e-12.

When I run it with delta of zero, the code does not return any curves for your example file; with 1e-12 I get the four expected curves.

This is in RH5SR12, by the way.

The problem persists in Rhino 6. In Rhino 5, the untrimmed side of the cylinder still gave an isocurve. Now, for the cylinder in the document no isocurves are returned at all when delta == 0.0.