Part: [skip ci] After removing a knot check if the B-spline is still valid

This commit is contained in:
wmayer
2020-10-30 13:55:31 +01:00
parent 6ebee86867
commit 462efdab37

View File

@@ -1400,11 +1400,25 @@ void GeomBSplineCurve::increaseMultiplicity(int index, int multiplicity)
bool GeomBSplineCurve::removeKnot(int index, int multiplicity, double tolerance)
{
try {
Handle(Geom_BSplineCurve) curve = Handle(Geom_BSplineCurve)::DownCast(this->handle());
return curve->RemoveKnot(index, multiplicity, tolerance) == Standard_True;
Handle(Geom_BSplineCurve) curve =Handle(Geom_BSplineCurve)::DownCast(myCurve->Copy());
if (curve->RemoveKnot(index, multiplicity, tolerance)) {
// It can happen that OCCT computes a negative weight but still claims the removal was successful
TColStd_Array1OfReal weights(1, curve->NbPoles());
curve->Weights(weights);
for (Standard_Integer i = weights.Lower(); i <= weights.Upper(); i++) {
double v = weights(i);
if (v <= gp::Resolution())
return false;
}
myCurve = curve;
return true;
}
return false;
}
catch (Standard_Failure& e) {
THROWM(Base::CADKernelError,e.GetMessageString())
}
}