0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GeomFill / GeomFill_Curved.cxx
1 // File:        GeomFill_Curved.cxx
2 // Created:     Tue Sep 28 17:58:37 1993
3 // Author:      Bruno DUMORTIER
4 //              <dub@sdsun1>
5
6 #include <GeomFill_Curved.ixx>
7
8 #include <gp_Pnt.hxx>
9 #include <gp_Vec.hxx>
10 #include <TColStd_Array1OfReal.hxx>
11 #include <TColgp_HArray2OfPnt.hxx>
12 #include <TColStd_HArray2OfReal.hxx>
13
14 #include <Standard_NotImplemented.hxx>
15
16 //=======================================================================
17 //function : GeomFill_Curved
18 //purpose  : 
19 //=======================================================================
20
21 GeomFill_Curved::GeomFill_Curved()
22 {
23 }
24
25
26 //=======================================================================
27 //function : GeomFill_Curved
28 //purpose  : 
29 //=======================================================================
30
31 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1, 
32                            const TColgp_Array1OfPnt& P2, 
33                            const TColgp_Array1OfPnt& P3, 
34                            const TColgp_Array1OfPnt& P4)
35 {
36   Init(P1, P2, P3, P4);
37 }
38
39
40 //=======================================================================
41 //function : GeomFill_Curved
42 //purpose  : 
43 //=======================================================================
44
45 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt&   P1, 
46                            const TColgp_Array1OfPnt&   P2, 
47                            const TColgp_Array1OfPnt&   P3, 
48                            const TColgp_Array1OfPnt&   P4,
49                            const TColStd_Array1OfReal& W1,
50                            const TColStd_Array1OfReal& W2,
51                            const TColStd_Array1OfReal& W3,
52                            const TColStd_Array1OfReal& W4)
53 {
54   Init(P1, P2, P3, P4, W1, W2, W3, W4);
55 }
56
57
58 //=======================================================================
59 //function : GeomFill_Curved
60 //purpose  : 
61 //=======================================================================
62
63 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1, 
64                            const TColgp_Array1OfPnt& P2, 
65                            const TColgp_Array1OfPnt& P3)
66 {
67   Init(P1, P2, P3);
68 }
69
70
71 //=======================================================================
72 //function : GeomFill_Curved
73 //purpose  : 
74 //=======================================================================
75
76 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt&   P1, 
77                            const TColgp_Array1OfPnt&   P2, 
78                            const TColgp_Array1OfPnt&   P3, 
79                            const TColStd_Array1OfReal& W1, 
80                            const TColStd_Array1OfReal& W2, 
81                            const TColStd_Array1OfReal& W3)
82 {
83   Init(P1, P2, P3, W1, W2, W3);
84 }
85
86
87 //=======================================================================
88 //function : GeomFill_Curved
89 //purpose  : 
90 //=======================================================================
91
92 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1, 
93                            const TColgp_Array1OfPnt& P2)
94 {
95   Init(P1, P2);
96 }
97
98
99 //=======================================================================
100 //function : GeomFill_Curved
101 //purpose  : 
102 //=======================================================================
103
104 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt&   P1, 
105                            const TColgp_Array1OfPnt&   P2, 
106                            const TColStd_Array1OfReal& W1, 
107                            const TColStd_Array1OfReal& W2)
108 {
109   Init(P1, P2, W1, W2);
110 }
111
112
113 //=======================================================================
114 //function : Init
115 //purpose  : 
116 //=======================================================================
117
118 void  GeomFill_Curved::Init(const TColgp_Array1OfPnt& P1, 
119                          const TColgp_Array1OfPnt& P2, 
120                          const TColgp_Array1OfPnt& P3, 
121                          const TColgp_Array1OfPnt& P4)
122 {
123   Standard_DomainError_Raise_if
124     ( P1.Length() != P3.Length() || P2.Length() != P4.Length()," ");
125
126   Standard_Integer NPolU = P1.Length();
127   Standard_Integer NPolV = P2.Length();
128   
129   IsRational = Standard_False;
130   
131   Standard_Real NU = NPolU - 1;
132   Standard_Real NV = NPolV - 1;
133   myPoles = new TColgp_HArray2OfPnt( 1, NPolU, 1, NPolV);
134   
135   // The boundaries are not modified
136   Standard_Integer i,j,k;
137   for ( i=1; i<=NPolU; i++) {
138     myPoles->SetValue( i, 1    , P1(i));
139     myPoles->SetValue( i, NPolV, P3(i));
140   }
141   Standard_Real PU,PU1,PV,PV1;
142   
143   for ( j=2; j<=NPolV-1; j++) {
144     PV  = (j-1)/NV;
145     PV1 = 1 - PV;
146     PV /= 2.;
147     PV1 /= 2.;
148     myPoles->SetValue( 1    , j, P4(j));
149     myPoles->SetValue( NPolU, j, P2(j));
150
151     for ( i=2; i<=NPolU-1; i++) {
152       PU  = (i-1)/NU;
153       PU1 = 1 - PU;
154       PU /= 2.;
155       PU1 /= 2.;
156       gp_Pnt P;
157       for (k=1; k<=3; k++) {
158         P.SetCoord(k, 
159                    PV1 * P1(i).Coord(k) + PV  * P3(i).Coord(k) +
160                    PU  * P2(j).Coord(k) + PU1 * P4(j).Coord(k)  );
161       }
162       myPoles->SetValue(i,j,P);
163     }
164   }
165 }
166
167
168 //=======================================================================
169 //function : Init
170 //purpose  : 
171 //=======================================================================
172
173 void  GeomFill_Curved::Init(const TColgp_Array1OfPnt&   P1, 
174                          const TColgp_Array1OfPnt&   P2, 
175                          const TColgp_Array1OfPnt&   P3, 
176                          const TColgp_Array1OfPnt&   P4,
177                          const TColStd_Array1OfReal& W1,
178                          const TColStd_Array1OfReal& W2,
179                          const TColStd_Array1OfReal& W3,
180                          const TColStd_Array1OfReal& W4)
181 {
182   Standard_DomainError_Raise_if
183     ( W1.Length() != W3.Length() || W2.Length() != W4.Length()," ");
184   Standard_DomainError_Raise_if
185     ( W1.Length() != P1.Length() || 
186       W2.Length() != P2.Length() || 
187       W3.Length() != P3.Length() || 
188       W4.Length() != P4.Length()   , " ");
189
190   Init(P1,P2,P3,P4);
191   IsRational = Standard_True;
192
193   Standard_Integer NPolU = W1.Length();
194   Standard_Integer NPolV = W2.Length();
195
196   Standard_Real NU = NPolU - 1;
197   Standard_Real NV = NPolV - 1;
198   myWeights = new TColStd_HArray2OfReal( 1, NPolU, 1, NPolV);
199   
200   // The boundaries are not modified
201   Standard_Integer i,j;
202   for ( i=1; i<=NPolU; i++) {
203     myWeights->SetValue( i, 1    , W1(i));
204     myWeights->SetValue( i, NPolV, W3(i));
205   }
206   Standard_Real PU,PU1,PV,PV1;
207   
208   for ( j=2; j<=NPolV-1; j++) {
209     PV  = (j-1)/NV;
210     PV1 = 1 - PV;
211     PV /= 2.;
212     PV1 /= 2.;
213     myWeights->SetValue( 1    , j, W4(j));
214     myWeights->SetValue( NPolU, j, W2(j));
215
216     for ( i=2; i<=NPolU-1; i++) {
217       PU  = (i-1)/NU;
218       PU1 = 1 - PU;
219       PU /= 2.;
220       PU1 /= 2.;
221       Standard_Real W = PV1 * W1(i) + PV  * W3(i) +
222                         PU  * W2(j) + PU1 * W4(j)  ;
223       myWeights->SetValue(i,j,W);
224     }
225   }
226 }
227
228
229 //=======================================================================
230 //function : Init
231 //purpose  : 
232 //=======================================================================
233
234 void  GeomFill_Curved::Init(const TColgp_Array1OfPnt& ,  // P1, 
235                          const TColgp_Array1OfPnt& ,  // P2, 
236                          const TColgp_Array1OfPnt&  )// P3)
237 {
238   Standard_NotImplemented::Raise(" ");
239 }
240
241
242 //=======================================================================
243 //function : Init
244 //purpose  : 
245 //=======================================================================
246
247 void  GeomFill_Curved::Init(const TColgp_Array1OfPnt&   ,  // P1, 
248                          const TColgp_Array1OfPnt&   ,  // P2, 
249                          const TColgp_Array1OfPnt&   ,  // P3, 
250                          const TColStd_Array1OfReal& ,  // W1, 
251                          const TColStd_Array1OfReal& ,  // W2,
252                          const TColStd_Array1OfReal&  ) // W3)
253 {
254   Standard_NotImplemented::Raise(" ");
255 }
256
257
258 //=======================================================================
259 //function : Init
260 //purpose  : 
261 //=======================================================================
262
263 void  GeomFill_Curved::Init(const TColgp_Array1OfPnt& P1,
264                          const TColgp_Array1OfPnt& P2)
265 {
266   Standard_Integer NPolU = P1.Length();
267   Standard_Integer NPolV = P2.Length();
268   
269   IsRational = Standard_False;
270   
271   myPoles = new TColgp_HArray2OfPnt( 1, NPolU, 1, NPolV);
272   
273   Standard_Integer i,j;
274   
275   for ( j=1; j<=NPolV; j++) {
276     gp_Vec Tra(P2(1),P2(j));
277     for ( i=1; i<=NPolU; i++) {
278       myPoles->SetValue( i, j, P1(i).Translated(Tra));
279     }
280   }
281 }
282
283
284 //=======================================================================
285 //function : Init
286 //purpose  : 
287 //=======================================================================
288
289 void  GeomFill_Curved::Init(const TColgp_Array1OfPnt&   P1, 
290                          const TColgp_Array1OfPnt&   P2, 
291                          const TColStd_Array1OfReal& W1, 
292                          const TColStd_Array1OfReal& W2)
293 {
294   Init(P1,P2);
295   IsRational = Standard_True;
296   
297   //Initialisation des poids.
298   Standard_Integer NPolU = W1.Length();
299   Standard_Integer NPolV = W2.Length();
300
301   myWeights = new TColStd_HArray2OfReal( 1, NPolU, 1, NPolV);
302   for (Standard_Integer j=1; j<=NPolV; j++) {
303     Standard_Real Factor = W2(j)/W1(1);
304     for (Standard_Integer i=1; i<=NPolU; i++) {
305       myWeights->SetValue(i,j,W1(i)*Factor);
306     }
307   }
308 }