OCC22324 Mistakes with parenthesis position in abs calls
[occt.git] / src / GeomFill / GeomFill_Coons.cxx
CommitLineData
7fd59977 1// File: GeomFill_Coons.cxx
2// Created: Wed Sep 29 10:46:05 1993
3// Author: Bruno DUMORTIER
4// <dub@sdsun1>
5
6#include <GeomFill_Coons.ixx>
7
8#include <BSplCLib.hxx>
9#include <PLib.hxx>
10#include <TColgp_HArray2OfPnt.hxx>
11#include <TColStd_HArray2OfReal.hxx>
12
13//=======================================================================
14//function : GeomFill_Coons
15//purpose :
16//=======================================================================
17
18GeomFill_Coons::GeomFill_Coons()
19{
20}
21
22
23//=======================================================================
24//function : GeomFill_Coons
25//purpose :
26//=======================================================================
27
28GeomFill_Coons::GeomFill_Coons(const TColgp_Array1OfPnt& P1,
29 const TColgp_Array1OfPnt& P2,
30 const TColgp_Array1OfPnt& P3,
31 const TColgp_Array1OfPnt& P4)
32{
33 Init( P1, P2, P3, P4);
34}
35
36
37//=======================================================================
38//function : GeomFill_Coons
39//purpose :
40//=======================================================================
41
42GeomFill_Coons::GeomFill_Coons(const TColgp_Array1OfPnt& P1,
43 const TColgp_Array1OfPnt& P2,
44 const TColgp_Array1OfPnt& P3,
45 const TColgp_Array1OfPnt& P4,
46 const TColStd_Array1OfReal& W1,
47 const TColStd_Array1OfReal& W2,
48 const TColStd_Array1OfReal& W3,
49 const TColStd_Array1OfReal& W4)
50{
51 Init( P1, P2, P3, P4, W1, W2, W3, W4);
52}
53
54
55//=======================================================================
56//function : Init
57//purpose :
58//=======================================================================
59
60void GeomFill_Coons::Init(const TColgp_Array1OfPnt& P1,
61 const TColgp_Array1OfPnt& P2,
62 const TColgp_Array1OfPnt& P3,
63 const TColgp_Array1OfPnt& P4)
64{
65 Standard_DomainError_Raise_if
66 ( P1.Length() != P3.Length() || P2.Length() != P4.Length()," ");
67
68 Standard_Integer NPolU = P1.Length();
69 Standard_Integer NPolV = P2.Length();
70
71 IsRational = Standard_False;
72
73 myPoles = new TColgp_HArray2OfPnt( 1, NPolU, 1, NPolV);
74
75 // The boundaries are not modified
76 Standard_Integer i,j,k;
77
78 for (i=1; i<=NPolU; i++) {
79 myPoles->SetValue( i, 1 , P1(i));
80 myPoles->SetValue( i, NPolV, P3(i));
81 }
82 for (i=1; i<=NPolV; i++) {
83 myPoles->SetValue( 1 , i, P2(i));
84 myPoles->SetValue( NPolU, i, P4(i));
85 }
86
87 // Calcul des coefficients multiplicateurs
88 TColgp_Array1OfPnt Coef ( 1, 4);
89 TColgp_Array1OfPnt Pole ( 1, 4);
90 TColgp_Array1OfPnt CoefU( 1, NPolU);
91 TColgp_Array1OfPnt CoefV( 1, NPolV);
92 Coef( 4) = gp_Pnt( 2., -2., 0.);
93 Coef( 3) = gp_Pnt( -3., 3., 0.);
94 Coef( 2) = gp_Pnt( 0., 0., 0.);
95 Coef( 1) = gp_Pnt( 1., 0., 0.);
96 PLib::CoefficientsPoles(Coef, PLib::NoWeights(),
97 Pole, PLib::NoWeights());
98 if (NPolU > 4) {
99 BSplCLib::IncreaseDegree(NPolU-1, Pole, PLib::NoWeights(),
100 CoefU, PLib::NoWeights());
101 }
102 else {
103 CoefU = Pole;
104 }
105 if (NPolV > 4) {
106 BSplCLib::IncreaseDegree(NPolV-1, Pole, PLib::NoWeights(),
107 CoefV, PLib::NoWeights());
108 }
109 else {
110 CoefV = Pole;
111 }
112 TColStd_Array1OfReal FU(2,NPolU-1);
113 TColStd_Array1OfReal GU(2,NPolU-1);
114 TColStd_Array1OfReal FV(2,NPolV-1);
115 TColStd_Array1OfReal GV(2,NPolV-1);
116 Standard_Real Dummy;
117 for ( i= 2; i< NPolU; i++) {
118 CoefU(i).Coord(FU(i), GU(i), Dummy);
119 }
120 for ( i= 2; i< NPolV; i++) {
121 CoefV(i).Coord(FV(i), GV(i), Dummy);
122 }
123
124 // Clacul des poles interieurs
125 gp_Pnt P;
126 for ( j=2; j<NPolV; j++) {
127 for ( i=2; i<NPolU; i++) {
128 for ( k=1; k<=3 ; k++) {
129 P.SetCoord( k,
130 FV(j) * (myPoles->Value(i ,1 )).Coord(k)
131 + GV(j) * (myPoles->Value(i ,NPolV)).Coord(k)
132 + FU(i) * (myPoles->Value(1 ,j )).Coord(k)
133 + GU(i) * (myPoles->Value(NPolU,j )).Coord(k)
134 - FU(i) * FV(j) * (myPoles->Value(1 ,1 )).Coord(k)
135 - FU(i) * GV(j) * (myPoles->Value(1 ,NPolV)).Coord(k)
136 - GU(i) * FV(j) * (myPoles->Value(NPolU,1 )).Coord(k)
137 - GU(i) * GV(j) * (myPoles->Value(NPolU,NPolV)).Coord(k));
138 }
139 myPoles->SetValue(i,j,P);
140 }
141 }
142}
143
144
145//=======================================================================
146//function : Init
147//purpose :
148//=======================================================================
149
150void GeomFill_Coons::Init(const TColgp_Array1OfPnt& P1,
151 const TColgp_Array1OfPnt& P2,
152 const TColgp_Array1OfPnt& P3,
153 const TColgp_Array1OfPnt& P4,
154 const TColStd_Array1OfReal& W1,
155 const TColStd_Array1OfReal& W2,
156 const TColStd_Array1OfReal& W3,
157 const TColStd_Array1OfReal& W4
158 )
159{
160
161 Standard_DomainError_Raise_if
162 ( W1.Length() != W3.Length() || W2.Length() != W4.Length()," ");
163 Standard_DomainError_Raise_if
164 ( W1.Length() != P1.Length() ||
165 W2.Length() != P2.Length() ||
166 W3.Length() != P3.Length() ||
167 W4.Length() != P4.Length() , " ");
168 Init(P1,P2,P3,P4);
169 IsRational = Standard_True;
170
171 Standard_Integer NPolU = W1.Length();
172 Standard_Integer NPolV = W2.Length();
173
174//#ifdef DEB
175 Standard_Real NU = NPolU - 1;
176 Standard_Real NV = NPolV - 1;
177//#endif
178 myWeights = new TColStd_HArray2OfReal( 1, NPolU, 1, NPolV);
179 // The boundaries are not modified
180 Standard_Integer i,j;
181 for ( i=1; i<=NPolU; i++) {
182 myWeights->SetValue( i, 1 , W1(i));
183 myWeights->SetValue( i, NPolV, W3(i));
184 }
185 Standard_Real PU,PU1,PV,PV1;
186
187 for ( j=2; j<=NPolV-1; j++) {
188 PV = (j-1)/NV;
189 PV1 = 1 - PV;
190 myWeights->SetValue( 1 , j, W4(j));
191 myWeights->SetValue( NPolU, j, W2(j));
192
193 for ( i=2; i<=NPolU-1; i++) {
194 PU = (i-1)/NU;
195 PU1 = 1 - PU;
196
197// Standard_Real W = 0.5 * ( PV1 * W1(i) + PV * W3(i) +
198// PU * W2(j) + PU1 * W4(j) );
199 Standard_Real W = PV1 * W1(i) + PV * W3(i) +
200 PU * W2(j) + PU1 * W4(j) -
201 ( PU1 * PV1 * W1(1) +
202 PU * PV1 * W2(1) +
203 PU * PV * W3(NPolU) +
204 PU1 * PV * W4(NPolV) );
205
206 myWeights->SetValue(i,j,W);
207 }
208 }
209
210}
211
212
213