I have the attached file with two curves:
badIntersect.3dm (56.9 KB)
and the following plugin command code:
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using Rhino.Geometry;
using Rhino.Geometry.Intersect;
using Rhino.Input;
using Rhino.Input.Custom;
namespace MyPlugin.Commands
{
public class MyCurveOverlap : Command
{
public MyCurveOverlap()
{
Instance = this;
}
public static MyCurveOverlap Instance { get; private set; }
public override string EnglishName => "MyCurveOverlap";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
Curve c1, c2;
using (GetObject go = new())
{
go.SetCommandPrompt("Choose first curve");
go.GeometryFilter = ObjectType.Curve;
if (go.Get() == GetResult.Cancel)
{
return Result.Cancel;
}
c1 = go.Object(0).Curve();
go.SetCommandPrompt("Choose second curve");
go.EnablePreSelect(false, true);
if (go.Get() == GetResult.Cancel)
{
return Result.Cancel;
}
c2 = go.Object(0).Curve();
}
foreach (IntersectionEvent ie in Intersection.CurveCurve(c1, c2, 0.01, 0.01))
{
if (ie.IsOverlap)
{
doc.Objects.Add(c1.Trim(ie.OverlapA));
doc.Objects.Add(c2.Trim(ie.OverlapB));
}
}
return Result.Success;
}
}
}
When I run the command on the two curves in the file, one of the added interval-trimmed curves is the overlapping portion of the first input curve, while the other is the non-overlapping portion of the second input curve. This happens when you pick the curves in either order (which rules out my suspicion that it had to do with interval wrapping on closed curves). This seems to be a clear bug, so I’d like to have some idea of its cause so I can handle it appropriately until it is fixed. When does this behavior happen and do you have any recommendations for addressing it?
Thanks,
- Russell