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
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.
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.
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.
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
26 #include <NCollection_LocalArray.hxx>
27 #include <math_Matrix.hxx>
28 #include <math_Gauss.hxx>
29 #include <Standard_ConstructionError.hxx>
30 #include <GeomAbs_Shape.hxx>
32 #include <math_Gauss.hxx>
35 // To convert points array into Real ..
36 // *********************************
38 //=======================================================================
41 //=======================================================================
43 void PLib::SetPoles(const TColgp_Array1OfPnt2d& Poles,
44 TColStd_Array1OfReal& FP)
46 Standard_Integer j = FP .Lower();
47 Standard_Integer PLower = Poles.Lower();
48 Standard_Integer PUpper = Poles.Upper();
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++;
57 //=======================================================================
60 //=======================================================================
62 void PLib::SetPoles(const TColgp_Array1OfPnt2d& Poles,
63 const TColStd_Array1OfReal& Weights,
64 TColStd_Array1OfReal& FP)
66 Standard_Integer j = FP .Lower();
67 Standard_Integer PLower = Poles.Lower();
68 Standard_Integer PUpper = Poles.Upper();
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++;
79 //=======================================================================
82 //=======================================================================
84 void PLib::GetPoles(const TColStd_Array1OfReal& FP,
85 TColgp_Array1OfPnt2d& Poles)
87 Standard_Integer j = FP .Lower();
88 Standard_Integer PLower = Poles.Lower();
89 Standard_Integer PUpper = Poles.Upper();
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++;
98 //=======================================================================
101 //=======================================================================
103 void PLib::GetPoles(const TColStd_Array1OfReal& FP,
104 TColgp_Array1OfPnt2d& Poles,
105 TColStd_Array1OfReal& Weights)
107 Standard_Integer j = FP .Lower();
108 Standard_Integer PLower = Poles.Lower();
109 Standard_Integer PUpper = Poles.Upper();
111 for (Standard_Integer i = PLower; i <= PUpper; i++) {
112 Standard_Real w = FP(j + 2);
114 gp_Pnt2d& P = Poles(i);
115 P.SetCoord(1,FP(j) / w); j++;
116 P.SetCoord(2,FP(j) / w); j++;
121 //=======================================================================
122 //function : SetPoles
124 //=======================================================================
126 void PLib::SetPoles(const TColgp_Array1OfPnt& Poles,
127 TColStd_Array1OfReal& FP)
129 Standard_Integer j = FP .Lower();
130 Standard_Integer PLower = Poles.Lower();
131 Standard_Integer PUpper = Poles.Upper();
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++;
141 //=======================================================================
142 //function : SetPoles
144 //=======================================================================
146 void PLib::SetPoles(const TColgp_Array1OfPnt& Poles,
147 const TColStd_Array1OfReal& Weights,
148 TColStd_Array1OfReal& FP)
150 Standard_Integer j = FP .Lower();
151 Standard_Integer PLower = Poles.Lower();
152 Standard_Integer PUpper = Poles.Upper();
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++;
164 //=======================================================================
165 //function : GetPoles
167 //=======================================================================
169 void PLib::GetPoles(const TColStd_Array1OfReal& FP,
170 TColgp_Array1OfPnt& Poles)
172 Standard_Integer j = FP .Lower();
173 Standard_Integer PLower = Poles.Lower();
174 Standard_Integer PUpper = Poles.Upper();
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++;
184 //=======================================================================
185 //function : GetPoles
187 //=======================================================================
189 void PLib::GetPoles(const TColStd_Array1OfReal& FP,
190 TColgp_Array1OfPnt& Poles,
191 TColStd_Array1OfReal& Weights)
193 Standard_Integer j = FP .Lower();
194 Standard_Integer PLower = Poles.Lower();
195 Standard_Integer PUpper = Poles.Upper();
197 for (Standard_Integer i = PLower; i <= PUpper; i++) {
198 Standard_Real w = FP(j + 3);
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++;
208 // specialized allocator
217 BinomAllocator (const Standard_Integer theMaxBinom)
219 myMaxBinom (theMaxBinom)
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];
226 for (i = 1; i < np1; ++i)
234 myBinom[i] = new Standard_Integer[ip1];
236 for (j = 0; j < id2; ++j)
238 myBinom[i][j] = k + myBinom[im1][j];
242 if (j > md2) j = im1 - j;
243 myBinom[i][id2] = k + myBinom[im1][j];
245 for (j = ip1 - md3; j < ip1; j++)
247 myBinom[i][j] = myBinom[i][i - j];
256 for (Standard_Integer i = 0; i <= myMaxBinom; ++i)
263 Standard_Real Value (const Standard_Integer N,
264 const Standard_Integer P) const
266 Standard_OutOfRange_Raise_if (N > myMaxBinom,
267 "PLib, BinomAllocator: requested degree is greater than maximum supported");
268 return Standard_Real (myBinom[N][P]);
272 Standard_Integer** myBinom;
273 Standard_Integer myMaxBinom;
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);
282 //=======================================================================
285 //=======================================================================
287 Standard_Real PLib::Bin(const Standard_Integer N,
288 const Standard_Integer P)
290 return THE_BINOM.Value (N, P);
293 //=======================================================================
294 //function : RationalDerivative
296 //=======================================================================
298 void PLib::RationalDerivative(const Standard_Integer Degree,
299 const Standard_Integer DerivativeRequest,
300 const Standard_Integer Dimension,
302 Standard_Real& RDers,
303 const Standard_Boolean All)
306 // Our purpose is to compute f = (u/v) derivated N = DerivativeRequest times
309 // Let C(N,P) be the binomial
314 // u = SUM C (q,p) f v
321 // (q) ( (q) (p) (q-p) )
322 // f = (1/v) ( u - SUM C (q,p) f v )
326 // make arrays for the binomial since computing it each time could raise a performance
328 // As oppose to the method below the <Der> array is organized in the following
331 // u (1) u (2) .... u (Dimension) v (1)
334 // u (1) u (2) .... u (Dimension) v (1)
336 // ............................................
338 // (Degree) (Degree) (Degree) (Degree)
339 // u (1) u (2) .... u (Dimension) v (1)
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;
347 NCollection_LocalArray<Standard_Real> binomial_array;
348 NCollection_LocalArray<Standard_Real> derivative_storage;
349 if (Dimension == 3) {
350 Standard_Integer DeRequest1 = DerivativeRequest + 1;
351 Standard_Integer MinDegRequ = DerivativeRequest;
352 if (MinDegRequ > Degree) MinDegRequ = Degree;
353 binomial_array.Allocate (DeRequest1);
355 for (ii = 0 ; ii < DeRequest1 ; ii++) {
356 binomial_array[ii] = 1.0e0 ;
359 Standard_Integer DimDeRequ1 = (DeRequest1 << 1) + DeRequest1;
360 derivative_storage.Allocate (DimDeRequ1);
361 RationalArray = derivative_storage ;
364 Inverse = 1.0e0 / PolesArray[3] ;
369 for (ii = 0 ; ii <= MinDegRequ ; ii++) {
372 RationalArray[Index] = PolesArray[OtherIndex]; Index++; OtherIndex++;
373 RationalArray[Index] = PolesArray[OtherIndex]; Index++; OtherIndex++;
374 RationalArray[Index] = PolesArray[OtherIndex];
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];
387 for (jj = ii ; jj >= 1 ; jj--) {
388 binomial_array[jj] += binomial_array[jj - 1] ;
390 RationalArray[Index] *= Inverse ; Index++;
391 RationalArray[Index] *= Inverse ; Index++;
392 RationalArray[Index] *= Inverse ; Index++;
395 for (ii= MinDegRequ + 1; ii <= DerivativeRequest ; ii++){
398 RationalArray[Index] = 0.0e0; Index++;
399 RationalArray[Index] = 0.0e0; Index++;
400 RationalArray[Index] = 0.0e0;
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];
412 for (jj = ii ; jj >= 1 ; jj--) {
413 binomial_array[jj] += binomial_array[jj - 1] ;
415 RationalArray[Index] *= Inverse; Index++;
416 RationalArray[Index] *= Inverse; Index++;
417 RationalArray[Index] *= Inverse; Index++;
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];
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;
435 binomial_array.Allocate (DeRequest1);
437 for (ii = 0 ; ii < DeRequest1 ; ii++) {
438 binomial_array[ii] = 1.0e0 ;
441 Standard_Integer DimDeRequ1 = Dimension * DeRequest1;
442 derivative_storage.Allocate (DimDeRequ1);
443 RationalArray = derivative_storage ;
446 Inverse = 1.0e0 / PolesArray[Dimension] ;
448 Index2 = - Dimension2;
451 for (ii = 0 ; ii <= MinDegRequ ; ii++) {
455 for (kk = 0 ; kk < Dimension ; kk++) {
456 RationalArray[Index] = PolesArray[OtherIndex]; Index++; OtherIndex++;
461 for (jj = ii - 1 ; jj >= 0 ; jj--) {
462 Factor = binomial_array[jj] * PolesArray[(ii-jj) * Dimension1 + Dimension];
464 for (kk = 0 ; kk < Dimension ; kk++) {
465 RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++;
468 Index1 -= Dimension2 ;
471 for (jj = ii ; jj >= 1 ; jj--) {
472 binomial_array[jj] += binomial_array[jj - 1] ;
475 for (kk = 0 ; kk < Dimension ; kk++) {
476 RationalArray[Index] *= Inverse ; Index++;
480 for (ii= MinDegRequ + 1; ii <= DerivativeRequest ; ii++){
484 for (kk = 0 ; kk < Dimension ; kk++) {
485 RationalArray[Index] = 0.0e0 ; Index++;
489 for (jj = ii - 1 ; jj >= ii - MinDegRequ ; jj--) {
490 Factor = binomial_array[jj] * PolesArray[(ii-jj) * Dimension1 + Dimension];
492 for (kk = 0 ; kk < Dimension ; kk++) {
493 RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++;
496 Index1 -= Dimension2 ;
499 for (jj = ii ; jj >= 1 ; jj--) {
500 binomial_array[jj] += binomial_array[jj - 1] ;
503 for (kk = 0 ; kk < Dimension ; kk++) {
504 RationalArray[Index] *= Inverse; Index++;
509 RationalArray = &RDers ;
510 Standard_Integer DimDeRequ = Dimension * DerivativeRequest;
512 for (kk = 0 ; kk < Dimension ; kk++) {
513 RationalArray[kk] = derivative_storage[DimDeRequ]; DimDeRequ++;
519 //=======================================================================
520 //function : RationalDerivatives
521 //purpose : Uses Homogeneous Poles Derivatives and Deivatives of Weights
522 //=======================================================================
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)
535 // Our purpose is to compute f = (u/v) derivated N times
538 // Let C(N,P) be the binomial
543 // u = SUM C (q,p) f v
550 // (q) ( (q) (p) (q-p) )
551 // f = (1/v) ( u - SUM C (q,p) f v )
555 // make arrays for the binomial since computing it each time could
556 // raize a performance issue
558 Standard_Real Inverse;
559 Standard_Real *PolesArray = &PolesDerivates;
560 Standard_Real *WeightsArray = &WeightsDerivates;
561 Standard_Real *RationalArray = &RationalDerivates;
562 Standard_Real Factor ;
564 Standard_Integer ii, Index, Index1, Index2, jj;
565 Standard_Integer DeRequest1 = DerivativeRequest + 1;
567 NCollection_LocalArray<Standard_Real> binomial_array (DeRequest1);
568 NCollection_LocalArray<Standard_Real> derivative_storage;
570 for (ii = 0 ; ii < DeRequest1 ; ii++) {
571 binomial_array[ii] = 1.0e0 ;
573 Inverse = 1.0e0 / WeightsArray[0] ;
574 if (Dimension == 3) {
578 for (ii = 0 ; ii < DeRequest1 ; ii++) {
581 RationalArray[Index] = PolesArray[Index] ; Index++;
582 RationalArray[Index] = PolesArray[Index] ; Index++;
583 RationalArray[Index] = PolesArray[Index] ;
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];
595 for (jj = ii ; jj >= 1 ; jj--) {
596 binomial_array[jj] += binomial_array[jj - 1] ;
598 RationalArray[Index] *= Inverse ; Index++;
599 RationalArray[Index] *= Inverse ; Index++;
600 RationalArray[Index] *= Inverse ; Index++;
605 Standard_Integer Dimension2 = Dimension << 1;
607 Index2 = - Dimension2;
609 for (ii = 0 ; ii < DeRequest1 ; ii++) {
613 for (kk = 0 ; kk < Dimension ; kk++) {
614 RationalArray[Index] = PolesArray[Index]; Index++;
618 for (jj = ii - 1 ; jj >= 0 ; jj--) {
619 Factor = binomial_array[jj] * WeightsArray[ii - jj] ;
621 for (kk = 0 ; kk < Dimension ; kk++) {
622 RationalArray[Index] -= Factor * RationalArray[Index1]; Index++; Index1++;
625 Index1 -= Dimension2;
628 for (jj = ii ; jj >= 1 ; jj--) {
629 binomial_array[jj] += binomial_array[jj - 1] ;
632 for (kk = 0 ; kk < Dimension ; kk++) {
633 RationalArray[Index] *= Inverse ; Index++;
639 //=======================================================================
640 //function : This evaluates a polynomial and its derivatives
641 //purpose : up to the requested order
642 //=======================================================================
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)
651 // the polynomial coefficients are assumed to be stored as follows :
653 // [0] [Dimension -1] X coefficient
655 // [Dimension] [Dimension + Dimension -1] X coefficient
657 // [2 * Dimension] [2 * Dimension + Dimension-1] X coefficient
659 // ...................................................
663 // [d * Dimension] [d * Dimension + Dimension-1] X coefficient
665 // where d is the Degree
668 Standard_Integer DegreeDimension = Degree * Dimension;
671 Standard_Real *RA = &Results ;
672 Standard_Real *PA = &PolynomialCoeff ;
673 Standard_Real *tmpRA = RA;
674 Standard_Real *tmpPA = PA + DegreeDimension;
680 if (DerivativeRequest > 0 ) {
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;
691 LocalRequest = Degree;
692 MaxIndex2 = MaxIndex1 = Degree;
696 for (ii = 1; ii <= LocalRequest; ii++) {
697 *tmpRA = 0.0e0; tmpRA ++ ;
700 for (jj = Degree ; jj > 0 ; jj--) {
705 for (ii = LocalRequest ; ii > 0 ; ii--) {
707 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
712 *valRA = Par * (*valRA) + (*tmpPA);
717 for (jj = Degree ; jj > 0 ; jj--) {
719 *tmpRA = Par * (*tmpRA) + (*tmpPA);
725 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
726 *tmpRA = *tmpPA; tmpRA++;
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;
738 LocalRequest = Degree;
739 MaxIndex2 = MaxIndex1 = DegreeDimension;
743 for (ii = 1; ii <= LocalRequest; ii++) {
744 *tmpRA = 0.0e0; tmpRA++;
745 *tmpRA = 0.0e0; tmpRA++;
748 for (jj = Degree ; jj > 0 ; jj--) {
754 for (ii = LocalRequest ; ii > 0 ; ii--) {
756 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
761 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
763 Index1 = MaxIndex1 + 1;
764 Index2 = MaxIndex2 + 1;
766 for (ii = LocalRequest ; ii > 0 ; ii--) {
768 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
773 *valRA = Par * (*valRA) + (*tmpPA);
780 for (jj = Degree ; jj > 0 ; jj--) {
783 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
784 *tmpRA = Par * (*tmpRA) + (*tmpPA);
791 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
792 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
793 *tmpRA = *tmpPA; tmpRA++;
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;
805 LocalRequest = Degree;
806 MaxIndex2 = MaxIndex1 = DegreeDimension;
810 for (ii = 1; ii <= LocalRequest; ii++) {
811 *tmpRA = 0.0e0; tmpRA++;
812 *tmpRA = 0.0e0; tmpRA++;
813 *tmpRA = 0.0e0; tmpRA++;
816 for (jj = Degree ; jj > 0 ; jj--) {
822 for (ii = LocalRequest ; ii > 0 ; ii--) {
824 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
829 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
831 Index1 = MaxIndex1 + 1;
832 Index2 = MaxIndex2 + 1;
834 for (ii = LocalRequest ; ii > 0 ; ii--) {
836 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
841 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
843 Index1 = MaxIndex1 + 2;
844 Index2 = MaxIndex2 + 2;
846 for (ii = LocalRequest ; ii > 0 ; ii--) {
848 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
853 *valRA = Par * (*valRA) + (*tmpPA);
860 for (jj = Degree ; jj > 0 ; jj--) {
863 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
864 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
865 *tmpRA = Par * (*tmpRA) + (*tmpPA);
872 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
873 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
874 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
876 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
877 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
878 *tmpRA = *tmpPA; tmpRA++;
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);
890 LocalRequest = Degree;
891 MaxIndex2 = MaxIndex1 = DegreeDimension;
895 for (ii = 1; ii <= LocalRequest; ii++) {
896 *tmpRA = 0.0e0; tmpRA++;
897 *tmpRA = 0.0e0; tmpRA++;
898 *tmpRA = 0.0e0; tmpRA++;
900 *tmpRA = 0.0e0; tmpRA++;
901 *tmpRA = 0.0e0; tmpRA++;
902 *tmpRA = 0.0e0; tmpRA++;
905 for (jj = Degree ; jj > 0 ; jj--) {
911 for (ii = LocalRequest ; ii > 0 ; ii--) {
913 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
918 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
920 Index1 = MaxIndex1 + 1;
921 Index2 = MaxIndex2 + 1;
923 for (ii = LocalRequest ; ii > 0 ; ii--) {
925 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
930 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
932 Index1 = MaxIndex1 + 2;
933 Index2 = MaxIndex2 + 2;
935 for (ii = LocalRequest ; ii > 0 ; ii--) {
937 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
942 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
944 Index1 = MaxIndex1 + 3;
945 Index2 = MaxIndex2 + 3;
947 for (ii = LocalRequest ; ii > 0 ; ii--) {
949 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
954 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
956 Index1 = MaxIndex1 + 4;
957 Index2 = MaxIndex2 + 4;
959 for (ii = LocalRequest ; ii > 0 ; ii--) {
961 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
966 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
968 Index1 = MaxIndex1 + 5;
969 Index2 = MaxIndex2 + 5;
971 for (ii = LocalRequest ; ii > 0 ; ii--) {
973 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
978 *valRA = Par * (*valRA) + (*tmpPA);
985 for (jj = Degree ; jj > 0 ; jj--) {
989 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
990 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
991 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
993 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
994 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
995 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1002 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1003 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1004 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1006 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1007 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1008 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1010 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1011 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1012 *tmpRA = *tmpPA; tmpRA++;
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;
1024 LocalRequest = Degree;
1025 MaxIndex2 = MaxIndex1 = DegreeDimension;
1029 for (ii = 1; ii <= LocalRequest; ii++) {
1030 *tmpRA = 0.0e0; tmpRA++;
1031 *tmpRA = 0.0e0; tmpRA++;
1032 *tmpRA = 0.0e0; tmpRA++;
1034 *tmpRA = 0.0e0; tmpRA++;
1035 *tmpRA = 0.0e0; tmpRA++;
1036 *tmpRA = 0.0e0; tmpRA++;
1038 *tmpRA = 0.0e0; tmpRA++;
1039 *tmpRA = 0.0e0; tmpRA++;
1040 *tmpRA = 0.0e0; tmpRA++;
1043 for (jj = Degree ; jj > 0 ; jj--) {
1049 for (ii = LocalRequest ; ii > 0 ; ii--) {
1050 valRA = &RA[Index1];
1051 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1055 valRA = &RA[Index1];
1056 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1058 Index1 = MaxIndex1 + 1;
1059 Index2 = MaxIndex2 + 1;
1061 for (ii = LocalRequest ; ii > 0 ; ii--) {
1062 valRA = &RA[Index1];
1063 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1067 valRA = &RA[Index1];
1068 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1070 Index1 = MaxIndex1 + 2;
1071 Index2 = MaxIndex2 + 2;
1073 for (ii = LocalRequest ; ii > 0 ; ii--) {
1074 valRA = &RA[Index1];
1075 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1079 valRA = &RA[Index1];
1080 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1082 Index1 = MaxIndex1 + 3;
1083 Index2 = MaxIndex2 + 3;
1085 for (ii = LocalRequest ; ii > 0 ; ii--) {
1086 valRA = &RA[Index1];
1087 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1091 valRA = &RA[Index1];
1092 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1094 Index1 = MaxIndex1 + 4;
1095 Index2 = MaxIndex2 + 4;
1097 for (ii = LocalRequest ; ii > 0 ; ii--) {
1098 valRA = &RA[Index1];
1099 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1103 valRA = &RA[Index1];
1104 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1106 Index1 = MaxIndex1 + 5;
1107 Index2 = MaxIndex2 + 5;
1109 for (ii = LocalRequest ; ii > 0 ; ii--) {
1110 valRA = &RA[Index1];
1111 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1115 valRA = &RA[Index1];
1116 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1118 Index1 = MaxIndex1 + 6;
1119 Index2 = MaxIndex2 + 6;
1121 for (ii = LocalRequest ; ii > 0 ; ii--) {
1122 valRA = &RA[Index1];
1123 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1127 valRA = &RA[Index1];
1128 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1130 Index1 = MaxIndex1 + 7;
1131 Index2 = MaxIndex2 + 7;
1133 for (ii = LocalRequest ; ii > 0 ; ii--) {
1134 valRA = &RA[Index1];
1135 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1139 valRA = &RA[Index1];
1140 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1142 Index1 = MaxIndex1 + 8;
1143 Index2 = MaxIndex2 + 8;
1145 for (ii = LocalRequest ; ii > 0 ; ii--) {
1146 valRA = &RA[Index1];
1147 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1151 valRA = &RA[Index1];
1152 *valRA = Par * (*valRA) + (*tmpPA);
1159 for (jj = Degree ; jj > 0 ; jj--) {
1163 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1164 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1165 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1167 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1168 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1169 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1171 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1172 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1173 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1180 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1181 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1182 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1184 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1185 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1186 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1188 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1189 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1190 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1192 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1193 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1194 *tmpRA = *tmpPA; tmpRA++;
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);
1206 LocalRequest = Degree;
1207 MaxIndex2 = MaxIndex1 = DegreeDimension;
1211 for (ii = 1; ii <= LocalRequest; ii++) {
1212 *tmpRA = 0.0e0; tmpRA++;
1213 *tmpRA = 0.0e0; tmpRA++;
1214 *tmpRA = 0.0e0; tmpRA++;
1216 *tmpRA = 0.0e0; tmpRA++;
1217 *tmpRA = 0.0e0; tmpRA++;
1218 *tmpRA = 0.0e0; tmpRA++;
1220 *tmpRA = 0.0e0; tmpRA++;
1221 *tmpRA = 0.0e0; tmpRA++;
1222 *tmpRA = 0.0e0; tmpRA++;
1224 *tmpRA = 0.0e0; tmpRA++;
1225 *tmpRA = 0.0e0; tmpRA++;
1226 *tmpRA = 0.0e0; tmpRA++;
1229 for (jj = Degree ; jj > 0 ; jj--) {
1235 for (ii = LocalRequest ; ii > 0 ; ii--) {
1236 valRA = &RA[Index1];
1237 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1241 valRA = &RA[Index1];
1242 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1244 Index1 = MaxIndex1 + 1;
1245 Index2 = MaxIndex2 + 1;
1247 for (ii = LocalRequest ; ii > 0 ; ii--) {
1248 valRA = &RA[Index1];
1249 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1253 valRA = &RA[Index1];
1254 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1256 Index1 = MaxIndex1 + 2;
1257 Index2 = MaxIndex2 + 2;
1259 for (ii = LocalRequest ; ii > 0 ; ii--) {
1260 valRA = &RA[Index1];
1261 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1265 valRA = &RA[Index1];
1266 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1268 Index1 = MaxIndex1 + 3;
1269 Index2 = MaxIndex2 + 3;
1271 for (ii = LocalRequest ; ii > 0 ; ii--) {
1272 valRA = &RA[Index1];
1273 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1277 valRA = &RA[Index1];
1278 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1280 Index1 = MaxIndex1 + 4;
1281 Index2 = MaxIndex2 + 4;
1283 for (ii = LocalRequest ; ii > 0 ; ii--) {
1284 valRA = &RA[Index1];
1285 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1289 valRA = &RA[Index1];
1290 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1292 Index1 = MaxIndex1 + 5;
1293 Index2 = MaxIndex2 + 5;
1295 for (ii = LocalRequest ; ii > 0 ; ii--) {
1296 valRA = &RA[Index1];
1297 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1301 valRA = &RA[Index1];
1302 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1304 Index1 = MaxIndex1 + 6;
1305 Index2 = MaxIndex2 + 6;
1307 for (ii = LocalRequest ; ii > 0 ; ii--) {
1308 valRA = &RA[Index1];
1309 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1313 valRA = &RA[Index1];
1314 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1316 Index1 = MaxIndex1 + 7;
1317 Index2 = MaxIndex2 + 7;
1319 for (ii = LocalRequest ; ii > 0 ; ii--) {
1320 valRA = &RA[Index1];
1321 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1325 valRA = &RA[Index1];
1326 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1328 Index1 = MaxIndex1 + 8;
1329 Index2 = MaxIndex2 + 8;
1331 for (ii = LocalRequest ; ii > 0 ; ii--) {
1332 valRA = &RA[Index1];
1333 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1337 valRA = &RA[Index1];
1338 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1340 Index1 = MaxIndex1 + 9;
1341 Index2 = MaxIndex2 + 9;
1343 for (ii = LocalRequest ; ii > 0 ; ii--) {
1344 valRA = &RA[Index1];
1345 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1349 valRA = &RA[Index1];
1350 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1352 Index1 = MaxIndex1 + 10;
1353 Index2 = MaxIndex2 + 10;
1355 for (ii = LocalRequest ; ii > 0 ; ii--) {
1356 valRA = &RA[Index1];
1357 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1361 valRA = &RA[Index1];
1362 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1364 Index1 = MaxIndex1 + 11;
1365 Index2 = MaxIndex2 + 11;
1367 for (ii = LocalRequest ; ii > 0 ; ii--) {
1368 valRA = &RA[Index1];
1369 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1373 valRA = &RA[Index1];
1374 *valRA = Par * (*valRA) + (*tmpPA);
1381 for (jj = Degree ; jj > 0 ; jj--) {
1385 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1386 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1387 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1389 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1390 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1391 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1393 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1394 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1395 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1397 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1398 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1399 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1407 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1408 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1409 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1411 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1412 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1413 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1415 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1416 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1417 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1419 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1420 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1421 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1423 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1424 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1425 *tmpRA = *tmpPA; tmpRA++;
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;
1437 LocalRequest = Degree;
1438 MaxIndex2 = MaxIndex1 = DegreeDimension;
1442 for (ii = 1; ii <= LocalRequest; ii++) {
1443 *tmpRA = 0.0e0; tmpRA++;
1444 *tmpRA = 0.0e0; tmpRA++;
1445 *tmpRA = 0.0e0; tmpRA++;
1447 *tmpRA = 0.0e0; tmpRA++;
1448 *tmpRA = 0.0e0; tmpRA++;
1449 *tmpRA = 0.0e0; tmpRA++;
1451 *tmpRA = 0.0e0; tmpRA++;
1452 *tmpRA = 0.0e0; tmpRA++;
1453 *tmpRA = 0.0e0; tmpRA++;
1455 *tmpRA = 0.0e0; tmpRA++;
1456 *tmpRA = 0.0e0; tmpRA++;
1457 *tmpRA = 0.0e0; tmpRA++;
1459 *tmpRA = 0.0e0; tmpRA++;
1460 *tmpRA = 0.0e0; tmpRA++;
1461 *tmpRA = 0.0e0; tmpRA++;
1464 for (jj = Degree ; jj > 0 ; jj--) {
1470 for (ii = LocalRequest ; ii > 0 ; ii--) {
1471 valRA = &RA[Index1];
1472 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1476 valRA = &RA[Index1];
1477 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1479 Index1 = MaxIndex1 + 1;
1480 Index2 = MaxIndex2 + 1;
1482 for (ii = LocalRequest ; ii > 0 ; ii--) {
1483 valRA = &RA[Index1];
1484 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1488 valRA = &RA[Index1];
1489 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1491 Index1 = MaxIndex1 + 2;
1492 Index2 = MaxIndex2 + 2;
1494 for (ii = LocalRequest ; ii > 0 ; ii--) {
1495 valRA = &RA[Index1];
1496 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1500 valRA = &RA[Index1];
1501 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1503 Index1 = MaxIndex1 + 3;
1504 Index2 = MaxIndex2 + 3;
1506 for (ii = LocalRequest ; ii > 0 ; ii--) {
1507 valRA = &RA[Index1];
1508 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1512 valRA = &RA[Index1];
1513 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1515 Index1 = MaxIndex1 + 4;
1516 Index2 = MaxIndex2 + 4;
1518 for (ii = LocalRequest ; ii > 0 ; ii--) {
1519 valRA = &RA[Index1];
1520 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1524 valRA = &RA[Index1];
1525 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1527 Index1 = MaxIndex1 + 5;
1528 Index2 = MaxIndex2 + 5;
1530 for (ii = LocalRequest ; ii > 0 ; ii--) {
1531 valRA = &RA[Index1];
1532 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1536 valRA = &RA[Index1];
1537 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1539 Index1 = MaxIndex1 + 6;
1540 Index2 = MaxIndex2 + 6;
1542 for (ii = LocalRequest ; ii > 0 ; ii--) {
1543 valRA = &RA[Index1];
1544 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1548 valRA = &RA[Index1];
1549 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1551 Index1 = MaxIndex1 + 7;
1552 Index2 = MaxIndex2 + 7;
1554 for (ii = LocalRequest ; ii > 0 ; ii--) {
1555 valRA = &RA[Index1];
1556 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1560 valRA = &RA[Index1];
1561 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1563 Index1 = MaxIndex1 + 8;
1564 Index2 = MaxIndex2 + 8;
1566 for (ii = LocalRequest ; ii > 0 ; ii--) {
1567 valRA = &RA[Index1];
1568 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1572 valRA = &RA[Index1];
1573 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1575 Index1 = MaxIndex1 + 9;
1576 Index2 = MaxIndex2 + 9;
1578 for (ii = LocalRequest ; ii > 0 ; ii--) {
1579 valRA = &RA[Index1];
1580 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1584 valRA = &RA[Index1];
1585 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1587 Index1 = MaxIndex1 + 10;
1588 Index2 = MaxIndex2 + 10;
1590 for (ii = LocalRequest ; ii > 0 ; ii--) {
1591 valRA = &RA[Index1];
1592 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1596 valRA = &RA[Index1];
1597 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1599 Index1 = MaxIndex1 + 11;
1600 Index2 = MaxIndex2 + 11;
1602 for (ii = LocalRequest ; ii > 0 ; ii--) {
1603 valRA = &RA[Index1];
1604 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1608 valRA = &RA[Index1];
1609 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1611 Index1 = MaxIndex1 + 12;
1612 Index2 = MaxIndex2 + 12;
1614 for (ii = LocalRequest ; ii > 0 ; ii--) {
1615 valRA = &RA[Index1];
1616 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1620 valRA = &RA[Index1];
1621 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1623 Index1 = MaxIndex1 + 13;
1624 Index2 = MaxIndex2 + 13;
1626 for (ii = LocalRequest ; ii > 0 ; ii--) {
1627 valRA = &RA[Index1];
1628 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1632 valRA = &RA[Index1];
1633 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1635 Index1 = MaxIndex1 + 14;
1636 Index2 = MaxIndex2 + 14;
1638 for (ii = LocalRequest ; ii > 0 ; ii--) {
1639 valRA = &RA[Index1];
1640 *valRA = Par * (*valRA) + ((Standard_Real)ii) * RA[Index2] ;
1644 valRA = &RA[Index1];
1645 *valRA = Par * (*valRA) + (*tmpPA);
1652 for (jj = Degree ; jj > 0 ; jj--) {
1656 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1657 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1658 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1660 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1661 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1662 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1664 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1665 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1666 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1668 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1669 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1670 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1672 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1673 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1674 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1681 Standard_Integer kk ;
1682 for ( kk = 0 ; kk < Dimension ; kk++) {
1683 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
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;
1696 LocalRequest = Degree;
1697 MaxIndex2 = MaxIndex1 = DegreeDimension;
1699 MaxIndex2 -= Dimension;
1701 for (ii = 1; ii <= MaxIndex1; ii++) {
1702 *tmpRA = 0.0e0; tmpRA++;
1705 for (jj = Degree ; jj > 0 ; jj--) {
1708 for (kk = 0 ; kk < Dimension ; kk++) {
1709 Index1 = MaxIndex1 + kk;
1710 Index2 = MaxIndex2 + kk;
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;
1718 valRA = &RA[Index1];
1719 *valRA = Par * (*valRA) + (*tmpPA); tmpPA++;
1726 for (jj = Degree ; jj > 0 ; jj--) {
1730 for (kk = 0 ; kk < Dimension ; kk++) {
1731 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1740 //=======================================================================
1741 //function : This evaluates a polynomial without derivative
1743 //=======================================================================
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)
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;
1758 switch (Dimension) {
1763 for (jj = Degree ; jj > 0 ; jj--) {
1766 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1771 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1775 for (jj = Degree ; jj > 0 ; jj--) {
1779 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1780 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1786 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1787 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1791 for (jj = Degree ; jj > 0 ; jj--) {
1795 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1796 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1797 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1803 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1804 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1805 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1807 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1808 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1812 for (jj = Degree ; jj > 0 ; jj--) {
1816 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1817 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1818 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1820 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1821 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1822 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1828 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1829 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1830 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1832 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1833 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1834 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1836 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1837 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1841 for (jj = Degree ; jj > 0 ; jj--) {
1845 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1846 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1847 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1849 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1850 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1851 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1853 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1854 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1855 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1861 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1862 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1863 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1865 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1866 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1867 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1869 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1870 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1871 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1873 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1874 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1878 for (jj = Degree ; jj > 0 ; jj--) {
1882 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1883 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1884 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1886 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1887 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1888 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1890 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1891 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1892 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1894 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1895 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1896 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1902 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1903 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1904 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1906 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1907 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1908 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1910 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1911 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1912 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1914 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1915 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1916 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1918 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1919 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1923 for (jj = Degree ; jj > 0 ; jj--) {
1927 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1928 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1929 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1931 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1932 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1933 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1935 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1936 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1937 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1939 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1940 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1941 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1943 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1944 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1945 *tmpRA = Par * (*tmpRA) + (*tmpPA);
1951 Standard_Integer kk ;
1952 for ( kk = 0 ; kk < Dimension ; kk++) {
1953 *tmpRA = *tmpPA; tmpRA++; tmpPA++;
1957 for (jj = Degree ; jj > 0 ; jj--) {
1961 for (kk = 0 ; kk < Dimension ; kk++) {
1962 *tmpRA = Par * (*tmpRA) + (*tmpPA); tmpPA++; tmpRA++;
1970 //=======================================================================
1971 //function : This evaluates a polynomial of 2 variables
1972 //purpose : or its derivative at the requested orders
1973 //=======================================================================
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)
1985 // the polynomial coefficients are assumed to be stored as follows :
1987 // [0] [Dimension -1] U V coefficient
1989 // [Dimension] [Dimension + Dimension -1] U V coefficient
1991 // [2 * Dimension] [2 * Dimension + Dimension-1] U V coefficient
1993 // ...................................................
1997 // [m * Dimension] [m * Dimension + Dimension-1] U V coefficient
1999 // where m = UDegree
2002 // [(m+1) * Dimension] [(m+1) * Dimension + Dimension-1] U V coefficient
2004 // ...................................................
2007 // [2*m * Dimension] [2*m * Dimension + Dimension-1] U V coefficient
2009 // ...................................................
2012 // [m*n * Dimension] [m*n * Dimension + Dimension-1] U V coefficient
2014 // where n = VDegree
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 ;
2025 PLib::EvalPolynomial(UParameter,
2032 PLib::EvalPolynomial(VParameter,
2039 index = Dimension*VDerivativeRequest;
2041 for (Standard_Integer i=0;i<Dimension;i++) {
2042 ResultArray[i] = Digit[index+i];
2048 //=======================================================================
2049 //function : This evaluates the lagrange polynomial and its derivatives
2050 //purpose : up to the requested order that interpolates a series of
2051 //points of dimension <Dimension> with given assigned parameters
2052 //=======================================================================
2055 PLib::EvalLagrange(const Standard_Real Parameter,
2056 const Standard_Integer DerivativeRequest,
2057 const Standard_Integer Degree,
2058 const Standard_Integer Dimension,
2059 Standard_Real& Values,
2060 Standard_Real& Parameters,
2061 Standard_Real& Results)
2064 // the points are assumed to be stored as follows in the Values array :
2066 // [0] [Dimension -1] first point coefficients
2068 // [Dimension] [Dimension + Dimension -1] second point coefficients
2070 // [2 * Dimension] [2 * Dimension + Dimension-1] third point coefficients
2072 // ...................................................
2076 // [d * Dimension] [d * Dimension + Dimension-1] d + 1 point coefficients
2078 // where d is the Degree
2080 // The ParameterArray stores the parameter value assign to each point in
2081 // order described above, that is
2082 // [0] is assign to first point
2083 // [1] is assign to second point
2085 Standard_Integer ii, jj, kk, Index, Index1, ReturnCode=0;
2086 Standard_Integer local_request = DerivativeRequest;
2087 Standard_Real *ParameterArray;
2088 Standard_Real difference;
2089 Standard_Real *PointsArray;
2090 Standard_Real *ResultArray ;
2092 PointsArray = &Values ;
2093 ParameterArray = &Parameters ;
2094 ResultArray = &Results ;
2095 if (local_request >= Degree) {
2096 local_request = Degree ;
2098 NCollection_LocalArray<Standard_Real> divided_differences_array ((Degree + 1) * Dimension);
2100 // Build the divided differences array
2103 for (ii = 0 ; ii < (Degree + 1) * Dimension ; ii++) {
2104 divided_differences_array[ii] = PointsArray[ii] ;
2107 for (ii = Degree ; ii >= 0 ; ii--) {
2109 for (jj = Degree ; jj > Degree - ii ; jj--) {
2110 Index = jj * Dimension ;
2111 Index1 = Index - Dimension ;
2113 for (kk = 0 ; kk < Dimension ; kk++) {
2114 divided_differences_array[Index + kk] -=
2115 divided_differences_array[Index1 + kk] ;
2118 ParameterArray[jj] - ParameterArray[jj - Degree -1 + ii] ;
2119 if (Abs(difference) < RealSmall()) {
2123 difference = 1.0e0 / difference ;
2125 for (kk = 0 ; kk < Dimension ; kk++) {
2126 divided_differences_array[Index + kk] *= difference ;
2132 // Evaluate the divided difference array polynomial which expresses as
2134 // P(t) = [t1] P + (t - t1) [t1,t2] P + (t - t1)(t - t2)[t1,t2,t3] P + ...
2135 // + (t - t1)(t - t2)(t - t3)...(t - td) [t1,t2,...,td+1] P
2137 // The ith slot in the divided_differences_array is [t1,t2,...,ti+1]
2140 Index = Degree * Dimension ;
2142 for (kk = 0 ; kk < Dimension ; kk++) {
2143 ResultArray[kk] = divided_differences_array[Index + kk] ;
2146 for (ii = Dimension ; ii < (local_request + 1) * Dimension ; ii++) {
2147 ResultArray[ii] = 0.0e0 ;
2150 for (ii = Degree ; ii >= 1 ; ii--) {
2151 difference = Parameter - ParameterArray[ii - 1] ;
2153 for (jj = local_request ; jj > 0 ; jj--) {
2154 Index = jj * Dimension ;
2155 Index1 = Index - Dimension ;
2157 for (kk = 0 ; kk < Dimension ; kk++) {
2158 ResultArray[Index + kk] *= difference ;
2159 ResultArray[Index + kk] += ResultArray[Index1+kk]*(Standard_Real) jj ;
2162 Index = (ii -1) * Dimension ;
2164 for (kk = 0 ; kk < Dimension ; kk++) {
2165 ResultArray[kk] *= difference ;
2166 ResultArray[kk] += divided_differences_array[Index+kk] ;
2170 return (ReturnCode) ;
2173 //=======================================================================
2174 //function : This evaluates the hermite polynomial and its derivatives
2175 //purpose : up to the requested order that interpolates a series of
2176 //points of dimension <Dimension> with given assigned parameters
2177 //=======================================================================
2179 Standard_Integer PLib::EvalCubicHermite
2180 (const Standard_Real Parameter,
2181 const Standard_Integer DerivativeRequest,
2182 const Standard_Integer Dimension,
2183 Standard_Real& Values,
2184 Standard_Real& Derivatives,
2185 Standard_Real& theParameters,
2186 Standard_Real& Results)
2189 // the points are assumed to be stored as follows in the Values array :
2191 // [0] [Dimension -1] first point coefficients
2193 // [Dimension] [Dimension + Dimension -1] last point coefficients
2196 // the derivatives are assumed to be stored as follows in
2197 // the Derivatives array :
2199 // [0] [Dimension -1] first point coefficients
2201 // [Dimension] [Dimension + Dimension -1] last point coefficients
2203 // The ParameterArray stores the parameter value assign to each point in
2204 // order described above, that is
2205 // [0] is assign to first point
2206 // [1] is assign to last point
2208 Standard_Integer ii, jj, kk, pp, Index, Index1, Degree, ReturnCode;
2209 Standard_Integer local_request = DerivativeRequest ;
2213 Standard_Real ParametersArray[4];
2214 Standard_Real difference;
2215 Standard_Real inverse;
2216 Standard_Real *FirstLast;
2217 Standard_Real *PointsArray;
2218 Standard_Real *DerivativesArray;
2219 Standard_Real *ResultArray ;
2221 DerivativesArray = &Derivatives ;
2222 PointsArray = &Values ;
2223 FirstLast = &theParameters ;
2224 ResultArray = &Results ;
2225 if (local_request >= Degree) {
2226 local_request = Degree ;
2228 NCollection_LocalArray<Standard_Real> divided_differences_array ((Degree + 1) * Dimension);
2230 for (ii = 0, jj = 0 ; ii < 2 ; ii++, jj+= 2) {
2231 ParametersArray[jj] =
2232 ParametersArray[jj+1] = FirstLast[ii] ;
2235 // Build the divided differences array
2238 // initialise it at the stage 2 of the building algorithm
2239 // for devided differences
2241 inverse = FirstLast[1] - FirstLast[0] ;
2242 inverse = 1.0e0 / inverse ;
2244 for (ii = 0, jj = Dimension, kk = 2 * Dimension, pp = 3 * Dimension ;
2246 ii++, jj++, kk++, pp++) {
2247 divided_differences_array[ii] = PointsArray[ii] ;
2248 divided_differences_array[kk] = inverse *
2249 (PointsArray[jj] - PointsArray[ii]) ;
2250 divided_differences_array[jj] = DerivativesArray[ii] ;
2251 divided_differences_array[pp] = DerivativesArray[jj] ;
2254 for (ii = 1 ; ii <= Degree ; ii++) {
2256 for (jj = Degree ; jj >= ii+1 ; jj--) {
2257 Index = jj * Dimension ;
2258 Index1 = Index - Dimension ;
2260 for (kk = 0 ; kk < Dimension ; kk++) {
2261 divided_differences_array[Index + kk] -=
2262 divided_differences_array[Index1 + kk] ;
2265 for (kk = 0 ; kk < Dimension ; kk++) {
2266 divided_differences_array[Index + kk] *= inverse ;
2272 // Evaluate the divided difference array polynomial which expresses as
2274 // P(t) = [t1] P + (t - t1) [t1,t2] P + (t - t1)(t - t2)[t1,t2,t3] P + ...
2275 // + (t - t1)(t - t2)(t - t3)...(t - td) [t1,t2,...,td+1] P
2277 // The ith slot in the divided_differences_array is [t1,t2,...,ti+1]
2280 Index = Degree * Dimension ;
2282 for (kk = 0 ; kk < Dimension ; kk++) {
2283 ResultArray[kk] = divided_differences_array[Index + kk] ;
2286 for (ii = Dimension ; ii < (local_request + 1) * Dimension ; ii++) {
2287 ResultArray[ii] = 0.0e0 ;
2290 for (ii = Degree ; ii >= 1 ; ii--) {
2291 difference = Parameter - ParametersArray[ii - 1] ;
2293 for (jj = local_request ; jj > 0 ; jj--) {
2294 Index = jj * Dimension ;
2295 Index1 = Index - Dimension ;
2297 for (kk = 0 ; kk < Dimension ; kk++) {
2298 ResultArray[Index + kk] *= difference ;
2299 ResultArray[Index + kk] += ResultArray[Index1+kk]*(Standard_Real) jj;
2302 Index = (ii -1) * Dimension ;
2304 for (kk = 0 ; kk < Dimension ; kk++) {
2305 ResultArray[kk] *= difference ;
2306 ResultArray[kk] += divided_differences_array[Index+kk] ;
2310 return (ReturnCode) ;
2313 //=======================================================================
2314 //function : HermiteCoefficients
2315 //purpose : calcul des polynomes d'Hermite
2316 //=======================================================================
2318 Standard_Boolean PLib::HermiteCoefficients(const Standard_Real FirstParameter,
2319 const Standard_Real LastParameter,
2320 const Standard_Integer FirstOrder,
2321 const Standard_Integer LastOrder,
2322 math_Matrix& MatrixCoefs)
2324 Standard_Integer NbCoeff = FirstOrder + LastOrder + 2, Ordre[2];
2325 Standard_Integer ii, jj, pp, cote, iof=0;
2326 Standard_Real Prod, TBorne = FirstParameter;
2327 math_Vector Coeff(1,NbCoeff), B(1, NbCoeff, 0.0);
2328 math_Matrix MAT(1,NbCoeff, 1,NbCoeff, 0.0);
2330 // Test de validites
2332 if ((FirstOrder < 0) || (LastOrder < 0)) return Standard_False;
2333 Standard_Real D1 = fabs(FirstParameter), D2 = fabs(LastParameter);
2334 if (D1 > 100 || D2 > 100) return Standard_False;
2336 if (D2 < 0.01) return Standard_False;
2337 if (fabs(LastParameter - FirstParameter) / D2 < 0.01) return Standard_False;
2339 // Calcul de la matrice a inverser (MAT)
2341 Ordre[0] = FirstOrder+1;
2342 Ordre[1] = LastOrder+1;
2344 for (cote=0; cote<=1; cote++) {
2347 for (pp=1; pp<=Ordre[cote]; pp++) {
2351 for (jj=pp; jj<=NbCoeff; jj++) {
2352 // tout se passe dans les 3 lignes suivantes
2353 MAT(ii, jj) = Coeff(jj) * Prod;
2354 Coeff(jj) *= jj - pp;
2358 TBorne = LastParameter;
2362 // resolution du systemes
2363 math_Gauss ResolCoeff(MAT, 1.0e-10);
2364 if (!ResolCoeff.IsDone()) return Standard_False;
2366 for (ii=1; ii<=NbCoeff; ii++) {
2368 ResolCoeff.Solve(B, Coeff);
2369 MatrixCoefs.SetRow( ii, Coeff);
2372 return Standard_True;
2375 //=======================================================================
2376 //function : CoefficientsPoles
2378 //=======================================================================
2380 void PLib::CoefficientsPoles (const TColgp_Array1OfPnt& Coefs,
2381 const TColStd_Array1OfReal& WCoefs,
2382 TColgp_Array1OfPnt& Poles,
2383 TColStd_Array1OfReal& Weights)
2385 TColStd_Array1OfReal tempC(1,3*Coefs.Length());
2386 PLib::SetPoles(Coefs,tempC);
2387 TColStd_Array1OfReal tempP(1,3*Poles.Length());
2388 PLib::SetPoles(Coefs,tempP);
2389 PLib::CoefficientsPoles(3,tempC,WCoefs,tempP,Weights);
2390 PLib::GetPoles(tempP,Poles);
2393 //=======================================================================
2394 //function : CoefficientsPoles
2396 //=======================================================================
2398 void PLib::CoefficientsPoles (const TColgp_Array1OfPnt2d& Coefs,
2399 const TColStd_Array1OfReal& WCoefs,
2400 TColgp_Array1OfPnt2d& Poles,
2401 TColStd_Array1OfReal& Weights)
2403 TColStd_Array1OfReal tempC(1,2*Coefs.Length());
2404 PLib::SetPoles(Coefs,tempC);
2405 TColStd_Array1OfReal tempP(1,2*Poles.Length());
2406 PLib::SetPoles(Coefs,tempP);
2407 PLib::CoefficientsPoles(2,tempC,WCoefs,tempP,Weights);
2408 PLib::GetPoles(tempP,Poles);
2411 //=======================================================================
2412 //function : CoefficientsPoles
2414 //=======================================================================
2416 void PLib::CoefficientsPoles (const TColStd_Array1OfReal& Coefs,
2417 const TColStd_Array1OfReal& WCoefs,
2418 TColStd_Array1OfReal& Poles,
2419 TColStd_Array1OfReal& Weights)
2421 PLib::CoefficientsPoles(1,Coefs,WCoefs,Poles,Weights);
2424 //=======================================================================
2425 //function : CoefficientsPoles
2427 //=======================================================================
2429 void PLib::CoefficientsPoles (const Standard_Integer dim,
2430 const TColStd_Array1OfReal& Coefs,
2431 const TColStd_Array1OfReal& WCoefs,
2432 TColStd_Array1OfReal& Poles,
2433 TColStd_Array1OfReal& Weights)
2435 Standard_Boolean rat = &WCoefs != NULL;
2436 Standard_Integer loc = Coefs.Lower();
2437 Standard_Integer lop = Poles.Lower();
2438 Standard_Integer lowc=0;
2439 Standard_Integer lowp=0;
2440 Standard_Integer upc = Coefs.Upper();
2441 Standard_Integer upp = Poles.Upper();
2442 Standard_Integer upwc=0;
2443 Standard_Integer upwp=0;
2444 Standard_Integer reflen = Coefs.Length()/dim;
2445 Standard_Integer i,j,k;
2448 lowc = WCoefs.Lower(); lowp = Weights.Lower();
2449 upwc = WCoefs.Upper(); upwp = Weights.Upper();
2452 for (i = 0; i < dim; i++){
2453 Poles (lop + i) = Coefs (loc + i);
2454 Poles (upp - i) = Coefs (upc - i);
2457 Weights (lowp) = WCoefs (lowc);
2458 Weights (upwp) = WCoefs (upwc);
2462 for (i = 2; i < reflen; i++ ) {
2463 Cnp = PLib::Bin(reflen - 1, i - 1);
2464 if (rat) Weights (lowp + i - 1) = WCoefs (lowc + i - 1) / Cnp;
2466 for(j = 0; j < dim; j++){
2467 Poles(lop + dim * (i-1) + j)= Coefs(loc + dim * (i-1) + j) / Cnp;
2471 for (i = 1; i <= reflen - 1; i++) {
2473 for (j = reflen - 1; j >= i; j--) {
2474 if (rat) Weights (lowp + j) += Weights (lowp + j -1);
2476 for(k = 0; k < dim; k++){
2477 Poles(lop + dim * j + k) += Poles(lop + dim * (j - 1) + k);
2483 for (i = 1; i <= reflen; i++) {
2485 for(j = 0; j < dim; j++){
2486 Poles(lop + dim * (i-1) + j) /= Weights(lowp + i -1);
2492 //=======================================================================
2493 //function : Trimming
2495 //=======================================================================
2497 void PLib::Trimming(const Standard_Real U1,
2498 const Standard_Real U2,
2499 TColgp_Array1OfPnt& Coefs,
2500 TColStd_Array1OfReal& WCoefs)
2502 TColStd_Array1OfReal temp(1,3*Coefs.Length());
2503 PLib::SetPoles(Coefs,temp);
2504 PLib::Trimming(U1,U2,3,temp,WCoefs);
2505 PLib::GetPoles(temp,Coefs);
2508 //=======================================================================
2509 //function : Trimming
2511 //=======================================================================
2513 void PLib::Trimming(const Standard_Real U1,
2514 const Standard_Real U2,
2515 TColgp_Array1OfPnt2d& Coefs,
2516 TColStd_Array1OfReal& WCoefs)
2518 TColStd_Array1OfReal temp(1,2*Coefs.Length());
2519 PLib::SetPoles(Coefs,temp);
2520 PLib::Trimming(U1,U2,2,temp,WCoefs);
2521 PLib::GetPoles(temp,Coefs);
2524 //=======================================================================
2525 //function : Trimming
2527 //=======================================================================
2529 void PLib::Trimming(const Standard_Real U1,
2530 const Standard_Real U2,
2531 TColStd_Array1OfReal& Coefs,
2532 TColStd_Array1OfReal& WCoefs)
2534 PLib::Trimming(U1,U2,1,Coefs,WCoefs);
2537 //=======================================================================
2538 //function : Trimming
2540 //=======================================================================
2542 void PLib::Trimming(const Standard_Real U1,
2543 const Standard_Real U2,
2544 const Standard_Integer dim,
2545 TColStd_Array1OfReal& Coefs,
2546 TColStd_Array1OfReal& WCoefs)
2550 // on fait le changement de variable v = (u-U1) / (U2-U1)
2551 // on exprime u = f(v) que l'on remplace dans l'expression polynomiale
2552 // decomposee sous la forme du schema iteratif de horner.
2554 Standard_Real lsp = U2 - U1;
2555 Standard_Integer indc, indw=0;
2556 Standard_Integer upc = Coefs.Upper() - dim + 1, upw=0;
2557 Standard_Integer len = Coefs.Length()/dim;
2558 Standard_Boolean rat = &WCoefs != NULL;
2561 if(len != WCoefs.Length())
2562 Standard_Failure::Raise("PLib::Trimming : nbcoefs/dim != nbweights !!!");
2563 upw = WCoefs.Upper();
2567 for (Standard_Integer i = 1; i <= len; i++) {
2568 Standard_Integer j ;
2569 indc = upc - dim*(i-1);
2570 if (rat) indw = upw - i + 1;
2571 //calcul du coefficient de degre le plus faible a l'iteration i
2573 for( j = 0; j < dim; j++){
2574 Coefs(indc - dim + j) += U1 * Coefs(indc + j);
2576 if (rat) WCoefs(indw - 1) += U1 * WCoefs(indw);
2578 //calcul des coefficients intermediaires :
2583 for(Standard_Integer k = 0; k < dim; k++){
2584 Coefs(indc - dim + k) =
2585 U1 * Coefs(indc + k) + lsp * Coefs(indc - dim + k);
2589 WCoefs(indw - 1) = U1 * WCoefs(indw) + lsp * WCoefs(indw - 1);
2593 //calcul du coefficient de degre le plus eleve :
2595 for(j = 0; j < dim; j++){
2596 Coefs(upc + j) *= lsp;
2598 if (rat) WCoefs(upw) *= lsp;
2602 //=======================================================================
2603 //function : CoefficientsPoles
2605 // Modified: 21/10/1996 by PMN : PolesCoefficient (PRO5852).
2606 // on ne bidouille plus les u et v c'est a l'appelant de savoir ce qu'il
2607 // fait avec BuildCache ou plus simplement d'utiliser PolesCoefficients
2608 //=======================================================================
2610 void PLib::CoefficientsPoles (const TColgp_Array2OfPnt& Coefs,
2611 const TColStd_Array2OfReal& WCoefs,
2612 TColgp_Array2OfPnt& Poles,
2613 TColStd_Array2OfReal& Weights)
2615 Standard_Boolean rat = (&WCoefs != NULL);
2616 Standard_Integer LowerRow = Poles.LowerRow();
2617 Standard_Integer UpperRow = Poles.UpperRow();
2618 Standard_Integer LowerCol = Poles.LowerCol();
2619 Standard_Integer UpperCol = Poles.UpperCol();
2620 Standard_Integer ColLength = Poles.ColLength();
2621 Standard_Integer RowLength = Poles.RowLength();
2623 // Bidouille pour retablir u et v pour les coefs calcules
2625 // Standard_Boolean inv = Standard_False; //ColLength != Coefs.ColLength();
2627 Standard_Integer Row, Col;
2628 Standard_Real W, Cnp;
2630 Standard_Integer I1, I2;
2631 Standard_Integer NPoleu , NPolev;
2634 for (NPoleu = LowerRow; NPoleu <= UpperRow; NPoleu++){
2635 Poles (NPoleu, LowerCol) = Coefs (NPoleu, LowerCol);
2637 Weights (NPoleu, LowerCol) = WCoefs (NPoleu, LowerCol);
2640 for (Col = LowerCol + 1; Col <= UpperCol - 1; Col++) {
2641 Cnp = PLib::Bin(RowLength - 1,Col - LowerCol);
2642 Temp = Coefs (NPoleu, Col).XYZ();
2644 Poles (NPoleu, Col).SetXYZ (Temp);
2646 Weights (NPoleu, Col) = WCoefs (NPoleu, Col) / Cnp;
2649 Poles (NPoleu, UpperCol) = Coefs (NPoleu, UpperCol);
2651 Weights (NPoleu, UpperCol) = WCoefs (NPoleu, UpperCol);
2654 for (I1 = 1; I1 <= RowLength - 1; I1++) {
2656 for (I2 = UpperCol; I2 >= LowerCol + I1; I2--) {
2658 (Poles (NPoleu, I2).XYZ(), Poles (NPoleu, I2-1).XYZ());
2659 Poles (NPoleu, I2).SetXYZ (Temp);
2660 if (rat) Weights(NPoleu, I2) += Weights(NPoleu, I2-1);
2665 for (NPolev = LowerCol; NPolev <= UpperCol; NPolev++){
2667 for (Row = LowerRow + 1; Row <= UpperRow - 1; Row++) {
2668 Cnp = PLib::Bin(ColLength - 1,Row - LowerRow);
2669 Temp = Poles (Row, NPolev).XYZ();
2671 Poles (Row, NPolev).SetXYZ (Temp);
2672 if (rat) Weights(Row, NPolev) /= Cnp;
2675 for (I1 = 1; I1 <= ColLength - 1; I1++) {
2677 for (I2 = UpperRow; I2 >= LowerRow + I1; I2--) {
2679 (Poles (I2, NPolev).XYZ(), Poles (I2-1, NPolev).XYZ());
2680 Poles (I2, NPolev).SetXYZ (Temp);
2681 if (rat) Weights(I2, NPolev) += Weights(I2-1, NPolev);
2687 for (Row = LowerRow; Row <= UpperRow; Row++) {
2689 for (Col = LowerCol; Col <= UpperCol; Col++) {
2690 W = Weights (Row, Col);
2691 Temp = Poles(Row, Col).XYZ();
2693 Poles(Row, Col).SetXYZ (Temp);
2699 //=======================================================================
2700 //function : UTrimming
2702 //=======================================================================
2704 void PLib::UTrimming(const Standard_Real U1,
2705 const Standard_Real U2,
2706 TColgp_Array2OfPnt& Coeffs,
2707 TColStd_Array2OfReal& WCoeffs)
2709 Standard_Boolean rat = &WCoeffs != NULL;
2710 Standard_Integer lr = Coeffs.LowerRow();
2711 Standard_Integer ur = Coeffs.UpperRow();
2712 Standard_Integer lc = Coeffs.LowerCol();
2713 Standard_Integer uc = Coeffs.UpperCol();
2714 TColgp_Array1OfPnt Temp (lr,ur);
2715 TColStd_Array1OfReal Temw (lr,ur);
2717 for (Standard_Integer icol = lc; icol <= uc; icol++) {
2718 Standard_Integer irow ;
2719 for ( irow = lr; irow <= ur; irow++) {
2720 Temp (irow) = Coeffs (irow, icol);
2721 if (rat) Temw (irow) = WCoeffs (irow, icol);
2723 if (rat) PLib::Trimming (U1, U2, Temp, Temw);
2724 else PLib::Trimming (U1, U2, Temp, PLib::NoWeights());
2726 for (irow = lr; irow <= ur; irow++) {
2727 Coeffs (irow, icol) = Temp (irow);
2728 if (rat) WCoeffs (irow, icol) = Temw (irow);
2733 //=======================================================================
2734 //function : VTrimming
2736 //=======================================================================
2738 void PLib::VTrimming(const Standard_Real V1,
2739 const Standard_Real V2,
2740 TColgp_Array2OfPnt& Coeffs,
2741 TColStd_Array2OfReal& WCoeffs)
2743 Standard_Boolean rat = &WCoeffs != NULL;
2744 Standard_Integer lr = Coeffs.LowerRow();
2745 Standard_Integer ur = Coeffs.UpperRow();
2746 Standard_Integer lc = Coeffs.LowerCol();
2747 Standard_Integer uc = Coeffs.UpperCol();
2748 TColgp_Array1OfPnt Temp (lc,uc);
2749 TColStd_Array1OfReal Temw (lc,uc);
2751 for (Standard_Integer irow = lr; irow <= ur; irow++) {
2752 Standard_Integer icol ;
2753 for ( icol = lc; icol <= uc; icol++) {
2754 Temp (icol) = Coeffs (irow, icol);
2755 if (rat) Temw (icol) = WCoeffs (irow, icol);
2757 if (rat) PLib::Trimming (V1, V2, Temp, Temw);
2758 else PLib::Trimming (V1, V2, Temp, PLib::NoWeights());
2760 for (icol = lc; icol <= uc; icol++) {
2761 Coeffs (irow, icol) = Temp (icol);
2762 if (rat) WCoeffs (irow, icol) = Temw (icol);
2767 //=======================================================================
2768 //function : HermiteInterpolate
2770 //=======================================================================
2772 Standard_Boolean PLib::HermiteInterpolate
2773 (const Standard_Integer Dimension,
2774 const Standard_Real FirstParameter,
2775 const Standard_Real LastParameter,
2776 const Standard_Integer FirstOrder,
2777 const Standard_Integer LastOrder,
2778 const TColStd_Array2OfReal& FirstConstr,
2779 const TColStd_Array2OfReal& LastConstr,
2780 TColStd_Array1OfReal& Coefficients)
2782 Standard_Real Pattern[3][6];
2784 // portage HP : il faut les initialiser 1 par 1
2805 math_Matrix A(0,FirstOrder+LastOrder+1, 0,FirstOrder+LastOrder+1);
2806 // The initialisation of the matrix A
2807 Standard_Integer irow ;
2808 for ( irow=0; irow<=FirstOrder; irow++) {
2809 Standard_Real FirstVal = 1.;
2811 for (Standard_Integer icol=0; icol<=FirstOrder+LastOrder+1; icol++) {
2812 A(irow,icol) = Pattern[irow][icol]*FirstVal;
2813 if (irow <= icol) FirstVal *= FirstParameter;
2817 for (irow=0; irow<=LastOrder; irow++) {
2818 Standard_Real LastVal = 1.;
2820 for (Standard_Integer icol=0; icol<=FirstOrder+LastOrder+1; icol++) {
2821 A(irow+FirstOrder+1,icol) = Pattern[irow][icol]*LastVal;
2822 if (irow <= icol) LastVal *= LastParameter;
2826 // The filled matrix A for FirstOrder=LastOrder=2 is:
2828 // 1 FP FP**2 FP**3 FP**4 FP**5
2829 // 0 1 2*FP 3*FP**2 4*FP**3 5*FP**4 FP - FirstParameter
2830 // 0 0 2 6*FP 12*FP**2 20*FP**3
2831 // 1 LP LP**2 LP**3 LP**4 LP**5
2832 // 0 1 2*LP 3*LP**2 4*LP**3 5*LP**4 LP - LastParameter
2833 // 0 0 2 6*LP 12*LP**2 20*LP**3
2835 // If FirstOrder or LastOrder <=2 then some rows and columns are missing.
2837 // If FirstOrder=1 then 3th row and 6th column are missing
2838 // If FirstOrder=LastOrder=0 then 2,3,5,6th rows and 3,4,5,6th columns are missing
2840 math_Gauss Equations(A);
2841 // cout << "A=" << A << endl;
2843 for (Standard_Integer idim=1; idim<=Dimension; idim++) {
2844 // cout << "idim=" << idim << endl;
2846 math_Vector B(0,FirstOrder+LastOrder+1);
2847 Standard_Integer icol ;
2848 for ( icol=0; icol<=FirstOrder; icol++)
2849 B(icol) = FirstConstr(idim,icol);
2851 for (icol=0; icol<=LastOrder; icol++)
2852 B(FirstOrder+1+icol) = LastConstr(idim,icol);
2853 // cout << "B=" << B << endl;
2855 // The solving of equations system A * X = B. Then B = X
2857 // cout << "After Solving" << endl << "B=" << B << endl;
2859 if (Equations.IsDone()==Standard_False) return Standard_False;
2861 // the filling of the Coefficients
2863 for (icol=0; icol<=FirstOrder+LastOrder+1; icol++)
2864 Coefficients(Dimension*icol+idim-1) = B(icol);
2866 return Standard_True;
2869 //=======================================================================
2870 //function : JacobiParameters
2872 //=======================================================================
2874 void PLib::JacobiParameters(const GeomAbs_Shape ConstraintOrder,
2875 const Standard_Integer MaxDegree,
2876 const Standard_Integer Code,
2877 Standard_Integer& NbGaussPoints,
2878 Standard_Integer& WorkDegree)
2880 // ConstraintOrder: Ordre de contrainte aux extremites :
2881 // C0 = contraintes de passage aux bornes;
2882 // C1 = C0 + contraintes de derivees 1eres;
2883 // C2 = C1 + contraintes de derivees 2ndes.
2884 // MaxDegree: Nombre maxi de coeff de la "courbe" polynomiale
2885 // d' approximation (doit etre superieur ou egal a
2886 // 2*NivConstr+2 et inferieur ou egal a 50).
2887 // Code: Code d' init. des parametres de discretisation.
2888 // (choix de NBPNTS et de NDGJAC de MAPF1C,MAPFXC).
2889 // = -5 Calcul tres rapide mais peu precis (8pts)
2890 // = -4 ' ' ' ' ' ' (10pts)
2891 // = -3 ' ' ' ' ' ' (15pts)
2892 // = -2 ' ' ' ' ' ' (20pts)
2893 // = -1 ' ' ' ' ' ' (25pts)
2894 // = 1 calcul rapide avec precision moyenne (30pts).
2895 // = 2 calcul rapide avec meilleure precision (40pts).
2896 // = 3 calcul un peu plus lent avec bonne precision (50 pts).
2897 // = 4 calcul lent avec la meilleure precision possible
2900 // The possible values of NbGaussPoints
2902 const Standard_Integer NDEG8=8, NDEG10=10, NDEG15=15, NDEG20=20, NDEG25=25,
2903 NDEG30=30, NDEG40=40, NDEG50=50, NDEG61=61;
2905 Standard_Integer NivConstr=0;
2906 switch (ConstraintOrder) {
2907 case GeomAbs_C0: NivConstr = 0; break;
2908 case GeomAbs_C1: NivConstr = 1; break;
2909 case GeomAbs_C2: NivConstr = 2; break;
2911 Standard_ConstructionError::Raise("Invalid ConstraintOrder");
2913 if (MaxDegree < 2*NivConstr+1)
2914 Standard_ConstructionError::Raise("Invalid MaxDegree");
2917 WorkDegree = MaxDegree + 9;
2919 WorkDegree = MaxDegree + 6;
2921 //---> Nbre mini de points necessaires.
2922 Standard_Integer IPMIN=0;
2923 if (WorkDegree < NDEG8)
2925 else if (WorkDegree < NDEG10)
2927 else if (WorkDegree < NDEG15)
2929 else if (WorkDegree < NDEG20)
2931 else if (WorkDegree < NDEG25)
2933 else if (WorkDegree < NDEG30)
2935 else if (WorkDegree < NDEG40)
2937 else if (WorkDegree < NDEG50)
2939 else if (WorkDegree < NDEG61)
2942 Standard_ConstructionError::Raise("Invalid MaxDegree");
2943 // ---> Nbre de points voulus.
2944 Standard_Integer IWANT=0;
2946 case -5: IWANT=NDEG8; break;
2947 case -4: IWANT=NDEG10; break;
2948 case -3: IWANT=NDEG15; break;
2949 case -2: IWANT=NDEG20; break;
2950 case -1: IWANT=NDEG25; break;
2951 case 1: IWANT=NDEG30; break;
2952 case 2: IWANT=NDEG40; break;
2953 case 3: IWANT=NDEG50; break;
2954 case 4: IWANT=NDEG61; break;
2956 Standard_ConstructionError::Raise("Invalid Code");
2958 //--> NbGaussPoints est le nombre de points de discretisation de la fonction,
2959 // il ne peut prendre que les valeurs 8,10,15,20,25,30,40,50 ou 61.
2960 // NbGaussPoints doit etre superieur strictement a WorkDegree.
2961 NbGaussPoints = Max(IPMIN,IWANT);
2962 // NbGaussPoints +=2;
2965 //=======================================================================
2966 //function : NivConstr
2967 //purpose : translates from GeomAbs_Shape to Integer
2968 //=======================================================================
2970 Standard_Integer PLib::NivConstr(const GeomAbs_Shape ConstraintOrder)
2972 Standard_Integer NivConstr=0;
2973 switch (ConstraintOrder) {
2974 case GeomAbs_C0: NivConstr = 0; break;
2975 case GeomAbs_C1: NivConstr = 1; break;
2976 case GeomAbs_C2: NivConstr = 2; break;
2978 Standard_ConstructionError::Raise("Invalid ConstraintOrder");
2983 //=======================================================================
2984 //function : ConstraintOrder
2985 //purpose : translates from Integer to GeomAbs_Shape
2986 //=======================================================================
2988 GeomAbs_Shape PLib::ConstraintOrder(const Standard_Integer NivConstr)
2990 GeomAbs_Shape ConstraintOrder=GeomAbs_C0;
2991 switch (NivConstr) {
2992 case 0: ConstraintOrder = GeomAbs_C0; break;
2993 case 1: ConstraintOrder = GeomAbs_C1; break;
2994 case 2: ConstraintOrder = GeomAbs_C2; break;
2996 Standard_ConstructionError::Raise("Invalid NivConstr");
2998 return ConstraintOrder;
3001 //=======================================================================
3002 //function : EvalLength
3004 //=======================================================================
3006 void PLib::EvalLength(const Standard_Integer Degree, const Standard_Integer Dimension,
3007 Standard_Real& PolynomialCoeff,
3008 const Standard_Real U1, const Standard_Real U2,
3009 Standard_Real& Length)
3011 Standard_Integer i,j,idim, degdim;
3012 Standard_Real C1,C2,Sum,Tran,X1,X2,Der1,Der2,D1,D2,DD;
3014 Standard_Real *PolynomialArray = &PolynomialCoeff ;
3016 Standard_Integer NbGaussPoints = 4 * Min((Degree/4)+1,10);
3018 math_Vector GaussPoints(1,NbGaussPoints);
3019 math::GaussPoints(NbGaussPoints,GaussPoints);
3021 math_Vector GaussWeights(1,NbGaussPoints);
3022 math::GaussWeights(NbGaussPoints,GaussWeights);
3024 C1 = (U2 + U1) / 2.;
3025 C2 = (U2 - U1) / 2.;
3027 //-----------------------------------------------------------
3028 //****** Integration - Boucle sur les intervalles de GAUSS **
3029 //-----------------------------------------------------------
3033 for (j=1; j<=NbGaussPoints/2; j++) {
3034 // Integration en tenant compte de la symetrie
3035 Tran = C2 * GaussPoints(j);
3039 //****** Derivation sur la dimension de l'espace **
3041 degdim = Degree*Dimension;
3043 for (idim=0; idim<Dimension; idim++) {
3044 D1 = D2 = Degree * PolynomialArray [idim + degdim];
3045 for (i=Degree-1; i>=1; i--) {
3046 DD = i * PolynomialArray [idim + i*Dimension];
3054 //****** Integration **
3056 Sum += GaussWeights(j) * C2 * (Sqrt(Der1) + Sqrt(Der2));
3058 //****** Fin de boucle dur les intervalles de GAUSS **
3064 //=======================================================================
3065 //function : EvalLength
3067 //=======================================================================
3069 void PLib::EvalLength(const Standard_Integer Degree, const Standard_Integer Dimension,
3070 Standard_Real& PolynomialCoeff,
3071 const Standard_Real U1, const Standard_Real U2,
3072 const Standard_Real Tol,
3073 Standard_Real& Length, Standard_Real& Error)
3076 Standard_Integer NbSubInt = 1, // Current number of subintervals
3077 MaxNbIter = 13, // Max number of iterations
3078 NbIter = 1; // Current number of iterations
3079 Standard_Real dU,OldLen,LenI;
3081 PLib::EvalLength(Degree,Dimension, PolynomialCoeff, U1,U2, Length);
3087 dU = (U2-U1)/NbSubInt;
3088 for (i=1; i<=NbSubInt; i++) {
3089 PLib::EvalLength(Degree,Dimension, PolynomialCoeff, U1+(i-1)*dU,U1+i*dU, LenI);
3093 Error = Abs(OldLen-Length);
3095 while (Error > Tol && NbIter <= MaxNbIter);