Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-08-28 |
2 | // Created by: Laurent BOURESCHE | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS | |
5 | // | |
6 | // The content of this file is subject to the Open CASCADE Technology Public | |
7 | // License Version 6.5 (the "License"). You may not use the content of this file | |
8 | // except in compliance with the License. Please obtain a copy of the License | |
9 | // at http://www.opencascade.org and read it completely before using this file. | |
10 | // | |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
13 | // | |
14 | // The Original Code and all software distributed under the License is | |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
16 | // Initial Developer hereby disclaims all such warranties, including without | |
17 | // limitation, any warranties of merchantability, fitness for a particular | |
18 | // purpose or non-infringement. Please see the License for the specific terms | |
19 | // and conditions governing the rights and limitations under the License. | |
20 | ||
7fd59977 | 21 | // Modified: 28/02/1996 by PMN : HermiteCoefficients added |
22 | // Modified: 18/06/1996 by PMN : NULL reference. | |
23 | // Modified: 19/02/1997 by JCT : EvalPoly2Var added | |
24 | ||
7fd59977 | 25 | #include <PLib.ixx> |
f7b4312f | 26 | #include <NCollection_LocalArray.hxx> |
7fd59977 | 27 | #include <math_Matrix.hxx> |
28 | #include <math_Gauss.hxx> | |
29 | #include <Standard_ConstructionError.hxx> | |
30 | #include <GeomAbs_Shape.hxx> | |
31 | ||
105aae76 | 32 | #include <math_Gauss.hxx> |
33 | #include <math.hxx> | |
34 | ||
7fd59977 | 35 | // To convert points array into Real .. |
36 | // ********************************* | |
37 | ||
105aae76 | 38 | //======================================================================= |
39 | //function : SetPoles | |
40 | //purpose : | |
41 | //======================================================================= | |
42 | ||
43 | void PLib::SetPoles(const TColgp_Array1OfPnt2d& Poles, | |
44 | TColStd_Array1OfReal& FP) | |
45 | { | |
46 | Standard_Integer j = FP .Lower(); | |
47 | Standard_Integer PLower = Poles.Lower(); | |
48 | Standard_Integer PUpper = Poles.Upper(); | |
49 | ||
50 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
51 | const gp_Pnt2d& P = Poles(i); | |
52 | FP(j) = P.Coord(1); j++; | |
53 | FP(j) = P.Coord(2); j++; | |
54 | } | |
55 | } | |
56 | ||
57 | //======================================================================= | |
58 | //function : SetPoles | |
59 | //purpose : | |
60 | //======================================================================= | |
61 | ||
62 | void PLib::SetPoles(const TColgp_Array1OfPnt2d& Poles, | |
63 | const TColStd_Array1OfReal& Weights, | |
64 | TColStd_Array1OfReal& FP) | |
65 | { | |
66 | Standard_Integer j = FP .Lower(); | |
67 | Standard_Integer PLower = Poles.Lower(); | |
68 | Standard_Integer PUpper = Poles.Upper(); | |
69 | ||
70 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
71 | Standard_Real w = Weights(i); | |
72 | const gp_Pnt2d& P = Poles(i); | |
73 | FP(j) = P.Coord(1) * w; j++; | |
74 | FP(j) = P.Coord(2) * w; j++; | |
75 | FP(j) = w; j++; | |
76 | } | |
77 | } | |
78 | ||
79 | //======================================================================= | |
80 | //function : GetPoles | |
81 | //purpose : | |
82 | //======================================================================= | |
7fd59977 | 83 | |
105aae76 | 84 | void PLib::GetPoles(const TColStd_Array1OfReal& FP, |
85 | TColgp_Array1OfPnt2d& Poles) | |
86 | { | |
87 | Standard_Integer j = FP .Lower(); | |
88 | Standard_Integer PLower = Poles.Lower(); | |
89 | Standard_Integer PUpper = Poles.Upper(); | |
90 | ||
91 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
92 | gp_Pnt2d& P = Poles(i); | |
93 | P.SetCoord(1,FP(j)); j++; | |
94 | P.SetCoord(2,FP(j)); j++; | |
95 | } | |
96 | } | |
7fd59977 | 97 | |
105aae76 | 98 | //======================================================================= |
99 | //function : GetPoles | |
100 | //purpose : | |
101 | //======================================================================= | |
7fd59977 | 102 | |
105aae76 | 103 | void PLib::GetPoles(const TColStd_Array1OfReal& FP, |
104 | TColgp_Array1OfPnt2d& Poles, | |
105 | TColStd_Array1OfReal& Weights) | |
106 | { | |
107 | Standard_Integer j = FP .Lower(); | |
108 | Standard_Integer PLower = Poles.Lower(); | |
109 | Standard_Integer PUpper = Poles.Upper(); | |
110 | ||
111 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
112 | Standard_Real w = FP(j + 2); | |
113 | Weights(i) = w; | |
114 | gp_Pnt2d& P = Poles(i); | |
115 | P.SetCoord(1,FP(j) / w); j++; | |
116 | P.SetCoord(2,FP(j) / w); j++; | |
117 | j++; | |
118 | } | |
119 | } | |
7fd59977 | 120 | |
105aae76 | 121 | //======================================================================= |
122 | //function : SetPoles | |
123 | //purpose : | |
124 | //======================================================================= | |
7fd59977 | 125 | |
105aae76 | 126 | void PLib::SetPoles(const TColgp_Array1OfPnt& Poles, |
127 | TColStd_Array1OfReal& FP) | |
128 | { | |
129 | Standard_Integer j = FP .Lower(); | |
130 | Standard_Integer PLower = Poles.Lower(); | |
131 | Standard_Integer PUpper = Poles.Upper(); | |
7fd59977 | 132 | |
105aae76 | 133 | for (Standard_Integer i = PLower; i <= PUpper; i++) { |
134 | const gp_Pnt& P = Poles(i); | |
135 | FP(j) = P.Coord(1); j++; | |
136 | FP(j) = P.Coord(2); j++; | |
137 | FP(j) = P.Coord(3); j++; | |
138 | } | |
139 | } | |
140 | ||
141 | //======================================================================= | |
142 | //function : SetPoles | |
143 | //purpose : | |
144 | //======================================================================= | |
145 | ||
146 | void PLib::SetPoles(const TColgp_Array1OfPnt& Poles, | |
147 | const TColStd_Array1OfReal& Weights, | |
148 | TColStd_Array1OfReal& FP) | |
149 | { | |
150 | Standard_Integer j = FP .Lower(); | |
151 | Standard_Integer PLower = Poles.Lower(); | |
152 | Standard_Integer PUpper = Poles.Upper(); | |
153 | ||
154 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
155 | Standard_Real w = Weights(i); | |
156 | const gp_Pnt& P = Poles(i); | |
157 | FP(j) = P.Coord(1) * w; j++; | |
158 | FP(j) = P.Coord(2) * w; j++; | |
159 | FP(j) = P.Coord(3) * w; j++; | |
160 | FP(j) = w; j++; | |
161 | } | |
162 | } | |
163 | ||
164 | //======================================================================= | |
165 | //function : GetPoles | |
166 | //purpose : | |
167 | //======================================================================= | |
168 | ||
169 | void PLib::GetPoles(const TColStd_Array1OfReal& FP, | |
170 | TColgp_Array1OfPnt& Poles) | |
171 | { | |
172 | Standard_Integer j = FP .Lower(); | |
173 | Standard_Integer PLower = Poles.Lower(); | |
174 | Standard_Integer PUpper = Poles.Upper(); | |
175 | ||
176 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
177 | gp_Pnt& P = Poles(i); | |
178 | P.SetCoord(1,FP(j)); j++; | |
179 | P.SetCoord(2,FP(j)); j++; | |
180 | P.SetCoord(3,FP(j)); j++; | |
181 | } | |
182 | } | |
183 | ||
184 | //======================================================================= | |
185 | //function : GetPoles | |
186 | //purpose : | |
187 | //======================================================================= | |
188 | ||
189 | void PLib::GetPoles(const TColStd_Array1OfReal& FP, | |
190 | TColgp_Array1OfPnt& Poles, | |
191 | TColStd_Array1OfReal& Weights) | |
192 | { | |
193 | Standard_Integer j = FP .Lower(); | |
194 | Standard_Integer PLower = Poles.Lower(); | |
195 | Standard_Integer PUpper = Poles.Upper(); | |
196 | ||
197 | for (Standard_Integer i = PLower; i <= PUpper; i++) { | |
198 | Standard_Real w = FP(j + 3); | |
199 | Weights(i) = w; | |
200 | gp_Pnt& P = Poles(i); | |
201 | P.SetCoord(1,FP(j) / w); j++; | |
202 | P.SetCoord(2,FP(j) / w); j++; | |
203 | P.SetCoord(3,FP(j) / w); j++; | |
204 | j++; | |
205 | } | |
206 | } | |
207 | ||
208 | // specialized allocator | |
209 | namespace | |
210 | { | |
7fd59977 | 211 | |
41194117 | 212 | class BinomAllocator |
7fd59977 | 213 | { |
41194117 K |
214 | public: |
215 | ||
216 | //! Main constructor | |
217 | BinomAllocator (const Standard_Integer theMaxBinom) | |
218 | : myBinom (NULL), | |
219 | myMaxBinom (theMaxBinom) | |
220 | { | |
221 | Standard_Integer i, im1, ip1, id2, md2, md3, j, k; | |
222 | Standard_Integer np1 = myMaxBinom + 1; | |
223 | myBinom = new Standard_Integer*[np1]; | |
224 | myBinom[0] = new Standard_Integer[1]; | |
225 | myBinom[0][0] = 1; | |
226 | for (i = 1; i < np1; ++i) | |
227 | { | |
7fd59977 | 228 | im1 = i - 1; |
229 | ip1 = i + 1; | |
230 | id2 = i >> 1; | |
231 | md2 = im1 >> 1; | |
232 | md3 = ip1 >> 1; | |
233 | k = 0; | |
41194117 | 234 | myBinom[i] = new Standard_Integer[ip1]; |
7fd59977 | 235 | |
41194117 K |
236 | for (j = 0; j < id2; ++j) |
237 | { | |
238 | myBinom[i][j] = k + myBinom[im1][j]; | |
239 | k = myBinom[im1][j]; | |
7fd59977 | 240 | } |
241 | j = id2; | |
242 | if (j > md2) j = im1 - j; | |
41194117 | 243 | myBinom[i][id2] = k + myBinom[im1][j]; |
7fd59977 | 244 | |
41194117 K |
245 | for (j = ip1 - md3; j < ip1; j++) |
246 | { | |
247 | myBinom[i][j] = myBinom[i][i - j]; | |
7fd59977 | 248 | } |
249 | } | |
7fd59977 | 250 | } |
7fd59977 | 251 | |
41194117 K |
252 | //! Destructor |
253 | ~BinomAllocator() | |
254 | { | |
255 | // free memory | |
256 | for (Standard_Integer i = 0; i <= myMaxBinom; ++i) | |
257 | { | |
258 | delete[] myBinom[i]; | |
259 | } | |
260 | delete[] myBinom; | |
261 | } | |
7fd59977 | 262 | |
41194117 K |
263 | Standard_Real Value (const Standard_Integer N, |
264 | const Standard_Integer P) const | |
265 | { | |
266 | Standard_OutOfRange_Raise_if (N > myMaxBinom, | |
267 | "PLib, BinomAllocator: requested degree is greater than maximum supported"); | |
268 | return Standard_Real (myBinom[N][P]); | |
7fd59977 | 269 | } |
41194117 K |
270 | |
271 | private: | |
272 | Standard_Integer** myBinom; | |
273 | Standard_Integer myMaxBinom; | |
274 | ||
275 | }; | |
276 | ||
41194117 K |
277 | // we do not call BSplCLib here to avoid Cyclic dependency detection by WOK |
278 | //static BinomAllocator THE_BINOM (BSplCLib::MaxDegree() + 1); | |
279 | static BinomAllocator THE_BINOM (25 + 1); | |
280 | }; | |
281 | ||
282 | //======================================================================= | |
283 | //function : Bin | |
284 | //purpose : | |
285 | //======================================================================= | |
286 | ||
287 | Standard_Real PLib::Bin(const Standard_Integer N, | |
288 | const Standard_Integer P) | |
289 | { | |
290 | return THE_BINOM.Value (N, P); | |
7fd59977 | 291 | } |
292 | ||
293 | //======================================================================= | |
294 | //function : RationalDerivative | |
295 | //purpose : | |
296 | //======================================================================= | |
297 | ||
298 | void PLib::RationalDerivative(const Standard_Integer Degree, | |
299 | const Standard_Integer DerivativeRequest, | |
300 | const Standard_Integer Dimension, | |
301 | Standard_Real& Ders, | |
302 | Standard_Real& RDers, | |
303 | const Standard_Boolean All) | |
304 | { | |
305 | // | |
306 | // Our purpose is to compute f = (u/v) derivated N = DerivativeRequest times | |
307 | // | |
308 | // We Write u = fv | |
309 | // Let C(N,P) be the binomial | |
310 | // | |
311 | // then we have | |
312 | // | |
313 | // (q) (p) (q-p) | |
314 | // u = SUM C (q,p) f v | |
315 | // p = 0 to q | |
316 | // | |
317 | // | |
318 | // Therefore | |
319 | // | |
320 | // | |
321 | // (q) ( (q) (p) (q-p) ) | |
322 | // f = (1/v) ( u - SUM C (q,p) f v ) | |
323 | // ( p = 0 to q-1 ) | |
324 | // | |
325 | // | |
326 | // make arrays for the binomial since computing it each time could raise a performance | |
327 | // issue | |
328 | // As oppose to the method below the <Der> array is organized in the following | |
329 | // fashion : | |
330 | // | |
331 | // u (1) u (2) .... u (Dimension) v (1) | |
332 | // | |
333 | // (1) (1) (1) (1) | |
334 | // u (1) u (2) .... u (Dimension) v (1) | |
335 | // | |
336 | // ............................................ | |
337 | // | |
338 | // (Degree) (Degree) (Degree) (Degree) | |
339 | // u (1) u (2) .... u (Dimension) v (1) | |
340 | // | |
341 | // | |
342 | Standard_Real Inverse; | |
343 | Standard_Real *PolesArray = &Ders; | |
344 | Standard_Real *RationalArray = &RDers; | |
345 | Standard_Real Factor ; | |
346 | Standard_Integer ii, Index, OtherIndex, Index1, Index2, jj; | |
f7b4312f | 347 | NCollection_LocalArray<Standard_Real> binomial_array; |
348 | NCollection_LocalArray<Standard_Real> derivative_storage; | |
7fd59977 | 349 | if (Dimension == 3) { |
350 | Standard_Integer DeRequest1 = DerivativeRequest + 1; | |
351 | Standard_Integer MinDegRequ = DerivativeRequest; | |
352 | if (MinDegRequ > Degree) MinDegRequ = Degree; | |
41194117 | 353 | binomial_array.Allocate (DeRequest1); |
7fd59977 | 354 | |
355 | for (ii = 0 ; ii < DeRequest1 ; ii++) { | |
356 | binomial_array[ii] = 1.0e0 ; | |
357 | } | |
358 | if (!All) { | |
359 | Standard_Integer DimDeRequ1 = (DeRequest1 << 1) + DeRequest1; | |
41194117 | 360 | derivative_storage.Allocate (DimDeRequ1); |
7fd59977 | 361 | RationalArray = derivative_storage ; |
362 | } | |
363 | ||
364 | Inverse = 1.0e0 / PolesArray[3] ; | |
365 | Index = 0 ; | |
366 | Index2 = - 6; | |
367 | OtherIndex = 0 ; | |
368 | ||
369 | for (ii = 0 ; ii <= MinDegRequ ; ii++) { | |
370 | Index2 += 3; | |
371 | Index1 = Index2; | |
372 | RationalArray[Index] = PolesArray[OtherIndex]; Index++; OtherIndex++; | |
373 | RationalArray[Index] = PolesArray[OtherIndex]; Index++; OtherIndex++; | |
374 | RationalArray[Index] = PolesArray[OtherIndex]; | |
375 | Index -= 2; | |
376 | OtherIndex += 2; | |
377 | ||
378 | for (jj = ii - 1 ; jj >= 0 ; jj--) { | |
379 | Factor = binomial_array[jj] * PolesArray[((ii-jj) << 2) + 3]; | |
380 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
381 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
382 | RationalArray[Index] -= Factor * RationalArray[Index1]; | |
383 | Index -= 2; | |
384 | Index1 -= 5; | |
385 | } | |
386 | ||
387 | for (jj = ii ; jj >= 1 ; jj--) { | |
388 | binomial_array[jj] += binomial_array[jj - 1] ; | |
389 | } | |
390 | RationalArray[Index] *= Inverse ; Index++; | |
391 | RationalArray[Index] *= Inverse ; Index++; | |
392 | RationalArray[Index] *= Inverse ; Index++; | |
393 | } | |
394 | ||
395 | for (ii= MinDegRequ + 1; ii <= DerivativeRequest ; ii++){ | |
396 | Index2 += 3; | |
397 | Index1 = Index2; | |
398 | RationalArray[Index] = 0.0e0; Index++; | |
399 | RationalArray[Index] = 0.0e0; Index++; | |
400 | RationalArray[Index] = 0.0e0; | |
401 | Index -= 2; | |
402 | ||
403 | for (jj = ii - 1 ; jj >= ii - MinDegRequ ; jj--) { | |
404 | Factor = binomial_array[jj] * PolesArray[((ii-jj) << 2) + 3]; | |
405 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
406 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
407 | RationalArray[Index] -= Factor * RationalArray[Index1]; | |
408 | Index -= 2; | |
409 | Index1 -= 5; | |
410 | } | |
411 | ||
412 | for (jj = ii ; jj >= 1 ; jj--) { | |
413 | binomial_array[jj] += binomial_array[jj - 1] ; | |
414 | } | |
415 | RationalArray[Index] *= Inverse; Index++; | |
416 | RationalArray[Index] *= Inverse; Index++; | |
417 | RationalArray[Index] *= Inverse; Index++; | |
418 | } | |
419 | ||
420 | if (!All) { | |
421 | RationalArray = &RDers ; | |
422 | Standard_Integer DimDeRequ = (DerivativeRequest << 1) + DerivativeRequest; | |
423 | RationalArray[0] = derivative_storage[DimDeRequ]; DimDeRequ++; | |
424 | RationalArray[1] = derivative_storage[DimDeRequ]; DimDeRequ++; | |
425 | RationalArray[2] = derivative_storage[DimDeRequ]; | |
426 | } | |
427 | } | |
428 | else { | |
429 | Standard_Integer kk; | |
430 | Standard_Integer Dimension1 = Dimension + 1; | |
431 | Standard_Integer Dimension2 = Dimension << 1; | |
432 | Standard_Integer DeRequest1 = DerivativeRequest + 1; | |
433 | Standard_Integer MinDegRequ = DerivativeRequest; | |
434 | if (MinDegRequ > Degree) MinDegRequ = Degree; | |
41194117 | 435 | binomial_array.Allocate (DeRequest1); |
7fd59977 | 436 | |
437 | for (ii = 0 ; ii < DeRequest1 ; ii++) { | |
438 | binomial_array[ii] = 1.0e0 ; | |
439 | } | |
440 | if (!All) { | |
441 | Standard_Integer DimDeRequ1 = Dimension * DeRequest1; | |
41194117 | 442 | derivative_storage.Allocate (DimDeRequ1); |
7fd59977 | 443 | RationalArray = derivative_storage ; |
444 | } | |
445 | ||
446 | Inverse = 1.0e0 / PolesArray[Dimension] ; | |
447 | Index = 0 ; | |
448 | Index2 = - Dimension2; | |
449 | OtherIndex = 0 ; | |
450 | ||
451 | for (ii = 0 ; ii <= MinDegRequ ; ii++) { | |
452 | Index2 += Dimension; | |
453 | Index1 = Index2; | |
454 | ||
455 | for (kk = 0 ; kk < Dimension ; kk++) { | |
456 | RationalArray[Index] = PolesArray[OtherIndex]; Index++; OtherIndex++; | |
457 | } | |
458 | Index -= Dimension; | |
459 | OtherIndex ++;; | |
460 | ||
461 | for (jj = ii - 1 ; jj >= 0 ; jj--) { | |
462 | Factor = binomial_array[jj] * PolesArray[(ii-jj) * Dimension1 + Dimension]; | |
463 | ||
464 | for (kk = 0 ; kk < Dimension ; kk++) { | |
465 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
466 | } | |
467 | Index -= Dimension ; | |
468 | Index1 -= Dimension2 ; | |
469 | } | |
470 | ||
471 | for (jj = ii ; jj >= 1 ; jj--) { | |
472 | binomial_array[jj] += binomial_array[jj - 1] ; | |
473 | } | |
474 | ||
475 | for (kk = 0 ; kk < Dimension ; kk++) { | |
476 | RationalArray[Index] *= Inverse ; Index++; | |
477 | } | |
478 | } | |
479 | ||
480 | for (ii= MinDegRequ + 1; ii <= DerivativeRequest ; ii++){ | |
481 | Index2 += Dimension; | |
482 | Index1 = Index2; | |
483 | ||
484 | for (kk = 0 ; kk < Dimension ; kk++) { | |
485 | RationalArray[Index] = 0.0e0 ; Index++; | |
486 | } | |
487 | Index -= Dimension; | |
488 | ||
489 | for (jj = ii - 1 ; jj >= ii - MinDegRequ ; jj--) { | |
490 | Factor = binomial_array[jj] * PolesArray[(ii-jj) * Dimension1 + Dimension]; | |
491 | ||
492 | for (kk = 0 ; kk < Dimension ; kk++) { | |
493 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
494 | } | |
495 | Index -= Dimension ; | |
496 | Index1 -= Dimension2 ; | |
497 | } | |
498 | ||
499 | for (jj = ii ; jj >= 1 ; jj--) { | |
500 | binomial_array[jj] += binomial_array[jj - 1] ; | |
501 | } | |
502 | ||
503 | for (kk = 0 ; kk < Dimension ; kk++) { | |
504 | RationalArray[Index] *= Inverse; Index++; | |
505 | } | |
506 | } | |
507 | ||
508 | if (!All) { | |
509 | RationalArray = &RDers ; | |
510 | Standard_Integer DimDeRequ = Dimension * DerivativeRequest; | |
511 | ||
512 | for (kk = 0 ; kk < Dimension ; kk++) { | |
513 | RationalArray[kk] = derivative_storage[DimDeRequ]; DimDeRequ++; | |
514 | } | |
515 | } | |
516 | } | |
517 | } | |
518 | ||
519 | //======================================================================= | |
520 | //function : RationalDerivatives | |
521 | //purpose : Uses Homogeneous Poles Derivatives and Deivatives of Weights | |
522 | //======================================================================= | |
523 | ||
524 | void PLib::RationalDerivatives(const Standard_Integer DerivativeRequest, | |
525 | const Standard_Integer Dimension, | |
526 | Standard_Real& PolesDerivates, | |
527 | // must be an array with | |
528 | // (DerivativeRequest + 1) * Dimension slots | |
529 | Standard_Real& WeightsDerivates, | |
530 | // must be an array with | |
531 | // (DerivativeRequest + 1) slots | |
532 | Standard_Real& RationalDerivates) | |
533 | { | |
534 | // | |
535 | // Our purpose is to compute f = (u/v) derivated N times | |
536 | // | |
537 | // We Write u = fv | |
538 | // Let C(N,P) be the binomial | |
539 | // | |
540 | // then we have | |
541 | // | |
542 | // (q) (p) (q-p) | |
543 | // u = SUM C (q,p) f v | |
544 | // p = 0 to q | |
545 | // | |
546 | // | |
547 | // Therefore | |
548 | // | |
549 | // | |
550 | // (q) ( (q) (p) (q-p) ) | |
551 | // f = (1/v) ( u - SUM C (q,p) f v ) | |
552 | // ( p = 0 to q-1 ) | |
553 | // | |
554 | // | |
555 | // make arrays for the binomial since computing it each time could | |
556 | // raize a performance issue | |
557 | // | |
558 | Standard_Real Inverse; | |
559 | Standard_Real *PolesArray = &PolesDerivates; | |
560 | Standard_Real *WeightsArray = &WeightsDerivates; | |
561 | Standard_Real *RationalArray = &RationalDerivates; | |
562 | Standard_Real Factor ; | |
563 | ||
564 | Standard_Integer ii, Index, Index1, Index2, jj; | |
565 | Standard_Integer DeRequest1 = DerivativeRequest + 1; | |
566 | ||
f7b4312f | 567 | NCollection_LocalArray<Standard_Real> binomial_array (DeRequest1); |
568 | NCollection_LocalArray<Standard_Real> derivative_storage; | |
7fd59977 | 569 | |
570 | for (ii = 0 ; ii < DeRequest1 ; ii++) { | |
571 | binomial_array[ii] = 1.0e0 ; | |
572 | } | |
573 | Inverse = 1.0e0 / WeightsArray[0] ; | |
574 | if (Dimension == 3) { | |
575 | Index = 0 ; | |
576 | Index2 = - 6 ; | |
577 | ||
578 | for (ii = 0 ; ii < DeRequest1 ; ii++) { | |
579 | Index2 += 3; | |
580 | Index1 = Index2; | |
581 | RationalArray[Index] = PolesArray[Index] ; Index++; | |
582 | RationalArray[Index] = PolesArray[Index] ; Index++; | |
583 | RationalArray[Index] = PolesArray[Index] ; | |
584 | Index -= 2; | |
585 | ||
586 | for (jj = ii - 1 ; jj >= 0 ; jj--) { | |
587 | Factor = binomial_array[jj] * WeightsArray[ii - jj] ; | |
588 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
589 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
590 | RationalArray[Index] -= Factor * RationalArray[Index1]; | |
591 | Index -= 2; | |
592 | Index1 -= 5; | |
593 | } | |
594 | ||
595 | for (jj = ii ; jj >= 1 ; jj--) { | |
596 | binomial_array[jj] += binomial_array[jj - 1] ; | |
597 | } | |
598 | RationalArray[Index] *= Inverse ; Index++; | |
599 | RationalArray[Index] *= Inverse ; Index++; | |
600 | RationalArray[Index] *= Inverse ; Index++; | |
601 | } | |
602 | } | |
603 | else { | |
604 | Standard_Integer kk; | |
605 | Standard_Integer Dimension2 = Dimension << 1; | |
606 | Index = 0 ; | |
607 | Index2 = - Dimension2; | |
608 | ||
609 | for (ii = 0 ; ii < DeRequest1 ; ii++) { | |
610 | Index2 += Dimension; | |
611 | Index1 = Index2; | |
612 | ||
613 | for (kk = 0 ; kk < Dimension ; kk++) { | |
614 | RationalArray[Index] = PolesArray[Index]; Index++; | |
615 | } | |
616 | Index -= Dimension; | |
617 | ||
618 | for (jj = ii - 1 ; jj >= 0 ; jj--) { | |
619 | Factor = binomial_array[jj] * WeightsArray[ii - jj] ; | |
620 | ||
621 | for (kk = 0 ; kk < Dimension ; kk++) { | |
622 | RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++; | |
623 | } | |
624 | Index -= Dimension; | |
625 | Index1 -= Dimension2; | |
626 | } | |
627 | ||
628 | for (jj = ii ; jj >= 1 ; jj--) { | |
629 | binomial_array[jj] += binomial_array[jj - 1] ; | |
630 | } | |
631 | ||
632 | for (kk = 0 ; kk < Dimension ; kk++) { | |
633 | RationalArray[Index] *= Inverse ; Index++; | |
634 | } | |
635 | } | |
636 | } | |
637 | } | |
638 | ||
639 | //======================================================================= | |
640 | //function : This evaluates a polynomial and its derivatives | |
641 | //purpose : up to the requested order | |
642 | //======================================================================= | |
643 | ||
644 | void PLib::EvalPolynomial(const Standard_Real Par, | |
645 | const Standard_Integer DerivativeRequest, | |
646 | const Standard_Integer Degree, | |
647 | const Standard_Integer Dimension, | |
648 | Standard_Real& PolynomialCoeff, | |
649 | Standard_Real& Results) | |
650 | // | |
651 | // the polynomial coefficients are assumed to be stored as follows : | |
652 | // 0 | |
653 | // [0] [Dimension -1] X coefficient | |
654 | // 1 | |
655 | // [Dimension] [Dimension + Dimension -1] X coefficient | |
656 | // 2 | |
657 | // [2 * Dimension] [2 * Dimension + Dimension-1] X coefficient | |
658 | // | |
659 | // ................................................... | |
660 | // | |
661 | // | |
662 | // d | |
663 | // [d * Dimension] [d * Dimension + Dimension-1] X coefficient | |
664 | // | |
665 | // where d is the Degree | |
666 | // | |
667 | { | |
668 | Standard_Integer DegreeDimension = Degree * Dimension; | |
669 | ||
670 | Standard_Integer jj; | |
671 | Standard_Real *RA = &Results ; | |
672 | Standard_Real *PA = &PolynomialCoeff ; | |
673 | Standard_Real *tmpRA = RA; | |
674 | Standard_Real *tmpPA = PA + DegreeDimension; | |
675 | ||
676 | switch (Dimension) { | |
677 | ||
678 | case 1 : { | |
679 | *tmpRA = *tmpPA; | |
680 | if (DerivativeRequest > 0 ) { | |
681 | tmpRA++ ; | |
682 | Standard_Real *valRA; | |
683 | Standard_Integer ii, LocalRequest; | |
684 | Standard_Integer Index1, Index2; | |
685 | Standard_Integer MaxIndex1, MaxIndex2; | |
686 | if (DerivativeRequest < Degree) { | |
687 | LocalRequest = DerivativeRequest; | |
688 | MaxIndex2 = MaxIndex1 = LocalRequest; | |
689 | } | |
690 | else { | |
691 | LocalRequest = Degree; | |
692 | MaxIndex2 = MaxIndex1 = Degree; | |
693 | } | |
694 | MaxIndex2 --; | |
695 | ||
696 | for (ii = 1; ii <= LocalRequest; ii++) { | |
697 | *tmpRA = 0.0e0; tmpRA ++ ; | |
698 | } | |
699 | ||
700 | for (jj = Degree ; jj > 0 ; jj--) { | |
701 | tmpPA --; | |
702 | Index1 = MaxIndex1; | |
703 | Index2 = MaxIndex2; | |
704 | ||
705 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
706 | valRA = &RA[Index1]; | |
707 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
708 | Index1 --; | |
709 | Index2 --; | |
710 | } | |
711 | valRA = &RA[Index1]; | |
712 | *valRA = Par * (*valRA) + (*tmpPA); | |
713 | } | |
714 | } | |
715 | else { | |
716 | ||
717 | for (jj = Degree ; jj > 0 ; jj--) { | |
718 | tmpPA --; | |
719 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
720 | } | |
721 | } | |
722 | break; | |
723 | } | |
724 | case 2 : { | |
725 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
726 | *tmpRA = *tmpPA; tmpRA++; | |
727 | tmpPA --; | |
728 | if (DerivativeRequest > 0 ) { | |
729 | Standard_Real *valRA; | |
730 | Standard_Integer ii, LocalRequest; | |
731 | Standard_Integer Index1, Index2; | |
732 | Standard_Integer MaxIndex1, MaxIndex2; | |
733 | if (DerivativeRequest < Degree) { | |
734 | LocalRequest = DerivativeRequest; | |
735 | MaxIndex2 = MaxIndex1 = LocalRequest << 1; | |
736 | } | |
737 | else { | |
738 | LocalRequest = Degree; | |
739 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
740 | } | |
741 | MaxIndex2 -= 2; | |
742 | ||
743 | for (ii = 1; ii <= LocalRequest; ii++) { | |
744 | *tmpRA = 0.0e0; tmpRA++; | |
745 | *tmpRA = 0.0e0; tmpRA++; | |
746 | } | |
747 | ||
748 | for (jj = Degree ; jj > 0 ; jj--) { | |
749 | tmpPA -= 2; | |
750 | ||
751 | Index1 = MaxIndex1; | |
752 | Index2 = MaxIndex2; | |
753 | ||
754 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
755 | valRA = &RA[Index1]; | |
756 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
757 | Index1 -= 2; | |
758 | Index2 -= 2; | |
759 | } | |
760 | valRA = &RA[Index1]; | |
761 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
762 | ||
763 | Index1 = MaxIndex1 + 1; | |
764 | Index2 = MaxIndex2 + 1; | |
765 | ||
766 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
767 | valRA = &RA[Index1]; | |
768 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
769 | Index1 -= 2; | |
770 | Index2 -= 2; | |
771 | } | |
772 | valRA = &RA[Index1]; | |
773 | *valRA = Par * (*valRA) + (*tmpPA); | |
774 | ||
775 | tmpPA --; | |
776 | } | |
777 | } | |
778 | else { | |
779 | ||
780 | for (jj = Degree ; jj > 0 ; jj--) { | |
781 | tmpPA -= 2; | |
782 | tmpRA = RA; | |
783 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
784 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
785 | tmpPA --; | |
786 | } | |
787 | } | |
788 | break; | |
789 | } | |
790 | case 3 : { | |
791 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
792 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
793 | *tmpRA = *tmpPA; tmpRA++; | |
794 | tmpPA -= 2; | |
795 | if (DerivativeRequest > 0 ) { | |
796 | Standard_Real *valRA; | |
797 | Standard_Integer ii, LocalRequest; | |
798 | Standard_Integer Index1, Index2; | |
799 | Standard_Integer MaxIndex1, MaxIndex2; | |
800 | if (DerivativeRequest < Degree) { | |
801 | LocalRequest = DerivativeRequest; | |
802 | MaxIndex2 = MaxIndex1 = (LocalRequest << 1) + LocalRequest; | |
803 | } | |
804 | else { | |
805 | LocalRequest = Degree; | |
806 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
807 | } | |
808 | MaxIndex2 -= 3; | |
809 | ||
810 | for (ii = 1; ii <= LocalRequest; ii++) { | |
811 | *tmpRA = 0.0e0; tmpRA++; | |
812 | *tmpRA = 0.0e0; tmpRA++; | |
813 | *tmpRA = 0.0e0; tmpRA++; | |
814 | } | |
815 | ||
816 | for (jj = Degree ; jj > 0 ; jj--) { | |
817 | tmpPA -= 3; | |
818 | ||
819 | Index1 = MaxIndex1; | |
820 | Index2 = MaxIndex2; | |
821 | ||
822 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
823 | valRA = &RA[Index1]; | |
824 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
825 | Index1 -= 3; | |
826 | Index2 -= 3; | |
827 | } | |
828 | valRA = &RA[Index1]; | |
829 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
830 | ||
831 | Index1 = MaxIndex1 + 1; | |
832 | Index2 = MaxIndex2 + 1; | |
833 | ||
834 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
835 | valRA = &RA[Index1]; | |
836 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
837 | Index1 -= 3; | |
838 | Index2 -= 3; | |
839 | } | |
840 | valRA = &RA[Index1]; | |
841 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
842 | ||
843 | Index1 = MaxIndex1 + 2; | |
844 | Index2 = MaxIndex2 + 2; | |
845 | ||
846 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
847 | valRA = &RA[Index1]; | |
848 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
849 | Index1 -= 3; | |
850 | Index2 -= 3; | |
851 | } | |
852 | valRA = &RA[Index1]; | |
853 | *valRA = Par * (*valRA) + (*tmpPA); | |
854 | ||
855 | tmpPA -= 2; | |
856 | } | |
857 | } | |
858 | else { | |
859 | ||
860 | for (jj = Degree ; jj > 0 ; jj--) { | |
861 | tmpPA -= 3; | |
862 | tmpRA = RA; | |
863 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
864 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
865 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
866 | tmpPA -= 2; | |
867 | } | |
868 | } | |
869 | break; | |
870 | } | |
871 | case 6 : { | |
872 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
873 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
874 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
875 | ||
876 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
877 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
878 | *tmpRA = *tmpPA; tmpRA++; | |
879 | tmpPA -= 5; | |
880 | if (DerivativeRequest > 0 ) { | |
881 | Standard_Real *valRA; | |
882 | Standard_Integer ii, LocalRequest; | |
883 | Standard_Integer Index1, Index2; | |
884 | Standard_Integer MaxIndex1, MaxIndex2; | |
885 | if (DerivativeRequest < Degree) { | |
886 | LocalRequest = DerivativeRequest; | |
887 | MaxIndex2 = MaxIndex1 = (LocalRequest << 2) + (LocalRequest << 1); | |
888 | } | |
889 | else { | |
890 | LocalRequest = Degree; | |
891 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
892 | } | |
893 | MaxIndex2 -= 6; | |
894 | ||
895 | for (ii = 1; ii <= LocalRequest; ii++) { | |
896 | *tmpRA = 0.0e0; tmpRA++; | |
897 | *tmpRA = 0.0e0; tmpRA++; | |
898 | *tmpRA = 0.0e0; tmpRA++; | |
899 | ||
900 | *tmpRA = 0.0e0; tmpRA++; | |
901 | *tmpRA = 0.0e0; tmpRA++; | |
902 | *tmpRA = 0.0e0; tmpRA++; | |
903 | } | |
904 | ||
905 | for (jj = Degree ; jj > 0 ; jj--) { | |
906 | tmpPA -= 6; | |
907 | ||
908 | Index1 = MaxIndex1; | |
909 | Index2 = MaxIndex2; | |
910 | ||
911 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
912 | valRA = &RA[Index1]; | |
913 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
914 | Index1 -= 6; | |
915 | Index2 -= 6; | |
916 | } | |
917 | valRA = &RA[Index1]; | |
918 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
919 | ||
920 | Index1 = MaxIndex1 + 1; | |
921 | Index2 = MaxIndex2 + 1; | |
922 | ||
923 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
924 | valRA = &RA[Index1]; | |
925 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
926 | Index1 -= 6; | |
927 | Index2 -= 6; | |
928 | } | |
929 | valRA = &RA[Index1]; | |
930 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
931 | ||
932 | Index1 = MaxIndex1 + 2; | |
933 | Index2 = MaxIndex2 + 2; | |
934 | ||
935 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
936 | valRA = &RA[Index1]; | |
937 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
938 | Index1 -= 6; | |
939 | Index2 -= 6; | |
940 | } | |
941 | valRA = &RA[Index1]; | |
942 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
943 | ||
944 | Index1 = MaxIndex1 + 3; | |
945 | Index2 = MaxIndex2 + 3; | |
946 | ||
947 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
948 | valRA = &RA[Index1]; | |
949 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
950 | Index1 -= 6; | |
951 | Index2 -= 6; | |
952 | } | |
953 | valRA = &RA[Index1]; | |
954 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
955 | ||
956 | Index1 = MaxIndex1 + 4; | |
957 | Index2 = MaxIndex2 + 4; | |
958 | ||
959 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
960 | valRA = &RA[Index1]; | |
961 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
962 | Index1 -= 6; | |
963 | Index2 -= 6; | |
964 | } | |
965 | valRA = &RA[Index1]; | |
966 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
967 | ||
968 | Index1 = MaxIndex1 + 5; | |
969 | Index2 = MaxIndex2 + 5; | |
970 | ||
971 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
972 | valRA = &RA[Index1]; | |
973 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
974 | Index1 -= 6; | |
975 | Index2 -= 6; | |
976 | } | |
977 | valRA = &RA[Index1]; | |
978 | *valRA = Par * (*valRA) + (*tmpPA); | |
979 | ||
980 | tmpPA -= 5; | |
981 | } | |
982 | } | |
983 | else { | |
984 | ||
985 | for (jj = Degree ; jj > 0 ; jj--) { | |
986 | tmpPA -= 6; | |
987 | tmpRA = RA; | |
988 | ||
989 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
990 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
991 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
992 | ||
993 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
994 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
995 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
996 | tmpPA -= 5; | |
997 | } | |
998 | } | |
999 | break; | |
1000 | } | |
1001 | case 9 : { | |
1002 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1003 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1004 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1005 | ||
1006 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1007 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1008 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1009 | ||
1010 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1011 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1012 | *tmpRA = *tmpPA; tmpRA++; | |
1013 | tmpPA -= 8; | |
1014 | if (DerivativeRequest > 0 ) { | |
1015 | Standard_Real *valRA; | |
1016 | Standard_Integer ii, LocalRequest; | |
1017 | Standard_Integer Index1, Index2; | |
1018 | Standard_Integer MaxIndex1, MaxIndex2; | |
1019 | if (DerivativeRequest < Degree) { | |
1020 | LocalRequest = DerivativeRequest; | |
1021 | MaxIndex2 = MaxIndex1 = (LocalRequest << 3) + LocalRequest; | |
1022 | } | |
1023 | else { | |
1024 | LocalRequest = Degree; | |
1025 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
1026 | } | |
1027 | MaxIndex2 -= 9; | |
1028 | ||
1029 | for (ii = 1; ii <= LocalRequest; ii++) { | |
1030 | *tmpRA = 0.0e0; tmpRA++; | |
1031 | *tmpRA = 0.0e0; tmpRA++; | |
1032 | *tmpRA = 0.0e0; tmpRA++; | |
1033 | ||
1034 | *tmpRA = 0.0e0; tmpRA++; | |
1035 | *tmpRA = 0.0e0; tmpRA++; | |
1036 | *tmpRA = 0.0e0; tmpRA++; | |
1037 | ||
1038 | *tmpRA = 0.0e0; tmpRA++; | |
1039 | *tmpRA = 0.0e0; tmpRA++; | |
1040 | *tmpRA = 0.0e0; tmpRA++; | |
1041 | } | |
1042 | ||
1043 | for (jj = Degree ; jj > 0 ; jj--) { | |
1044 | tmpPA -= 9; | |
1045 | ||
1046 | Index1 = MaxIndex1; | |
1047 | Index2 = MaxIndex2; | |
1048 | ||
1049 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1050 | valRA = &RA[Index1]; | |
1051 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1052 | Index1 -= 9; | |
1053 | Index2 -= 9; | |
1054 | } | |
1055 | valRA = &RA[Index1]; | |
1056 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1057 | ||
1058 | Index1 = MaxIndex1 + 1; | |
1059 | Index2 = MaxIndex2 + 1; | |
1060 | ||
1061 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1062 | valRA = &RA[Index1]; | |
1063 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1064 | Index1 -= 9; | |
1065 | Index2 -= 9; | |
1066 | } | |
1067 | valRA = &RA[Index1]; | |
1068 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1069 | ||
1070 | Index1 = MaxIndex1 + 2; | |
1071 | Index2 = MaxIndex2 + 2; | |
1072 | ||
1073 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1074 | valRA = &RA[Index1]; | |
1075 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1076 | Index1 -= 9; | |
1077 | Index2 -= 9; | |
1078 | } | |
1079 | valRA = &RA[Index1]; | |
1080 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1081 | ||
1082 | Index1 = MaxIndex1 + 3; | |
1083 | Index2 = MaxIndex2 + 3; | |
1084 | ||
1085 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1086 | valRA = &RA[Index1]; | |
1087 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1088 | Index1 -= 9; | |
1089 | Index2 -= 9; | |
1090 | } | |
1091 | valRA = &RA[Index1]; | |
1092 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1093 | ||
1094 | Index1 = MaxIndex1 + 4; | |
1095 | Index2 = MaxIndex2 + 4; | |
1096 | ||
1097 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1098 | valRA = &RA[Index1]; | |
1099 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1100 | Index1 -= 9; | |
1101 | Index2 -= 9; | |
1102 | } | |
1103 | valRA = &RA[Index1]; | |
1104 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1105 | ||
1106 | Index1 = MaxIndex1 + 5; | |
1107 | Index2 = MaxIndex2 + 5; | |
1108 | ||
1109 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1110 | valRA = &RA[Index1]; | |
1111 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1112 | Index1 -= 9; | |
1113 | Index2 -= 9; | |
1114 | } | |
1115 | valRA = &RA[Index1]; | |
1116 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1117 | ||
1118 | Index1 = MaxIndex1 + 6; | |
1119 | Index2 = MaxIndex2 + 6; | |
1120 | ||
1121 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1122 | valRA = &RA[Index1]; | |
1123 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1124 | Index1 -= 9; | |
1125 | Index2 -= 9; | |
1126 | } | |
1127 | valRA = &RA[Index1]; | |
1128 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1129 | ||
1130 | Index1 = MaxIndex1 + 7; | |
1131 | Index2 = MaxIndex2 + 7; | |
1132 | ||
1133 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1134 | valRA = &RA[Index1]; | |
1135 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1136 | Index1 -= 9; | |
1137 | Index2 -= 9; | |
1138 | } | |
1139 | valRA = &RA[Index1]; | |
1140 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1141 | ||
1142 | Index1 = MaxIndex1 + 8; | |
1143 | Index2 = MaxIndex2 + 8; | |
1144 | ||
1145 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1146 | valRA = &RA[Index1]; | |
1147 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1148 | Index1 -= 9; | |
1149 | Index2 -= 9; | |
1150 | } | |
1151 | valRA = &RA[Index1]; | |
1152 | *valRA = Par * (*valRA) + (*tmpPA); | |
1153 | ||
1154 | tmpPA -= 8; | |
1155 | } | |
1156 | } | |
1157 | else { | |
1158 | ||
1159 | for (jj = Degree ; jj > 0 ; jj--) { | |
1160 | tmpPA -= 9; | |
1161 | tmpRA = RA; | |
1162 | ||
1163 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1164 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1165 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1166 | ||
1167 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1168 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1169 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1170 | ||
1171 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1172 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1173 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1174 | tmpPA -= 8; | |
1175 | } | |
1176 | } | |
1177 | break; | |
1178 | } | |
1179 | case 12 : { | |
1180 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1181 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1182 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1183 | ||
1184 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1185 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1186 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1187 | ||
1188 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1189 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1190 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1191 | ||
1192 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1193 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1194 | *tmpRA = *tmpPA; tmpRA++; | |
1195 | tmpPA -= 11; | |
1196 | if (DerivativeRequest > 0 ) { | |
1197 | Standard_Real *valRA; | |
1198 | Standard_Integer ii, LocalRequest; | |
1199 | Standard_Integer Index1, Index2; | |
1200 | Standard_Integer MaxIndex1, MaxIndex2; | |
1201 | if (DerivativeRequest < Degree) { | |
1202 | LocalRequest = DerivativeRequest; | |
1203 | MaxIndex2 = MaxIndex1 = (LocalRequest << 3) + (LocalRequest << 2); | |
1204 | } | |
1205 | else { | |
1206 | LocalRequest = Degree; | |
1207 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
1208 | } | |
1209 | MaxIndex2 -= 12; | |
1210 | ||
1211 | for (ii = 1; ii <= LocalRequest; ii++) { | |
1212 | *tmpRA = 0.0e0; tmpRA++; | |
1213 | *tmpRA = 0.0e0; tmpRA++; | |
1214 | *tmpRA = 0.0e0; tmpRA++; | |
1215 | ||
1216 | *tmpRA = 0.0e0; tmpRA++; | |
1217 | *tmpRA = 0.0e0; tmpRA++; | |
1218 | *tmpRA = 0.0e0; tmpRA++; | |
1219 | ||
1220 | *tmpRA = 0.0e0; tmpRA++; | |
1221 | *tmpRA = 0.0e0; tmpRA++; | |
1222 | *tmpRA = 0.0e0; tmpRA++; | |
1223 | ||
1224 | *tmpRA = 0.0e0; tmpRA++; | |
1225 | *tmpRA = 0.0e0; tmpRA++; | |
1226 | *tmpRA = 0.0e0; tmpRA++; | |
1227 | } | |
1228 | ||
1229 | for (jj = Degree ; jj > 0 ; jj--) { | |
1230 | tmpPA -= 12; | |
1231 | ||
1232 | Index1 = MaxIndex1; | |
1233 | Index2 = MaxIndex2; | |
1234 | ||
1235 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1236 | valRA = &RA[Index1]; | |
1237 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1238 | Index1 -= 12; | |
1239 | Index2 -= 12; | |
1240 | } | |
1241 | valRA = &RA[Index1]; | |
1242 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1243 | ||
1244 | Index1 = MaxIndex1 + 1; | |
1245 | Index2 = MaxIndex2 + 1; | |
1246 | ||
1247 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1248 | valRA = &RA[Index1]; | |
1249 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1250 | Index1 -= 12; | |
1251 | Index2 -= 12; | |
1252 | } | |
1253 | valRA = &RA[Index1]; | |
1254 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1255 | ||
1256 | Index1 = MaxIndex1 + 2; | |
1257 | Index2 = MaxIndex2 + 2; | |
1258 | ||
1259 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1260 | valRA = &RA[Index1]; | |
1261 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1262 | Index1 -= 12; | |
1263 | Index2 -= 12; | |
1264 | } | |
1265 | valRA = &RA[Index1]; | |
1266 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1267 | ||
1268 | Index1 = MaxIndex1 + 3; | |
1269 | Index2 = MaxIndex2 + 3; | |
1270 | ||
1271 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1272 | valRA = &RA[Index1]; | |
1273 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1274 | Index1 -= 12; | |
1275 | Index2 -= 12; | |
1276 | } | |
1277 | valRA = &RA[Index1]; | |
1278 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1279 | ||
1280 | Index1 = MaxIndex1 + 4; | |
1281 | Index2 = MaxIndex2 + 4; | |
1282 | ||
1283 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1284 | valRA = &RA[Index1]; | |
1285 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1286 | Index1 -= 12; | |
1287 | Index2 -= 12; | |
1288 | } | |
1289 | valRA = &RA[Index1]; | |
1290 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1291 | ||
1292 | Index1 = MaxIndex1 + 5; | |
1293 | Index2 = MaxIndex2 + 5; | |
1294 | ||
1295 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1296 | valRA = &RA[Index1]; | |
1297 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1298 | Index1 -= 12; | |
1299 | Index2 -= 12; | |
1300 | } | |
1301 | valRA = &RA[Index1]; | |
1302 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1303 | ||
1304 | Index1 = MaxIndex1 + 6; | |
1305 | Index2 = MaxIndex2 + 6; | |
1306 | ||
1307 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1308 | valRA = &RA[Index1]; | |
1309 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1310 | Index1 -= 12; | |
1311 | Index2 -= 12; | |
1312 | } | |
1313 | valRA = &RA[Index1]; | |
1314 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1315 | ||
1316 | Index1 = MaxIndex1 + 7; | |
1317 | Index2 = MaxIndex2 + 7; | |
1318 | ||
1319 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1320 | valRA = &RA[Index1]; | |
1321 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1322 | Index1 -= 12; | |
1323 | Index2 -= 12; | |
1324 | } | |
1325 | valRA = &RA[Index1]; | |
1326 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1327 | ||
1328 | Index1 = MaxIndex1 + 8; | |
1329 | Index2 = MaxIndex2 + 8; | |
1330 | ||
1331 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1332 | valRA = &RA[Index1]; | |
1333 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1334 | Index1 -= 12; | |
1335 | Index2 -= 12; | |
1336 | } | |
1337 | valRA = &RA[Index1]; | |
1338 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1339 | ||
1340 | Index1 = MaxIndex1 + 9; | |
1341 | Index2 = MaxIndex2 + 9; | |
1342 | ||
1343 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1344 | valRA = &RA[Index1]; | |
1345 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1346 | Index1 -= 12; | |
1347 | Index2 -= 12; | |
1348 | } | |
1349 | valRA = &RA[Index1]; | |
1350 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1351 | ||
1352 | Index1 = MaxIndex1 + 10; | |
1353 | Index2 = MaxIndex2 + 10; | |
1354 | ||
1355 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1356 | valRA = &RA[Index1]; | |
1357 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1358 | Index1 -= 12; | |
1359 | Index2 -= 12; | |
1360 | } | |
1361 | valRA = &RA[Index1]; | |
1362 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1363 | ||
1364 | Index1 = MaxIndex1 + 11; | |
1365 | Index2 = MaxIndex2 + 11; | |
1366 | ||
1367 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1368 | valRA = &RA[Index1]; | |
1369 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1370 | Index1 -= 12; | |
1371 | Index2 -= 12; | |
1372 | } | |
1373 | valRA = &RA[Index1]; | |
1374 | *valRA = Par * (*valRA) + (*tmpPA); | |
1375 | ||
1376 | tmpPA -= 11; | |
1377 | } | |
1378 | } | |
1379 | else { | |
1380 | ||
1381 | for (jj = Degree ; jj > 0 ; jj--) { | |
1382 | tmpPA -= 12; | |
1383 | tmpRA = RA; | |
1384 | ||
1385 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1386 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1387 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1388 | ||
1389 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1390 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1391 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1392 | ||
1393 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1394 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1395 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1396 | ||
1397 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1398 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1399 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1400 | tmpPA -= 11; | |
1401 | } | |
1402 | } | |
1403 | break; | |
1404 | break; | |
1405 | } | |
1406 | case 15 : { | |
1407 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1408 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1409 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1410 | ||
1411 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1412 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1413 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1414 | ||
1415 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1416 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1417 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1418 | ||
1419 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1420 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1421 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1422 | ||
1423 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1424 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1425 | *tmpRA = *tmpPA; tmpRA++; | |
1426 | tmpPA -= 14; | |
1427 | if (DerivativeRequest > 0 ) { | |
1428 | Standard_Real *valRA; | |
1429 | Standard_Integer ii, LocalRequest; | |
1430 | Standard_Integer Index1, Index2; | |
1431 | Standard_Integer MaxIndex1, MaxIndex2; | |
1432 | if (DerivativeRequest < Degree) { | |
1433 | LocalRequest = DerivativeRequest; | |
1434 | MaxIndex2 = MaxIndex1 = (LocalRequest << 4) - LocalRequest; | |
1435 | } | |
1436 | else { | |
1437 | LocalRequest = Degree; | |
1438 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
1439 | } | |
1440 | MaxIndex2 -= 15; | |
1441 | ||
1442 | for (ii = 1; ii <= LocalRequest; ii++) { | |
1443 | *tmpRA = 0.0e0; tmpRA++; | |
1444 | *tmpRA = 0.0e0; tmpRA++; | |
1445 | *tmpRA = 0.0e0; tmpRA++; | |
1446 | ||
1447 | *tmpRA = 0.0e0; tmpRA++; | |
1448 | *tmpRA = 0.0e0; tmpRA++; | |
1449 | *tmpRA = 0.0e0; tmpRA++; | |
1450 | ||
1451 | *tmpRA = 0.0e0; tmpRA++; | |
1452 | *tmpRA = 0.0e0; tmpRA++; | |
1453 | *tmpRA = 0.0e0; tmpRA++; | |
1454 | ||
1455 | *tmpRA = 0.0e0; tmpRA++; | |
1456 | *tmpRA = 0.0e0; tmpRA++; | |
1457 | *tmpRA = 0.0e0; tmpRA++; | |
1458 | ||
1459 | *tmpRA = 0.0e0; tmpRA++; | |
1460 | *tmpRA = 0.0e0; tmpRA++; | |
1461 | *tmpRA = 0.0e0; tmpRA++; | |
1462 | } | |
1463 | ||
1464 | for (jj = Degree ; jj > 0 ; jj--) { | |
1465 | tmpPA -= 15; | |
1466 | ||
1467 | Index1 = MaxIndex1; | |
1468 | Index2 = MaxIndex2; | |
1469 | ||
1470 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1471 | valRA = &RA[Index1]; | |
1472 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1473 | Index1 -= 15; | |
1474 | Index2 -= 15; | |
1475 | } | |
1476 | valRA = &RA[Index1]; | |
1477 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1478 | ||
1479 | Index1 = MaxIndex1 + 1; | |
1480 | Index2 = MaxIndex2 + 1; | |
1481 | ||
1482 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1483 | valRA = &RA[Index1]; | |
1484 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1485 | Index1 -= 15; | |
1486 | Index2 -= 15; | |
1487 | } | |
1488 | valRA = &RA[Index1]; | |
1489 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1490 | ||
1491 | Index1 = MaxIndex1 + 2; | |
1492 | Index2 = MaxIndex2 + 2; | |
1493 | ||
1494 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1495 | valRA = &RA[Index1]; | |
1496 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1497 | Index1 -= 15; | |
1498 | Index2 -= 15; | |
1499 | } | |
1500 | valRA = &RA[Index1]; | |
1501 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1502 | ||
1503 | Index1 = MaxIndex1 + 3; | |
1504 | Index2 = MaxIndex2 + 3; | |
1505 | ||
1506 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1507 | valRA = &RA[Index1]; | |
1508 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1509 | Index1 -= 15; | |
1510 | Index2 -= 15; | |
1511 | } | |
1512 | valRA = &RA[Index1]; | |
1513 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1514 | ||
1515 | Index1 = MaxIndex1 + 4; | |
1516 | Index2 = MaxIndex2 + 4; | |
1517 | ||
1518 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1519 | valRA = &RA[Index1]; | |
1520 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1521 | Index1 -= 15; | |
1522 | Index2 -= 15; | |
1523 | } | |
1524 | valRA = &RA[Index1]; | |
1525 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1526 | ||
1527 | Index1 = MaxIndex1 + 5; | |
1528 | Index2 = MaxIndex2 + 5; | |
1529 | ||
1530 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1531 | valRA = &RA[Index1]; | |
1532 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1533 | Index1 -= 15; | |
1534 | Index2 -= 15; | |
1535 | } | |
1536 | valRA = &RA[Index1]; | |
1537 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1538 | ||
1539 | Index1 = MaxIndex1 + 6; | |
1540 | Index2 = MaxIndex2 + 6; | |
1541 | ||
1542 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1543 | valRA = &RA[Index1]; | |
1544 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1545 | Index1 -= 15; | |
1546 | Index2 -= 15; | |
1547 | } | |
1548 | valRA = &RA[Index1]; | |
1549 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1550 | ||
1551 | Index1 = MaxIndex1 + 7; | |
1552 | Index2 = MaxIndex2 + 7; | |
1553 | ||
1554 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1555 | valRA = &RA[Index1]; | |
1556 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1557 | Index1 -= 15; | |
1558 | Index2 -= 15; | |
1559 | } | |
1560 | valRA = &RA[Index1]; | |
1561 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1562 | ||
1563 | Index1 = MaxIndex1 + 8; | |
1564 | Index2 = MaxIndex2 + 8; | |
1565 | ||
1566 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1567 | valRA = &RA[Index1]; | |
1568 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1569 | Index1 -= 15; | |
1570 | Index2 -= 15; | |
1571 | } | |
1572 | valRA = &RA[Index1]; | |
1573 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1574 | ||
1575 | Index1 = MaxIndex1 + 9; | |
1576 | Index2 = MaxIndex2 + 9; | |
1577 | ||
1578 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1579 | valRA = &RA[Index1]; | |
1580 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1581 | Index1 -= 15; | |
1582 | Index2 -= 15; | |
1583 | } | |
1584 | valRA = &RA[Index1]; | |
1585 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1586 | ||
1587 | Index1 = MaxIndex1 + 10; | |
1588 | Index2 = MaxIndex2 + 10; | |
1589 | ||
1590 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1591 | valRA = &RA[Index1]; | |
1592 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1593 | Index1 -= 15; | |
1594 | Index2 -= 15; | |
1595 | } | |
1596 | valRA = &RA[Index1]; | |
1597 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1598 | ||
1599 | Index1 = MaxIndex1 + 11; | |
1600 | Index2 = MaxIndex2 + 11; | |
1601 | ||
1602 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1603 | valRA = &RA[Index1]; | |
1604 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1605 | Index1 -= 15; | |
1606 | Index2 -= 15; | |
1607 | } | |
1608 | valRA = &RA[Index1]; | |
1609 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1610 | ||
1611 | Index1 = MaxIndex1 + 12; | |
1612 | Index2 = MaxIndex2 + 12; | |
1613 | ||
1614 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1615 | valRA = &RA[Index1]; | |
1616 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1617 | Index1 -= 15; | |
1618 | Index2 -= 15; | |
1619 | } | |
1620 | valRA = &RA[Index1]; | |
1621 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1622 | ||
1623 | Index1 = MaxIndex1 + 13; | |
1624 | Index2 = MaxIndex2 + 13; | |
1625 | ||
1626 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1627 | valRA = &RA[Index1]; | |
1628 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1629 | Index1 -= 15; | |
1630 | Index2 -= 15; | |
1631 | } | |
1632 | valRA = &RA[Index1]; | |
1633 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1634 | ||
1635 | Index1 = MaxIndex1 + 14; | |
1636 | Index2 = MaxIndex2 + 14; | |
1637 | ||
1638 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1639 | valRA = &RA[Index1]; | |
1640 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1641 | Index1 -= 15; | |
1642 | Index2 -= 15; | |
1643 | } | |
1644 | valRA = &RA[Index1]; | |
1645 | *valRA = Par * (*valRA) + (*tmpPA); | |
1646 | ||
1647 | tmpPA -= 14; | |
1648 | } | |
1649 | } | |
1650 | else { | |
1651 | ||
1652 | for (jj = Degree ; jj > 0 ; jj--) { | |
1653 | tmpPA -= 15; | |
1654 | tmpRA = RA; | |
1655 | ||
1656 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1657 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1658 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1659 | ||
1660 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1661 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1662 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1663 | ||
1664 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1665 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1666 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1667 | ||
1668 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1669 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1670 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1671 | ||
1672 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1673 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1674 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1675 | tmpPA -= 14; | |
1676 | } | |
1677 | } | |
1678 | break; | |
1679 | } | |
1680 | default : { | |
1681 | Standard_Integer kk ; | |
1682 | for ( kk = 0 ; kk < Dimension ; kk++) { | |
1683 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1684 | } | |
1685 | tmpPA -= Dimension; | |
1686 | if (DerivativeRequest > 0 ) { | |
1687 | Standard_Real *valRA; | |
1688 | Standard_Integer ii, LocalRequest; | |
1689 | Standard_Integer Index1, Index2; | |
1690 | Standard_Integer MaxIndex1, MaxIndex2; | |
1691 | if (DerivativeRequest < Degree) { | |
1692 | LocalRequest = DerivativeRequest; | |
1693 | MaxIndex2 = MaxIndex1 = LocalRequest * Dimension; | |
1694 | } | |
1695 | else { | |
1696 | LocalRequest = Degree; | |
1697 | MaxIndex2 = MaxIndex1 = DegreeDimension; | |
1698 | } | |
1699 | MaxIndex2 -= Dimension; | |
1700 | ||
1701 | for (ii = 1; ii <= MaxIndex1; ii++) { | |
1702 | *tmpRA = 0.0e0; tmpRA++; | |
1703 | } | |
1704 | ||
1705 | for (jj = Degree ; jj > 0 ; jj--) { | |
1706 | tmpPA -= Dimension; | |
1707 | ||
1708 | for (kk = 0 ; kk < Dimension ; kk++) { | |
1709 | Index1 = MaxIndex1 + kk; | |
1710 | Index2 = MaxIndex2 + kk; | |
1711 | ||
1712 | for (ii = LocalRequest ; ii > 0 ; ii--) { | |
1713 | valRA = &RA[Index1]; | |
1714 | *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ; | |
1715 | Index1 -= Dimension; | |
1716 | Index2 -= Dimension; | |
1717 | } | |
1718 | valRA = &RA[Index1]; | |
1719 | *valRA = Par * (*valRA) + (*tmpPA); tmpPA++; | |
1720 | } | |
1721 | tmpPA -= Dimension; | |
1722 | } | |
1723 | } | |
1724 | else { | |
1725 | ||
1726 | for (jj = Degree ; jj > 0 ; jj--) { | |
1727 | tmpPA -= Dimension; | |
1728 | tmpRA = RA; | |
1729 | ||
1730 | for (kk = 0 ; kk < Dimension ; kk++) { | |
1731 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1732 | } | |
1733 | tmpPA -= Dimension; | |
1734 | } | |
1735 | } | |
1736 | } | |
1737 | } | |
1738 | } | |
1739 | ||
1740 | //======================================================================= | |
1741 | //function : This evaluates a polynomial without derivative | |
1742 | //purpose : | |
1743 | //======================================================================= | |
1744 | ||
1745 | void PLib::NoDerivativeEvalPolynomial(const Standard_Real Par, | |
1746 | const Standard_Integer Degree, | |
1747 | const Standard_Integer Dimension, | |
1748 | const Standard_Integer DegreeDimension, | |
1749 | Standard_Real& PolynomialCoeff, | |
1750 | Standard_Real& Results) | |
1751 | { | |
1752 | Standard_Integer jj; | |
1753 | Standard_Real *RA = &Results ; | |
1754 | Standard_Real *PA = &PolynomialCoeff ; | |
1755 | Standard_Real *tmpRA = RA; | |
1756 | Standard_Real *tmpPA = PA + DegreeDimension; | |
1757 | ||
1758 | switch (Dimension) { | |
1759 | ||
1760 | case 1 : { | |
1761 | *tmpRA = *tmpPA; | |
1762 | ||
1763 | for (jj = Degree ; jj > 0 ; jj--) { | |
1764 | tmpPA--; | |
1765 | ||
1766 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1767 | } | |
1768 | break; | |
1769 | } | |
1770 | case 2 : { | |
1771 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1772 | *tmpRA = *tmpPA; | |
1773 | tmpPA--; | |
1774 | ||
1775 | for (jj = Degree ; jj > 0 ; jj--) { | |
1776 | tmpPA -= 2; | |
1777 | tmpRA = RA; | |
1778 | ||
1779 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1780 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1781 | tmpPA--; | |
1782 | } | |
1783 | break; | |
1784 | } | |
1785 | case 3 : { | |
1786 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1787 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1788 | *tmpRA = *tmpPA; | |
1789 | tmpPA -= 2; | |
1790 | ||
1791 | for (jj = Degree ; jj > 0 ; jj--) { | |
1792 | tmpPA -= 3; | |
1793 | tmpRA = RA; | |
1794 | ||
1795 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1796 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1797 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1798 | tmpPA -= 2; | |
1799 | } | |
1800 | break; | |
1801 | } | |
1802 | case 6 : { | |
1803 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1804 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1805 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1806 | ||
1807 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1808 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1809 | *tmpRA = *tmpPA; | |
1810 | tmpPA -= 5; | |
1811 | ||
1812 | for (jj = Degree ; jj > 0 ; jj--) { | |
1813 | tmpPA -= 6; | |
1814 | tmpRA = RA; | |
1815 | ||
1816 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1817 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1818 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1819 | ||
1820 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1821 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1822 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1823 | tmpPA -= 5; | |
1824 | } | |
1825 | break; | |
1826 | } | |
1827 | case 9 : { | |
1828 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1829 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1830 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1831 | ||
1832 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1833 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1834 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1835 | ||
1836 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1837 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1838 | *tmpRA = *tmpPA; | |
1839 | tmpPA -= 8; | |
1840 | ||
1841 | for (jj = Degree ; jj > 0 ; jj--) { | |
1842 | tmpPA -= 9; | |
1843 | tmpRA = RA; | |
1844 | ||
1845 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1846 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1847 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1848 | ||
1849 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1850 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1851 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1852 | ||
1853 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1854 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1855 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1856 | tmpPA -= 8; | |
1857 | } | |
1858 | break; | |
1859 | } | |
1860 | case 12 : { | |
1861 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1862 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1863 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1864 | ||
1865 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1866 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1867 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1868 | ||
1869 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1870 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1871 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1872 | ||
1873 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1874 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1875 | *tmpRA = *tmpPA; | |
1876 | tmpPA -= 11; | |
1877 | ||
1878 | for (jj = Degree ; jj > 0 ; jj--) { | |
1879 | tmpPA -= 12; | |
1880 | tmpRA = RA; | |
1881 | ||
1882 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1883 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1884 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1885 | ||
1886 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1887 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1888 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1889 | ||
1890 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1891 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1892 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1893 | ||
1894 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1895 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1896 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1897 | tmpPA -= 11; | |
1898 | } | |
1899 | break; | |
1900 | } | |
1901 | case 15 : { | |
1902 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1903 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1904 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1905 | ||
1906 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1907 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1908 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1909 | ||
1910 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1911 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1912 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1913 | ||
1914 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1915 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1916 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1917 | ||
1918 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1919 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1920 | *tmpRA = *tmpPA; | |
1921 | tmpPA -= 14; | |
1922 | ||
1923 | for (jj = Degree ; jj > 0 ; jj--) { | |
1924 | tmpPA -= 15; | |
1925 | tmpRA = RA; | |
1926 | ||
1927 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1928 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1929 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1930 | ||
1931 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1932 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1933 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1934 | ||
1935 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1936 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1937 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1938 | ||
1939 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1940 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1941 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1942 | ||
1943 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1944 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1945 | *tmpRA = Par * (*tmpRA) + (*tmpPA); | |
1946 | tmpPA -= 14; | |
1947 | } | |
1948 | break; | |
1949 | } | |
1950 | default : { | |
1951 | Standard_Integer kk ; | |
1952 | for ( kk = 0 ; kk < Dimension ; kk++) { | |
1953 | *tmpRA = *tmpPA; tmpRA++; tmpPA++; | |
1954 | } | |
1955 | tmpPA -= Dimension; | |
1956 | ||
1957 | for (jj = Degree ; jj > 0 ; jj--) { | |
1958 | tmpPA -= Dimension; | |
1959 | tmpRA = RA; | |
1960 | ||
1961 | for (kk = 0 ; kk < Dimension ; kk++) { | |
1962 | *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++; | |
1963 | } | |
1964 | tmpPA -= Dimension; | |
1965 | } | |
1966 | } | |
1967 | } | |
1968 | } | |
1969 | ||
1970 | //======================================================================= | |
1971 | //function : This evaluates a polynomial of 2 variables | |
1972 | //purpose : or its derivative at the requested orders | |
1973 | //======================================================================= | |
1974 | ||
1975 | void PLib::EvalPoly2Var(const Standard_Real UParameter, | |
1976 | const Standard_Real VParameter, | |
1977 | const Standard_Integer UDerivativeRequest, | |
1978 | const Standard_Integer VDerivativeRequest, | |
1979 | const Standard_Integer UDegree, | |
1980 | const Standard_Integer VDegree, | |
1981 | const Standard_Integer Dimension, | |
1982 | Standard_Real& PolynomialCoeff, | |
1983 | Standard_Real& Results) | |
1984 | // | |
1985 | // the polynomial coefficients are assumed to be stored as follows : | |
1986 | // 0 0 | |
1987 | // [0] [Dimension -1] U V coefficient | |
1988 | // 1 0 | |
1989 | // [Dimension] [Dimension + Dimension -1] U V coefficient | |
1990 | // 2 0 | |
1991 | // [2 * Dimension] [2 * Dimension + Dimension-1] U V coefficient | |
1992 | // | |
1993 | // ................................................... | |
1994 | // | |
1995 | // | |
1996 | // m 0 | |
1997 | // [m * Dimension] [m * Dimension + Dimension-1] U V coefficient | |
1998 | // | |
1999 | // where m = UDegree | |
2000 | // | |
2001 | // 0 1 | |
2002 | // [(m+1) * Dimension] [(m+1) * Dimension + Dimension-1] U V coefficient | |
2003 | // | |
2004 | // ................................................... | |
2005 | // | |
2006 | // m 1 | |
2007 | // [2*m * Dimension] [2*m * Dimension + Dimension-1] U V coefficient | |
2008 | // | |
2009 | // ................................................... | |
2010 | // | |
2011 | // m n | |
2012 | // [m*n * Dimension] [m*n * Dimension + Dimension-1] U V coefficient | |
2013 | // | |
2014 | // where n = VDegree | |
2015 | { | |
2016 | Standard_Integer Udim = (VDegree+1)*Dimension, | |
2017 | index = Udim*UDerivativeRequest; | |
2018 | TColStd_Array1OfReal Curve(1, Udim*(UDerivativeRequest+1)); | |
2019 | TColStd_Array1OfReal Point(1, Dimension*(VDerivativeRequest+1)); | |
2020 | Standard_Real * Result = (Standard_Real *) &Curve.ChangeValue(1); | |
2021 | Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1); | |
2022 | Standard_Real * ResultArray ; | |
2023 | ResultArray = &Results ; | |
2024 | ||
2025 | PLib::EvalPolynomial(UParameter, | |
2026 | UDerivativeRequest, | |
2027 | UDegree, | |
2028 | Udim, | |
2029 | PolynomialCoeff, | |
2030 | Result[0]); | |
2031 | ||
2032 | PLib::EvalPolynomial(VParameter, | |
2033 | VDerivativeRequest, | |
2034 | VDegree, | |
2035 | Dimension, | |
2036 | Result[index], | |
2037 | Digit[0]); | |
2038 | ||
2039 | index = Dimension*VDerivativeRequest; | |
2040 | ||
2041 | for (Standard_Integer i=0;i<Dimension;i++) { | |
2042 | ResultArray[i] = Digit[index+i]; | |
2043 | } | |
2044 | } | |
2045 | ||
2046 | ||
2047 | static Standard_Integer storage_divided = 0 ; | |
2048 | static Standard_Real *divided_differences_array = NULL; | |
2049 | ||
2050 | //======================================================================= | |
2051 | //function : This evaluates the lagrange polynomial and its derivatives | |
2052 | //purpose : up to the requested order that interpolates a series of | |
2053 | //points of dimension <Dimension> with given assigned parameters | |
2054 | //======================================================================= | |
2055 | ||
2056 | Standard_Integer | |
2057 | PLib::EvalLagrange(const Standard_Real Parameter, | |
2058 | const Standard_Integer DerivativeRequest, | |
2059 | const Standard_Integer Degree, | |
2060 | const Standard_Integer Dimension, | |
2061 | Standard_Real& Values, | |
2062 | Standard_Real& Parameters, | |
2063 | Standard_Real& Results) | |
2064 | { | |
2065 | // | |
2066 | // the points are assumed to be stored as follows in the Values array : | |
2067 | // | |
2068 | // [0] [Dimension -1] first point coefficients | |
2069 | // | |
2070 | // [Dimension] [Dimension + Dimension -1] second point coefficients | |
2071 | // | |
2072 | // [2 * Dimension] [2 * Dimension + Dimension-1] third point coefficients | |
2073 | // | |
2074 | // ................................................... | |
2075 | // | |
2076 | // | |
2077 | // | |
2078 | // [d * Dimension] [d * Dimension + Dimension-1] d + 1 point coefficients | |
2079 | // | |
2080 | // where d is the Degree | |
2081 | // | |
2082 | // The ParameterArray stores the parameter value assign to each point in | |
2083 | // order described above, that is | |
2084 | // [0] is assign to first point | |
2085 | // [1] is assign to second point | |
2086 | // | |
2087 | Standard_Integer ii, jj, kk, Index, Index1, ReturnCode=0; | |
2088 | Standard_Integer local_request = DerivativeRequest; | |
2089 | Standard_Real *ParameterArray; | |
2090 | Standard_Real difference; | |
2091 | Standard_Real *PointsArray; | |
2092 | Standard_Real *ResultArray ; | |
2093 | ||
2094 | PointsArray = &Values ; | |
2095 | ParameterArray = &Parameters ; | |
2096 | ResultArray = &Results ; | |
2097 | if (local_request >= Degree) { | |
2098 | local_request = Degree ; | |
41194117 | 2099 | } |
f7b4312f | 2100 | NCollection_LocalArray<Standard_Real> divided_differences_array ((Degree + 1) * Dimension); |
7fd59977 | 2101 | // |
2102 | // Build the divided differences array | |
2103 | // | |
2104 | ||
2105 | for (ii = 0 ; ii < (Degree + 1) * Dimension ; ii++) { | |
2106 | divided_differences_array[ii] = PointsArray[ii] ; | |
2107 | } | |
2108 | ||
2109 | for (ii = Degree ; ii >= 0 ; ii--) { | |
2110 | ||
2111 | for (jj = Degree ; jj > Degree - ii ; jj--) { | |
2112 | Index = jj * Dimension ; | |
2113 | Index1 = Index - Dimension ; | |
2114 | ||
2115 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2116 | divided_differences_array[Index + kk] -= | |
2117 | divided_differences_array[Index1 + kk] ; | |
2118 | } | |
2119 | difference = | |
2120 | ParameterArray[jj] - ParameterArray[jj - Degree -1 + ii] ; | |
2121 | if (Abs(difference) < RealSmall()) { | |
2122 | ReturnCode = 1 ; | |
2123 | goto FINISH ; | |
2124 | } | |
2125 | difference = 1.0e0 / difference ; | |
2126 | ||
2127 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2128 | divided_differences_array[Index + kk] *= difference ; | |
2129 | } | |
2130 | } | |
2131 | } | |
2132 | // | |
2133 | // | |
2134 | // Evaluate the divided difference array polynomial which expresses as | |
2135 | // | |
2136 | // P(t) = [t1] P + (t - t1) [t1,t2] P + (t - t1)(t - t2)[t1,t2,t3] P + ... | |
2137 | // + (t - t1)(t - t2)(t - t3)...(t - td) [t1,t2,...,td+1] P | |
2138 | // | |
2139 | // The ith slot in the divided_differences_array is [t1,t2,...,ti+1] | |
2140 | // | |
2141 | // | |
2142 | Index = Degree * Dimension ; | |
2143 | ||
2144 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2145 | ResultArray[kk] = divided_differences_array[Index + kk] ; | |
2146 | } | |
2147 | ||
2148 | for (ii = Dimension ; ii < (local_request + 1) * Dimension ; ii++) { | |
2149 | ResultArray[ii] = 0.0e0 ; | |
2150 | } | |
2151 | ||
2152 | for (ii = Degree ; ii >= 1 ; ii--) { | |
2153 | difference = Parameter - ParameterArray[ii - 1] ; | |
2154 | ||
2155 | for (jj = local_request ; jj > 0 ; jj--) { | |
2156 | Index = jj * Dimension ; | |
2157 | Index1 = Index - Dimension ; | |
2158 | ||
2159 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2160 | ResultArray[Index + kk] *= difference ; | |
2161 | ResultArray[Index + kk] += ResultArray[Index1+kk]*(Standard_Real) jj ; | |
2162 | } | |
2163 | } | |
2164 | Index = (ii -1) * Dimension ; | |
2165 | ||
2166 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2167 | ResultArray[kk] *= difference ; | |
2168 | ResultArray[kk] += divided_differences_array[Index+kk] ; | |
2169 | } | |
2170 | } | |
2171 | FINISH : | |
2172 | return (ReturnCode) ; | |
2173 | } | |
2174 | ||
2175 | //======================================================================= | |
2176 | //function : This evaluates the hermite polynomial and its derivatives | |
2177 | //purpose : up to the requested order that interpolates a series of | |
2178 | //points of dimension <Dimension> with given assigned parameters | |
2179 | //======================================================================= | |
2180 | ||
2181 | Standard_Integer PLib::EvalCubicHermite | |
2182 | (const Standard_Real Parameter, | |
2183 | const Standard_Integer DerivativeRequest, | |
2184 | const Standard_Integer Dimension, | |
2185 | Standard_Real& Values, | |
2186 | Standard_Real& Derivatives, | |
2187 | Standard_Real& theParameters, | |
2188 | Standard_Real& Results) | |
2189 | { | |
2190 | // | |
2191 | // the points are assumed to be stored as follows in the Values array : | |
2192 | // | |
2193 | // [0] [Dimension -1] first point coefficients | |
2194 | // | |
2195 | // [Dimension] [Dimension + Dimension -1] last point coefficients | |
2196 | // | |
2197 | // | |
2198 | // the derivatives are assumed to be stored as follows in | |
2199 | // the Derivatives array : | |
2200 | // | |
2201 | // [0] [Dimension -1] first point coefficients | |
2202 | // | |
2203 | // [Dimension] [Dimension + Dimension -1] last point coefficients | |
2204 | // | |
2205 | // The ParameterArray stores the parameter value assign to each point in | |
2206 | // order described above, that is | |
2207 | // [0] is assign to first point | |
2208 | // [1] is assign to last point | |
2209 | // | |
2210 | Standard_Integer ii, jj, kk, pp, Index, Index1, Degree, ReturnCode; | |
2211 | Standard_Integer local_request = DerivativeRequest ; | |
2212 | ||
2213 | ReturnCode = 0 ; | |
2214 | Degree = 3 ; | |
2215 | Standard_Real ParametersArray[4]; | |
2216 | Standard_Real difference; | |
2217 | Standard_Real inverse; | |
2218 | Standard_Real *FirstLast; | |
2219 | Standard_Real *PointsArray; | |
2220 | Standard_Real *DerivativesArray; | |
2221 | Standard_Real *ResultArray ; | |
2222 | ||
2223 | DerivativesArray = &Derivatives ; | |
2224 | PointsArray = &Values ; | |
2225 | FirstLast = &theParameters ; | |
2226 | ResultArray = &Results ; | |
2227 | if (local_request >= Degree) { | |
2228 | local_request = Degree ; | |
2229 | } | |
f7b4312f | 2230 | NCollection_LocalArray<Standard_Real> divided_differences_array ((Degree + 1) * Dimension); |
7fd59977 | 2231 | |
2232 | for (ii = 0, jj = 0 ; ii < 2 ; ii++, jj+= 2) { | |
2233 | ParametersArray[jj] = | |
2234 | ParametersArray[jj+1] = FirstLast[ii] ; | |
2235 | } | |
2236 | // | |
2237 | // Build the divided differences array | |
2238 | // | |
2239 | // | |
2240 | // initialise it at the stage 2 of the building algorithm | |
2241 | // for devided differences | |
2242 | // | |
2243 | inverse = FirstLast[1] - FirstLast[0] ; | |
2244 | inverse = 1.0e0 / inverse ; | |
2245 | ||
2246 | for (ii = 0, jj = Dimension, kk = 2 * Dimension, pp = 3 * Dimension ; | |
2247 | ii < Dimension ; | |
2248 | ii++, jj++, kk++, pp++) { | |
2249 | divided_differences_array[ii] = PointsArray[ii] ; | |
2250 | divided_differences_array[kk] = inverse * | |
2251 | (PointsArray[jj] - PointsArray[ii]) ; | |
2252 | divided_differences_array[jj] = DerivativesArray[ii] ; | |
2253 | divided_differences_array[pp] = DerivativesArray[jj] ; | |
2254 | } | |
2255 | ||
2256 | for (ii = 1 ; ii <= Degree ; ii++) { | |
2257 | ||
2258 | for (jj = Degree ; jj >= ii+1 ; jj--) { | |
2259 | Index = jj * Dimension ; | |
2260 | Index1 = Index - Dimension ; | |
2261 | ||
2262 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2263 | divided_differences_array[Index + kk] -= | |
2264 | divided_differences_array[Index1 + kk] ; | |
2265 | } | |
2266 | ||
2267 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2268 | divided_differences_array[Index + kk] *= inverse ; | |
2269 | } | |
2270 | } | |
2271 | } | |
2272 | // | |
2273 | // | |
2274 | // Evaluate the divided difference array polynomial which expresses as | |
2275 | // | |
2276 | // P(t) = [t1] P + (t - t1) [t1,t2] P + (t - t1)(t - t2)[t1,t2,t3] P + ... | |
2277 | // + (t - t1)(t - t2)(t - t3)...(t - td) [t1,t2,...,td+1] P | |
2278 | // | |
2279 | // The ith slot in the divided_differences_array is [t1,t2,...,ti+1] | |
2280 | // | |
2281 | // | |
2282 | Index = Degree * Dimension ; | |
2283 | ||
2284 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2285 | ResultArray[kk] = divided_differences_array[Index + kk] ; | |
2286 | } | |
2287 | ||
2288 | for (ii = Dimension ; ii < (local_request + 1) * Dimension ; ii++) { | |
2289 | ResultArray[ii] = 0.0e0 ; | |
2290 | } | |
2291 | ||
2292 | for (ii = Degree ; ii >= 1 ; ii--) { | |
2293 | difference = Parameter - ParametersArray[ii - 1] ; | |
2294 | ||
2295 | for (jj = local_request ; jj > 0 ; jj--) { | |
2296 | Index = jj * Dimension ; | |
2297 | Index1 = Index - Dimension ; | |
2298 | ||
2299 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2300 | ResultArray[Index + kk] *= difference ; | |
2301 | ResultArray[Index + kk] += ResultArray[Index1+kk]*(Standard_Real) jj; | |
2302 | } | |
2303 | } | |
2304 | Index = (ii -1) * Dimension ; | |
2305 | ||
2306 | for (kk = 0 ; kk < Dimension ; kk++) { | |
2307 | ResultArray[kk] *= difference ; | |
2308 | ResultArray[kk] += divided_differences_array[Index+kk] ; | |
2309 | } | |
2310 | } | |
2311 | // FINISH : | |
2312 | return (ReturnCode) ; | |
2313 | } | |
2314 | ||
2315 | //======================================================================= | |
2316 | //function : HermiteCoefficients | |
2317 | //purpose : calcul des polynomes d'Hermite | |
2318 | //======================================================================= | |
2319 | ||
2320 | Standard_Boolean PLib::HermiteCoefficients(const Standard_Real FirstParameter, | |
2321 | const Standard_Real LastParameter, | |
2322 | const Standard_Integer FirstOrder, | |
2323 | const Standard_Integer LastOrder, | |
2324 | math_Matrix& MatrixCoefs) | |
2325 | { | |
2326 | Standard_Integer NbCoeff = FirstOrder + LastOrder + 2, Ordre[2]; | |
2327 | Standard_Integer ii, jj, pp, cote, iof=0; | |
2328 | Standard_Real Prod, TBorne = FirstParameter; | |
2329 | math_Vector Coeff(1,NbCoeff), B(1, NbCoeff, 0.0); | |
2330 | math_Matrix MAT(1,NbCoeff, 1,NbCoeff, 0.0); | |
2331 | ||
2332 | // Test de validites | |
2333 | ||
2334 | if ((FirstOrder < 0) || (LastOrder < 0)) return Standard_False; | |
2335 | Standard_Real D1 = fabs(FirstParameter), D2 = fabs(LastParameter); | |
2336 | if (D1 > 100 || D2 > 100) return Standard_False; | |
2337 | D2 += D1; | |
2338 | if (D2 < 0.01) return Standard_False; | |
2339 | if (fabs(LastParameter - FirstParameter) / D2 < 0.01) return Standard_False; | |
2340 | ||
2341 | // Calcul de la matrice a inverser (MAT) | |
2342 | ||
2343 | Ordre[0] = FirstOrder+1; | |
2344 | Ordre[1] = LastOrder+1; | |
2345 | ||
2346 | for (cote=0; cote<=1; cote++) { | |
2347 | Coeff.Init(1); | |
2348 | ||
2349 | for (pp=1; pp<=Ordre[cote]; pp++) { | |
2350 | ii = pp + iof; | |
2351 | Prod = 1; | |
2352 | ||
2353 | for (jj=pp; jj<=NbCoeff; jj++) { | |
2354 | // tout se passe dans les 3 lignes suivantes | |
2355 | MAT(ii, jj) = Coeff(jj) * Prod; | |
2356 | Coeff(jj) *= jj - pp; | |
2357 | Prod *= TBorne; | |
2358 | } | |
2359 | } | |
2360 | TBorne = LastParameter; | |
2361 | iof = Ordre[0]; | |
2362 | } | |
2363 | ||
2364 | // resolution du systemes | |
2365 | math_Gauss ResolCoeff(MAT, 1.0e-10); | |
2366 | if (!ResolCoeff.IsDone()) return Standard_False; | |
2367 | ||
2368 | for (ii=1; ii<=NbCoeff; ii++) { | |
2369 | B(ii) = 1; | |
2370 | ResolCoeff.Solve(B, Coeff); | |
2371 | MatrixCoefs.SetRow( ii, Coeff); | |
2372 | B(ii) = 0; | |
2373 | } | |
2374 | return Standard_True; | |
2375 | } | |
2376 | ||
2377 | //======================================================================= | |
2378 | //function : CoefficientsPoles | |
2379 | //purpose : | |
2380 | //======================================================================= | |
2381 | ||
2382 | void PLib::CoefficientsPoles (const TColgp_Array1OfPnt& Coefs, | |
2383 | const TColStd_Array1OfReal& WCoefs, | |
2384 | TColgp_Array1OfPnt& Poles, | |
2385 | TColStd_Array1OfReal& Weights) | |
2386 | { | |
2387 | TColStd_Array1OfReal tempC(1,3*Coefs.Length()); | |
2388 | PLib::SetPoles(Coefs,tempC); | |
2389 | TColStd_Array1OfReal tempP(1,3*Poles.Length()); | |
2390 | PLib::SetPoles(Coefs,tempP); | |
2391 | PLib::CoefficientsPoles(3,tempC,WCoefs,tempP,Weights); | |
2392 | PLib::GetPoles(tempP,Poles); | |
2393 | } | |
2394 | ||
2395 | //======================================================================= | |
2396 | //function : CoefficientsPoles | |
2397 | //purpose : | |
2398 | //======================================================================= | |
2399 | ||
2400 | void PLib::CoefficientsPoles (const TColgp_Array1OfPnt2d& Coefs, | |
2401 | const TColStd_Array1OfReal& WCoefs, | |
2402 | TColgp_Array1OfPnt2d& Poles, | |
2403 | TColStd_Array1OfReal& Weights) | |
2404 | { | |
2405 | TColStd_Array1OfReal tempC(1,2*Coefs.Length()); | |
2406 | PLib::SetPoles(Coefs,tempC); | |
2407 | TColStd_Array1OfReal tempP(1,2*Poles.Length()); | |
2408 | PLib::SetPoles(Coefs,tempP); | |
2409 | PLib::CoefficientsPoles(2,tempC,WCoefs,tempP,Weights); | |
2410 | PLib::GetPoles(tempP,Poles); | |
2411 | } | |
2412 | ||
2413 | //======================================================================= | |
2414 | //function : CoefficientsPoles | |
2415 | //purpose : | |
2416 | //======================================================================= | |
2417 | ||
2418 | void PLib::CoefficientsPoles (const TColStd_Array1OfReal& Coefs, | |
2419 | const TColStd_Array1OfReal& WCoefs, | |
2420 | TColStd_Array1OfReal& Poles, | |
2421 | TColStd_Array1OfReal& Weights) | |
2422 | { | |
2423 | PLib::CoefficientsPoles(1,Coefs,WCoefs,Poles,Weights); | |
2424 | } | |
2425 | ||
2426 | //======================================================================= | |
2427 | //function : CoefficientsPoles | |
2428 | //purpose : | |
2429 | //======================================================================= | |
2430 | ||
2431 | void PLib::CoefficientsPoles (const Standard_Integer dim, | |
2432 | const TColStd_Array1OfReal& Coefs, | |
2433 | const TColStd_Array1OfReal& WCoefs, | |
2434 | TColStd_Array1OfReal& Poles, | |
2435 | TColStd_Array1OfReal& Weights) | |
2436 | { | |
2437 | Standard_Boolean rat = &WCoefs != NULL; | |
2438 | Standard_Integer loc = Coefs.Lower(); | |
2439 | Standard_Integer lop = Poles.Lower(); | |
2440 | Standard_Integer lowc=0; | |
2441 | Standard_Integer lowp=0; | |
2442 | Standard_Integer upc = Coefs.Upper(); | |
2443 | Standard_Integer upp = Poles.Upper(); | |
2444 | Standard_Integer upwc=0; | |
2445 | Standard_Integer upwp=0; | |
2446 | Standard_Integer reflen = Coefs.Length()/dim; | |
2447 | Standard_Integer i,j,k; | |
2448 | //Les Extremites. | |
2449 | if (rat) { | |
2450 | lowc = WCoefs.Lower(); lowp = Weights.Lower(); | |
2451 | upwc = WCoefs.Upper(); upwp = Weights.Upper(); | |
2452 | } | |
2453 | ||
2454 | for (i = 0; i < dim; i++){ | |
2455 | Poles (lop + i) = Coefs (loc + i); | |
2456 | Poles (upp - i) = Coefs (upc - i); | |
2457 | } | |
2458 | if (rat) { | |
2459 | Weights (lowp) = WCoefs (lowc); | |
2460 | Weights (upwp) = WCoefs (upwc); | |
2461 | } | |
2462 | ||
2463 | Standard_Real Cnp; | |
7fd59977 | 2464 | for (i = 2; i < reflen; i++ ) { |
2465 | Cnp = PLib::Bin(reflen - 1, i - 1); | |
2466 | if (rat) Weights (lowp + i - 1) = WCoefs (lowc + i - 1) / Cnp; | |
2467 | ||
2468 | for(j = 0; j < dim; j++){ | |
2469 | Poles(lop + dim * (i-1) + j)= Coefs(loc + dim * (i-1) + j) / Cnp; | |
2470 | } | |
2471 | } | |
2472 | ||
2473 | for (i = 1; i <= reflen - 1; i++) { | |
2474 | ||
2475 | for (j = reflen - 1; j >= i; j--) { | |
2476 | if (rat) Weights (lowp + j) += Weights (lowp + j -1); | |
2477 | ||
2478 | for(k = 0; k < dim; k++){ | |
2479 | Poles(lop + dim * j + k) += Poles(lop + dim * (j - 1) + k); | |
2480 | } | |
2481 | } | |
2482 | } | |
2483 | if (rat) { | |
2484 | ||
2485 | for (i = 1; i <= reflen; i++) { | |
2486 | ||
2487 | for(j = 0; j < dim; j++){ | |
2488 | Poles(lop + dim * (i-1) + j) /= Weights(lowp + i -1); | |
2489 | } | |
2490 | } | |
2491 | } | |
2492 | } | |
2493 | ||
2494 | //======================================================================= | |
2495 | //function : Trimming | |
2496 | //purpose : | |
2497 | //======================================================================= | |
2498 | ||
2499 | void PLib::Trimming(const Standard_Real U1, | |
2500 | const Standard_Real U2, | |
2501 | TColgp_Array1OfPnt& Coefs, | |
2502 | TColStd_Array1OfReal& WCoefs) | |
2503 | { | |
2504 | TColStd_Array1OfReal temp(1,3*Coefs.Length()); | |
2505 | PLib::SetPoles(Coefs,temp); | |
2506 | PLib::Trimming(U1,U2,3,temp,WCoefs); | |
2507 | PLib::GetPoles(temp,Coefs); | |
2508 | } | |
2509 | ||
2510 | //======================================================================= | |
2511 | //function : Trimming | |
2512 | //purpose : | |
2513 | //======================================================================= | |
2514 | ||
2515 | void PLib::Trimming(const Standard_Real U1, | |
2516 | const Standard_Real U2, | |
2517 | TColgp_Array1OfPnt2d& Coefs, | |
2518 | TColStd_Array1OfReal& WCoefs) | |
2519 | { | |
2520 | TColStd_Array1OfReal temp(1,2*Coefs.Length()); | |
2521 | PLib::SetPoles(Coefs,temp); | |
2522 | PLib::Trimming(U1,U2,2,temp,WCoefs); | |
2523 | PLib::GetPoles(temp,Coefs); | |
2524 | } | |
2525 | ||
2526 | //======================================================================= | |
2527 | //function : Trimming | |
2528 | //purpose : | |
2529 | //======================================================================= | |
2530 | ||
2531 | void PLib::Trimming(const Standard_Real U1, | |
2532 | const Standard_Real U2, | |
2533 | TColStd_Array1OfReal& Coefs, | |
2534 | TColStd_Array1OfReal& WCoefs) | |
2535 | { | |
2536 | PLib::Trimming(U1,U2,1,Coefs,WCoefs); | |
2537 | } | |
2538 | ||
2539 | //======================================================================= | |
2540 | //function : Trimming | |
2541 | //purpose : | |
2542 | //======================================================================= | |
2543 | ||
2544 | void PLib::Trimming(const Standard_Real U1, | |
2545 | const Standard_Real U2, | |
2546 | const Standard_Integer dim, | |
2547 | TColStd_Array1OfReal& Coefs, | |
2548 | TColStd_Array1OfReal& WCoefs) | |
2549 | { | |
2550 | ||
2551 | // principe : | |
2552 | // on fait le changement de variable v = (u-U1) / (U2-U1) | |
2553 | // on exprime u = f(v) que l'on remplace dans l'expression polynomiale | |
2554 | // decomposee sous la forme du schema iteratif de horner. | |
2555 | ||
2556 | Standard_Real lsp = U2 - U1; | |
2557 | Standard_Integer indc, indw=0; | |
2558 | Standard_Integer upc = Coefs.Upper() - dim + 1, upw=0; | |
2559 | Standard_Integer len = Coefs.Length()/dim; | |
2560 | Standard_Boolean rat = &WCoefs != NULL; | |
2561 | ||
2562 | if (rat) { | |
2563 | if(len != WCoefs.Length()) | |
2564 | Standard_Failure::Raise("PLib::Trimming : nbcoefs/dim != nbweights !!!"); | |
2565 | upw = WCoefs.Upper(); | |
2566 | } | |
2567 | len --; | |
2568 | ||
2569 | for (Standard_Integer i = 1; i <= len; i++) { | |
2570 | Standard_Integer j ; | |
2571 | indc = upc - dim*(i-1); | |
2572 | if (rat) indw = upw - i + 1; | |
2573 | //calcul du coefficient de degre le plus faible a l'iteration i | |
2574 | ||
2575 | for( j = 0; j < dim; j++){ | |
2576 | Coefs(indc - dim + j) += U1 * Coefs(indc + j); | |
2577 | } | |
2578 | if (rat) WCoefs(indw - 1) += U1 * WCoefs(indw); | |
2579 | ||
2580 | //calcul des coefficients intermediaires : | |
2581 | ||
2582 | while (indc < upc){ | |
2583 | indc += dim; | |
2584 | ||
2585 | for(Standard_Integer k = 0; k < dim; k++){ | |
2586 | Coefs(indc - dim + k) = | |
2587 | U1 * Coefs(indc + k) + lsp * Coefs(indc - dim + k); | |
2588 | } | |
2589 | if (rat) { | |
2590 | indw ++; | |
2591 | WCoefs(indw - 1) = U1 * WCoefs(indw) + lsp * WCoefs(indw - 1); | |
2592 | } | |
2593 | } | |
2594 | ||
2595 | //calcul du coefficient de degre le plus eleve : | |
2596 | ||
2597 | for(j = 0; j < dim; j++){ | |
2598 | Coefs(upc + j) *= lsp; | |
2599 | } | |
2600 | if (rat) WCoefs(upw) *= lsp; | |
2601 | } | |
2602 | } | |
2603 | ||
2604 | //======================================================================= | |
2605 | //function : CoefficientsPoles | |
2606 | //purpose : | |
2607 | // Modified: 21/10/1996 by PMN : PolesCoefficient (PRO5852). | |
2608 | // on ne bidouille plus les u et v c'est a l'appelant de savoir ce qu'il | |
2609 | // fait avec BuildCache ou plus simplement d'utiliser PolesCoefficients | |
2610 | //======================================================================= | |
2611 | ||
2612 | void PLib::CoefficientsPoles (const TColgp_Array2OfPnt& Coefs, | |
2613 | const TColStd_Array2OfReal& WCoefs, | |
2614 | TColgp_Array2OfPnt& Poles, | |
2615 | TColStd_Array2OfReal& Weights) | |
2616 | { | |
2617 | Standard_Boolean rat = (&WCoefs != NULL); | |
2618 | Standard_Integer LowerRow = Poles.LowerRow(); | |
2619 | Standard_Integer UpperRow = Poles.UpperRow(); | |
2620 | Standard_Integer LowerCol = Poles.LowerCol(); | |
2621 | Standard_Integer UpperCol = Poles.UpperCol(); | |
2622 | Standard_Integer ColLength = Poles.ColLength(); | |
2623 | Standard_Integer RowLength = Poles.RowLength(); | |
2624 | ||
2625 | // Bidouille pour retablir u et v pour les coefs calcules | |
2626 | // par buildcache | |
2627 | // Standard_Boolean inv = Standard_False; //ColLength != Coefs.ColLength(); | |
2628 | ||
2629 | Standard_Integer Row, Col; | |
2630 | Standard_Real W, Cnp; | |
2631 | ||
2632 | Standard_Integer I1, I2; | |
2633 | Standard_Integer NPoleu , NPolev; | |
2634 | gp_XYZ Temp; | |
7fd59977 | 2635 | |
2636 | for (NPoleu = LowerRow; NPoleu <= UpperRow; NPoleu++){ | |
2637 | Poles (NPoleu, LowerCol) = Coefs (NPoleu, LowerCol); | |
2638 | if (rat) { | |
2639 | Weights (NPoleu, LowerCol) = WCoefs (NPoleu, LowerCol); | |
2640 | } | |
2641 | ||
2642 | for (Col = LowerCol + 1; Col <= UpperCol - 1; Col++) { | |
2643 | Cnp = PLib::Bin(RowLength - 1,Col - LowerCol); | |
2644 | Temp = Coefs (NPoleu, Col).XYZ(); | |
2645 | Temp.Divide (Cnp); | |
2646 | Poles (NPoleu, Col).SetXYZ (Temp); | |
2647 | if (rat) { | |
2648 | Weights (NPoleu, Col) = WCoefs (NPoleu, Col) / Cnp; | |
2649 | } | |
2650 | } | |
2651 | Poles (NPoleu, UpperCol) = Coefs (NPoleu, UpperCol); | |
2652 | if (rat) { | |
2653 | Weights (NPoleu, UpperCol) = WCoefs (NPoleu, UpperCol); | |
2654 | } | |
2655 | ||
2656 | for (I1 = 1; I1 <= RowLength - 1; I1++) { | |
2657 | ||
2658 | for (I2 = UpperCol; I2 >= LowerCol + I1; I2--) { | |
2659 | Temp.SetLinearForm | |
2660 | (Poles (NPoleu, I2).XYZ(), Poles (NPoleu, I2-1).XYZ()); | |
2661 | Poles (NPoleu, I2).SetXYZ (Temp); | |
2662 | if (rat) Weights(NPoleu, I2) += Weights(NPoleu, I2-1); | |
2663 | } | |
2664 | } | |
2665 | } | |
7fd59977 | 2666 | |
2667 | for (NPolev = LowerCol; NPolev <= UpperCol; NPolev++){ | |
2668 | ||
2669 | for (Row = LowerRow + 1; Row <= UpperRow - 1; Row++) { | |
2670 | Cnp = PLib::Bin(ColLength - 1,Row - LowerRow); | |
2671 | Temp = Poles (Row, NPolev).XYZ(); | |
2672 | Temp.Divide (Cnp); | |
2673 | Poles (Row, NPolev).SetXYZ (Temp); | |
2674 | if (rat) Weights(Row, NPolev) /= Cnp; | |
2675 | } | |
2676 | ||
2677 | for (I1 = 1; I1 <= ColLength - 1; I1++) { | |
2678 | ||
2679 | for (I2 = UpperRow; I2 >= LowerRow + I1; I2--) { | |
2680 | Temp.SetLinearForm | |
2681 | (Poles (I2, NPolev).XYZ(), Poles (I2-1, NPolev).XYZ()); | |
2682 | Poles (I2, NPolev).SetXYZ (Temp); | |
2683 | if (rat) Weights(I2, NPolev) += Weights(I2-1, NPolev); | |
2684 | } | |
2685 | } | |
2686 | } | |
2687 | if (rat) { | |
2688 | ||
2689 | for (Row = LowerRow; Row <= UpperRow; Row++) { | |
2690 | ||
2691 | for (Col = LowerCol; Col <= UpperCol; Col++) { | |
2692 | W = Weights (Row, Col); | |
2693 | Temp = Poles(Row, Col).XYZ(); | |
2694 | Temp.Divide (W); | |
2695 | Poles(Row, Col).SetXYZ (Temp); | |
2696 | } | |
2697 | } | |
2698 | } | |
2699 | } | |
2700 | ||
2701 | //======================================================================= | |
2702 | //function : UTrimming | |
2703 | //purpose : | |
2704 | //======================================================================= | |
2705 | ||
2706 | void PLib::UTrimming(const Standard_Real U1, | |
2707 | const Standard_Real U2, | |
2708 | TColgp_Array2OfPnt& Coeffs, | |
2709 | TColStd_Array2OfReal& WCoeffs) | |
2710 | { | |
2711 | Standard_Boolean rat = &WCoeffs != NULL; | |
2712 | Standard_Integer lr = Coeffs.LowerRow(); | |
2713 | Standard_Integer ur = Coeffs.UpperRow(); | |
2714 | Standard_Integer lc = Coeffs.LowerCol(); | |
2715 | Standard_Integer uc = Coeffs.UpperCol(); | |
2716 | TColgp_Array1OfPnt Temp (lr,ur); | |
2717 | TColStd_Array1OfReal Temw (lr,ur); | |
2718 | ||
2719 | for (Standard_Integer icol = lc; icol <= uc; icol++) { | |
2720 | Standard_Integer irow ; | |
2721 | for ( irow = lr; irow <= ur; irow++) { | |
2722 | Temp (irow) = Coeffs (irow, icol); | |
2723 | if (rat) Temw (irow) = WCoeffs (irow, icol); | |
2724 | } | |
2725 | if (rat) PLib::Trimming (U1, U2, Temp, Temw); | |
2726 | else PLib::Trimming (U1, U2, Temp, PLib::NoWeights()); | |
2727 | ||
2728 | for (irow = lr; irow <= ur; irow++) { | |
2729 | Coeffs (irow, icol) = Temp (irow); | |
2730 | if (rat) WCoeffs (irow, icol) = Temw (irow); | |
2731 | } | |
2732 | } | |
2733 | } | |
2734 | ||
2735 | //======================================================================= | |
2736 | //function : VTrimming | |
2737 | //purpose : | |
2738 | //======================================================================= | |
2739 | ||
2740 | void PLib::VTrimming(const Standard_Real V1, | |
2741 | const Standard_Real V2, | |
2742 | TColgp_Array2OfPnt& Coeffs, | |
2743 | TColStd_Array2OfReal& WCoeffs) | |
2744 | { | |
2745 | Standard_Boolean rat = &WCoeffs != NULL; | |
2746 | Standard_Integer lr = Coeffs.LowerRow(); | |
2747 | Standard_Integer ur = Coeffs.UpperRow(); | |
2748 | Standard_Integer lc = Coeffs.LowerCol(); | |
2749 | Standard_Integer uc = Coeffs.UpperCol(); | |
2750 | TColgp_Array1OfPnt Temp (lc,uc); | |
2751 | TColStd_Array1OfReal Temw (lc,uc); | |
2752 | ||
2753 | for (Standard_Integer irow = lr; irow <= ur; irow++) { | |
2754 | Standard_Integer icol ; | |
2755 | for ( icol = lc; icol <= uc; icol++) { | |
2756 | Temp (icol) = Coeffs (irow, icol); | |
2757 | if (rat) Temw (icol) = WCoeffs (irow, icol); | |
2758 | } | |
2759 | if (rat) PLib::Trimming (V1, V2, Temp, Temw); | |
2760 | else PLib::Trimming (V1, V2, Temp, PLib::NoWeights()); | |
2761 | ||
2762 | for (icol = lc; icol <= uc; icol++) { | |
2763 | Coeffs (irow, icol) = Temp (icol); | |
2764 | if (rat) WCoeffs (irow, icol) = Temw (icol); | |
2765 | } | |
2766 | } | |
2767 | } | |
2768 | ||
2769 | //======================================================================= | |
2770 | //function : HermiteInterpolate | |
2771 | //purpose : | |
2772 | //======================================================================= | |
2773 | ||
2774 | Standard_Boolean PLib::HermiteInterpolate | |
2775 | (const Standard_Integer Dimension, | |
2776 | const Standard_Real FirstParameter, | |
2777 | const Standard_Real LastParameter, | |
2778 | const Standard_Integer FirstOrder, | |
2779 | const Standard_Integer LastOrder, | |
2780 | const TColStd_Array2OfReal& FirstConstr, | |
2781 | const TColStd_Array2OfReal& LastConstr, | |
2782 | TColStd_Array1OfReal& Coefficients) | |
2783 | { | |
2784 | Standard_Real Pattern[3][6]; | |
2785 | ||
2786 | // portage HP : il faut les initialiser 1 par 1 | |
2787 | ||
2788 | Pattern[0][0] = 1; | |
2789 | Pattern[0][1] = 1; | |
2790 | Pattern[0][2] = 1; | |
2791 | Pattern[0][3] = 1; | |
2792 | Pattern[0][4] = 1; | |
2793 | Pattern[0][5] = 1; | |
2794 | Pattern[1][0] = 0; | |
2795 | Pattern[1][1] = 1; | |
2796 | Pattern[1][2] = 2; | |
2797 | Pattern[1][3] = 3; | |
2798 | Pattern[1][4] = 4; | |
2799 | Pattern[1][5] = 5; | |
2800 | Pattern[2][0] = 0; | |
2801 | Pattern[2][1] = 0; | |
2802 | Pattern[2][2] = 2; | |
2803 | Pattern[2][3] = 6; | |
2804 | Pattern[2][4] = 12; | |
2805 | Pattern[2][5] = 20; | |
2806 | ||
2807 | math_Matrix A(0,FirstOrder+LastOrder+1, 0,FirstOrder+LastOrder+1); | |
2808 | // The initialisation of the matrix A | |
2809 | Standard_Integer irow ; | |
2810 | for ( irow=0; irow<=FirstOrder; irow++) { | |
2811 | Standard_Real FirstVal = 1.; | |
2812 | ||
2813 | for (Standard_Integer icol=0; icol<=FirstOrder+LastOrder+1; icol++) { | |
2814 | A(irow,icol) = Pattern[irow][icol]*FirstVal; | |
2815 | if (irow <= icol) FirstVal *= FirstParameter; | |
2816 | } | |
2817 | } | |
2818 | ||
2819 | for (irow=0; irow<=LastOrder; irow++) { | |
2820 | Standard_Real LastVal = 1.; | |
2821 | ||
2822 | for (Standard_Integer icol=0; icol<=FirstOrder+LastOrder+1; icol++) { | |
2823 | A(irow+FirstOrder+1,icol) = Pattern[irow][icol]*LastVal; | |
2824 | if (irow <= icol) LastVal *= LastParameter; | |
2825 | } | |
2826 | } | |
2827 | // | |
2828 | // The filled matrix A for FirstOrder=LastOrder=2 is: | |
2829 | // | |
2830 | // 1 FP FP**2 FP**3 FP**4 FP**5 | |
2831 | // 0 1 2*FP 3*FP**2 4*FP**3 5*FP**4 FP - FirstParameter | |
2832 | // 0 0 2 6*FP 12*FP**2 20*FP**3 | |
2833 | // 1 LP LP**2 LP**3 LP**4 LP**5 | |
2834 | // 0 1 2*LP 3*LP**2 4*LP**3 5*LP**4 LP - LastParameter | |
2835 | // 0 0 2 6*LP 12*LP**2 20*LP**3 | |
2836 | // | |
2837 | // If FirstOrder or LastOrder <=2 then some rows and columns are missing. | |
2838 | // For example: | |
2839 | // If FirstOrder=1 then 3th row and 6th column are missing | |
2840 | // If FirstOrder=LastOrder=0 then 2,3,5,6th rows and 3,4,5,6th columns are missing | |
2841 | ||
2842 | math_Gauss Equations(A); | |
2843 | // cout << "A=" << A << endl; | |
2844 | ||
2845 | for (Standard_Integer idim=1; idim<=Dimension; idim++) { | |
2846 | // cout << "idim=" << idim << endl; | |
2847 | ||
2848 | math_Vector B(0,FirstOrder+LastOrder+1); | |
2849 | Standard_Integer icol ; | |
2850 | for ( icol=0; icol<=FirstOrder; icol++) | |
2851 | B(icol) = FirstConstr(idim,icol); | |
2852 | ||
2853 | for (icol=0; icol<=LastOrder; icol++) | |
2854 | B(FirstOrder+1+icol) = LastConstr(idim,icol); | |
2855 | // cout << "B=" << B << endl; | |
2856 | ||
2857 | // The solving of equations system A * X = B. Then B = X | |
2858 | Equations.Solve(B); | |
2859 | // cout << "After Solving" << endl << "B=" << B << endl; | |
2860 | ||
2861 | if (Equations.IsDone()==Standard_False) return Standard_False; | |
2862 | ||
2863 | // the filling of the Coefficients | |
2864 | ||
2865 | for (icol=0; icol<=FirstOrder+LastOrder+1; icol++) | |
2866 | Coefficients(Dimension*icol+idim-1) = B(icol); | |
2867 | } | |
2868 | return Standard_True; | |
2869 | } | |
2870 | ||
2871 | //======================================================================= | |
2872 | //function : JacobiParameters | |
2873 | //purpose : | |
2874 | //======================================================================= | |
2875 | ||
2876 | void PLib::JacobiParameters(const GeomAbs_Shape ConstraintOrder, | |
2877 | const Standard_Integer MaxDegree, | |
2878 | const Standard_Integer Code, | |
2879 | Standard_Integer& NbGaussPoints, | |
2880 | Standard_Integer& WorkDegree) | |
2881 | { | |
2882 | // ConstraintOrder: Ordre de contrainte aux extremites : | |
2883 | // C0 = contraintes de passage aux bornes; | |
2884 | // C1 = C0 + contraintes de derivees 1eres; | |
2885 | // C2 = C1 + contraintes de derivees 2ndes. | |
2886 | // MaxDegree: Nombre maxi de coeff de la "courbe" polynomiale | |
2887 | // d' approximation (doit etre superieur ou egal a | |
2888 | // 2*NivConstr+2 et inferieur ou egal a 50). | |
2889 | // Code: Code d' init. des parametres de discretisation. | |
2890 | // (choix de NBPNTS et de NDGJAC de MAPF1C,MAPFXC). | |
2891 | // = -5 Calcul tres rapide mais peu precis (8pts) | |
2892 | // = -4 ' ' ' ' ' ' (10pts) | |
2893 | // = -3 ' ' ' ' ' ' (15pts) | |
2894 | // = -2 ' ' ' ' ' ' (20pts) | |
2895 | // = -1 ' ' ' ' ' ' (25pts) | |
2896 | // = 1 calcul rapide avec precision moyenne (30pts). | |
2897 | // = 2 calcul rapide avec meilleure precision (40pts). | |
2898 | // = 3 calcul un peu plus lent avec bonne precision (50 pts). | |
2899 | // = 4 calcul lent avec la meilleure precision possible | |
2900 | // (61pts). | |
2901 | ||
2902 | // The possible values of NbGaussPoints | |
2903 | ||
2904 | const Standard_Integer NDEG8=8, NDEG10=10, NDEG15=15, NDEG20=20, NDEG25=25, | |
2905 | NDEG30=30, NDEG40=40, NDEG50=50, NDEG61=61; | |
2906 | ||
2907 | Standard_Integer NivConstr=0; | |
2908 | switch (ConstraintOrder) { | |
2909 | case GeomAbs_C0: NivConstr = 0; break; | |
2910 | case GeomAbs_C1: NivConstr = 1; break; | |
2911 | case GeomAbs_C2: NivConstr = 2; break; | |
2912 | default: | |
2913 | Standard_ConstructionError::Raise("Invalid ConstraintOrder"); | |
2914 | } | |
2915 | if (MaxDegree < 2*NivConstr+1) | |
2916 | Standard_ConstructionError::Raise("Invalid MaxDegree"); | |
2917 | ||
2918 | if (Code >= 1) | |
2919 | WorkDegree = MaxDegree + 9; | |
2920 | else | |
2921 | WorkDegree = MaxDegree + 6; | |
2922 | ||
2923 | //---> Nbre mini de points necessaires. | |
2924 | Standard_Integer IPMIN=0; | |
2925 | if (WorkDegree < NDEG8) | |
2926 | IPMIN=NDEG8; | |
2927 | else if (WorkDegree < NDEG10) | |
2928 | IPMIN=NDEG10; | |
2929 | else if (WorkDegree < NDEG15) | |
2930 | IPMIN=NDEG15; | |
2931 | else if (WorkDegree < NDEG20) | |
2932 | IPMIN=NDEG20; | |
2933 | else if (WorkDegree < NDEG25) | |
2934 | IPMIN=NDEG25; | |
2935 | else if (WorkDegree < NDEG30) | |
2936 | IPMIN=NDEG30; | |
2937 | else if (WorkDegree < NDEG40) | |
2938 | IPMIN=NDEG40; | |
2939 | else if (WorkDegree < NDEG50) | |
2940 | IPMIN=NDEG50; | |
2941 | else if (WorkDegree < NDEG61) | |
2942 | IPMIN=NDEG61; | |
2943 | else | |
2944 | Standard_ConstructionError::Raise("Invalid MaxDegree"); | |
2945 | // ---> Nbre de points voulus. | |
2946 | Standard_Integer IWANT=0; | |
2947 | switch (Code) { | |
2948 | case -5: IWANT=NDEG8; break; | |
2949 | case -4: IWANT=NDEG10; break; | |
2950 | case -3: IWANT=NDEG15; break; | |
2951 | case -2: IWANT=NDEG20; break; | |
2952 | case -1: IWANT=NDEG25; break; | |
2953 | case 1: IWANT=NDEG30; break; | |
2954 | case 2: IWANT=NDEG40; break; | |
2955 | case 3: IWANT=NDEG50; break; | |
2956 | case 4: IWANT=NDEG61; break; | |
2957 | default: | |
2958 | Standard_ConstructionError::Raise("Invalid Code"); | |
2959 | } | |
2960 | //--> NbGaussPoints est le nombre de points de discretisation de la fonction, | |
2961 | // il ne peut prendre que les valeurs 8,10,15,20,25,30,40,50 ou 61. | |
2962 | // NbGaussPoints doit etre superieur strictement a WorkDegree. | |
2963 | NbGaussPoints = Max(IPMIN,IWANT); | |
2964 | // NbGaussPoints +=2; | |
2965 | } | |
2966 | ||
2967 | //======================================================================= | |
2968 | //function : NivConstr | |
2969 | //purpose : translates from GeomAbs_Shape to Integer | |
2970 | //======================================================================= | |
2971 | ||
2972 | Standard_Integer PLib::NivConstr(const GeomAbs_Shape ConstraintOrder) | |
2973 | { | |
2974 | Standard_Integer NivConstr=0; | |
2975 | switch (ConstraintOrder) { | |
2976 | case GeomAbs_C0: NivConstr = 0; break; | |
2977 | case GeomAbs_C1: NivConstr = 1; break; | |
2978 | case GeomAbs_C2: NivConstr = 2; break; | |
2979 | default: | |
2980 | Standard_ConstructionError::Raise("Invalid ConstraintOrder"); | |
2981 | } | |
2982 | return NivConstr; | |
2983 | } | |
2984 | ||
2985 | //======================================================================= | |
2986 | //function : ConstraintOrder | |
2987 | //purpose : translates from Integer to GeomAbs_Shape | |
2988 | //======================================================================= | |
2989 | ||
2990 | GeomAbs_Shape PLib::ConstraintOrder(const Standard_Integer NivConstr) | |
2991 | { | |
2992 | GeomAbs_Shape ConstraintOrder=GeomAbs_C0; | |
2993 | switch (NivConstr) { | |
2994 | case 0: ConstraintOrder = GeomAbs_C0; break; | |
2995 | case 1: ConstraintOrder = GeomAbs_C1; break; | |
2996 | case 2: ConstraintOrder = GeomAbs_C2; break; | |
2997 | default: | |
2998 | Standard_ConstructionError::Raise("Invalid NivConstr"); | |
2999 | } | |
3000 | return ConstraintOrder; | |
3001 | } | |
3002 | ||
3003 | //======================================================================= | |
3004 | //function : EvalLength | |
3005 | //purpose : | |
3006 | //======================================================================= | |
3007 | ||
3008 | void PLib::EvalLength(const Standard_Integer Degree, const Standard_Integer Dimension, | |
3009 | Standard_Real& PolynomialCoeff, | |
3010 | const Standard_Real U1, const Standard_Real U2, | |
3011 | Standard_Real& Length) | |
3012 | { | |
3013 | Standard_Integer i,j,idim, degdim; | |
3014 | Standard_Real C1,C2,Sum,Tran,X1,X2,Der1,Der2,D1,D2,DD; | |
3015 | ||
3016 | Standard_Real *PolynomialArray = &PolynomialCoeff ; | |
3017 | ||
3018 | Standard_Integer NbGaussPoints = 4 * Min((Degree/4)+1,10); | |
3019 | ||
3020 | math_Vector GaussPoints(1,NbGaussPoints); | |
3021 | math::GaussPoints(NbGaussPoints,GaussPoints); | |
3022 | ||
3023 | math_Vector GaussWeights(1,NbGaussPoints); | |
3024 | math::GaussWeights(NbGaussPoints,GaussWeights); | |
3025 | ||
3026 | C1 = (U2 + U1) / 2.; | |
3027 | C2 = (U2 - U1) / 2.; | |
3028 | ||
3029 | //----------------------------------------------------------- | |
3030 | //****** Integration - Boucle sur les intervalles de GAUSS ** | |
3031 | //----------------------------------------------------------- | |
3032 | ||
3033 | Sum = 0; | |
3034 | ||
3035 | for (j=1; j<=NbGaussPoints/2; j++) { | |
3036 | // Integration en tenant compte de la symetrie | |
3037 | Tran = C2 * GaussPoints(j); | |
3038 | X1 = C1 + Tran; | |
3039 | X2 = C1 - Tran; | |
3040 | ||
3041 | //****** Derivation sur la dimension de l'espace ** | |
3042 | ||
3043 | degdim = Degree*Dimension; | |
3044 | Der1 = Der2 = 0.; | |
3045 | for (idim=0; idim<Dimension; idim++) { | |
3046 | D1 = D2 = Degree * PolynomialArray [idim + degdim]; | |
3047 | for (i=Degree-1; i>=1; i--) { | |
3048 | DD = i * PolynomialArray [idim + i*Dimension]; | |
3049 | D1 = D1 * X1 + DD; | |
3050 | D2 = D2 * X2 + DD; | |
3051 | } | |
3052 | Der1 += D1 * D1; | |
3053 | Der2 += D2 * D2; | |
3054 | } | |
3055 | ||
3056 | //****** Integration ** | |
3057 | ||
3058 | Sum += GaussWeights(j) * C2 * (Sqrt(Der1) + Sqrt(Der2)); | |
3059 | ||
3060 | //****** Fin de boucle dur les intervalles de GAUSS ** | |
3061 | } | |
3062 | Length = Sum; | |
3063 | } | |
3064 | ||
3065 | ||
3066 | //======================================================================= | |
3067 | //function : EvalLength | |
3068 | //purpose : | |
3069 | //======================================================================= | |
3070 | ||
3071 | void PLib::EvalLength(const Standard_Integer Degree, const Standard_Integer Dimension, | |
3072 | Standard_Real& PolynomialCoeff, | |
3073 | const Standard_Real U1, const Standard_Real U2, | |
3074 | const Standard_Real Tol, | |
3075 | Standard_Real& Length, Standard_Real& Error) | |
3076 | { | |
3077 | Standard_Integer i; | |
3078 | Standard_Integer NbSubInt = 1, // Current number of subintervals | |
3079 | MaxNbIter = 13, // Max number of iterations | |
3080 | NbIter = 1; // Current number of iterations | |
3081 | Standard_Real dU,OldLen,LenI; | |
3082 | ||
3083 | PLib::EvalLength(Degree,Dimension, PolynomialCoeff, U1,U2, Length); | |
3084 | ||
3085 | do { | |
3086 | OldLen = Length; | |
3087 | Length = 0.; | |
3088 | NbSubInt *= 2; | |
3089 | dU = (U2-U1)/NbSubInt; | |
3090 | for (i=1; i<=NbSubInt; i++) { | |
3091 | PLib::EvalLength(Degree,Dimension, PolynomialCoeff, U1+(i-1)*dU,U1+i*dU, LenI); | |
3092 | Length += LenI; | |
3093 | } | |
3094 | NbIter++; | |
3095 | Error = Abs(OldLen-Length); | |
3096 | } | |
3097 | while (Error > Tol && NbIter <= MaxNbIter); | |
3098 | } |