Part: Geometry - Add function to trim a B-Spline

================================================

Supports both non-periodic and periodic case
This commit is contained in:
Abdullah Tahiri
2021-01-27 07:51:16 +01:00
committed by abdullahtahiriyo
parent 8be50486af
commit 2afcbff0d6
2 changed files with 33 additions and 0 deletions

View File

@@ -1539,6 +1539,37 @@ bool GeomBSplineCurve::removeKnot(int index, int multiplicity, double tolerance)
}
}
void GeomBSplineCurve::Trim(double u, double v)
{
auto splitUnwrappedBSpline = [this](double u, double v) {
// it makes a copy internally (checked in the source code of OCCT)
auto handle = GeomConvert::SplitBSplineCurve ( myCurve,
u,
v,
Precision::Confusion()
);
setHandle(handle);
};
try {
if(!isPeriodic()) {
splitUnwrappedBSpline(u, v);
}
else { // periodic
if( v < u ) { // wraps over origin
v = v + 1.0; // v needs one extra lap (1.0)
splitUnwrappedBSpline(u, v);
}
else {
splitUnwrappedBSpline(u, v);
}
}
}
catch (Standard_Failure& e) {
THROWM(Base::CADKernelError,e.GetMessageString())
}
}
// Persistence implementer
unsigned int GeomBSplineCurve::getMemSize (void) const