Part: Geometry - Add function to trim a B-Spline
================================================ Supports both non-periodic and periodic case
This commit is contained in:
committed by
abdullahtahiriyo
parent
8be50486af
commit
2afcbff0d6
@@ -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
|
||||
|
||||
@@ -307,6 +307,8 @@ public:
|
||||
void increaseMultiplicity(int index, int multiplicity);
|
||||
bool removeKnot(int index, int multiplicity, double tolerance = Precision::PConfusion());
|
||||
|
||||
void Trim(double u, double v);
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
virtual void Save(Base::Writer &/*writer*/) const;
|
||||
|
||||
Reference in New Issue
Block a user