Intersection between a trimmed surface and a line

Dear colleagues,
I am trying to find intersection between a trimmed surface and a line, using c# common operator:
Rhino.Geometry.Intersect.CurveIntersections Cross = Rhino.Geometry.Intersect.Intersection.CurveSurface(cline, surf, 0.001, tl);

In case “cline” intersect “surf” in the trimmed area CurveSurface() returns a point, but it is not a valid point.
In previous implementation of the same algorithm in RVB script, I used operator:

If Rhino.IsPointOnSurface(arrSurfs(j), arrPoint) Then …

and it solved a problem.
Could anybody be so kind to help me for finding a solution of this problem?

Hi @gstoilov,

Surfaces do not have trims. Trimmed surfaces are represented by Breps, which contain structures which maintain the active/inactive portions of a surface. A Brep face, in other words.

Thus, when you intersect a surface with a curve, you are always evaluating against an untrimmed surface, as surfaces do not have trims.

To intersect a curve and a Brep face, use Intersection.CurveBrepFace.

For example:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  var gs = new GetObject();
  gs.SetCommandPrompt("Select surface");
  gs.GeometryFilter = Rhino.DocObjects.ObjectType.Surface;
  gs.SubObjectSelect = true;
  if (gs.CommandResult() != Result.Success)
    return gs.CommandResult();

  var face = gs.Object(0).Face();
  if (null == face)
    return Result.Failure;

  var gc = new GetObject();
  gc.SetCommandPrompt("Select curve");
  gc.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
  gc.EnablePreSelect(false, true);
  gc.DeselectAllBeforePostSelect = false;
  if (gc.CommandResult() != Result.Success)
    return gc.CommandResult();

  var curve = gc.Object(0).Curve();
  if (null == curve)
    return Result.Failure;

  var tol = doc.ModelAbsoluteTolerance;
  var rc = Intersection.CurveBrepFace(curve, face, tol, out Curve[] outCurves, out Point3d[] outPoints);
  if (rc)
    foreach (var c in outCurves)

    foreach (var pt in outPoints)


  return Result.Success;

– Dale

Thank you for the explanation Dale.

Hi @dale , is possible to find the intersection between a trimmed surface and a line?


Andrés Uribe

HI @auribe,

Yes - see my reply and sample code above.

– Dale

Hi @dale, thank you for your quick reply. However, I was wondering if its possible to do so using Open Nurbs methods. Right now I am using the “GetClosestPoint” method of the ON_Surface class. The method returns the closest point even if it is outside of the trimmed area. My problem is that I need to get only those points that lies inside the trimmed area.
Thanks in advance,

Andrés Uribe

Example: Due to the untrimmed gray surface is bigger, I am getting points outside of it (the expected point should lie only inside)

Hi @auribe,

Since you are using C++, just use the RhinoCurveFaceIntersect utility function to calculate the intersection of your curve and your trimmed Brep face. See rhinoSdkUtilities.h for more details.

Another useful function is RhinoIsPointOnFace, which determines if a point is in the active region of a face. Again, see rhinoSdkUtilities.h for more details.

– Dale