Sketcher: BSpline FreeGCS geometry definition

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

multiplicities, degree and periodic are left as non-parameters of the solver, while still allowing certain manipulations to be effected from the solver
in certain situations (for example modifying the multiplicity of start/end nodes when applying G1,G2,G3 constraints between BSplines).
This commit is contained in:
Abdullah Tahiri 2017-01-04 01:19:18 +01:00
parent b277620138
commit 80adf30da3
2 changed files with 99 additions and 0 deletions

View File

@ -607,4 +607,75 @@ ArcOfParabola* ArcOfParabola::Copy()
return crv;
}
// bspline
DeriVector2 BSpline::CalculateNormal(Point& p, double* derivparam)
{
// place holder
DeriVector2 ret = DeriVector2();
return ret;
}
DeriVector2 BSpline::Value(double u, double du, double* derivparam)
{
// place holder
DeriVector2 ret = DeriVector2();
return ret;
}
int BSpline::PushOwnParams(VEC_pD &pvec)
{
int cnt=0;
for(VEC_P::const_iterator it = poles.begin(); it != poles.end(); ++it) {
pvec.push_back( (*it).x );
pvec.push_back( (*it).y );
}
cnt = cnt + poles.size() * 2;
pvec.insert(pvec.end(), weights.begin(), weights.end());
cnt = cnt + weights.size();
pvec.insert(pvec.end(), knots.begin(), knots.end());
cnt = cnt + knots.size();
pvec.push_back(start.x); cnt++;
pvec.push_back(start.y); cnt++;
pvec.push_back(end.x); cnt++;
pvec.push_back(end.y); cnt++;
return cnt;
}
void BSpline::ReconstructOnNewPvec(VEC_pD &pvec, int &cnt)
{
for(VEC_P::iterator it = poles.begin(); it != poles.end(); ++it) {
(*it).x = pvec[cnt]; cnt++;
(*it).y = pvec[cnt]; cnt++;
}
for(VEC_pD::iterator it = weights.begin(); it != weights.end(); ++it) {
(*it) = pvec[cnt]; cnt++;
}
for(VEC_pD::iterator it = knots.begin(); it != knots.end(); ++it) {
(*it) = pvec[cnt]; cnt++;
}
start.x=pvec[cnt]; cnt++;
start.y=pvec[cnt]; cnt++;
end.x=pvec[cnt]; cnt++;
end.y=pvec[cnt]; cnt++;
}
BSpline* BSpline::Copy()
{
BSpline* crv = new BSpline(*this);
return crv;
}
}//namespace GCS

View File

@ -36,6 +36,8 @@ namespace GCS
double *y;
};
typedef std::vector<Point> VEC_P;
///Class DeriVector2 holds a vector value and its derivative on the
///parameter that the derivatives are being calculated for now. x,y is the
///actual vector (v). dx,dy is a derivative of the vector by a parameter
@ -270,6 +272,32 @@ namespace GCS
virtual ArcOfParabola* Copy();
};
class BSpline: public Curve
{
public:
BSpline(){periodic=false;degree=2;}
virtual ~BSpline(){}
// parameters
VEC_P poles;
VEC_pD weights;
VEC_pD knots;
// dependent parameters (depends on previous parameters,
// but an "arcrules" constraint alike would be required to gain the commodity of simple coincident
// with endpoint constraints)
Point start;
Point end;
// not solver parameters
VEC_I mult;
int degree;
bool periodic;
// interface helpers
DeriVector2 CalculateNormal(Point &p, double* derivparam = 0);
virtual DeriVector2 Value(double u, double du, double* derivparam = 0);
virtual int PushOwnParams(VEC_pD &pvec);
virtual void ReconstructOnNewPvec (VEC_pD &pvec, int &cnt);
virtual BSpline* Copy();
};
} //namespace GCS
#endif // PLANEGCS_GEO_H