I’ve go two surfaces, one surface of revolution which entirely encompasses a nurbs surface. If I try to find the intersection curve it only finds a part of the intersection. This also means I cannot trim the nurbs etc.
Getting the nurb form is not sufficient for this case (@Arjan is my co-worker and we’ve tried to solve this problem using the nurb form already). You actually need to rebuild the surface to get a decent intersection curve. Run the code below and the intersection on the nurb surface is the same as the intersection on the revolve surface.
public Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef sRef;
Result res = RhinoGet.GetOneObject("revolve-srf", false, ObjectType.Surface, out sRef);
if (res != Result.Success)
return res;
doc.Objects.Select(sRef, false);
ObjRef tRef;
res = RhinoGet.GetOneObject("srf-2", false, ObjectType.Surface, out tRef);
if (res != Result.Success)
return res;
Surface revSrf = sRef.Surface();
Surface t = tRef.Surface();
Curve[] cx;
Point3d[] px;
if (Intersection.SurfaceSurface(revSrf, t, doc.ModelAbsoluteTolerance, out cx, out px))
{
if (null != cx)
{
ObjectAttributes a = new ObjectAttributes {Name = "Intersection rev-surface"};
foreach (var c in cx)
{
doc.Objects.AddCurve(c, a);
}
}
}
using (var ns = revSrf.ToNurbsSurface())
{
if (Intersection.SurfaceSurface(ns, t, doc.ModelAbsoluteTolerance, out cx, out px))
{
if (null != cx)
{
ObjectAttributes a = new ObjectAttributes { Name = "Intersection nurbs-surface" };
foreach (var c in cx)
{
doc.Objects.AddCurve(c, a);
}
}
}
}
using (var rebuilt = revSrf.Rebuild(3, 3, 30, 30))
{
if (Intersection.SurfaceSurface(rebuilt, t, doc.ModelAbsoluteTolerance, out cx, out px))
{
if (null != cx)
{
ObjectAttributes a = new ObjectAttributes { Name = "Intersection rebuilt-surface" };
foreach (var c in cx)
{
doc.Objects.AddCurve(c, a);
}
}
}
}
return Result.Success;
}
See attached file, this is one in the same category but has nothing to do with revolved surfaces. Again, due to an incomplete intersection operations like boolean union fail. I only have to slightly nudge the geometry to make it work.