|
|
|||
File indexing completed on 2026-09-16 09:18:20
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 <NCollection_Array1.hxx> 0025 #include <NCollection_Array2.hxx> 0026 #include <gp_Pnt.hxx> 0027 #include <gp_Pnt2d.hxx> 0028 #include <Standard_Boolean.hxx> 0029 #include <GeomAbs_Shape.hxx> 0030 class math_Matrix; 0031 0032 //! PLib means Polynomial functions library. This pk 0033 //! provides basic computation functions for 0034 //! polynomial functions. 0035 //! Note: weight arrays can be passed by pointer for 0036 //! some functions so that NULL pointer is valid. 0037 //! That means no weights passed. 0038 class PLib 0039 { 0040 public: 0041 DEFINE_STANDARD_ALLOC 0042 0043 //! Used as argument for a non rational functions 0044 inline static NCollection_Array1<double>* NoWeights() { return nullptr; } 0045 0046 //! Used as argument for a non rational functions 0047 inline static NCollection_Array2<double>* NoWeights2() { return nullptr; } 0048 0049 //! Copy in FP the coordinates of the poles. 0050 Standard_EXPORT static void SetPoles(const NCollection_Array1<gp_Pnt>& Poles, 0051 NCollection_Array1<double>& FP); 0052 0053 //! Copy in FP the coordinates of the poles. 0054 Standard_EXPORT static void SetPoles(const NCollection_Array1<gp_Pnt>& Poles, 0055 const NCollection_Array1<double>& Weights, 0056 NCollection_Array1<double>& FP); 0057 0058 //! Get from FP the coordinates of the poles. 0059 Standard_EXPORT static void GetPoles(const NCollection_Array1<double>& FP, 0060 NCollection_Array1<gp_Pnt>& Poles); 0061 0062 //! Get from FP the coordinates of the poles. 0063 Standard_EXPORT static void GetPoles(const NCollection_Array1<double>& FP, 0064 NCollection_Array1<gp_Pnt>& Poles, 0065 NCollection_Array1<double>& Weights); 0066 0067 //! Copy in FP the coordinates of the poles. 0068 Standard_EXPORT static void SetPoles(const NCollection_Array1<gp_Pnt2d>& Poles, 0069 NCollection_Array1<double>& FP); 0070 0071 //! Copy in FP the coordinates of the poles. 0072 Standard_EXPORT static void SetPoles(const NCollection_Array1<gp_Pnt2d>& Poles, 0073 const NCollection_Array1<double>& Weights, 0074 NCollection_Array1<double>& FP); 0075 0076 //! Get from FP the coordinates of the poles. 0077 Standard_EXPORT static void GetPoles(const NCollection_Array1<double>& FP, 0078 NCollection_Array1<gp_Pnt2d>& Poles); 0079 0080 //! Get from FP the coordinates of the poles. 0081 Standard_EXPORT static void GetPoles(const NCollection_Array1<double>& FP, 0082 NCollection_Array1<gp_Pnt2d>& Poles, 0083 NCollection_Array1<double>& Weights); 0084 0085 //! Returns the Binomial Cnp. N should be <= BSplCLib::MaxDegree(). 0086 Standard_EXPORT static double Bin(const int N, const int P); 0087 0088 //! Computes the derivatives of a ratio at order 0089 //! <N> in dimension <Dimension>. 0090 //! 0091 //! <Ders> is an array containing the values of the 0092 //! input derivatives from 0 to std::min(<N>,<Degree>). 0093 //! For orders higher than <Degree> the inputcd /s2d1/BMDL/ 0094 //! derivatives are assumed to be 0. 0095 //! 0096 //! Content of <Ders>: 0097 //! 0098 //! x(1),x(2),...,x(Dimension),w 0099 //! x'(1),x'(2),...,x'(Dimension),w' 0100 //! x''(1),x''(2),...,x''(Dimension),w'' 0101 //! 0102 //! If <All> is false, only the derivative at order 0103 //! <N> is computed. <RDers> is an array of length 0104 //! Dimension which will contain the result: 0105 //! 0106 //! x(1)/w , x(2)/w , ... derivated <N> times 0107 //! 0108 //! If <All> is true all the derivatives up to order 0109 //! <N> are computed. <RDers> is an array of length 0110 //! Dimension * (N+1) which will contains: 0111 //! 0112 //! x(1)/w , x(2)/w , ... 0113 //! x(1)/w , x(2)/w , ... derivated <1> times 0114 //! x(1)/w , x(2)/w , ... derivated <2> times 0115 //! ... 0116 //! x(1)/w , x(2)/w , ... derivated <N> times 0117 //! 0118 //! Warning: <RDers> must be dimensioned properly. 0119 Standard_EXPORT static void RationalDerivative(const int Degree, 0120 const int N, 0121 const int Dimension, 0122 double& Ders, 0123 double& RDers, 0124 const bool All = true); 0125 0126 //! Computes DerivativesRequest derivatives of a ratio at 0127 //! of a BSpline function of degree <Degree> 0128 //! dimension <Dimension>. 0129 //! 0130 //! <PolesDerivatives> is an array containing the values 0131 //! of the input derivatives from 0 to <DerivativeRequest> 0132 //! For orders higher than <Degree> the input 0133 //! derivatives are assumed to be 0. 0134 //! 0135 //! Content of <PoleasDerivatives> : 0136 //! 0137 //! x(1),x(2),...,x(Dimension) 0138 //! x'(1),x'(2),...,x'(Dimension) 0139 //! x''(1),x''(2),...,x''(Dimension) 0140 //! 0141 //! WeightsDerivatives is an array that contains derivatives 0142 //! from 0 to <DerivativeRequest> 0143 //! After returning from the routine the array 0144 //! RationalDerivatives contains the following 0145 //! x(1)/w , x(2)/w , ... 0146 //! x(1)/w , x(2)/w , ... derivated once 0147 //! x(1)/w , x(2)/w , ... twice 0148 //! x(1)/w , x(2)/w , ... derivated <DerivativeRequest> times 0149 //! 0150 //! The array RationalDerivatives and PolesDerivatives 0151 //! can be same since the overwrite is non destructive within 0152 //! the algorithm 0153 //! 0154 //! Warning: <RationalDerivates> must be dimensioned properly. 0155 Standard_EXPORT static void RationalDerivatives(const int DerivativesRequest, 0156 const int Dimension, 0157 double& PolesDerivatives, 0158 double& WeightsDerivatives, 0159 double& RationalDerivates); 0160 0161 //! Performs Horner method with synthetic division for derivatives 0162 //! parameter <U>, with <Degree> and <Dimension>. 0163 //! PolynomialCoeff are stored in the following fashion 0164 //! @code 0165 //! c0(1) c0(2) .... c0(Dimension) 0166 //! c1(1) c1(2) .... c1(Dimension) 0167 //! 0168 //! cDegree(1) cDegree(2) .... cDegree(Dimension) 0169 //! @endcode 0170 //! where the polynomial is defined as : 0171 //! @code 0172 //! 2 Degree 0173 //! c0 + c1 X + c2 X + .... cDegree X 0174 //! @endcode 0175 //! Results stores the result in the following format 0176 //! @code 0177 //! f(1) f(2) .... f(Dimension) 0178 //! (1) (1) (1) 0179 //! f (1) f (2) .... f (Dimension) 0180 //! 0181 //! (DerivativeRequest) (DerivativeRequest) 0182 //! f (1) f (Dimension) 0183 //! @endcode 0184 //! this just evaluates the point at parameter U 0185 //! 0186 //! Warning: <Results> and <PolynomialCoeff> must be dimensioned properly 0187 Standard_EXPORT static void EvalPolynomial(const double U, 0188 const int DerivativeOrder, 0189 const int Degree, 0190 const int Dimension, 0191 const double& PolynomialCoeff, 0192 double& Results); 0193 0194 //! Same as above with DerivativeOrder = 0; 0195 Standard_EXPORT static void NoDerivativeEvalPolynomial(const double U, 0196 const int Degree, 0197 const int Dimension, 0198 const int DegreeDimension, 0199 const double& PolynomialCoeff, 0200 double& Results); 0201 0202 //! Applies EvalPolynomial twice to evaluate the derivative 0203 //! of orders UDerivativeOrder in U, VDerivativeOrder in V 0204 //! at parameters U,V 0205 //! 0206 //! PolynomialCoeff are stored in the following fashion 0207 //! @code 0208 //! c00(1) .... c00(Dimension) 0209 //! c10(1) .... c10(Dimension) 0210 //! .... 0211 //! cm0(1) .... cm0(Dimension) 0212 //! .... 0213 //! c01(1) .... c01(Dimension) 0214 //! c11(1) .... c11(Dimension) 0215 //! .... 0216 //! cm1(1) .... cm1(Dimension) 0217 //! .... 0218 //! c0n(1) .... c0n(Dimension) 0219 //! c1n(1) .... c1n(Dimension) 0220 //! .... 0221 //! cmn(1) .... cmn(Dimension) 0222 //! @endcode 0223 //! where the polynomial is defined as : 0224 //! @code 0225 //! 2 m 0226 //! c00 + c10 U + c20 U + .... + cm0 U 0227 //! 2 m 0228 //! + c01 V + c11 UV + c21 U V + .... + cm1 U V 0229 //! n m n 0230 //! + .... + c0n V + .... + cmn U V 0231 //! @endcode 0232 //! with m = UDegree and n = VDegree 0233 //! 0234 //! Results stores the result in the following format 0235 //! @code 0236 //! f(1) f(2) .... f(Dimension) 0237 //! @endcode 0238 //! Warning: <Results> and <PolynomialCoeff> must be dimensioned properly 0239 Standard_EXPORT static void EvalPoly2Var(const double U, 0240 const double V, 0241 const int UDerivativeOrder, 0242 const int VDerivativeOrder, 0243 const int UDegree, 0244 const int VDegree, 0245 const int Dimension, 0246 double& PolynomialCoeff, 0247 double& Results); 0248 0249 //! Performs the Lagrange Interpolation of 0250 //! given series of points with given parameters 0251 //! with the requested derivative order 0252 //! Results will store things in the following format 0253 //! with d = DerivativeOrder 0254 //! @code 0255 //! [0], [Dimension-1] : value 0256 //! [Dimension], [Dimension + Dimension-1] : first derivative 0257 //! 0258 //! [d *Dimension], [d*Dimension + Dimension-1]: dth derivative 0259 //! @endcode 0260 Standard_EXPORT static int EvalLagrange(const double U, 0261 const int DerivativeOrder, 0262 const int Degree, 0263 const int Dimension, 0264 double& ValueArray, 0265 double& ParameterArray, 0266 double& Results); 0267 0268 //! Performs the Cubic Hermite Interpolation of 0269 //! given series of points with given parameters 0270 //! with the requested derivative order. 0271 //! ValueArray stores the value at the first and 0272 //! last parameter. It has the following format : 0273 //! @code 0274 //! [0], [Dimension-1] : value at first param 0275 //! [Dimension], [Dimension + Dimension-1] : value at last param 0276 //! @endcode 0277 //! Derivative array stores the value of the derivatives 0278 //! at the first parameter and at the last parameter 0279 //! in the following format 0280 //! @code 0281 //! [0], [Dimension-1] : derivative at 0282 //! @endcode 0283 //! first param 0284 //! @code 0285 //! [Dimension], [Dimension + Dimension-1] : derivative at 0286 //! @endcode 0287 //! last param 0288 //! 0289 //! ParameterArray stores the first and last parameter 0290 //! in the following format : 0291 //! @code 0292 //! [0] : first parameter 0293 //! [1] : last parameter 0294 //! @endcode 0295 //! 0296 //! Results will store things in the following format 0297 //! with d = DerivativeOrder 0298 //! @code 0299 //! [0], [Dimension-1] : value 0300 //! [Dimension], [Dimension + Dimension-1] : first derivative 0301 //! 0302 //! [d *Dimension], [d*Dimension + Dimension-1]: dth derivative 0303 //! @endcode 0304 Standard_EXPORT static int EvalCubicHermite(const double U, 0305 const int DerivativeOrder, 0306 const int Dimension, 0307 double& ValueArray, 0308 double& DerivativeArray, 0309 double& ParameterArray, 0310 double& Results); 0311 0312 //! This build the coefficient of Hermite's polynomes on 0313 //! [FirstParameter, LastParameter] 0314 //! 0315 //! if j <= FirstOrder+1 then 0316 //! 0317 //! MatrixCoefs[i, j] = ith coefficient of the polynome H0,j-1 0318 //! 0319 //! else 0320 //! 0321 //! MatrixCoefs[i, j] = ith coefficient of the polynome H1,k 0322 //! with k = j - FirstOrder - 2 0323 //! 0324 //! return false if 0325 //! - |FirstParameter| > 100 0326 //! - |LastParameter| > 100 0327 //! - |FirstParameter| +|LastParameter| < 1/100 0328 //! - |LastParameter - FirstParameter| 0329 //! / (|FirstParameter| +|LastParameter|) < 1/100 0330 Standard_EXPORT static bool HermiteCoefficients(const double FirstParameter, 0331 const double LastParameter, 0332 const int FirstOrder, 0333 const int LastOrder, 0334 math_Matrix& MatrixCoefs); 0335 0336 Standard_EXPORT static void CoefficientsPoles(const NCollection_Array1<gp_Pnt>& Coefs, 0337 const NCollection_Array1<double>* WCoefs, 0338 NCollection_Array1<gp_Pnt>& Poles, 0339 NCollection_Array1<double>* WPoles); 0340 0341 Standard_EXPORT static void CoefficientsPoles(const NCollection_Array1<gp_Pnt2d>& Coefs, 0342 const NCollection_Array1<double>* WCoefs, 0343 NCollection_Array1<gp_Pnt2d>& Poles, 0344 NCollection_Array1<double>* WPoles); 0345 0346 Standard_EXPORT static void CoefficientsPoles(const NCollection_Array1<double>& Coefs, 0347 const NCollection_Array1<double>* WCoefs, 0348 NCollection_Array1<double>& Poles, 0349 NCollection_Array1<double>* WPoles); 0350 0351 Standard_EXPORT static void CoefficientsPoles(const int dim, 0352 const NCollection_Array1<double>& Coefs, 0353 const NCollection_Array1<double>* WCoefs, 0354 NCollection_Array1<double>& Poles, 0355 NCollection_Array1<double>* WPoles); 0356 0357 Standard_EXPORT static void Trimming(const double U1, 0358 const double U2, 0359 NCollection_Array1<gp_Pnt>& Coeffs, 0360 NCollection_Array1<double>* WCoeffs); 0361 0362 Standard_EXPORT static void Trimming(const double U1, 0363 const double U2, 0364 NCollection_Array1<gp_Pnt2d>& Coeffs, 0365 NCollection_Array1<double>* WCoeffs); 0366 0367 Standard_EXPORT static void Trimming(const double U1, 0368 const double U2, 0369 NCollection_Array1<double>& Coeffs, 0370 NCollection_Array1<double>* WCoeffs); 0371 0372 Standard_EXPORT static void Trimming(const double U1, 0373 const double U2, 0374 const int dim, 0375 NCollection_Array1<double>& Coeffs, 0376 NCollection_Array1<double>* WCoeffs); 0377 0378 Standard_EXPORT static void CoefficientsPoles(const NCollection_Array2<gp_Pnt>& Coefs, 0379 const NCollection_Array2<double>* WCoefs, 0380 NCollection_Array2<gp_Pnt>& Poles, 0381 NCollection_Array2<double>* WPoles); 0382 0383 Standard_EXPORT static void UTrimming(const double U1, 0384 const double U2, 0385 NCollection_Array2<gp_Pnt>& Coeffs, 0386 NCollection_Array2<double>* WCoeffs); 0387 0388 Standard_EXPORT static void VTrimming(const double V1, 0389 const double V2, 0390 NCollection_Array2<gp_Pnt>& Coeffs, 0391 NCollection_Array2<double>* WCoeffs); 0392 0393 //! Compute the coefficients in the canonical base of the 0394 //! polynomial satisfying the given constraints 0395 //! at the given parameters 0396 //! The array FirstContr(i,j) i=1,Dimension j=0,FirstOrder 0397 //! contains the values of the constraint at parameter FirstParameter 0398 //! idem for LastConstr 0399 Standard_EXPORT static bool HermiteInterpolate(const int Dimension, 0400 const double FirstParameter, 0401 const double LastParameter, 0402 const int FirstOrder, 0403 const int LastOrder, 0404 const NCollection_Array2<double>& FirstConstr, 0405 const NCollection_Array2<double>& LastConstr, 0406 NCollection_Array1<double>& Coefficients); 0407 0408 //! Compute the number of points used for integral 0409 //! computations (NbGaussPoints) and the degree of Jacobi 0410 //! Polynomial (WorkDegree). 0411 //! ConstraintOrder has to be GeomAbs_C0, GeomAbs_C1 or GeomAbs_C2 0412 //! Code: Code d' init. des parametres de discretisation. 0413 //! = -5 0414 //! = -4 0415 //! = -3 0416 //! = -2 0417 //! = -1 0418 //! = 1 calcul rapide avec precision moyenne. 0419 //! = 2 calcul rapide avec meilleure precision. 0420 //! = 3 calcul un peu plus lent avec bonne precision. 0421 //! = 4 calcul lent avec la meilleure precision possible. 0422 Standard_EXPORT static void JacobiParameters(const GeomAbs_Shape ConstraintOrder, 0423 const int MaxDegree, 0424 const int Code, 0425 int& NbGaussPoints, 0426 int& WorkDegree); 0427 0428 //! translates from GeomAbs_Shape to Integer 0429 Standard_EXPORT static int NivConstr(const GeomAbs_Shape ConstraintOrder); 0430 0431 //! translates from Integer to GeomAbs_Shape 0432 Standard_EXPORT static GeomAbs_Shape ConstraintOrder(const int NivConstr); 0433 0434 Standard_EXPORT static void EvalLength(const int Degree, 0435 const int Dimension, 0436 double& PolynomialCoeff, 0437 const double U1, 0438 const double U2, 0439 double& Length); 0440 0441 Standard_EXPORT static void EvalLength(const int Degree, 0442 const int Dimension, 0443 double& PolynomialCoeff, 0444 const double U1, 0445 const double U2, 0446 const double Tol, 0447 double& Length, 0448 double& Error); 0449 }; 0450 0451 #endif // _PLib_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|