#define No_Standard_DimensionError
-#include <BSplCLib.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_Geometry.hxx>
#include <gp.hxx>
//purpose :
//=======================================================================
-Geom_BezierCurve::Geom_BezierCurve(const TColgp_Array1OfPnt& Poles):
-validcache(0), parametercache(0.), spanlenghtcache(1.)
+Geom_BezierCurve::Geom_BezierCurve(const TColgp_Array1OfPnt& Poles)
{
Standard_Integer nbpoles = Poles.Length();
if(nbpoles < 2 || nbpoles > (Geom_BezierCurve::MaxDegree() + 1))
//=======================================================================
Geom_BezierCurve::Geom_BezierCurve(const TColgp_Array1OfPnt& Poles,
- const TColStd_Array1OfReal& Weights):
- validcache(0), parametercache(0.), spanlenghtcache(1.)
+ const TColStd_Array1OfReal& Weights)
{
// copy the poles
Standard_Integer nbpoles = Poles.Length();
cweights(nbpoles-i+1) = w;
}
}
-
- UpdateCoefficients();
}
//=======================================================================
{
closed = (Abs(Value(U1).Distance (Value(U2))) <= Precision::Confusion());
- if(!CoefficientsOK(0.)) UpdateCoefficients(0.);
+ TColStd_Array1OfReal bidflatknots(BSplCLib::FlatBezierKnots(Degree()), 1, 2 * (Degree() + 1));
+ TColgp_HArray1OfPnt coeffs(1, poles->Size());
if (IsRational()) {
- PLib::Trimming(U1,U2,coeffs->ChangeArray1(),
- &wcoeffs->ChangeArray1());
- PLib::CoefficientsPoles(coeffs->Array1(),
- &wcoeffs->Array1(),
- poles->ChangeArray1(),
- &weights->ChangeArray1());
+ TColStd_Array1OfReal wcoeffs(1, poles->Size());
+ BSplCLib::BuildCache(0.0, 1.0, 0, Degree(), bidflatknots,
+ poles->Array1(), &weights->Array1(), coeffs, &wcoeffs);
+ PLib::Trimming(U1, U2, coeffs, &wcoeffs);
+ PLib::CoefficientsPoles(coeffs, &wcoeffs, poles->ChangeArray1(), &weights->ChangeArray1());
}
else {
- PLib::Trimming(U1,U2,coeffs->ChangeArray1(), PLib::NoWeights());
- PLib::CoefficientsPoles(coeffs->Array1(), PLib::NoWeights(),
- poles->ChangeArray1(), PLib::NoWeights());
+ BSplCLib::BuildCache(0.0, 1.0, 0, Degree(), bidflatknots,
+ poles->Array1(), BSplCLib::NoWeights(), coeffs, BSplCLib::NoWeights());
+ PLib::Trimming(U1, U2, coeffs, PLib::NoWeights());
+ PLib::CoefficientsPoles(coeffs, PLib::NoWeights(), poles->ChangeArray1(), PLib::NoWeights());
}
- UpdateCoefficients();
}
//=======================================================================
if (Index == 1 || Index == cpoles.Length()) {
closed = (cpoles(1).Distance(cpoles(NbPoles())) <= Precision::Confusion());
}
- UpdateCoefficients();
}
//=======================================================================
// set weights of 1.
weights = new TColStd_HArray1OfReal(1,nbpoles);
- wcoeffs = new TColStd_HArray1OfReal(1,nbpoles);
weights->Init(1.);
}
cweights(Index) = Weight;
// is it turning into non rational
- if (wasrat) {
- if (!Rational(cweights)) {
- weights.Nullify();
- wcoeffs.Nullify();
- }
- }
- UpdateCoefficients();
+ if (wasrat && !Rational(cweights))
+ weights.Nullify();
}
//=======================================================================
void Geom_BezierCurve::D0 (const Standard_Real U, gp_Pnt& P ) const
{
- // Idee lumineuse sacrifiee sur l autel des performances.
- //
- // if(!CoefficientsOK(U))
- // ((Geom_BezierCurve*)(void*)this)->UpdateCoefficients(U);
- if (IsRational())
- BSplCLib::CacheD0(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- &wcoeffs->Array1(),
- P);
- else
- BSplCLib::CacheD0(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(), BSplCLib::NoWeights(), P);
+ BSplCLib::D0(U, Poles(), Weights(), P);
}
//=======================================================================
void Geom_BezierCurve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const
{
- // Idee lumineuse sacrifiee sur l autel des performances.
- //
- // if(!CoefficientsOK(U))
- // ((Geom_BezierCurve*)(void*)this)->UpdateCoefficients(U);
- if (IsRational())
- BSplCLib::CacheD1(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- &wcoeffs->Array1(),
- P,V1);
- else
- BSplCLib::CacheD1(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- BSplCLib::NoWeights(),
- P,V1);
+ BSplCLib::D1(U, Poles(), Weights(), P, V1);
}
//=======================================================================
gp_Vec& V1,
gp_Vec& V2) const
{
- // Idee lumineuse sacrifiee sur l autel des performances.
- //
- // if(!CoefficientsOK(U))
- // ((Geom_BezierCurve*)(void*)this)->UpdateCoefficients(U);
- if (IsRational())
- BSplCLib::CacheD2(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- &wcoeffs->Array1(),
- P,V1,V2);
- else
- BSplCLib::CacheD2(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- BSplCLib::NoWeights(),
- P,V1,V2);
+ BSplCLib::D2(U, Poles(), Weights(), P, V1, V2);
}
//=======================================================================
gp_Vec& V2,
gp_Vec& V3) const
{
- if(!CoefficientsOK(U))
- ((Geom_BezierCurve*)(void*)this)->UpdateCoefficients(U);
- if (IsRational())
- BSplCLib::CacheD3(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- &wcoeffs->Array1(),
- P,V1,V2,V3);
- else
- BSplCLib::CacheD3(U,Degree(),parametercache,spanlenghtcache,
- coeffs->Array1(),
- BSplCLib::NoWeights(),
- P,V1,V2,V3);
+ BSplCLib::D3(U, Poles(), Weights(), P, V1, V2, V3);
}
//=======================================================================
for (Standard_Integer i = 1; i <= nbpoles; i++)
cpoles (i).Transform(T);
-
- UpdateCoefficients();
}
//=======================================================================
// set fields
poles = Poles;
- coeffs = new TColgp_HArray1OfPnt (1,nbpoles);
- if (rational) {
+ if (rational)
weights = Weights;
- wcoeffs = new TColStd_HArray1OfReal (1, nbpoles, 0.0);
- }
- else {
- weights.Nullify();
- wcoeffs.Nullify();
- }
-
- UpdateCoefficients();
-}
-
-//=======================================================================
-//function : CoefficientsOK
-//purpose :
-//=======================================================================
-
-Standard_Boolean Geom_BezierCurve::CoefficientsOK(const Standard_Real U)const
-{
- return (validcache && ((parametercache == 0. && U < 1.) ||
- (parametercache == 1. && U >= 1.)));
-}
-
-//=======================================================================
-//function : UpdateCoefficients
-//purpose :
-//=======================================================================
-
-//void Geom_BezierCurve::UpdateCoefficients(const Standard_Real U)
-void Geom_BezierCurve::UpdateCoefficients(const Standard_Real )
-{
- maxderivinvok = 0;
- parametercache = 0.;
- //
- // Idee lumineuse sacrifiee sur l autel des performances.
- // if (U >= 1.) parametercache = 1.;
- TColStd_Array1OfReal bidflatknots(BSplCLib::FlatBezierKnots(Degree()),
- 1, 2*(Degree()+1));
- if (IsRational())
- BSplCLib::BuildCache(parametercache,spanlenghtcache,0,Degree(),
- bidflatknots,poles->Array1(),
- &weights->Array1(),
- coeffs->ChangeArray1(),
- &wcoeffs->ChangeArray1());
else
- BSplCLib::BuildCache(parametercache,spanlenghtcache,0,Degree(),
- bidflatknots,poles->Array1(),
- BSplCLib::NoWeights(),
- coeffs->ChangeArray1(),
- BSplCLib::NoWeights());
- validcache = 1;
+ weights.Nullify();
}