b311480e |
1 | // Created on: 1995-12-04 |
2 | // Created by: Laurent BOURESCHE |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <GeomFill_Boundary.hxx> |
19 | #include <GeomFill_CoonsAlgPatch.hxx> |
20 | #include <gp_Pnt.hxx> |
21 | #include <gp_Vec.hxx> |
7fd59977 |
22 | #include <gp_XYZ.hxx> |
42cf5bc1 |
23 | #include <Law_Function.hxx> |
24 | #include <Law_Linear.hxx> |
25 | #include <Standard_Type.hxx> |
7fd59977 |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(GeomFill_CoonsAlgPatch,MMgt_TShared) |
28 | |
7fd59977 |
29 | //======================================================================= |
30 | //function : GeomFill_CoonsAlgPatch |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | GeomFill_CoonsAlgPatch::GeomFill_CoonsAlgPatch |
34 | (const Handle(GeomFill_Boundary)& B1, |
35 | const Handle(GeomFill_Boundary)& B2, |
36 | const Handle(GeomFill_Boundary)& B3, |
37 | const Handle(GeomFill_Boundary)& B4) |
38 | { |
39 | bound[0] = B1; bound[1] = B2; bound[2] = B3; bound[3] = B4; |
40 | Standard_Real deb0, deb1, fin0, fin1; |
5b111128 |
41 | |
7fd59977 |
42 | B2->Bounds(deb1,fin1); |
5b111128 |
43 | Handle(Law_Linear) aLaw0 = new Law_Linear(); |
44 | aLaw0->Set (deb1, 1., fin1, 0.); |
45 | a[0] = aLaw0; |
46 | |
7fd59977 |
47 | B1->Bounds(deb0,fin0); |
5b111128 |
48 | Handle(Law_Linear) aLaw1 = new Law_Linear(); |
49 | aLaw1->Set (deb0, 0., fin0, 1.); |
50 | a[1] = aLaw1; |
7fd59977 |
51 | |
52 | gp_XYZ temp; |
53 | temp = B4->Value(deb1).XYZ().Added(B1->Value(deb0).XYZ()); |
54 | temp.Multiply(0.5); |
55 | c[0].SetXYZ(temp); |
56 | temp = B1->Value(fin0).XYZ().Added(B2->Value(deb1).XYZ()); |
57 | temp.Multiply(0.5); |
58 | c[1].SetXYZ(temp); |
59 | temp = B2->Value(fin1).XYZ().Added(B3->Value(fin0).XYZ()); |
60 | temp.Multiply(0.5); |
61 | c[2].SetXYZ(temp); |
62 | temp = B3->Value(deb0).XYZ().Added(B4->Value(fin1).XYZ()); |
63 | temp.Multiply(0.5); |
64 | c[3].SetXYZ(temp); |
65 | } |
66 | |
67 | |
68 | //======================================================================= |
69 | //function : SetFunc |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | void GeomFill_CoonsAlgPatch::SetFunc(const Handle(Law_Function)& f1, |
74 | const Handle(Law_Function)& f2) |
75 | { |
76 | a[0] = f1; |
77 | a[1] = f2; |
78 | } |
79 | |
80 | |
81 | //======================================================================= |
82 | //function : Func |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | void GeomFill_CoonsAlgPatch::Func(Handle(Law_Function)& f1, |
87 | Handle(Law_Function)& f2)const |
88 | { |
89 | f1 = a[0]; |
90 | f2 = a[1]; |
91 | } |
92 | |
93 | |
94 | //======================================================================= |
95 | //function : Value |
96 | //purpose : |
97 | //======================================================================= |
98 | |
99 | //gp_Pnt GeomFill_CoonsAlgPatch::Value(const Standard_Real U, |
100 | gp_Pnt GeomFill_CoonsAlgPatch::Value(const Standard_Real , |
101 | const Standard_Real V) const |
102 | { |
103 | Standard_Real a0,a1,a2,a3; |
104 | a0 = a[0]->Value(V); |
105 | a1 = a[1]->Value(V); |
106 | a2 = 1. - a0; |
107 | a3 = 1. - a1; |
108 | gp_XYZ cor,cortemp; |
109 | |
110 | cor = bound[0]->Value(V).XYZ(); |
111 | cor.Multiply(a0); |
112 | |
113 | cortemp = bound[1]->Value(V).XYZ(); |
114 | cortemp.Multiply(a1); |
115 | cor.Add(cortemp); |
116 | |
117 | cortemp = bound[2]->Value(V).XYZ(); |
118 | cortemp.Multiply(a2); |
119 | cor.Add(cortemp); |
120 | |
121 | cortemp = bound[3]->Value(V).XYZ(); |
122 | cortemp.Multiply(a3); |
123 | cor.Add(cortemp); |
124 | |
125 | cortemp = c[0].XYZ(); |
126 | cortemp.Multiply(-a0*a3); |
127 | cor.Add(cortemp); |
128 | |
129 | cortemp = c[1].XYZ(); |
130 | cortemp.Multiply(-a0*a1); |
131 | cor.Add(cortemp); |
132 | |
133 | cortemp = c[2].XYZ(); |
134 | cortemp.Multiply(-a1*a2); |
135 | cor.Add(cortemp); |
136 | |
137 | cortemp = c[3].XYZ(); |
138 | cortemp.Multiply(-a2*a3); |
139 | cor.Add(cortemp); |
140 | |
141 | return gp_Pnt(cor); |
142 | } |
143 | |
144 | |
145 | //======================================================================= |
146 | //function : D1U |
147 | //purpose : |
148 | //======================================================================= |
149 | |
150 | gp_Vec GeomFill_CoonsAlgPatch::D1U(const Standard_Real U, |
151 | const Standard_Real V) const |
152 | { |
153 | Standard_Real a0,a1,a2,a3,bid; |
154 | a0 = a[0]->Value(V); |
155 | a[1]->D1(U,bid,a1); |
156 | a2 = 1 - a0; |
157 | a3 = -a1; |
158 | gp_XYZ cor,cortemp; |
159 | gp_Pnt pbid; |
160 | gp_Vec vbid; |
161 | |
162 | bound[0]->D1(U,pbid,vbid); |
163 | cor = vbid.XYZ(); |
164 | cor.Multiply(a0); |
165 | |
166 | cortemp = bound[1]->Value(V).XYZ(); |
167 | cortemp.Multiply(a1); |
168 | cor.Add(cortemp); |
169 | |
170 | bound[2]->D1(U,pbid,vbid); |
171 | cortemp = vbid.XYZ(); |
172 | cortemp.Multiply(a2); |
173 | cor.Add(cortemp); |
174 | |
175 | cortemp = bound[3]->Value(V).XYZ(); |
176 | cortemp.Multiply(a3); |
177 | cor.Add(cortemp); |
178 | |
179 | cortemp = c[0].XYZ(); |
180 | cortemp.Multiply(-a0*a3); |
181 | cor.Add(cortemp); |
182 | |
183 | cortemp = c[1].XYZ(); |
184 | cortemp.Multiply(-a0*a1); |
185 | cor.Add(cortemp); |
186 | |
187 | cortemp = c[2].XYZ(); |
188 | cortemp.Multiply(-a1*a2); |
189 | cor.Add(cortemp); |
190 | |
191 | cortemp = c[3].XYZ(); |
192 | cortemp.Multiply(-a2*a3); |
193 | cor.Add(cortemp); |
194 | |
195 | vbid.SetXYZ(cor); |
196 | return vbid; |
197 | } |
198 | |
199 | |
200 | //======================================================================= |
201 | //function : D1V |
202 | //purpose : |
203 | //======================================================================= |
204 | |
205 | gp_Vec GeomFill_CoonsAlgPatch::D1V(const Standard_Real U, |
206 | const Standard_Real V) const |
207 | { |
208 | Standard_Real a0,a1,a2,a3,bid; |
209 | a[0]->D1(V,bid,a0); |
210 | a1 = a[1]->Value(U); |
211 | a2 = -a0; |
212 | a3 = 1. - a1; |
213 | gp_XYZ cor,cortemp; |
214 | gp_Pnt pbid; |
215 | gp_Vec vbid; |
216 | |
217 | cor = bound[0]->Value(U).XYZ(); |
218 | cor.Multiply(a0); |
219 | |
220 | bound[1]->D1(V,pbid,vbid); |
221 | cortemp = vbid.XYZ(); |
222 | cortemp.Multiply(a1); |
223 | cor.Add(cortemp); |
224 | |
225 | cortemp = bound[2]->Value(U).XYZ(); |
226 | cortemp.Multiply(a2); |
227 | cor.Add(cortemp); |
228 | |
229 | bound[3]->D1(V,pbid,vbid); |
230 | cortemp = vbid.XYZ(); |
231 | cortemp.Multiply(a3); |
232 | cor.Add(cortemp); |
233 | |
234 | cortemp = c[0].XYZ(); |
235 | cortemp.Multiply(-a0*a3); |
236 | cor.Add(cortemp); |
237 | |
238 | cortemp = c[1].XYZ(); |
239 | cortemp.Multiply(-a0*a1); |
240 | cor.Add(cortemp); |
241 | |
242 | cortemp = c[2].XYZ(); |
243 | cortemp.Multiply(-a1*a2); |
244 | cor.Add(cortemp); |
245 | |
246 | cortemp = c[3].XYZ(); |
247 | cortemp.Multiply(-a2*a3); |
248 | cor.Add(cortemp); |
249 | |
250 | vbid.SetXYZ(cor); |
251 | return vbid; |
252 | } |
253 | |
254 | |
255 | //======================================================================= |
256 | //function : DUV |
257 | //purpose : |
258 | //======================================================================= |
259 | |
260 | gp_Vec GeomFill_CoonsAlgPatch::DUV(const Standard_Real U, |
261 | const Standard_Real V) const |
262 | { |
263 | Standard_Real a0,a1,a2,a3,bid; |
264 | a[0]->D1(V,bid,a0); |
265 | a[1]->D1(U,bid,a1); |
266 | a2 = -a0; |
267 | a3 = -a1; |
268 | |
269 | gp_XYZ cor,cortemp; |
270 | gp_Pnt pbid; |
271 | gp_Vec vbid; |
272 | |
273 | bound[0]->D1(U,pbid,vbid); |
274 | cor = vbid.XYZ(); |
275 | cor.Multiply(a0); |
276 | |
277 | bound[1]->D1(V,pbid,vbid); |
278 | cortemp = vbid.XYZ(); |
279 | cortemp.Multiply(a1); |
280 | cor.Add(cortemp); |
281 | |
282 | bound[2]->D1(U,pbid,vbid); |
283 | cortemp = vbid.XYZ(); |
284 | cortemp.Multiply(a2); |
285 | cor.Add(cortemp); |
286 | |
287 | bound[3]->D1(V,pbid,vbid); |
288 | cortemp = vbid.XYZ(); |
289 | cortemp.Multiply(a3); |
290 | cor.Add(cortemp); |
291 | |
292 | cortemp = c[0].XYZ(); |
293 | cortemp.Multiply(-a0*a3); |
294 | cor.Add(cortemp); |
295 | |
296 | cortemp = c[1].XYZ(); |
297 | cortemp.Multiply(-a0*a1); |
298 | cor.Add(cortemp); |
299 | |
300 | cortemp = c[2].XYZ(); |
301 | cortemp.Multiply(-a1*a2); |
302 | cor.Add(cortemp); |
303 | |
304 | cortemp = c[3].XYZ(); |
305 | cortemp.Multiply(-a2*a3); |
306 | cor.Add(cortemp); |
307 | |
308 | vbid.SetXYZ(cor); |
309 | return vbid; |
310 | } |
311 | |
312 | |
313 | //======================================================================= |
314 | //function : Bound |
315 | //purpose : |
316 | //======================================================================= |
317 | |
318 | const Handle(GeomFill_Boundary)& GeomFill_CoonsAlgPatch::Bound |
319 | (const Standard_Integer I) const |
320 | { |
321 | return bound[I]; |
322 | } |
323 | |
324 | |
325 | //======================================================================= |
326 | //function : Corner |
327 | //purpose : |
328 | //======================================================================= |
329 | |
330 | const gp_Pnt& GeomFill_CoonsAlgPatch::Corner(const Standard_Integer I) const |
331 | { |
332 | return c[I]; |
333 | } |
334 | |
335 | //======================================================================= |
336 | //function : Func |
337 | //purpose : |
338 | //======================================================================= |
339 | |
340 | const Handle(Law_Function)& GeomFill_CoonsAlgPatch::Func |
341 | (const Standard_Integer I)const |
342 | { |
343 | return a[I]; |
344 | } |