Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:38

0001 // Created on: 1995-08-28
0002 // Created by: Laurent BOURESCHE
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _PLib_HeaderFile
0018 #define _PLib_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TColStd_Array1OfReal.hxx>
0025 #include <TColStd_Array2OfReal.hxx>
0026 #include <TColgp_Array1OfPnt.hxx>
0027 #include <TColgp_Array1OfPnt2d.hxx>
0028 #include <Standard_Boolean.hxx>
0029 #include <TColgp_Array2OfPnt.hxx>
0030 #include <GeomAbs_Shape.hxx>
0031 class math_Matrix;
0032 
0033 
0034 //! PLib means Polynomial  functions library.  This pk
0035 //! provides  basic       computation    functions for
0036 //! polynomial functions.
0037 //! Note: weight arrays can be passed by pointer for
0038 //! some functions so that NULL pointer is valid.
0039 //! That means no weights passed.
0040 class PLib 
0041 {
0042 public:
0043 
0044   DEFINE_STANDARD_ALLOC
0045 
0046   
0047   //! Used as argument for a non rational functions
0048   inline static TColStd_Array1OfReal* NoWeights()
0049   {
0050     return NULL;
0051   }
0052   
0053   //! Used as argument for a non rational functions
0054   inline static TColStd_Array2OfReal* NoWeights2()
0055   {
0056     return NULL;
0057   }
0058 
0059   //! Copy in FP the coordinates of the poles.
0060   Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt& Poles, TColStd_Array1OfReal& FP);
0061   
0062   //! Copy in FP the coordinates of the poles.
0063   Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, TColStd_Array1OfReal& FP);
0064   
0065   //! Get from FP the coordinates of the poles.
0066   Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt& Poles);
0067   
0068   //! Get from FP the coordinates of the poles.
0069   Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt& Poles, TColStd_Array1OfReal& Weights);
0070   
0071   //! Copy in FP the coordinates of the poles.
0072   Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt2d& Poles, TColStd_Array1OfReal& FP);
0073   
0074   //! Copy in FP the coordinates of the poles.
0075   Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, TColStd_Array1OfReal& FP);
0076   
0077   //! Get from FP the coordinates of the poles.
0078   Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt2d& Poles);
0079   
0080   //! Get from FP the coordinates of the poles.
0081   Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt2d& Poles, TColStd_Array1OfReal& Weights);
0082   
0083   //! Returns the Binomial Cnp. N should be <= BSplCLib::MaxDegree().
0084   Standard_EXPORT static Standard_Real Bin (const Standard_Integer N, const Standard_Integer P);
0085   
0086   //! Computes the derivatives of a ratio at order
0087   //! <N> in dimension <Dimension>.
0088   //!
0089   //! <Ders> is an  array containing the  values  of the
0090   //! input   derivatives from  0 to  Min(<N>,<Degree>).
0091   //! For   orders   higher  than <Degree>    the  inputcd /s2d1/BMDL/
0092   //! derivatives   are assumed to be  0.
0093   //!
0094   //! Content of <Ders> :
0095   //!
0096   //! x(1),x(2),...,x(Dimension),w
0097   //! x'(1),x'(2),...,x'(Dimension),w'
0098   //! x''(1),x''(2),...,x''(Dimension),w''
0099   //!
0100   //! If  <All> is false, only the   derivative at order
0101   //! <N> is computed.  <RDers>  is an array   of length
0102   //! Dimension which will contain the result :
0103   //!
0104   //! x(1)/w , x(2)/w ,  ... derivated <N> times
0105   //!
0106   //! If <All> is  true all the  derivatives up to order
0107   //! <N> are computed.   <RDers> is an array of  length
0108   //! Dimension * (N+1) which will contains :
0109   //!
0110   //! x(1)/w , x(2)/w ,  ...
0111   //! x(1)/w , x(2)/w ,  ... derivated <1> times
0112   //! x(1)/w , x(2)/w ,  ... derivated <2> times
0113   //! ...
0114   //! x(1)/w , x(2)/w ,  ... derivated <N> times
0115   //!
0116   //! Warning: <RDers> must be dimensionned properly.
0117   Standard_EXPORT static void RationalDerivative (const Standard_Integer Degree, const Standard_Integer N, const Standard_Integer Dimension, Standard_Real& Ders, Standard_Real& RDers, const Standard_Boolean All = Standard_True);
0118   
0119   //! Computes DerivativesRequest derivatives of a ratio at
0120   //! of a BSpline function of degree <Degree>
0121   //! dimension <Dimension>.
0122   //!
0123   //! <PolesDerivatives> is an  array containing the  values
0124   //! of the input   derivatives from  0 to  <DerivativeRequest>
0125   //! For   orders   higher  than <Degree>    the  input
0126   //! derivatives   are assumed to be  0.
0127   //!
0128   //! Content of <PoleasDerivatives> :
0129   //!
0130   //! x(1),x(2),...,x(Dimension)
0131   //! x'(1),x'(2),...,x'(Dimension)
0132   //! x''(1),x''(2),...,x''(Dimension)
0133   //!
0134   //! WeightsDerivatives is an array that contains derivatives
0135   //! from 0 to  <DerivativeRequest>
0136   //! After returning from the routine the array
0137   //! RationalDerivatives contains the following
0138   //! x(1)/w , x(2)/w ,  ...
0139   //! x(1)/w , x(2)/w ,  ...   derivated once
0140   //! x(1)/w , x(2)/w ,  ...   twice
0141   //! x(1)/w , x(2)/w ,  ... derivated <DerivativeRequest> times
0142   //!
0143   //! The array RationalDerivatives and PolesDerivatives
0144   //! can be same since the overwrite is non destructive within
0145   //! the algorithm
0146   //!
0147   //! Warning: <RationalDerivates> must be dimensionned properly.
0148   Standard_EXPORT static void RationalDerivatives (const Standard_Integer DerivativesRequest, const Standard_Integer Dimension, Standard_Real& PolesDerivatives, Standard_Real& WeightsDerivatives, Standard_Real& RationalDerivates);
0149   
0150   //! Performs Horner method with synthetic division for derivatives
0151   //! parameter <U>, with <Degree> and <Dimension>.
0152   //! PolynomialCoeff are stored in the following fashion
0153   //! @code
0154   //! c0(1)      c0(2) ....       c0(Dimension)
0155   //! c1(1)      c1(2) ....       c1(Dimension)
0156   //!
0157   //! cDegree(1) cDegree(2) ....  cDegree(Dimension)
0158   //! @endcode
0159   //! where the polynomial is defined as :
0160   //! @code
0161   //! 2                     Degree
0162   //! c0 + c1 X + c2 X  +  ....   cDegree X
0163   //! @endcode
0164   //! Results stores the result in the following format
0165   //! @code
0166   //! f(1)             f(2)  ....     f(Dimension)
0167   //! (1)           (1)              (1)
0168   //! f  (1)        f   (2) ....     f   (Dimension)
0169   //!
0170   //! (DerivativeRequest)            (DerivativeRequest)
0171   //! f  (1)                         f   (Dimension)
0172   //! @endcode
0173   //! this just evaluates the point at parameter U
0174   //!
0175   //! Warning: <Results> and <PolynomialCoeff> must be dimensioned properly
0176   Standard_EXPORT static void EvalPolynomial (const Standard_Real U, const Standard_Integer DerivativeOrder, const Standard_Integer Degree, const Standard_Integer Dimension, Standard_Real& PolynomialCoeff, Standard_Real& Results);
0177   
0178   //! Same as above with DerivativeOrder = 0;
0179   Standard_EXPORT static void NoDerivativeEvalPolynomial (const Standard_Real U, const Standard_Integer Degree, const Standard_Integer Dimension, const Standard_Integer DegreeDimension, Standard_Real& PolynomialCoeff, Standard_Real& Results);
0180   
0181   //! Applies EvalPolynomial twice to evaluate the derivative
0182   //! of orders UDerivativeOrder in U, VDerivativeOrder in V
0183   //! at parameters U,V
0184   //!
0185   //! PolynomialCoeff are stored in the following fashion
0186   //! @code
0187   //! c00(1)  ....       c00(Dimension)
0188   //! c10(1)  ....       c10(Dimension)
0189   //! ....
0190   //! cm0(1)  ....       cm0(Dimension)
0191   //! ....
0192   //! c01(1)  ....       c01(Dimension)
0193   //! c11(1)  ....       c11(Dimension)
0194   //! ....
0195   //! cm1(1)  ....       cm1(Dimension)
0196   //! ....
0197   //! c0n(1)  ....       c0n(Dimension)
0198   //! c1n(1)  ....       c1n(Dimension)
0199   //! ....
0200   //! cmn(1)  ....       cmn(Dimension)
0201   //! @endcode
0202   //! where the polynomial is defined as :
0203   //! @code
0204   //! 2                 m
0205   //! c00 + c10 U + c20 U  +  ....  + cm0 U
0206   //! 2                   m
0207   //! + c01 V + c11 UV + c21 U V  +  ....  + cm1 U  V
0208   //! n               m n
0209   //! + .... + c0n V +  ....  + cmn U V
0210   //! @endcode
0211   //! with m = UDegree and n = VDegree
0212   //!
0213   //! Results stores the result in the following format
0214   //! @code
0215   //! f(1)             f(2)  ....     f(Dimension)
0216   //! @endcode
0217   //! Warning: <Results> and <PolynomialCoeff> must be dimensioned properly
0218   Standard_EXPORT static void EvalPoly2Var (const Standard_Real U, const Standard_Real V, const Standard_Integer UDerivativeOrder, const Standard_Integer VDerivativeOrder, const Standard_Integer UDegree, const Standard_Integer VDegree, const Standard_Integer Dimension, Standard_Real& PolynomialCoeff, Standard_Real& Results);
0219   
0220   //! Performs the Lagrange Interpolation of
0221   //! given series of points with given parameters
0222   //! with the requested derivative order
0223   //! Results will store things in the following format
0224   //! with d = DerivativeOrder
0225   //! @code
0226   //! [0],             [Dimension-1]              : value
0227   //! [Dimension],     [Dimension  + Dimension-1] : first derivative
0228   //!
0229   //! [d *Dimension],  [d*Dimension + Dimension-1]: dth   derivative
0230   //! @endcode
0231   Standard_EXPORT static Standard_Integer EvalLagrange (const Standard_Real U, const Standard_Integer DerivativeOrder, const Standard_Integer Degree, const Standard_Integer Dimension, Standard_Real& ValueArray, Standard_Real& ParameterArray, Standard_Real& Results);
0232   
0233   //! Performs the Cubic Hermite Interpolation of
0234   //! given series of points with given parameters
0235   //! with the requested derivative order.
0236   //! ValueArray stores the value at the first and
0237   //! last parameter. It has the following format :
0238   //! @code
0239   //! [0],             [Dimension-1]              : value at first param
0240   //! [Dimension],     [Dimension  + Dimension-1] : value at last param
0241   //! @endcode
0242   //! Derivative array stores the value of the derivatives
0243   //! at the first parameter and at the last parameter
0244   //! in the following format
0245   //! @code
0246   //! [0],             [Dimension-1]              : derivative at
0247   //! @endcode
0248   //! first param
0249   //! @code
0250   //! [Dimension],     [Dimension  + Dimension-1] : derivative at
0251   //! @endcode
0252   //! last param
0253   //!
0254   //! ParameterArray  stores the first and last parameter
0255   //! in the following format :
0256   //! @code
0257   //! [0] : first parameter
0258   //! [1] : last  parameter
0259   //! @endcode
0260   //!
0261   //! Results will store things in the following format
0262   //! with d = DerivativeOrder
0263   //! @code
0264   //! [0],             [Dimension-1]              : value
0265   //! [Dimension],     [Dimension  + Dimension-1] : first derivative
0266   //!
0267   //! [d *Dimension],  [d*Dimension + Dimension-1]: dth   derivative
0268   //! @endcode
0269   Standard_EXPORT static Standard_Integer EvalCubicHermite (const Standard_Real U, const Standard_Integer DerivativeOrder, const Standard_Integer Dimension, Standard_Real& ValueArray, Standard_Real& DerivativeArray, Standard_Real& ParameterArray, Standard_Real& Results);
0270   
0271   //! This build the coefficient of Hermite's polynomes on
0272   //! [FirstParameter, LastParameter]
0273   //!
0274   //! if j <= FirstOrder+1 then
0275   //!
0276   //! MatrixCoefs[i, j] = ith coefficient of the polynome H0,j-1
0277   //!
0278   //! else
0279   //!
0280   //! MatrixCoefs[i, j] = ith coefficient of the polynome H1,k
0281   //! with k = j - FirstOrder - 2
0282   //!
0283   //! return false if
0284   //! - |FirstParameter| > 100
0285   //! - |LastParameter| > 100
0286   //! - |FirstParameter| +|LastParameter| < 1/100
0287   //! -   |LastParameter - FirstParameter|
0288   //! / (|FirstParameter| +|LastParameter|)  < 1/100
0289   Standard_EXPORT static Standard_Boolean HermiteCoefficients (const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Integer FirstOrder, const Standard_Integer LastOrder, math_Matrix& MatrixCoefs);
0290   
0291   Standard_EXPORT static void CoefficientsPoles (const TColgp_Array1OfPnt& Coefs, const TColStd_Array1OfReal* WCoefs, TColgp_Array1OfPnt& Poles, TColStd_Array1OfReal* WPoles);
0292   
0293   Standard_EXPORT static void CoefficientsPoles (const TColgp_Array1OfPnt2d& Coefs, const TColStd_Array1OfReal* WCoefs, TColgp_Array1OfPnt2d& Poles, TColStd_Array1OfReal* WPoles);
0294   
0295   Standard_EXPORT static void CoefficientsPoles (const TColStd_Array1OfReal& Coefs, const TColStd_Array1OfReal* WCoefs, TColStd_Array1OfReal& Poles, TColStd_Array1OfReal* WPoles);
0296   
0297   Standard_EXPORT static void CoefficientsPoles (const Standard_Integer dim, const TColStd_Array1OfReal& Coefs, const TColStd_Array1OfReal* WCoefs, TColStd_Array1OfReal& Poles, TColStd_Array1OfReal* WPoles);
0298   
0299   Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, TColgp_Array1OfPnt& Coeffs, TColStd_Array1OfReal* WCoeffs);
0300   
0301   Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, TColgp_Array1OfPnt2d& Coeffs, TColStd_Array1OfReal* WCoeffs);
0302   
0303   Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, TColStd_Array1OfReal& Coeffs, TColStd_Array1OfReal* WCoeffs);
0304   
0305   Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, const Standard_Integer dim, TColStd_Array1OfReal& Coeffs, TColStd_Array1OfReal* WCoeffs);
0306   
0307   Standard_EXPORT static void CoefficientsPoles (const TColgp_Array2OfPnt& Coefs, const TColStd_Array2OfReal* WCoefs, TColgp_Array2OfPnt& Poles, TColStd_Array2OfReal* WPoles);
0308   
0309   Standard_EXPORT static void UTrimming (const Standard_Real U1, const Standard_Real U2, TColgp_Array2OfPnt& Coeffs, TColStd_Array2OfReal* WCoeffs);
0310   
0311   Standard_EXPORT static void VTrimming (const Standard_Real V1, const Standard_Real V2, TColgp_Array2OfPnt& Coeffs, TColStd_Array2OfReal* WCoeffs);
0312   
0313   //! Compute the coefficients in the canonical base of the
0314   //! polynomial satisfying the given constraints
0315   //! at the given parameters
0316   //! The array FirstContr(i,j) i=1,Dimension j=0,FirstOrder
0317   //! contains the values of the constraint at parameter FirstParameter
0318   //! idem for LastConstr
0319   Standard_EXPORT static Standard_Boolean HermiteInterpolate (const Standard_Integer Dimension, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Integer FirstOrder, const Standard_Integer LastOrder, const TColStd_Array2OfReal& FirstConstr, const TColStd_Array2OfReal& LastConstr, TColStd_Array1OfReal& Coefficients);
0320   
0321   //! Compute the number of points used for integral
0322   //! computations (NbGaussPoints) and the degree of Jacobi
0323   //! Polynomial (WorkDegree).
0324   //! ConstraintOrder has to be GeomAbs_C0, GeomAbs_C1 or GeomAbs_C2
0325   //! Code: Code d' init. des parametres de discretisation.
0326   //! = -5
0327   //! = -4
0328   //! = -3
0329   //! = -2
0330   //! = -1
0331   //! =  1 calcul rapide avec precision moyenne.
0332   //! =  2 calcul rapide avec meilleure precision.
0333   //! =  3 calcul un peu plus lent avec bonne precision.
0334   //! =  4 calcul lent avec la meilleure precision possible.
0335   Standard_EXPORT static void JacobiParameters (const GeomAbs_Shape ConstraintOrder, const Standard_Integer MaxDegree, const Standard_Integer Code, Standard_Integer& NbGaussPoints, Standard_Integer& WorkDegree);
0336   
0337   //! translates from GeomAbs_Shape to Integer
0338   Standard_EXPORT static Standard_Integer NivConstr (const GeomAbs_Shape ConstraintOrder);
0339   
0340   //! translates from Integer to GeomAbs_Shape
0341   Standard_EXPORT static GeomAbs_Shape ConstraintOrder (const Standard_Integer NivConstr);
0342   
0343   Standard_EXPORT static void EvalLength (const Standard_Integer Degree, const Standard_Integer Dimension, Standard_Real& PolynomialCoeff, const Standard_Real U1, const Standard_Real U2, Standard_Real& Length);
0344   
0345   Standard_EXPORT static void EvalLength (const Standard_Integer Degree, const Standard_Integer Dimension, Standard_Real& PolynomialCoeff, const Standard_Real U1, const Standard_Real U2, const Standard_Real Tol, Standard_Real& Length, Standard_Real& Error);
0346 
0347 };
0348 
0349 #endif // _PLib_HeaderFile