//aKnotMultiplicities = new TColStd_HArray1OfInteger(1,NbKnots);
const Handle(TColStd_HArray1OfInteger)& aKnotMultiplicities = BSCW->KnotMultiplicities();
+ //aKnots = new TColStd_HArray1OfReal(1,NbKnots);
+ const Handle(TColStd_HArray1OfReal)& aKnots = BSCW->Knots();
+ // Count number of unique knots
Standard_Integer i;
- Standard_Integer aFMulDiff = 0,aLMulDiff = 0;
- TColStd_Array1OfInteger Mult(1,NbKnots);
+ Standard_Integer NbUniqueKnots = 0;
+ Standard_Real lastKnot = RealFirst();
for (i=1; i<=NbKnots; ++i) {
- Standard_Integer aCurrentVal = aKnotMultiplicities->Value(i);
+ if (aKnots->Value(i) - lastKnot > Epsilon (Abs(lastKnot))) {
+ NbUniqueKnots++;
+ lastKnot = aKnots->Value(i);
+ }
+ }
+
+ TColStd_Array1OfReal Kn(1,NbUniqueKnots);
+ TColStd_Array1OfInteger Mult(1,NbUniqueKnots);
+ lastKnot = aKnots->Value(1);
+ Kn.SetValue(1, aKnots->Value(1));
+ Mult.SetValue(1, aKnotMultiplicities->Value(1));
+ Standard_Integer pos = 1;
+ for (i=2; i<=NbKnots; i++) {
+ if (aKnots->Value(i) - lastKnot > Epsilon (Abs(lastKnot))) {
+ pos++;
+ Kn.SetValue(pos, aKnots->Value(i));
+ Mult.SetValue(pos, aKnotMultiplicities->Value(i));
+ lastKnot = aKnots->Value(i);
+ }
+ else {
+ // Knot not unique, increase multiplicity
+ Standard_Integer curMult = Mult.Value(pos);
+ Mult.SetValue(pos, curMult + aKnotMultiplicities->Value(i));
+ }
+ }
+
+ Standard_Integer aFMulDiff = 0,aLMulDiff = 0;
+ for (i=1; i<=NbUniqueKnots; ++i) {
+ Standard_Integer aCurrentVal = Mult.Value(i);
if (aCurrentVal > Deg + 1)
{
if (i == 1) aFMulDiff = aCurrentVal - Deg - 1;
return Standard_False;
}
- //aKnots = new TColStd_HArray1OfReal(1,NbKnots);
- const Handle(TColStd_HArray1OfReal)& aKnots = BSCW->Knots();
- TColStd_Array1OfReal Kn(1,NbKnots);
- for (i=1; i<=NbKnots; i++) {
- Kn.SetValue(i,aKnots->Value(i));
- }
-
// --- Does the Curve descriptor LOOKS like a periodic descriptor ? ---
Standard_Integer SumMult = 0;
- for (i=1; i<=NbKnots; i++) {
- SumMult += aKnotMultiplicities->Value(i);
+ for (i=1; i<=NbUniqueKnots; i++) {
+ SumMult += Mult.Value(i);
}
Standard_Boolean shouldBePeriodic;
if (SumMult == (NbPoles + Deg + 1)) {
shouldBePeriodic = Standard_False;
}
- else if ((aKnotMultiplicities->Value(1) ==
- aKnotMultiplicities->Value(NbKnots)) &&
- ((SumMult - aKnotMultiplicities->Value(1)) == NbPoles)) {
+ else if ((Mult.Value(1) ==
+ Mult.Value(NbUniqueKnots)) &&
+ ((SumMult - Mult.Value(1)) == NbPoles)) {
shouldBePeriodic = Standard_True;
}
else { // --- What is that ??? ---