private void adoptKnotsAndMultiplicities(NurbsCurve nc)
{
double tol = (nc.Knots[nc.Knots.Count - 1] - nc.Knots[0]) / Math.Max(1000, nc.Knots.Count) / 1000;
if (nc.IsPeriodic)
{
int kc = 1;
if (nc.Knots[1] - nc.Knots[0] < tol)
kc = 2;
else
{
mKnots.Add(nc.Knots[0] - (nc.Knots[1] - nc.Knots[0]));
mMultiplicities.Add(1);
}
double knot = nc.Knots[0];
for (int icounter = 1; icounter < nc.Knots.Count; icounter++)
{
double t = nc.Knots[icounter];
if ((t - knot) > tol)
{
mKnots.Add(knot);
mMultiplicities.Add(kc);
knot = t;
kc = 1;
}
else
kc++;
}
mKnots.Add(knot);
if (kc > 1)
mMultiplicities.Add(kc + 1);
else
{
mMultiplicities.Add(1);
mKnots.Add(knot + (knot - nc.Knots[nc.Knots.Count - 2]));
mMultiplicities.Add(1);
}
}
else
{
int kc = 2;
double knot = nc.Knots[0];
for (int icounter = 1; icounter < nc.Knots.Count; icounter++)
{
double t = nc.Knots[icounter];
if ((t - knot) > tol)
{
mKnots.Add(knot);
mMultiplicities.Add(kc);
knot = t;
kc = 1;
}
else
kc++;
}
mKnots.Add(knot);
mMultiplicities.Add(kc + 1);
}
}