00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef REEN_APPROXSURFACE_H
00025 #define REEN_APPROXSURFACE_H
00026
00027 #include <TColStd_Array1OfReal.hxx>
00028 #include <TColStd_Array1OfInteger.hxx>
00029 #include <TColgp_Array1OfPnt.hxx>
00030 #include <TColgp_Array2OfPnt.hxx>
00031 #include <TColgp_Array1OfPnt2d.hxx>
00032 #include <Handle_Geom_BSplineSurface.hxx>
00033 #include <math_Matrix.hxx>
00034
00035 #include <Base/Vector3D.h>
00036
00037 namespace Base {
00038 class SequencerLauncher;
00039 }
00040
00041
00042
00043 namespace Reen {
00044
00045 class ReenExport SplineBasisfunction
00046 {
00047 public:
00052 SplineBasisfunction(int iSize);
00053
00060 SplineBasisfunction(TColStd_Array1OfReal& vKnots, int iOrder=1);
00061
00070 SplineBasisfunction(TColStd_Array1OfReal& vKnots, TColStd_Array1OfInteger& vMults, int iSize, int iOrder=1);
00071
00072 virtual ~SplineBasisfunction();
00073
00082 virtual double BasisFunction(int iIndex, double fParam)=0;
00096 virtual void DerivativesOfBasisFunction(int iIndex, int iMaxDer, double fParam,
00097 TColStd_Array1OfReal& Derivat)=0;
00098
00102 virtual double DerivativeOfBasisFunction(int iIndex, int k, double fParam)=0;
00103
00108 virtual void SetKnots(TColStd_Array1OfReal& vKnots, int iOrder=1);
00109
00116 virtual void SetKnots(TColStd_Array1OfReal& vKnots, TColStd_Array1OfInteger& vMults, int iOrder=1);
00117
00118 protected:
00119
00120
00121 TColStd_Array1OfReal _vKnotVector;
00122
00123
00124 int _iOrder;
00125
00126 };
00127
00128 class ReenExport BSplineBasis : public SplineBasisfunction
00129 {
00130 public:
00131
00136 BSplineBasis(int iSize);
00137
00144 BSplineBasis(TColStd_Array1OfReal& vKnots, int iOrder=1);
00145
00154 BSplineBasis(TColStd_Array1OfReal& vKnots, TColStd_Array1OfInteger& vMults, int iSize, int iOrder=1);
00155
00161 virtual int FindSpan(double fParam);
00162
00174 virtual void AllBasisFunctions(double fParam, TColStd_Array1OfReal& vFuncVals);
00175
00183 virtual double BasisFunction(int iIndex, double fParam);
00184
00196 virtual void DerivativesOfBasisFunction(int iIndex, int iMaxDer, double fParam,
00197 TColStd_Array1OfReal& Derivat);
00198
00202 virtual double DerivativeOfBasisFunction(int iIndex, int k, double fParam);
00203
00209 virtual double GetIntegralOfProductOfBSplines(int i, int j, int r, int s);
00210
00214 virtual~ BSplineBasis();
00215
00216 protected:
00217
00222 virtual void GenerateRootsAndWeights(TColStd_Array1OfReal& vAbscissas, TColStd_Array1OfReal& vWeights);
00223
00227 virtual void FindIntegrationArea(int iIdx1, int iIdx2, int& iBegin, int& iEnd);
00228
00233 int CalcSize(int r, int s);
00234 };
00235
00236 class ReenExport ParameterCorrection
00237 {
00238
00239 public:
00240
00241 ParameterCorrection(
00242 unsigned short usUOrder=4,
00243 unsigned short usVOrder=4,
00244 unsigned short usUCtrlpoints=6,
00245 unsigned short usVCtrlpoints=6);
00246
00247 virtual ~ParameterCorrection()
00248 {
00249 delete _pvcPoints;
00250 delete _pvcUVParam;
00251 };
00252
00253 protected:
00257 virtual void CalcEigenvectors();
00258
00266 virtual bool DoInitialParameterCorrection(float fSizeFactor=0.0f);
00267
00271 virtual bool GetUVParameters(float fSizeFactor);
00272
00276 virtual void DoParameterCorrection(unsigned short usIter)=0;
00277
00281 virtual bool SolveWithoutSmoothing()=0;
00282
00286 virtual bool SolveWithSmoothing(float fWeight)=0;
00287
00288 public:
00292 virtual Handle_Geom_BSplineSurface CreateSurface(
00293 const TColgp_Array1OfPnt& points,
00294 unsigned short usIter,
00295 bool bParaCor,
00296 float fSizeFactor=0.0f);
00301 virtual void SetUVW(const Base::Vector3f& clU, const Base::Vector3f& clV, const Base::Vector3f& clW, bool bUseDir=true);
00302
00306 virtual void GetUVW(Base::Vector3f& clU, Base::Vector3f& clV, Base::Vector3f& clW) const;
00307
00311 virtual Base::Vector3f GetGravityPoint() const;
00312
00316 virtual void EnableSmoothing(bool bSmooth=true, float fSmoothInfl=1.0f);
00317
00318 protected:
00319 bool _bGetUVDir;
00320 bool _bSmoothing;
00321 float _fSmoothInfluence;
00322 unsigned short _usUOrder;
00323 unsigned short _usVOrder;
00324 unsigned short _usUCtrlpoints;
00325 unsigned short _usVCtrlpoints;
00326 Base::Vector3f _clU;
00327 Base::Vector3f _clV;
00328 Base::Vector3f _clW;
00329 TColgp_Array1OfPnt* _pvcPoints;
00330 TColgp_Array1OfPnt2d* _pvcUVParam;
00331 TColgp_Array2OfPnt _vCtrlPntsOfSurf;
00332 TColStd_Array1OfReal _vUKnots;
00333 TColStd_Array1OfReal _vVKnots;
00334 TColStd_Array1OfInteger _vUMults;
00335 TColStd_Array1OfInteger _vVMults;
00336 };
00337
00339
00348 class ReenExport BSplineParameterCorrection : public ParameterCorrection
00349 {
00350
00351 public:
00352
00353 BSplineParameterCorrection(
00354 unsigned short usUOrder=4,
00355 unsigned short usVOrder=4,
00356 unsigned short usUCtrlpoints=6,
00357 unsigned short usVCtrlpoints=6);
00358
00359 virtual ~BSplineParameterCorrection(){};
00360
00361 protected:
00365 virtual void Init();
00366
00370 virtual void DoParameterCorrection(unsigned short usIter);
00371
00375 virtual bool SolveWithoutSmoothing();
00376
00381 virtual bool SolveWithSmoothing(float fWeight);
00382
00383 public:
00387 void SetUKnots(const std::vector<float>& afKnots);
00388
00392 void SetVKnots(const std::vector<float>& afKnots);
00393
00397 virtual const math_Matrix& GetFirstSmoothMatrix() const;
00398
00402 virtual const math_Matrix& GetSecondSmoothMatrix() const;
00403
00407 virtual const math_Matrix& GetThirdSmoothMatrix() const;
00408
00412 virtual void SetFirstSmoothMatrix(const math_Matrix& rclMat);
00413
00417 virtual void SetSecondSmoothMatrix(const math_Matrix& rclMat);
00418
00422 virtual void SetThirdSmoothMatrix(const math_Matrix& rclMat);
00423
00427 virtual void EnableSmoothing(bool bSmooth=true, float fSmoothInfl=1.0f);
00428
00432 virtual void EnableSmoothing(bool bSmooth, float fSmoothInfl,
00433 float fFirst, float fSec, float fThird);
00434
00435 protected:
00440 virtual void CalcSmoothingTerms(bool bRecalc, float fFirst, float fSecond, float fThird);
00441
00446 virtual void CalcFirstSmoothMatrix(Base::SequencerLauncher&);
00447
00452 virtual void CalcSecondSmoothMatrix(Base::SequencerLauncher&);
00453
00457 virtual void CalcThirdSmoothMatrix(Base::SequencerLauncher&);
00458
00459 protected:
00460 BSplineBasis _clUSpline;
00461 BSplineBasis _clVSpline;
00462 math_Matrix _clSmoothMatrix;
00463 math_Matrix _clFirstMatrix;
00464 math_Matrix _clSecondMatrix;
00465 math_Matrix _clThirdMatrix;
00466 };
00467
00468 }
00469
00470 #endif // REEN_APPROXSURFACE_H