Skip to content

Commit

Permalink
Part: [skip ci] After removing a knot check if the B-spline is still …
Browse files Browse the repository at this point in the history
…valid
  • Loading branch information
wwmayer committed Oct 30, 2020
1 parent 6ebee86 commit 462efda
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Mod/Part/App/Geometry.cpp
Expand Up @@ -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())
}
}
Expand Down

0 comments on commit 462efda

Please sign in to comment.