Integration of OCCT 6.5.0 from SVN
[occt.git] / src / GeomFill / GeomFill_CoonsAlgPatch.cxx
1 // File:        GeomFill_CoonsAlgPatch.cxx
2 // Created:     Mon Dec  4 14:41:51 1995
3 // Author:      Laurent BOURESCHE
4 //              <lbo@phylox>
5
6
7 #include <GeomFill_CoonsAlgPatch.ixx>
8 #include <Law_Linear.hxx>
9 #include <gp_XYZ.hxx>
10
11 //=======================================================================
12 //function : GeomFill_CoonsAlgPatch
13 //purpose  : 
14 //=======================================================================
15
16 GeomFill_CoonsAlgPatch::GeomFill_CoonsAlgPatch
17 (const Handle(GeomFill_Boundary)& B1, 
18  const Handle(GeomFill_Boundary)& B2, 
19  const Handle(GeomFill_Boundary)& B3, 
20  const Handle(GeomFill_Boundary)& B4)
21 {
22   bound[0] = B1; bound[1] = B2; bound[2] = B3; bound[3] = B4; 
23   Standard_Real deb0, deb1, fin0, fin1;
24   B2->Bounds(deb1,fin1);
25   a[0] = new Law_Linear();
26   (*((Handle_Law_Linear*) &a[0]))->Set(deb1,1.,fin1,0.);
27   B1->Bounds(deb0,fin0);
28   a[1] = new Law_Linear();
29   (*((Handle_Law_Linear*) &a[1]))->Set(deb0,0.,fin0,1.);
30
31   gp_XYZ temp;
32   temp = B4->Value(deb1).XYZ().Added(B1->Value(deb0).XYZ());
33   temp.Multiply(0.5);
34   c[0].SetXYZ(temp);
35   temp = B1->Value(fin0).XYZ().Added(B2->Value(deb1).XYZ());
36   temp.Multiply(0.5);
37   c[1].SetXYZ(temp);
38   temp = B2->Value(fin1).XYZ().Added(B3->Value(fin0).XYZ());
39   temp.Multiply(0.5);
40   c[2].SetXYZ(temp);
41   temp = B3->Value(deb0).XYZ().Added(B4->Value(fin1).XYZ());
42   temp.Multiply(0.5);
43   c[3].SetXYZ(temp);
44 }
45
46
47 //=======================================================================
48 //function : SetFunc
49 //purpose  : 
50 //=======================================================================
51
52 void GeomFill_CoonsAlgPatch::SetFunc(const Handle(Law_Function)& f1, 
53                                      const Handle(Law_Function)& f2)
54 {
55   a[0] = f1;
56   a[1] = f2;
57 }
58
59
60 //=======================================================================
61 //function : Func
62 //purpose  : 
63 //=======================================================================
64
65 void GeomFill_CoonsAlgPatch::Func(Handle(Law_Function)& f1, 
66                                   Handle(Law_Function)& f2)const 
67 {
68   f1 = a[0];
69   f2 = a[1];
70 }
71
72
73 //=======================================================================
74 //function : Value
75 //purpose  : 
76 //=======================================================================
77
78 //gp_Pnt GeomFill_CoonsAlgPatch::Value(const Standard_Real U, 
79 gp_Pnt GeomFill_CoonsAlgPatch::Value(const Standard_Real , 
80                                      const Standard_Real V) const 
81 {
82   Standard_Real a0,a1,a2,a3;
83   a0 = a[0]->Value(V);
84   a1 = a[1]->Value(V);
85   a2 = 1. - a0;
86   a3 = 1. - a1;
87   gp_XYZ cor,cortemp;
88
89   cor = bound[0]->Value(V).XYZ();
90   cor.Multiply(a0);
91
92   cortemp = bound[1]->Value(V).XYZ();
93   cortemp.Multiply(a1);
94   cor.Add(cortemp);
95
96   cortemp = bound[2]->Value(V).XYZ();
97   cortemp.Multiply(a2);
98   cor.Add(cortemp);
99
100   cortemp = bound[3]->Value(V).XYZ();
101   cortemp.Multiply(a3);
102   cor.Add(cortemp);
103
104   cortemp = c[0].XYZ();
105   cortemp.Multiply(-a0*a3);
106   cor.Add(cortemp);
107   
108   cortemp = c[1].XYZ();
109   cortemp.Multiply(-a0*a1);
110   cor.Add(cortemp);
111   
112   cortemp = c[2].XYZ();
113   cortemp.Multiply(-a1*a2);
114   cor.Add(cortemp);
115   
116   cortemp = c[3].XYZ();
117   cortemp.Multiply(-a2*a3);
118   cor.Add(cortemp);
119
120   return gp_Pnt(cor);
121 }
122
123
124 //=======================================================================
125 //function : D1U
126 //purpose  : 
127 //=======================================================================
128
129 gp_Vec GeomFill_CoonsAlgPatch::D1U(const Standard_Real U, 
130                                    const Standard_Real V) const 
131 {
132   Standard_Real a0,a1,a2,a3,bid;
133   a0 = a[0]->Value(V);
134   a[1]->D1(U,bid,a1);
135   a2 = 1 - a0;
136   a3 = -a1;
137   gp_XYZ cor,cortemp;
138   gp_Pnt pbid;
139   gp_Vec vbid;
140
141   bound[0]->D1(U,pbid,vbid);
142   cor = vbid.XYZ();
143   cor.Multiply(a0);
144
145   cortemp = bound[1]->Value(V).XYZ();
146   cortemp.Multiply(a1);
147   cor.Add(cortemp);
148
149   bound[2]->D1(U,pbid,vbid);
150   cortemp = vbid.XYZ();
151   cortemp.Multiply(a2);
152   cor.Add(cortemp);
153
154   cortemp = bound[3]->Value(V).XYZ();
155   cortemp.Multiply(a3);
156   cor.Add(cortemp);
157
158   cortemp = c[0].XYZ();
159   cortemp.Multiply(-a0*a3);
160   cor.Add(cortemp);
161   
162   cortemp = c[1].XYZ();
163   cortemp.Multiply(-a0*a1);
164   cor.Add(cortemp);
165   
166   cortemp = c[2].XYZ();
167   cortemp.Multiply(-a1*a2);
168   cor.Add(cortemp);
169   
170   cortemp = c[3].XYZ();
171   cortemp.Multiply(-a2*a3);
172   cor.Add(cortemp);
173   
174   vbid.SetXYZ(cor);
175   return vbid;
176 }
177
178
179 //=======================================================================
180 //function : D1V
181 //purpose  : 
182 //=======================================================================
183
184 gp_Vec GeomFill_CoonsAlgPatch::D1V(const Standard_Real U, 
185                                    const Standard_Real V) const 
186 {
187   Standard_Real a0,a1,a2,a3,bid;
188   a[0]->D1(V,bid,a0);
189   a1 = a[1]->Value(U);
190   a2 = -a0;
191   a3 = 1. - a1;
192   gp_XYZ cor,cortemp;
193   gp_Pnt pbid;
194   gp_Vec vbid;
195
196   cor = bound[0]->Value(U).XYZ();
197   cor.Multiply(a0);
198
199   bound[1]->D1(V,pbid,vbid);
200   cortemp = vbid.XYZ();
201   cortemp.Multiply(a1);
202   cor.Add(cortemp);
203
204   cortemp = bound[2]->Value(U).XYZ();
205   cortemp.Multiply(a2);
206   cor.Add(cortemp);
207
208   bound[3]->D1(V,pbid,vbid);
209   cortemp = vbid.XYZ();
210   cortemp.Multiply(a3);
211   cor.Add(cortemp);
212
213   cortemp = c[0].XYZ();
214   cortemp.Multiply(-a0*a3);
215   cor.Add(cortemp);
216   
217   cortemp = c[1].XYZ();
218   cortemp.Multiply(-a0*a1);
219   cor.Add(cortemp);
220   
221   cortemp = c[2].XYZ();
222   cortemp.Multiply(-a1*a2);
223   cor.Add(cortemp);
224   
225   cortemp = c[3].XYZ();
226   cortemp.Multiply(-a2*a3);
227   cor.Add(cortemp);
228   
229   vbid.SetXYZ(cor);
230   return vbid;
231 }
232
233
234 //=======================================================================
235 //function : DUV
236 //purpose  : 
237 //=======================================================================
238
239 gp_Vec GeomFill_CoonsAlgPatch::DUV(const Standard_Real U, 
240                                    const Standard_Real V) const 
241 {
242   Standard_Real a0,a1,a2,a3,bid;
243   a[0]->D1(V,bid,a0);
244   a[1]->D1(U,bid,a1);
245   a2 = -a0;
246   a3 = -a1;
247
248   gp_XYZ cor,cortemp;
249   gp_Pnt pbid;
250   gp_Vec vbid;
251
252   bound[0]->D1(U,pbid,vbid);
253   cor = vbid.XYZ();
254   cor.Multiply(a0);
255
256   bound[1]->D1(V,pbid,vbid);
257   cortemp = vbid.XYZ();
258   cortemp.Multiply(a1);
259   cor.Add(cortemp);
260
261   bound[2]->D1(U,pbid,vbid);
262   cortemp = vbid.XYZ();
263   cortemp.Multiply(a2);
264   cor.Add(cortemp);
265
266   bound[3]->D1(V,pbid,vbid);
267   cortemp = vbid.XYZ();
268   cortemp.Multiply(a3);
269   cor.Add(cortemp);
270
271   cortemp = c[0].XYZ();
272   cortemp.Multiply(-a0*a3);
273   cor.Add(cortemp);
274   
275   cortemp = c[1].XYZ();
276   cortemp.Multiply(-a0*a1);
277   cor.Add(cortemp);
278   
279   cortemp = c[2].XYZ();
280   cortemp.Multiply(-a1*a2);
281   cor.Add(cortemp);
282   
283   cortemp = c[3].XYZ();
284   cortemp.Multiply(-a2*a3);
285   cor.Add(cortemp);
286   
287   vbid.SetXYZ(cor);
288   return vbid;
289 }
290
291
292 //=======================================================================
293 //function : Bound
294 //purpose  : 
295 //=======================================================================
296
297 const Handle(GeomFill_Boundary)& GeomFill_CoonsAlgPatch::Bound
298 (const Standard_Integer I) const 
299 {
300   return bound[I];
301 }
302
303
304 //=======================================================================
305 //function : Corner
306 //purpose  : 
307 //=======================================================================
308
309 const gp_Pnt& GeomFill_CoonsAlgPatch::Corner(const Standard_Integer I) const 
310 {
311   return c[I];
312 }
313
314 //=======================================================================
315 //function : Func
316 //purpose  : 
317 //=======================================================================
318
319 const Handle(Law_Function)& GeomFill_CoonsAlgPatch::Func
320 (const Standard_Integer I)const
321 {
322   return a[I];
323 }