0031939: Coding - correction of spelling errors in comments [part 10]
[occt.git] / src / PLib / PLib.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-08-28
2// Created by: Laurent BOURESCHE
3// Copyright (c) 1995-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _PLib_HeaderFile
18#define _PLib_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <TColStd_Array1OfReal.hxx>
25#include <TColStd_Array2OfReal.hxx>
26#include <TColgp_Array1OfPnt.hxx>
27#include <TColgp_Array1OfPnt2d.hxx>
28#include <Standard_Real.hxx>
29#include <Standard_Integer.hxx>
30#include <Standard_Boolean.hxx>
31#include <TColgp_Array2OfPnt.hxx>
32#include <GeomAbs_Shape.hxx>
33class math_Matrix;
34class PLib_Base;
35class PLib_JacobiPolynomial;
36class PLib_HermitJacobi;
37class PLib_DoubleJacobiPolynomial;
38
39
40//! PLib means Polynomial functions library. This pk
41//! provides basic computation functions for
42//! polynomial functions.
0e14656b 43//! Note: weight arrays can be passed by pointer for
44//! some functions so that NULL pointer is valid.
45//! That means no weights passed.
42cf5bc1 46class PLib
47{
48public:
49
50 DEFINE_STANDARD_ALLOC
51
52
53 //! Used as argument for a non rational functions
0e14656b 54 inline static TColStd_Array1OfReal* NoWeights()
55 {
56 return NULL;
57 }
42cf5bc1 58
59 //! Used as argument for a non rational functions
0e14656b 60 inline static TColStd_Array2OfReal* NoWeights2()
61 {
62 return NULL;
63 }
64
42cf5bc1 65 //! Copy in FP the coordinates of the poles.
66 Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt& Poles, TColStd_Array1OfReal& FP);
67
68 //! Copy in FP the coordinates of the poles.
69 Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, TColStd_Array1OfReal& FP);
70
71 //! Get from FP the coordinates of the poles.
72 Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt& Poles);
73
74 //! Get from FP the coordinates of the poles.
75 Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt& Poles, TColStd_Array1OfReal& Weights);
76
77 //! Copy in FP the coordinates of the poles.
78 Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt2d& Poles, TColStd_Array1OfReal& FP);
79
80 //! Copy in FP the coordinates of the poles.
81 Standard_EXPORT static void SetPoles (const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, TColStd_Array1OfReal& FP);
82
83 //! Get from FP the coordinates of the poles.
84 Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt2d& Poles);
85
86 //! Get from FP the coordinates of the poles.
87 Standard_EXPORT static void GetPoles (const TColStd_Array1OfReal& FP, TColgp_Array1OfPnt2d& Poles, TColStd_Array1OfReal& Weights);
88
89 //! Returns the Binomial Cnp. N should be <= BSplCLib::MaxDegree().
90 Standard_EXPORT static Standard_Real Bin (const Standard_Integer N, const Standard_Integer P);
91
92 //! Computes the derivatives of a ratio at order
93 //! <N> in dimension <Dimension>.
94 //!
95 //! <Ders> is an array containing the values of the
96 //! input derivatives from 0 to Min(<N>,<Degree>).
97 //! For orders higher than <Degree> the inputcd /s2d1/BMDL/
98 //! derivatives are assumed to be 0.
99 //!
100 //! Content of <Ders> :
101 //!
102 //! x(1),x(2),...,x(Dimension),w
103 //! x'(1),x'(2),...,x'(Dimension),w'
104 //! x''(1),x''(2),...,x''(Dimension),w''
105 //!
106 //! If <All> is false, only the derivative at order
107 //! <N> is computed. <RDers> is an array of length
108 //! Dimension which will contain the result :
109 //!
110 //! x(1)/w , x(2)/w , ... derivated <N> times
111 //!
112 //! If <All> is true all the derivatives up to order
113 //! <N> are computed. <RDers> is an array of length
114 //! Dimension * (N+1) which will contains :
115 //!
116 //! x(1)/w , x(2)/w , ...
117 //! x(1)/w , x(2)/w , ... derivated <1> times
118 //! x(1)/w , x(2)/w , ... derivated <2> times
119 //! ...
120 //! x(1)/w , x(2)/w , ... derivated <N> times
121 //!
122 //! Warning: <RDers> must be dimensionned properly.
123 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);
124
125 //! Computes DerivativesRequest derivatives of a ratio at
126 //! of a BSpline function of degree <Degree>
127 //! dimension <Dimension>.
128 //!
129 //! <PolesDerivatives> is an array containing the values
130 //! of the input derivatives from 0 to <DerivativeRequest>
131 //! For orders higher than <Degree> the input
132 //! derivatives are assumed to be 0.
133 //!
134 //! Content of <PoleasDerivatives> :
135 //!
136 //! x(1),x(2),...,x(Dimension)
137 //! x'(1),x'(2),...,x'(Dimension)
138 //! x''(1),x''(2),...,x''(Dimension)
139 //!
140 //! WeightsDerivatives is an array that contains derivatives
141 //! from 0 to <DerivativeRequest>
142 //! After returning from the routine the array
143 //! RationalDerivatives contains the following
144 //! x(1)/w , x(2)/w , ...
145 //! x(1)/w , x(2)/w , ... derivated once
146 //! x(1)/w , x(2)/w , ... twice
147 //! x(1)/w , x(2)/w , ... derivated <DerivativeRequest> times
148 //!
149 //! The array RationalDerivatives and PolesDerivatives
150 //! can be same since the overwrite is non destructive within
151 //! the algorithm
152 //!
153 //! Warning: <RationalDerivates> must be dimensionned properly.
154 Standard_EXPORT static void RationalDerivatives (const Standard_Integer DerivativesRequest, const Standard_Integer Dimension, Standard_Real& PolesDerivatives, Standard_Real& WeightsDerivatives, Standard_Real& RationalDerivates);
155
316ea293 156 //! Performs Horner method with synthetic division for derivatives
42cf5bc1 157 //! parameter <U>, with <Degree> and <Dimension>.
158 //! PolynomialCoeff are stored in the following fashion
316ea293 159 //! @code
42cf5bc1 160 //! c0(1) c0(2) .... c0(Dimension)
161 //! c1(1) c1(2) .... c1(Dimension)
162 //!
163 //! cDegree(1) cDegree(2) .... cDegree(Dimension)
316ea293 164 //! @endcode
42cf5bc1 165 //! where the polynomial is defined as :
316ea293 166 //! @code
42cf5bc1 167 //! 2 Degree
168 //! c0 + c1 X + c2 X + .... cDegree X
316ea293 169 //! @endcode
42cf5bc1 170 //! Results stores the result in the following format
316ea293 171 //! @code
42cf5bc1 172 //! f(1) f(2) .... f(Dimension)
173 //! (1) (1) (1)
174 //! f (1) f (2) .... f (Dimension)
175 //!
176 //! (DerivativeRequest) (DerivativeRequest)
177 //! f (1) f (Dimension)
316ea293 178 //! @endcode
42cf5bc1 179 //! this just evaluates the point at parameter U
180 //!
181 //! Warning: <Results> and <PolynomialCoeff> must be dimensioned properly
182 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);
183
184 //! Same as above with DerivativeOrder = 0;
185 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);
186
187 //! Applies EvalPolynomial twice to evaluate the derivative
188 //! of orders UDerivativeOrder in U, VDerivativeOrder in V
189 //! at parameters U,V
190 //!
191 //! PolynomialCoeff are stored in the following fashion
316ea293 192 //! @code
42cf5bc1 193 //! c00(1) .... c00(Dimension)
194 //! c10(1) .... c10(Dimension)
195 //! ....
196 //! cm0(1) .... cm0(Dimension)
197 //! ....
198 //! c01(1) .... c01(Dimension)
199 //! c11(1) .... c11(Dimension)
200 //! ....
201 //! cm1(1) .... cm1(Dimension)
202 //! ....
203 //! c0n(1) .... c0n(Dimension)
204 //! c1n(1) .... c1n(Dimension)
205 //! ....
206 //! cmn(1) .... cmn(Dimension)
316ea293 207 //! @endcode
42cf5bc1 208 //! where the polynomial is defined as :
316ea293 209 //! @code
42cf5bc1 210 //! 2 m
211 //! c00 + c10 U + c20 U + .... + cm0 U
212 //! 2 m
213 //! + c01 V + c11 UV + c21 U V + .... + cm1 U V
214 //! n m n
215 //! + .... + c0n V + .... + cmn U V
316ea293 216 //! @endcode
42cf5bc1 217 //! with m = UDegree and n = VDegree
218 //!
219 //! Results stores the result in the following format
316ea293 220 //! @code
42cf5bc1 221 //! f(1) f(2) .... f(Dimension)
316ea293 222 //! @endcode
42cf5bc1 223 //! Warning: <Results> and <PolynomialCoeff> must be dimensioned properly
224 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);
225
226 //! Performs the Lagrange Interpolation of
227 //! given series of points with given parameters
228 //! with the requested derivative order
229 //! Results will store things in the following format
230 //! with d = DerivativeOrder
316ea293 231 //! @code
42cf5bc1 232 //! [0], [Dimension-1] : value
233 //! [Dimension], [Dimension + Dimension-1] : first derivative
234 //!
235 //! [d *Dimension], [d*Dimension + Dimension-1]: dth derivative
316ea293 236 //! @endcode
42cf5bc1 237 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);
238
239 //! Performs the Cubic Hermite Interpolation of
240 //! given series of points with given parameters
241 //! with the requested derivative order.
242 //! ValueArray stores the value at the first and
243 //! last parameter. It has the following format :
316ea293 244 //! @code
42cf5bc1 245 //! [0], [Dimension-1] : value at first param
246 //! [Dimension], [Dimension + Dimension-1] : value at last param
316ea293 247 //! @endcode
42cf5bc1 248 //! Derivative array stores the value of the derivatives
249 //! at the first parameter and at the last parameter
250 //! in the following format
316ea293 251 //! @code
42cf5bc1 252 //! [0], [Dimension-1] : derivative at
316ea293 253 //! @endcode
42cf5bc1 254 //! first param
316ea293 255 //! @code
42cf5bc1 256 //! [Dimension], [Dimension + Dimension-1] : derivative at
316ea293 257 //! @endcode
42cf5bc1 258 //! last param
259 //!
260 //! ParameterArray stores the first and last parameter
261 //! in the following format :
316ea293 262 //! @code
42cf5bc1 263 //! [0] : first parameter
264 //! [1] : last parameter
316ea293 265 //! @endcode
42cf5bc1 266 //!
267 //! Results will store things in the following format
268 //! with d = DerivativeOrder
316ea293 269 //! @code
42cf5bc1 270 //! [0], [Dimension-1] : value
271 //! [Dimension], [Dimension + Dimension-1] : first derivative
272 //!
273 //! [d *Dimension], [d*Dimension + Dimension-1]: dth derivative
316ea293 274 //! @endcode
42cf5bc1 275 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);
276
277 //! This build the coefficient of Hermite's polynomes on
278 //! [FirstParameter, LastParameter]
279 //!
280 //! if j <= FirstOrder+1 then
281 //!
282 //! MatrixCoefs[i, j] = ith coefficient of the polynome H0,j-1
283 //!
284 //! else
285 //!
286 //! MatrixCoefs[i, j] = ith coefficient of the polynome H1,k
287 //! with k = j - FirstOrder - 2
288 //!
289 //! return false if
290 //! - |FirstParameter| > 100
291 //! - |LastParameter| > 100
292 //! - |FirstParameter| +|LastParameter| < 1/100
293 //! - |LastParameter - FirstParameter|
294 //! / (|FirstParameter| +|LastParameter|) < 1/100
295 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);
296
0e14656b 297 Standard_EXPORT static void CoefficientsPoles (const TColgp_Array1OfPnt& Coefs, const TColStd_Array1OfReal* WCoefs, TColgp_Array1OfPnt& Poles, TColStd_Array1OfReal* WPoles);
42cf5bc1 298
0e14656b 299 Standard_EXPORT static void CoefficientsPoles (const TColgp_Array1OfPnt2d& Coefs, const TColStd_Array1OfReal* WCoefs, TColgp_Array1OfPnt2d& Poles, TColStd_Array1OfReal* WPoles);
42cf5bc1 300
0e14656b 301 Standard_EXPORT static void CoefficientsPoles (const TColStd_Array1OfReal& Coefs, const TColStd_Array1OfReal* WCoefs, TColStd_Array1OfReal& Poles, TColStd_Array1OfReal* WPoles);
42cf5bc1 302
0e14656b 303 Standard_EXPORT static void CoefficientsPoles (const Standard_Integer dim, const TColStd_Array1OfReal& Coefs, const TColStd_Array1OfReal* WCoefs, TColStd_Array1OfReal& Poles, TColStd_Array1OfReal* WPoles);
42cf5bc1 304
0e14656b 305 Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, TColgp_Array1OfPnt& Coeffs, TColStd_Array1OfReal* WCoeffs);
42cf5bc1 306
0e14656b 307 Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, TColgp_Array1OfPnt2d& Coeffs, TColStd_Array1OfReal* WCoeffs);
42cf5bc1 308
0e14656b 309 Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, TColStd_Array1OfReal& Coeffs, TColStd_Array1OfReal* WCoeffs);
42cf5bc1 310
0e14656b 311 Standard_EXPORT static void Trimming (const Standard_Real U1, const Standard_Real U2, const Standard_Integer dim, TColStd_Array1OfReal& Coeffs, TColStd_Array1OfReal* WCoeffs);
42cf5bc1 312
0e14656b 313 Standard_EXPORT static void CoefficientsPoles (const TColgp_Array2OfPnt& Coefs, const TColStd_Array2OfReal* WCoefs, TColgp_Array2OfPnt& Poles, TColStd_Array2OfReal* WPoles);
42cf5bc1 314
0e14656b 315 Standard_EXPORT static void UTrimming (const Standard_Real U1, const Standard_Real U2, TColgp_Array2OfPnt& Coeffs, TColStd_Array2OfReal* WCoeffs);
42cf5bc1 316
0e14656b 317 Standard_EXPORT static void VTrimming (const Standard_Real V1, const Standard_Real V2, TColgp_Array2OfPnt& Coeffs, TColStd_Array2OfReal* WCoeffs);
42cf5bc1 318
319 //! Compute the coefficients in the canonical base of the
320 //! polynomial satisfying the given constraints
321 //! at the given parameters
322 //! The array FirstContr(i,j) i=1,Dimension j=0,FirstOrder
323 //! contains the values of the constraint at parameter FirstParameter
324 //! idem for LastConstr
325 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);
326
327 //! Compute the number of points used for integral
328 //! computations (NbGaussPoints) and the degree of Jacobi
329 //! Polynomial (WorkDegree).
330 //! ConstraintOrder has to be GeomAbs_C0, GeomAbs_C1 or GeomAbs_C2
331 //! Code: Code d' init. des parametres de discretisation.
332 //! = -5
333 //! = -4
334 //! = -3
335 //! = -2
336 //! = -1
337 //! = 1 calcul rapide avec precision moyenne.
338 //! = 2 calcul rapide avec meilleure precision.
339 //! = 3 calcul un peu plus lent avec bonne precision.
340 //! = 4 calcul lent avec la meilleure precision possible.
341 Standard_EXPORT static void JacobiParameters (const GeomAbs_Shape ConstraintOrder, const Standard_Integer MaxDegree, const Standard_Integer Code, Standard_Integer& NbGaussPoints, Standard_Integer& WorkDegree);
342
343 //! translates from GeomAbs_Shape to Integer
344 Standard_EXPORT static Standard_Integer NivConstr (const GeomAbs_Shape ConstraintOrder);
345
346 //! translates from Integer to GeomAbs_Shape
347 Standard_EXPORT static GeomAbs_Shape ConstraintOrder (const Standard_Integer NivConstr);
348
349 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);
350
351 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);
352
353
354
355
356protected:
357
358
359
360
361
362private:
363
364
365
366
367friend class PLib_Base;
368friend class PLib_JacobiPolynomial;
369friend class PLib_HermitJacobi;
370friend class PLib_DoubleJacobiPolynomial;
371
372};
373
42cf5bc1 374#endif // _PLib_HeaderFile