When I add a BREP that has surfaces with kinks (in the maritime lingo: knuckles) I usually add it to override the CreaseSplitting setting:
Brep b; //defined elsewhere
doc.Objects.AddBrep(b, null, null, false, false);
But, when I replace an existing BREP with a BREP that has kinks, the BREP is split, even if the new BREP did not have this splitting. This is not what I expect to happen when I use “Replace”, it should respect the input and not tamper with it.
To reproduce, run the command below after setting CreaseSplitting=Yes. Before the replacement, the BREP is not split, but after the replacement it is.
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
NurbsSurface ns = MakeKinkySurface();
Brep b = ns.ToBrep();
const bool asReference = false;
const bool splitKinkySurfaces = false;
Guid g = doc.Objects.AddBrep(b, null, null, asReference, splitKinkySurfaces);
doc.Views.Redraw();
bool replace = false;
RhinoGet.GetBool("Replace", true, "No", "Yes", ref replace);
if (replace)
doc.Objects.Replace(g, b);
doc.Views.Redraw();
return Result.Success;
}
private static NurbsSurface MakeKinkySurface()
{
NurbsSurface ns = NurbsSurface.Create(3, false, 4, 4, 4, 7);
ns.KnotsU[0] = 0;
ns.KnotsU[1] = 0;
ns.KnotsU[2] = 0;
ns.KnotsU[3] = 1;
ns.KnotsU[4] = 1;
ns.KnotsU[5] = 1;
ns.KnotsV[0] = 0;
ns.KnotsV[1] = 0;
ns.KnotsV[2] = 0;
ns.KnotsV[3] = 1;
ns.KnotsV[4] = 1;
ns.KnotsV[5] = 1;
ns.KnotsV[6] = 2;
ns.KnotsV[7] = 2;
ns.KnotsV[8] = 2;
ns.Points.SetControlPoint(0, 0, new Point3d(0, 0, 0));
ns.Points.SetControlPoint(0, 1, new Point3d(16.666666666666664, 0, 0));
ns.Points.SetControlPoint(0, 2, new Point3d(33.333333333333329, 0, 0));
ns.Points.SetControlPoint(0, 3, new Point3d(49.999999999999993, 0, 0));
ns.Points.SetControlPoint(0, 4, new Point3d(66.666666666666657, -23.157838028054677, 0));
ns.Points.SetControlPoint(0, 5, new Point3d(83.333333333333329, -23.157838028054677, 0));
ns.Points.SetControlPoint(0, 6, new Point3d(100, -23.157838028054677, 0));
ns.Points.SetControlPoint(1, 0, new Point3d(0, 3.333333333333333, 5));
ns.Points.SetControlPoint(1, 1, new Point3d(16.666666666666671, 3.3333333333333335, 5));
ns.Points.SetControlPoint(1, 2, new Point3d(33.333333333333343, 3.3333333333333335, 5));
ns.Points.SetControlPoint(1, 3, new Point3d(50.000000000000014, 3.333333333333333, 5));
ns.Points.SetControlPoint(1, 4, new Point3d(66.666666666666686, -19.824504694721345, 5));
ns.Points.SetControlPoint(1, 5, new Point3d(83.333333333333343, -19.824504694721345, 5));
ns.Points.SetControlPoint(1, 6, new Point3d(100, -19.824504694721345, 5));
ns.Points.SetControlPoint(2, 0, new Point3d(0, 6.6666666666666661, 10));
ns.Points.SetControlPoint(2, 1, new Point3d(16.666666666666664, 6.666666666666667, 10));
ns.Points.SetControlPoint(2, 2, new Point3d(33.333333333333329, 6.666666666666667, 10));
ns.Points.SetControlPoint(2, 3, new Point3d(49.999999999999993, 6.6666666666666661, 10));
ns.Points.SetControlPoint(2, 4, new Point3d(66.666666666666657, -16.491171361388012, 10));
ns.Points.SetControlPoint(2, 5, new Point3d(83.333333333333329, -16.491171361388012, 10));
ns.Points.SetControlPoint(2, 6, new Point3d(100, -16.491171361388012, 10));
ns.Points.SetControlPoint(3, 0, new Point3d(0, 10, 15));
ns.Points.SetControlPoint(3, 1, new Point3d(16.666666666666664, 10, 15));
ns.Points.SetControlPoint(3, 2, new Point3d(33.333333333333329, 10, 15));
ns.Points.SetControlPoint(3, 3, new Point3d(49.999999999999993, 10, 15));
ns.Points.SetControlPoint(3, 4, new Point3d(66.666666666666657, -13.157838028054677, 15));
ns.Points.SetControlPoint(3, 5, new Point3d(83.333333333333329, -13.157838028054677, 15));
ns.Points.SetControlPoint(3, 6, new Point3d(100, -13.157838028054677, 15));
return ns;
}