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