Unexpected behavior in Brep.Trim with non-intersecting plane

Hi @Dale, I recently ran into a behavior for the Brep.Trim method when trimming against a plane that does not intersect the brep. From the documentation I would have expected the result of the trim to be different depending on the plane normal (either trimming away everything or keeping everything). Here is a test command. The plane distance seems to have the expected sign. Let me know if I’m misinterpreting, thanks.

public class NonintersectingTrimCommand : Command
{
	public override string EnglishName
	{
		get { return "TestNonintersectingTrim"; }
	}

	protected override Result RunCommand(RhinoDoc doc, RunMode mode)
	{
		Brep brepBox = Brep.CreateFromBox(new Box(Plane.WorldXY, new Interval(0, 1), new Interval(0, 1), new Interval(0, 1)));

		Plane cutter = new Plane(new Point3d(0, 0, 2), Vector3d.ZAxis);
		var trimmedBreps = brepBox.Trim(cutter, doc.ModelAbsoluteTolerance);
		RhinoApp.WriteLine(string.Format("Number of trimmed breps with Z up = {0}", trimmedBreps.Length));
		var dist = cutter.DistanceTo(brepBox.GetBoundingBox(true).Center);
		RhinoApp.WriteLine(string.Format("Sign of distance with Z up = {0}", Math.Sign(dist)));

		cutter = new Plane(new Point3d(0, 0, 2), -Vector3d.ZAxis);
		trimmedBreps = brepBox.Trim(cutter, doc.ModelAbsoluteTolerance);
		RhinoApp.WriteLine(string.Format("Number of trimmed breps with Z down = {0}", trimmedBreps.Length));
		dist = cutter.DistanceTo(brepBox.GetBoundingBox(true).Center);
		RhinoApp.WriteLine(string.Format("Sign of distance with Z down = {0}", Math.Sign(dist)));

		return Result.Success;
	}
}

Hi @LarryL,

I believe for the comments to be valid, trimming must be successful.

– Dale

Ok, thanks Dale.