0022312: Translation of french commentaries in OCCT files
[occt.git] / src / AdvApp2Var / AdvApp2Var_Patch.cxx
CommitLineData
7fd59977 1// File: AdvApp2Var_Patch.cxx
2// Created: Tue Jul 2 12:12:24 1996
3// Author: Joelle CHAUVET
4// <jct@sgi38>
5// Modified: Wed Jan 15 10:04:41 1997
6// by: Joelle CHAUVET
7// G1135 : Methods CutSense with criterion, Coefficients,
8// CritValue, SetCritValue
9// Modified: Tue May 19 10:22:44 1998
10// by: Joelle CHAUVET / Jean-Marc LACHAUME
11// Initialisation de myCritValue pour OSF
12
13#include <AdvApp2Var_Patch.ixx>
14#include <AdvApp2Var_Node.hxx>
15#include <AdvApp2Var_Iso.hxx>
16#include <gp_Pnt.hxx>
17#include <TColgp_HArray2OfPnt.hxx>
18#include <TColgp_Array2OfPnt.hxx>
19#include <TColStd_HArray1OfInteger.hxx>
20#include <TColStd_HArray1OfReal.hxx>
21#include <TColStd_HArray2OfReal.hxx>
22#include <TColStd_Array2OfReal.hxx>
23#include <Convert_GridPolynomialToPoles.hxx>
24#include <Standard_ConstructionError.hxx>
25
26#include <AdvApp2Var_ApproxF2var.hxx>
27#include <AdvApp2Var_MathBase.hxx>
28
29
30//============================================================================
31//function : AdvApp2Var_Patch
32//purpose :
33//============================================================================
34
35AdvApp2Var_Patch::AdvApp2Var_Patch() :
36myU0(0.),
37myU1(1.),
38myV0(0.),
39myV1(1.),
40myOrdInU(0),
41myOrdInV(0),
7c97b4a3
KS
42myNbCoeffInU(0),
43myNbCoeffInV(0),
7fd59977 44myApprIsDone(Standard_False),
45myHasResult(Standard_False),
46myCutSense(0),
47myDiscIsDone(Standard_False),
48myCritValue(0.)
49{
50}
51
52//============================================================================
53//function : AdvApp2Var_Patch
54//purpose :
55//============================================================================
56
57AdvApp2Var_Patch::AdvApp2Var_Patch(const Standard_Real U0,
58 const Standard_Real U1,
59 const Standard_Real V0,
60 const Standard_Real V1,
61 const Standard_Integer iu,
62 const Standard_Integer iv) :
63myU0(U0),
64myU1(U1),
65myV0(V0),
66myV1(V1),
67myOrdInU(iu),
68myOrdInV(iv),
7c97b4a3
KS
69myNbCoeffInU(0),
70myNbCoeffInV(0),
7fd59977 71myApprIsDone(Standard_False),
72myHasResult(Standard_False),
73myCutSense(0),
74myDiscIsDone(Standard_False),
75myCritValue(0.)
76{
77}
78
79//============================================================================
80//function : IsDiscretised
81//purpose :
82//============================================================================
83
84Standard_Boolean AdvApp2Var_Patch::IsDiscretised() const
85{
86 return myDiscIsDone;
87}
88
89//============================================================================
90//function : Discretise
91//purpose :
92//============================================================================
93
94void AdvApp2Var_Patch::Discretise(const AdvApp2Var_Context& Conditions,
95 const AdvApp2Var_Framework& Constraints,
96 const AdvApp2Var_EvaluatorFunc2Var& Func)
97{
98
99// les donnees stockees dans le Context
100 Standard_Integer NDIMEN, NBSESP, NDIMSE, ISOFAV;
101 NDIMEN = Conditions.TotalDimension();
102 NBSESP = Conditions.TotalNumberSSP();
103// Attention : ne marche que pour le 3D
104 NDIMSE = 3;
105 ISOFAV = Conditions.FavorIso();
106
107// les donnees relatives au patch a discretiser
108 Standard_Integer NBPNTU, NBPNTV;
109 Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV;
110 Handle (TColStd_HArray1OfReal) HUROOT = Conditions.URoots();
111 Handle (TColStd_HArray1OfReal) HVROOT = Conditions.VRoots();
112 Standard_Real * UROOT;
113 UROOT = (Standard_Real *) &HUROOT ->ChangeArray1()(HUROOT ->Lower());
114 NBPNTU = (Conditions.URoots())->Length();
115 if (myOrdInU>-1) NBPNTU -= 2;
116 Standard_Real * VROOT;
117 VROOT = (Standard_Real *) &HVROOT ->ChangeArray1()(HVROOT ->Lower());
118 NBPNTV = (Conditions.VRoots())->Length();
119 if (myOrdInV>-1) NBPNTV -= 2;
120
121// les donnees stockees dans le Framework Constraints cad Noeuds et Isos
122// C1, C2, C3 et C4 sont dimensionnes en FORTRAN a (NDIMEN,IORDRU+2,IORDRV+2)
123 Standard_Integer SIZE=NDIMEN*(IORDRU+2)*(IORDRV+2);
124 Handle (TColStd_HArray1OfReal) HCOINS =
125 new TColStd_HArray1OfReal(1,SIZE*4);
126 HCOINS->Init(0.);
127
128 Standard_Integer iu,iv;
129 Standard_Real du=(myU1-myU0)/2,dv=(myV1-myV0)/2,rho,valnorm;
130
131 for (iu=0;iu<=myOrdInU;iu++) {
132 for (iv=0;iv<=myOrdInV;iv++) {
133// facteur de normalisation
134 rho = pow(du,iu)*pow(dv,iv);
135
136// F(U0,V0) et ses derivees normalisees sur (-1,1)
137 valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X();
138 HCOINS->SetValue( 1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv , valnorm );
139 valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y();
140 HCOINS->SetValue( 2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
141 valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z();
142 HCOINS->SetValue( 3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
143
144// F(U1,V0) et ses derivees normalisees sur (-1,1)
145 valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X();
146 HCOINS->SetValue( SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
147 valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y();
148 HCOINS->SetValue( SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
149 valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z();
150 HCOINS->SetValue( SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
151
152// F(U0,V1) et ses derivees normalisees sur (-1,1)
153 valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X();
154 HCOINS->SetValue( 2*SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
155 valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y();
156 HCOINS->SetValue( 2*SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
157 valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z();
158 HCOINS->SetValue( 2*SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
159
160// F(U1,V1) et ses derivees normalisees sur (-1,1)
161 valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X();
162 HCOINS->SetValue( 3*SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
163 valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y();
164 HCOINS->SetValue( 3*SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
165 valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z();
166 HCOINS->SetValue( 3*SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm );
167 }
168 }
169 Standard_Real *C1 =
170 (Standard_Real *) &HCOINS ->ChangeArray1()(HCOINS ->Lower());
171 Standard_Real *C2 = C1 + SIZE;
172 Standard_Real *C3 = C2 + SIZE;
173 Standard_Real *C4 = C3 + SIZE;
174
175// tableaux SomTab et Diftab de discretisation des isos U=U0 et U=U1
176// SU0, SU1, DU0 et DU1 sont dimensionnes en FORTRAN a
177// (1+NBPNTV/2)*NDIMEN*(IORDRU+1)
178
179 SIZE = (1+NBPNTV/2)*NDIMEN;
180
181 Handle (TColStd_HArray1OfReal) HSU0
182 = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1));
183 HSU0 ->ChangeArray1() =
184 ( (Constraints.IsoU(myU0,myV0,myV1)).SomTab() ) ->Array1();
185
186 Handle (TColStd_HArray1OfReal) HDU0
187 = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1));
188 HDU0 ->ChangeArray1() =
189 ( (Constraints.IsoU(myU0,myV0,myV1)).DifTab() ) ->Array1();
190
191 Handle (TColStd_HArray1OfReal) HSU1
192 = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1));
193 HSU1 ->ChangeArray1() =
194 ( (Constraints.IsoU(myU1,myV0,myV1)).SomTab() ) ->Array1();
195
196 Handle (TColStd_HArray1OfReal) HDU1
197 = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1));
198 HDU1 ->ChangeArray1() =
199 ( (Constraints.IsoU(myU1,myV0,myV1)).DifTab() ) ->Array1();
200
201// normalisation
202 Standard_Integer ideb1,ideb2,ideb3,ideb4,jj;
203 for (iu=1;iu<=IORDRU;iu++) {
204 rho = pow(du,iu);
205 ideb1 = HSU0->Lower() + iu*SIZE -1;
206 ideb2 = HDU0->Lower() + iu*SIZE -1;
207 ideb3 = HSU1->Lower() + iu*SIZE -1;
208 ideb4 = HDU1->Lower() + iu*SIZE -1;
209 for (jj=1;jj<=SIZE;jj++) {
210 HSU0 ->SetValue(ideb1+jj,rho*HSU0->Value(ideb1+jj));
211 HDU0 ->SetValue(ideb2+jj,rho*HDU0->Value(ideb2+jj));
212 HSU1 ->SetValue(ideb3+jj,rho*HSU1->Value(ideb3+jj));
213 HDU1 ->SetValue(ideb4+jj,rho*HDU1->Value(ideb4+jj));
214 }
215 }
216
217 Standard_Real *SU0 =
218 (Standard_Real *) &HSU0 ->ChangeArray1()(HSU0 ->Lower());
219 Standard_Real *DU0 =
220 (Standard_Real *) &HDU0 ->ChangeArray1()(HDU0 ->Lower());
221 Standard_Real *SU1 =
222 (Standard_Real *) &HSU1 ->ChangeArray1()(HSU1 ->Lower());
223 Standard_Real *DU1 =
224 (Standard_Real *) &HDU1 ->ChangeArray1()(HDU1 ->Lower());
225
226// tableaux SomTab et Diftab de discretisation des isos V=V0 et V=V1
227// SU0, SU1, DU0 et DU1 sont dimensionnes en FORTRAN a
228// (1+NBPNTU/2)*NDIMEN*(IORDRV+1)
229
230 SIZE = (1+NBPNTU/2)*NDIMEN;
231
232 Handle (TColStd_HArray1OfReal) HSV0
233 = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1));
234 HSV0 ->ChangeArray1() =
235 ( (Constraints.IsoV(myU0,myU1,myV0)).SomTab() ) ->Array1();
236
237 Handle (TColStd_HArray1OfReal) HDV0
238 = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1));
239 HDV0 ->ChangeArray1() =
240 ( (Constraints.IsoV(myU0,myU1,myV0)).DifTab() ) ->Array1();
241
242 Handle (TColStd_HArray1OfReal) HSV1
243 = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1));
244 HSV1 ->ChangeArray1() =
245 ( (Constraints.IsoV(myU0,myU1,myV1)).SomTab() ) ->Array1();
246
247 Handle (TColStd_HArray1OfReal) HDV1
248 = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1));
249 HDV1 ->ChangeArray1() =
250 ( (Constraints.IsoV(myU0,myU1,myV1)).DifTab() ) ->Array1();
251
252// normalisation
253 for (iv=1;iv<=IORDRV;iv++) {
254 rho = pow(dv,iv);
255 ideb1 = HSV0->Lower() + iv*SIZE -1;
256 ideb2 = HDV0->Lower() + iv*SIZE -1;
257 ideb3 = HSV1->Lower() + iv*SIZE -1;
258 ideb4 = HDV1->Lower() + iv*SIZE -1;
259 for (jj=1;jj<=SIZE;jj++) {
260 HSV0 ->SetValue(ideb1+jj,rho*HSV0->Value(ideb1+jj));
261 HDV0 ->SetValue(ideb2+jj,rho*HDV0->Value(ideb2+jj));
262 HSV1 ->SetValue(ideb3+jj,rho*HSV1->Value(ideb3+jj));
263 HDV1 ->SetValue(ideb4+jj,rho*HDV1->Value(ideb4+jj));
264 }
265 }
266
267 Standard_Real *SV0 =
268 (Standard_Real *) &HSV0 ->ChangeArray1()(HSV0 ->Lower());
269 Standard_Real *DV0 =
270 (Standard_Real *) &HDV0 ->ChangeArray1()(HDV0 ->Lower());
271 Standard_Real *SV1 =
272 (Standard_Real *) &HSV1 ->ChangeArray1()(HSV1 ->Lower());
273 Standard_Real *DV1 =
274 (Standard_Real *) &HDV1 ->ChangeArray1()(HDV1 ->Lower());
275
276// SOSOTB et DIDITB sont dimensionnes en FORTRAN a
277// (0:NBPNTU/2,0:NBPNTV/2,NDIMEN)
278
279 SIZE=(1+NBPNTU/2)*(1+NBPNTV/2)*NDIMEN;
280
281 Handle (TColStd_HArray1OfReal) HSOSO =
282 new TColStd_HArray1OfReal(1,SIZE);
283 Standard_Real *SOSOTB =
284 (Standard_Real *) &HSOSO ->ChangeArray1()(HSOSO ->Lower());
285 HSOSO->Init(0.);
286 Handle (TColStd_HArray1OfReal) HDIDI =
287 new TColStd_HArray1OfReal(1,SIZE);
288 Standard_Real *DIDITB =
289 (Standard_Real *) &HDIDI ->ChangeArray1()(HDIDI ->Lower());
290 HDIDI->Init(0.);
291
292// SODITB et DISOTB sont dimensionnes en FORTRAN a
293// (1:NBPNTU/2,1:NBPNTV/2,NDIMEN)
294
295 SIZE=(NBPNTU/2)*(NBPNTV/2)*NDIMEN;
296
297 Handle (TColStd_HArray1OfReal) HSODI =
298 new TColStd_HArray1OfReal(1,SIZE);
299 Standard_Real *SODITB =
300 (Standard_Real *) &HSODI ->ChangeArray1()(HSODI ->Lower());
301 HSODI->Init(0.);
302 Handle (TColStd_HArray1OfReal) HDISO =
303 new TColStd_HArray1OfReal(1,SIZE);
304 Standard_Real *DISOTB =
305 (Standard_Real *) &HDISO ->ChangeArray1()(HDISO ->Lower());
306 HDISO->Init(0.);
307
308 Standard_Integer IERCOD=0;
309
310// discretisation des polynomes d'interpolation
311 AdvApp2Var_ApproxF2var::mma2cdi_(&NDIMEN,&NBPNTU,UROOT,&NBPNTV,VROOT,&IORDRU,&IORDRV,
312 C1,C2,C3,C4,SU0,SU1,DU0,DU1,SV0,SV1,DV0,DV1,
313 SOSOTB,SODITB,DISOTB,DIDITB,&IERCOD);
314
315// discretisation du carreau
316 Standard_Real UDBFN[2],VDBFN[2];
317 UDBFN[0] = myU0;
318 UDBFN[1] = myU1;
319 VDBFN[0] = myV0;
320 VDBFN[1] = myV1;
321
322 SIZE = Max(NBPNTU,NBPNTV);
323 Handle (TColStd_HArray1OfReal) HTABLE =
324 new TColStd_HArray1OfReal(1,SIZE);
325 Standard_Real *TAB =
326 (Standard_Real *) &HTABLE ->ChangeArray1()(HTABLE ->Lower());
327
328 Handle (TColStd_HArray1OfReal) HPOINTS =
329 new TColStd_HArray1OfReal(1,SIZE*NDIMEN);
330 Standard_Real *PTS =
331 (Standard_Real *) &HPOINTS ->ChangeArray1()(HPOINTS ->Lower());
332
333 // GCC 3.0 would not accept this line without the void
334 // pointer cast. Perhaps the real problem is a definition
335 // somewhere that has a void * in it.
336 AdvApp2Var_ApproxF2var::mma2ds1_(&NDIMEN,
337 UDBFN,
338 VDBFN,
339 /*(void *)*/Func,
340 &NBPNTU,
341 &NBPNTV,
342 UROOT,
343 VROOT,
344 &ISOFAV,
345 SOSOTB,
346 DISOTB,
347 SODITB,
348 DIDITB,
349 PTS,
350 TAB,
351 &IERCOD);
352
353// on stocke les resultats
354 if (IERCOD == 0) {
355 myDiscIsDone = Standard_True;
356 mySosoTab = HSOSO;
357 myDisoTab = HDISO;
358 mySodiTab = HSODI;
359 myDidiTab = HDIDI;
360 }
361 else {
362 myDiscIsDone = Standard_False;
363 }
364}
365
366//============================================================================
367//function : HasResult
368//purpose :
369//============================================================================
370
371Standard_Boolean AdvApp2Var_Patch::HasResult() const
372{
373 return myHasResult;
374}
375
376//============================================================================
377//function : IsApproximated
378//purpose :
379//============================================================================
380
381Standard_Boolean AdvApp2Var_Patch::IsApproximated() const
382{
383 return myApprIsDone;
384}
385
386//============================================================================
387//function : AddConstraints
388//purpose :
389//============================================================================
390
391void AdvApp2Var_Patch::AddConstraints(const AdvApp2Var_Context& Conditions,
392 const AdvApp2Var_Framework& Constraints)
393{
394// les donnees stockees dans le Context
395 Standard_Integer NDIMEN, NBSESP, NDIMSE;
396 Standard_Integer IERCOD, NCFLMU, NCFLMV, NDegU, NDegV;
397 NDIMEN = Conditions.TotalDimension();
398 NBSESP = Conditions.TotalNumberSSP();
399// Attention : ne marche que pour le 3D
400 NDIMSE = 3;
401 NCFLMU = Conditions.ULimit();
402 NCFLMV = Conditions.VLimit();
403 NDegU = NCFLMU - 1;
404 NDegV = NCFLMV - 1;
405
406// les donnees relatives au patch a approcher
407 Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV;
408 Standard_Real *PATCAN =
409 (Standard_Real *) &myEquation ->ChangeArray1()(myEquation ->Lower());
410
411// les courbes d'approximation des Isos U
412 Standard_Integer SIZE = NCFLMV*NDIMEN;
413 Handle (TColStd_HArray1OfReal) HIsoU0
414 = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1));
415 HIsoU0 -> ChangeArray1() =
416 (Constraints.IsoU(myU0,myV0,myV1)).Polynom() -> Array1();
417 Standard_Real *IsoU0 =
418 (Standard_Real *) &HIsoU0 ->ChangeArray1()(HIsoU0 ->Lower());
419 Handle (TColStd_HArray1OfInteger) HCFU0
420 = new TColStd_HArray1OfInteger(1,IORDRU+1);
421 Standard_Integer *NCFU0 =
422 (Standard_Integer *) &HCFU0 ->ChangeArray1()(HCFU0 ->Lower());
423 HCFU0->Init( (Constraints.IsoU(myU0,myV0,myV1)).NbCoeff() );
424
425 Handle (TColStd_HArray1OfReal) HIsoU1
426 = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1));
427 HIsoU1 -> ChangeArray1() =
428 (Constraints.IsoU(myU1,myV0,myV1)).Polynom() -> Array1();
429 Standard_Real *IsoU1 =
430 (Standard_Real *) &HIsoU1 ->ChangeArray1()(HIsoU1 ->Lower());
431 Handle (TColStd_HArray1OfInteger) HCFU1
432 = new TColStd_HArray1OfInteger(1,IORDRU+1);
433 Standard_Integer *NCFU1 =
434 (Standard_Integer *) &HCFU1 ->ChangeArray1()(HCFU1 ->Lower());
435 HCFU1->Init( (Constraints.IsoU(myU1,myV0,myV1)).NbCoeff() );
436
437// normalisation des Isos U
438 Standard_Integer iu,iv;
439 Standard_Real du=(myU1-myU0)/2,dv=(myV1-myV0)/2,rho,valnorm;
440 Standard_Integer ideb0,ideb1,jj;
441
442 for (iu=1;iu<=IORDRU;iu++) {
443 rho = pow(du,iu);
444 ideb0 = HIsoU0->Lower() + iu*SIZE -1;
445 ideb1 = HIsoU1->Lower() + iu*SIZE -1;
446 for (jj=1;jj<=SIZE;jj++) {
447 HIsoU0->SetValue(ideb0+jj,rho*HIsoU0->Value(ideb0+jj));
448 HIsoU1->SetValue(ideb1+jj,rho*HIsoU1->Value(ideb1+jj));
449 }
450 }
451
452// les courbes d'approximation des Isos V
453 SIZE = NCFLMU*NDIMEN;
454 Handle (TColStd_HArray1OfReal) HIsoV0
455 = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1));
456 HIsoV0 -> ChangeArray1() =
457 (Constraints.IsoV(myU0,myU1,myV0)).Polynom() -> Array1();
458 Standard_Real *IsoV0 =
459 (Standard_Real *) &HIsoV0 ->ChangeArray1()(HIsoV0 ->Lower());
460 Handle (TColStd_HArray1OfInteger) HCFV0
461 = new TColStd_HArray1OfInteger(1,IORDRV+1);
462 Standard_Integer *NCFV0 =
463 (Standard_Integer *) &HCFV0 ->ChangeArray1()(HCFV0 ->Lower());
464 HCFV0->Init( (Constraints.IsoV(myU0,myU1,myV0)).NbCoeff() );
465
466 Handle (TColStd_HArray1OfReal) HIsoV1
467 = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1));
468 HIsoV1 -> ChangeArray1() =
469 (Constraints.IsoV(myU0,myU1,myV1)).Polynom() -> Array1();
470 Standard_Real *IsoV1 =
471 (Standard_Real *) &HIsoV1 ->ChangeArray1()(HIsoV1 ->Lower());
472 Handle (TColStd_HArray1OfInteger) HCFV1
473 = new TColStd_HArray1OfInteger(1,IORDRV+1);
474 Standard_Integer *NCFV1 =
475 (Standard_Integer *) &HCFV1 ->ChangeArray1()(HCFV1 ->Lower());
476 HCFV1->Init( (Constraints.IsoV(myU0,myU1,myV1)).NbCoeff() );
477
478// normalisation des Isos V
479 for (iv=1;iv<=IORDRV;iv++) {
480 rho = pow(dv,iv);
481 ideb0 = HIsoV0->Lower() + iv*SIZE -1;
482 ideb1 = HIsoV1->Lower() + iv*SIZE -1;
483 for (jj=1;jj<=SIZE;jj++) {
484 HIsoV0 ->SetValue(ideb0+jj,rho*HIsoV0->Value(ideb0+jj));
485 HIsoV1->SetValue(ideb1+jj,rho*HIsoV1->Value(ideb1+jj));
486 }
487 }
488
489// ajout des contraintes a V constant
490 Handle (TColStd_HArray1OfReal) HHERMV
491 = new TColStd_HArray1OfReal(1,(2*IORDRV+2)*(2*IORDRV+2));
492 Standard_Real *HermV =
493 (Standard_Real *) &HHERMV ->ChangeArray1()(HHERMV ->Lower());
494 if (IORDRV>=0) {
495 AdvApp2Var_ApproxF2var::mma1her_(&IORDRV,HermV,&IERCOD);
496 if (IERCOD!=0) {
497 Standard_ConstructionError::Raise
498 ("AdvApp2Var_Patch::AddConstraints : Error in FORTRAN");
499 }
500 AdvApp2Var_ApproxF2var::mma2ac2_(&NDIMEN,
501 &NDegU,
502 &NDegV,
503 &IORDRV,
504 &NCFLMU,
505 NCFV0,
506 IsoV0,
507 NCFV1,
508 IsoV1,
509 HermV,
510 PATCAN);
511 }
512
513// ajout des contraintes a U constant
514 Handle (TColStd_HArray1OfReal) HHERMU
515 = new TColStd_HArray1OfReal(1,(2*IORDRU+2)*(2*IORDRU+2));
516 Standard_Real *HermU =
517 (Standard_Real *) &HHERMU ->ChangeArray1()(HHERMU ->Lower());
518 if (IORDRU>=0) {
519 AdvApp2Var_ApproxF2var::mma1her_(&IORDRU,HermU,&IERCOD);
520 if (IERCOD!=0) {
521 Standard_ConstructionError::Raise
522 ("AdvApp2Var_Patch::AddConstraints : Error in FORTRAN");
523 }
524 AdvApp2Var_ApproxF2var::mma2ac3_(&NDIMEN,&NDegU,&NDegV,&IORDRU,&NCFLMV,
525 NCFU0,IsoU0,NCFU1,IsoU1,HermU,PATCAN);
526 }
527
528// ajout des contraintes de coins
529 Standard_Integer ideb;
530 SIZE=NDIMEN*(IORDRU+2)*(IORDRV+2);
531 Handle (TColStd_HArray1OfReal) HCOINS =
532 new TColStd_HArray1OfReal(1,SIZE*4);
533
534 for (iu=0;iu<=myOrdInU;iu++) {
535 for (iv=0;iv<=myOrdInV;iv++) {
536 rho = pow(du,iu)*pow(dv,iv);
537
538// -F(U0,V0) et ses derivees normalisees sur (-1,1)
539 ideb = HCOINS->Lower() + NDIMEN*iu+NDIMEN*(IORDRU+2)*iv - 1;
540 valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X();
541 HCOINS->SetValue( 1+ideb , valnorm );
542 valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y();
543 HCOINS->SetValue( 2+ideb , valnorm );
544 valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z();
545 HCOINS->SetValue( 3+ideb , valnorm );
546
547// -F(U1,V0) et ses derivees normalisees sur (-1,1)
548 ideb += SIZE;
549 valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X();
550 HCOINS->SetValue( 1+ideb , valnorm );
551 valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y();
552 HCOINS->SetValue( 2+ideb , valnorm );
553 valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z();
554 HCOINS->SetValue( 3+ideb , valnorm );
555
556// -F(U0,V1) et ses derivees normalisees sur (-1,1)
557 ideb += SIZE;
558 valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X();
559 HCOINS->SetValue( 1+ideb , valnorm );
560 valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y();
561 HCOINS->SetValue( 2+ideb , valnorm );
562 valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z();
563 HCOINS->SetValue( 3+ideb , valnorm );
564
565// -F(U1,V1) et ses derivees normalisees sur (-1,1)
566 ideb += SIZE;
567 valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X();
568 HCOINS->SetValue( 1+ideb , valnorm );
569 valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y();
570 HCOINS->SetValue( 2+ideb , valnorm );
571 valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z();
572 HCOINS->SetValue( 3+ideb , valnorm );
573 }
574 }
575
576// tableaux necessaires pour le FORTRAN
577 Standard_Integer IORDMX = Max(IORDRU,IORDRV);
578 Handle (TColStd_HArray1OfReal) HEXTR =
579 new TColStd_HArray1OfReal(1,2*IORDMX+2);
580 Standard_Real *EXTR =
581 (Standard_Real *) &HEXTR ->ChangeArray1()(HEXTR ->Lower());
582 Handle (TColStd_HArray1OfReal) HFACT =
583 new TColStd_HArray1OfReal(1,IORDMX+1);
584 Standard_Real *FACT =
585 (Standard_Real *) &HFACT ->ChangeArray1()(HFACT ->Lower());
586
587 Standard_Integer idim,ncf0,ncf1,iun=1;
588 Standard_Real *Is;
589
590// ajout des extremites des isos U
591 for (iu=1;iu<=IORDRU+1;iu++) {
592 ncf0 = HCFU0->Value(HCFU0->Lower()+iu-1);
593 ncf1 = HCFU1->Value(HCFU1->Lower()+iu-1);
594 for (idim=1;idim<=NDIMEN;idim++) {
595 Is = IsoU0 + NCFLMV*(idim-1) + NCFLMV*NDIMEN*(iu-1);
596 AdvApp2Var_MathBase::mmdrc11_(&IORDRV,&iun,&ncf0,Is,EXTR,FACT);
597 for (iv=1;iv<=IORDRV+1;iv++) {
598 ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1;
599 HCOINS->ChangeValue(idim+ideb) += HEXTR->Value(1+2*(iv-1));
600 HCOINS->ChangeValue(2*SIZE+idim+ideb) += HEXTR->Value(2+2*(iv-1));
601 }
602 Is = IsoU1 + NCFLMV*(idim-1) + NCFLMV*NDIMEN*(iu-1);
603 AdvApp2Var_MathBase::mmdrc11_(&IORDRV,&iun,&ncf1,Is,EXTR,FACT);
604 for (iv=1;iv<=IORDRV+1;iv++) {
605 ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1;
606 HCOINS->ChangeValue(SIZE+idim+ideb) += HEXTR->Value(1+2*(iv-1));
607 HCOINS->ChangeValue(3*SIZE+idim+ideb) += HEXTR->Value(2+2*(iv-1));
608 }
609 }
610 }
611
612// ajout des extremites des isos V
613 for (iv=1;iv<=IORDRV+1;iv++) {
614 ncf0 = HCFV0->Value(HCFV0->Lower()+iv-1);
615 ncf1 = HCFV1->Value(HCFV1->Lower()+iv-1);
616 for (idim=1;idim<=NDIMEN;idim++) {
617 Is = IsoV0 + NCFLMU*(idim-1) + NCFLMU*NDIMEN*(iv-1);
618 AdvApp2Var_MathBase::mmdrc11_(&IORDRU,&iun,&ncf0,Is,EXTR,FACT);
619 for (iu=1;iu<=IORDRU+1;iu++) {
620 ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1;
621 HCOINS->ChangeValue(idim+ideb) += HEXTR->Value(1+2*(iu-1));
622 HCOINS->ChangeValue(SIZE+idim+ideb) += HEXTR->Value(2+2*(iu-1));
623 }
624 Is = IsoV1 + NCFLMU*(idim-1) + NCFLMU*NDIMEN*(iv-1);
625 AdvApp2Var_MathBase::mmdrc11_(&IORDRU,&iun,&ncf1,Is,EXTR,FACT);
626 for (iu=1;iu<=IORDRU+1;iu++) {
627 ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1;
628 HCOINS->ChangeValue(2*SIZE+idim+ideb) += HEXTR->Value(1+2*(iu-1));
629 HCOINS->ChangeValue(3*SIZE+idim+ideb) += HEXTR->Value(2+2*(iu-1));
630 }
631 }
632 }
633
634// ajout du tout a PATCAN
635 Standard_Real *C1 =
636 (Standard_Real *) &HCOINS ->ChangeArray1()(HCOINS ->Lower());
637 Standard_Real *C2 = C1 + SIZE;
638 Standard_Real *C3 = C2 + SIZE;
639 Standard_Real *C4 = C3 + SIZE;
640 if ( IORDRU>=0 && IORDRV>=0 ) {
641 AdvApp2Var_ApproxF2var::mma2ac1_(&NDIMEN,&NDegU,&NDegV,&IORDRU,&IORDRV,
642 C1,C2,C3,C4,HermU,HermV,PATCAN);
643 }
644}
645
646//============================================================================
647//function : AddErrors
648//purpose :
649//============================================================================
650
651void AdvApp2Var_Patch::AddErrors(const AdvApp2Var_Framework& Constraints)
652{
653 Standard_Integer NBSESP = 1, iesp;
654 Standard_Integer iu,iv;
655
656 Standard_Real errU,errV,error,hmax[4];
657 hmax[0] = 0;
658 hmax[1] = 1;
659 hmax[2] = 1.5;
660 hmax[3] = 1.75;
661
662 for (iesp=1;iesp<=NBSESP;iesp++) {
663 // erreur max dans le sous-espace iesp
664 errU=0.;
665 for (iv=1;iv<=myOrdInV+1;iv++) {
666 error = ((Constraints.IsoV(myU0,myU1,myV0)).MaxErrors())->Value(iesp,iv);
667 errU = Max(errU,error);
668 error = ((Constraints.IsoV(myU0,myU1,myV1)).MaxErrors())->Value(iesp,iv);
669 errU = Max(errU,error);
670 }
671 errV=0.;
672 for (iu=1;iu<=myOrdInU+1;iu++) {
673 error = ((Constraints.IsoU(myU0,myV0,myV1)).MaxErrors())->Value(iesp,iu);
674 errV = Max(errV,error);
675 error = ((Constraints.IsoU(myU1,myV0,myV1)).MaxErrors())->Value(iesp,iu);
676 errV = Max(errV,error);
677 }
678 myMaxErrors->ChangeValue(iesp) +=
679 errU * hmax[myOrdInV+1] + errV * hmax[myOrdInU+1];
680
681 // erreur moyenne dans le sous-espace iesp
682 errU=0.;
683 for (iv=1;iv<=myOrdInV+1;iv++) {
684 error = ((Constraints.IsoV(myU0,myU1,myV0)).MoyErrors())->Value(iesp,iv);
685 errU = Max(errU,error);
686 error = ((Constraints.IsoV(myU0,myU1,myV1)).MoyErrors())->Value(iesp,iv);
687 errU = Max(errU,error);
688 }
689 errV=0.;
690 for (iu=1;iu<=myOrdInU+1;iu++) {
691 error = ((Constraints.IsoU(myU0,myV0,myV1)).MoyErrors())->Value(iesp,iu);
692 errV = Max(errV,error);
693 error = ((Constraints.IsoU(myU1,myV0,myV1)).MoyErrors())->Value(iesp,iu);
694 errV = Max(errV,error);
695 }
696 error = myMoyErrors->Value(iesp);
697 error *= error;
698 error += errU*hmax[myOrdInV+1] * errU*hmax[myOrdInV+1]
699 + errV*hmax[myOrdInU+1] * errV*hmax[myOrdInU+1];
700 myMoyErrors->SetValue(iesp,Sqrt(error));
701
702 // erreurs maxi aux iso-frontieres
703 Handle (TColStd_HArray2OfReal) HERISO
704 = new TColStd_HArray2OfReal(1,NBSESP,1,4);
705 HERISO->SetValue(iesp,1,
706 ((Constraints.IsoV(myU0,myU1,myV0)).MaxErrors())->Value(iesp,1));
707 HERISO->SetValue(iesp,2,
708 ((Constraints.IsoV(myU0,myU1,myV1)).MaxErrors())->Value(iesp,1));
709 HERISO->SetValue(iesp,3,
710 ((Constraints.IsoU(myU0,myV0,myV1)).MaxErrors())->Value(iesp,1));
711 HERISO->SetValue(iesp,4,
712 ((Constraints.IsoU(myU1,myV0,myV1)).MaxErrors())->Value(iesp,1));
713
714// calcul des erreurs max aux coins
715 Standard_Real emax1=0.,emax2=0.,emax3=0.,emax4=0.,err1,err2,err3,err4;
716 for (iu=0;iu<=myOrdInU;iu++) {
717 for (iv=0;iv<=myOrdInV;iv++) {
718 error = (Constraints.Node(myU0,myV0)).Error(iu,iv);
719 emax1 = Max(emax1,error);
720 error = (Constraints.Node(myU1,myV0)).Error(iu,iv);
721 emax2 = Max(emax2,error);
722 error = (Constraints.Node(myU0,myV1)).Error(iu,iv);
723 emax3 = Max(emax3,error);
724 error = (Constraints.Node(myU1,myV1)).Error(iu,iv);
725 emax4 = Max(emax4,error);
726 }
727 }
728
729// calcul des erreurs max sur les bords
730 err1 = Max(emax1,emax2);
731 err2 = Max(emax3,emax4);
732 err3 = Max(emax1,emax3);
733 err4 = Max(emax2,emax4);
734
735// calcul des erreurs finales sur les isos internes
736 if ( (Constraints.IsoV(myU0,myU1,myV0)).Position() == 0 ) {
737 HERISO ->ChangeValue(iesp,1) += err1*hmax[myOrdInU+1];
738 }
739 if ( (Constraints.IsoV(myU0,myU1,myV1)).Position() == 0 ) {
740 HERISO ->ChangeValue(iesp,2) += err2*hmax[myOrdInU+1];
741 }
742 if ( (Constraints.IsoU(myU0,myV0,myV1)).Position() == 0 ) {
743 HERISO ->ChangeValue(iesp,3) += err3*hmax[myOrdInV+1];
744 }
745 if ( (Constraints.IsoU(myU1,myV0,myV1)).Position() == 0 ) {
746 HERISO ->ChangeValue(iesp,4) += err4*hmax[myOrdInV+1];
747 }
748 myIsoErrors = HERISO;
749 }
750}
751
752//============================================================================
753//function : MakeApprox
754//purpose :
755//============================================================================
756
757void AdvApp2Var_Patch::MakeApprox(const AdvApp2Var_Context& Conditions,
758 const AdvApp2Var_Framework& Constraints,
759 const Standard_Integer NumDec)
760{
761
762// les donnees stockees dans le Context
763 Standard_Integer NDIMEN, NBSESP, NDIMSE;
764 Standard_Integer NBPNTU, NBPNTV, NCFLMU, NCFLMV, NDJACU, NDJACV;
765 Standard_Integer NDegU, NDegV, NJacU, NJacV;
766 NDIMEN = Conditions.TotalDimension();
767 NBSESP = Conditions.TotalNumberSSP();
768 NDIMSE = 3;
769 NBPNTU = (Conditions.URoots())->Length();
770 if (myOrdInU>-1) NBPNTU -= 2;
771 NBPNTV = (Conditions.VRoots())->Length();
772 if (myOrdInV>-1) NBPNTV -= 2;
773 NCFLMU = Conditions.ULimit();
774 NCFLMV = Conditions.VLimit();
775 NDegU = NCFLMU - 1;
776 NDegV = NCFLMV - 1;
777 NDJACU = Conditions.UJacDeg();
778 NDJACV = Conditions.VJacDeg();
779 NJacU = NDJACU + 1;
780 NJacV = NDJACV + 1;
781
782// les donnees relatives au patch a approcher
783 Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV,
784 NDMINU = 1, NDMINV = 1, NCOEFU, NCOEFV;
785// NDMINU et NDMINV dependent du nb de coeff des isos voisines
786// et de l'ordre de continuite souhaite
787 NDMINU = Max(1,2*IORDRU+1);
788 NCOEFU = (Constraints.IsoV(myU0,myU1,myV0)).NbCoeff()-1;
789 NDMINU = Max(NDMINU,NCOEFU);
790 NCOEFU = (Constraints.IsoV(myU0,myU1,myV1)).NbCoeff()-1;
791 NDMINU = Max(NDMINU,NCOEFU);
792
793 NDMINV = Max(1,2*IORDRV+1);
794 NCOEFV = (Constraints.IsoU(myU0,myV0,myV1)).NbCoeff()-1;
795 NDMINV = Max(NDMINV,NCOEFV);
796 NCOEFV = (Constraints.IsoU(myU1,myV0,myV1)).NbCoeff()-1;
797 NDMINV = Max(NDMINV,NCOEFV);
798
799// les tableaux des approximations
800 Handle (TColStd_HArray1OfReal) HEPSAPR =
801 new TColStd_HArray1OfReal(1,NBSESP);
802 Handle (TColStd_HArray1OfReal) HEPSFRO =
803 new TColStd_HArray1OfReal(1,NBSESP*8);
804 Standard_Integer iesp;
805 for (iesp=1;iesp<=NBSESP;iesp++) {
806 HEPSAPR->SetValue(iesp,(Conditions.IToler())->Value(iesp));
807 HEPSFRO->SetValue(iesp,(Conditions.FToler())->Value(iesp,1));
808 HEPSFRO->SetValue(iesp+NBSESP,(Conditions.FToler())->Value(iesp,2));
809 HEPSFRO->SetValue(iesp+2*NBSESP,(Conditions.FToler())->Value(iesp,3));
810 HEPSFRO->SetValue(iesp+3*NBSESP,(Conditions.FToler())->Value(iesp,4));
811 HEPSFRO->SetValue(iesp+4*NBSESP,(Conditions.CToler())->Value(iesp,1));
812 HEPSFRO->SetValue(iesp+5*NBSESP,(Conditions.CToler())->Value(iesp,2));
813 HEPSFRO->SetValue(iesp+6*NBSESP,(Conditions.CToler())->Value(iesp,3));
814 HEPSFRO->SetValue(iesp+7*NBSESP,(Conditions.CToler())->Value(iesp,4));
815 }
816 Standard_Real *EPSAPR =
817 (Standard_Real *) &HEPSAPR ->ChangeArray1()(HEPSAPR ->Lower());
818 Standard_Real *EPSFRO =
819 (Standard_Real *) &HEPSFRO ->ChangeArray1()(HEPSFRO ->Lower());
820
821 Standard_Integer SIZE=(1+NDJACU)*(1+NDJACV)*NDIMEN;
822 Handle (TColStd_HArray1OfReal) HPJAC =
823 new TColStd_HArray1OfReal(1,SIZE);
824 Standard_Real *PATJAC =
825 (Standard_Real *) &HPJAC ->ChangeArray1()(HPJAC ->Lower());
826 SIZE=2*SIZE;
827 Handle (TColStd_HArray1OfReal) HPAUX =
828 new TColStd_HArray1OfReal(1,SIZE);
829 Standard_Real *PATAUX =
830 (Standard_Real *) &HPAUX ->ChangeArray1()(HPAUX ->Lower());
831 SIZE=NCFLMU*NCFLMV*NDIMEN;
832 Handle (TColStd_HArray1OfReal) HPCAN =
833 new TColStd_HArray1OfReal(1,SIZE);
834 Standard_Real *PATCAN =
835 (Standard_Real *) &HPCAN ->ChangeArray1()(HPCAN ->Lower());
836 Handle (TColStd_HArray1OfReal) HERRMAX =
837 new TColStd_HArray1OfReal(1,NBSESP);
838 Standard_Real *ERRMAX =
839 (Standard_Real *) &HERRMAX ->ChangeArray1()(HERRMAX ->Lower());
840 Handle (TColStd_HArray1OfReal) HERRMOY =
841 new TColStd_HArray1OfReal(1,NBSESP);
842 Standard_Real *ERRMOY =
843 (Standard_Real *) &HERRMOY ->ChangeArray1()(HERRMOY ->Lower());
844
845// les tableaux de discretisation du carreau
846 Standard_Real *SOSOTB =
847 (Standard_Real *) &mySosoTab ->ChangeArray1()(mySosoTab ->Lower());
848 Standard_Real *DISOTB =
849 (Standard_Real *) &myDisoTab ->ChangeArray1()(myDisoTab ->Lower());
850 Standard_Real *SODITB =
851 (Standard_Real *) &mySodiTab ->ChangeArray1()(mySodiTab ->Lower());
852 Standard_Real *DIDITB =
853 (Standard_Real *) &myDidiTab ->ChangeArray1()(myDidiTab ->Lower());
854
855// approximation
856 Standard_Integer ITYDEC=0, IERCOD=0;
857 Standard_Integer iun=1,itrois=3;
858 NCOEFU=0;
859 NCOEFV=0;
860 AdvApp2Var_ApproxF2var::mma2ce1_((integer *)&NumDec,
861 &NDIMEN,
862 &NBSESP,
863 &NDIMSE,
864 &NDMINU,
865 &NDMINV,
866 &NDegU,
867 &NDegV,
868 &NDJACU,
869 &NDJACV,
870 &IORDRU,
871 &IORDRV,
872 &NBPNTU,
873 &NBPNTV,
874 EPSAPR,
875 SOSOTB,
876 DISOTB,
877 SODITB,
878 DIDITB,
879 PATJAC,
880 ERRMAX,
881 ERRMOY,
882 &NCOEFU,
883 &NCOEFV,
884 &ITYDEC,
885 &IERCOD);
886
887// les resultats
888 myCutSense = ITYDEC;
889 if (ITYDEC == 0 && IERCOD<=0) {
890 myHasResult = Standard_True;
891 myApprIsDone = (IERCOD==0);
892 myNbCoeffInU = NCOEFU+1;
893 myNbCoeffInV = NCOEFV+1;
894 myMaxErrors = HERRMAX;
895 myMoyErrors = HERRMOY;
896
897// Passage en canonique sur [-1,1]
898 AdvApp2Var_MathBase::mmfmca9_(&NJacU,&NJacV,&NDIMEN,&myNbCoeffInU,&myNbCoeffInV,
899 &NDIMEN,PATJAC,PATJAC);
900 AdvApp2Var_ApproxF2var::mma2can_(&NCFLMU,&NCFLMV,&NDIMEN,
901 &myOrdInU,&myOrdInV,&myNbCoeffInU,
902 &myNbCoeffInV,
903 PATJAC,PATAUX,PATCAN,&IERCOD);
904 if (IERCOD !=0) {
905 Standard_ConstructionError::Raise
906 ("AdvApp2Var_Patch::MakeApprox : Error in FORTRAN");
907 }
908 myEquation = HPCAN;
909
910// Ajout des contraintes et des erreurs
911 AddConstraints(Conditions,Constraints);
912 AddErrors(Constraints);
913
914// Reduction des degres si possible
915 PATCAN = (Standard_Real *)
916 &myEquation->ChangeArray1()(myEquation ->Lower());
917
918 AdvApp2Var_ApproxF2var::mma2fx6_(&NCFLMU,
919 &NCFLMV,
920 &NDIMEN,
921 &NBSESP,
922 &itrois,
923 &iun,
924 &iun,
925 &IORDRU,
926 &IORDRV,
927 EPSAPR,
928 EPSFRO,
929 PATCAN,
930 ERRMAX,
931 &myNbCoeffInU,
932 &myNbCoeffInV);
933
934// transposition (NCFLMU,NCFLMV,NDIMEN)Fortran-C++
935 Standard_Integer aIU, aIN, dim, ii, jj;
936 for (dim=1; dim<=NDIMEN; dim++){
937 aIN = (dim-1)*NCFLMU*NCFLMV;
938 for (ii=1; ii<=NCFLMU; ii++) {
939 aIU = (ii-1)*NDIMEN*NCFLMV;
940 for (jj=1; jj<=NCFLMV; jj++) {
941 HPAUX->SetValue(dim+NDIMEN*(jj-1)+aIU ,
942 myEquation->Value(ii+NCFLMU*(jj-1)+aIN) );
943 }
944 }
945 }
946 myEquation = HPAUX;
947 }
948 else {
949 myApprIsDone = Standard_False;
950 myHasResult = Standard_False;
951 }
952}
953
954//============================================================================
955//function : ChangeDomain
956//purpose :
957//============================================================================
958
959void AdvApp2Var_Patch::ChangeDomain(const Standard_Real a,
960 const Standard_Real b,
961 const Standard_Real c,
962 const Standard_Real d)
963{
964 myU0 = a;
965 myU1 = b;
966 myV0 = c;
967 myV1 = d;
968}
969
970//============================================================================
971//function : ResetApprox
972//purpose : permet d'effacer un resultat lorsqu'il faut decouper
973//============================================================================
974
975void AdvApp2Var_Patch::ResetApprox()
976{
977 myApprIsDone = Standard_False;
978 myHasResult = Standard_False;
979}
980
981//============================================================================
982//function : OverwriteApprox
983//purpose : permet de conserver un resultat
984// meme si la precision n'est pas satisfaite
985//============================================================================
986
987void AdvApp2Var_Patch::OverwriteApprox()
988{
989 if (myHasResult) myApprIsDone = Standard_True;
990}
991
992//============================================================================
993//function : U0
994//purpose :
995//============================================================================
996
997Standard_Real AdvApp2Var_Patch::U0() const
998{
999 return myU0;
1000}
1001
1002//============================================================================
1003//function : U1
1004//purpose :
1005//============================================================================
1006
1007Standard_Real AdvApp2Var_Patch::U1() const
1008{
1009 return myU1;
1010}
1011
1012//============================================================================
1013//function : V0
1014//purpose :
1015//============================================================================
1016
1017Standard_Real AdvApp2Var_Patch::V0() const
1018{
1019 return myV0;
1020}
1021
1022//============================================================================
1023//function : V1
1024//purpose :
1025//============================================================================
1026
1027Standard_Real AdvApp2Var_Patch::V1() const
1028{
1029 return myV1;
1030}
1031
1032//============================================================================
1033//function : UOrder
1034//purpose :
1035//============================================================================
1036
1037Standard_Integer AdvApp2Var_Patch::UOrder() const
1038{
1039 return myOrdInU;
1040}
1041
1042
1043//============================================================================
1044//function : VOrder
1045//purpose :
1046//============================================================================
1047
1048Standard_Integer AdvApp2Var_Patch::VOrder() const
1049{
1050 return myOrdInV;
1051}
1052
1053
1054//============================================================================
1055//function : CutSense sans Critere
1056//purpose : 0 : OK; 1 : decoupe necessaire en U;
1057// 2 : dec. nec. en V; 3 : dec. nec. en U et en V
1058//============================================================================
1059
1060Standard_Integer AdvApp2Var_Patch::CutSense() const
1061{
1062 return myCutSense;
1063}
1064
1065
1066//============================================================================
1067//function : CutSense avec critere
1068//purpose : 0 : OK; 1 : decoupe necessaire en U;
1069// 2 : dec. nec. en V; 3 : dec. nec. en U et en V
1070//============================================================================
1071
1072Standard_Integer AdvApp2Var_Patch::CutSense(const AdvApp2Var_Criterion& Crit,
1073 const Standard_Integer NumDec) const
1074{
1075 Standard_Boolean CritRel = (Crit.Type() == AdvApp2Var_Relative);
1076 if ( CritRel && !IsApproximated()) {
1077 return myCutSense;
1078 }
1079 else {
1080 if (Crit.IsSatisfied(*this)) {
1081 return 0;
1082 }
1083 else {
1084 return NumDec;
1085 }
1086 }
1087}
1088
1089
1090//============================================================================
1091//function : NbCoeffInU
1092//purpose :
1093//============================================================================
1094
1095Standard_Integer AdvApp2Var_Patch::NbCoeffInU() const
1096{
1097 return myNbCoeffInU;
1098}
1099
1100//============================================================================
1101//function : NbCoeffInV
1102//purpose :
1103//============================================================================
1104
1105Standard_Integer AdvApp2Var_Patch::NbCoeffInV() const
1106{
1107 return myNbCoeffInV;
1108}
1109
1110//============================================================================
1111//function : ChangeNbCoeff
1112//purpose : permet d'augmenter le nombre de coeff (cf Network)
1113//============================================================================
1114
1115void AdvApp2Var_Patch::ChangeNbCoeff(const Standard_Integer NbCoeffU,
1116 const Standard_Integer NbCoeffV)
1117{
1118 if (myNbCoeffInU<NbCoeffU) myNbCoeffInU = NbCoeffU;
1119 if (myNbCoeffInV<NbCoeffV) myNbCoeffInV = NbCoeffV;
1120}
1121
1122//============================================================================
1123//function : MaxErrors
1124//purpose : retourne les erreurs max de l'approximation polynomiale
1125//============================================================================
1126
1127Handle(TColStd_HArray1OfReal)
1128AdvApp2Var_Patch::MaxErrors() const
1129{
1130 return myMaxErrors;
1131}
1132
1133//============================================================================
1134//function : AverageErrors
1135//purpose : retourne les erreurs moyennes de l'approximation polynomiale
1136//============================================================================
1137
1138Handle(TColStd_HArray1OfReal)
1139AdvApp2Var_Patch::AverageErrors() const
1140{
1141 return myMoyErrors;
1142}
1143
1144//============================================================================
1145//function : IsoErrors
1146//purpose : retourne les erreurs max sur les frontieres de l'approx. polyn.
1147//============================================================================
1148
1149Handle(TColStd_HArray2OfReal)
1150AdvApp2Var_Patch::IsoErrors() const
1151{
1152 return myIsoErrors;
1153}
1154
1155//============================================================================
1156//function : Poles
1157//purpose : retourne les poles de l'approximation polynomiale
1158//============================================================================
1159
1160Handle(TColgp_HArray2OfPnt)
1161AdvApp2Var_Patch::Poles(const Standard_Integer SSPIndex,
1162 const AdvApp2Var_Context & Cond) const
1163{
1164 Handle(TColStd_HArray1OfReal) SousEquation;
1165 if ( Cond.TotalNumberSSP( ) == 1 && SSPIndex == 1 ) {
1166 SousEquation = myEquation;
1167 }
1168 else {
1169 Standard_ConstructionError::Raise
1170 ("AdvApp2Var_Patch::Poles : SSPIndex out of range");
1171 }
1172 Handle(TColStd_HArray1OfReal) Intervalle =
1173 new (TColStd_HArray1OfReal) (1,2);
1174 Intervalle->SetValue(1, -1);
1175 Intervalle->SetValue(2, 1);
1176
1177
1178 Handle(TColStd_HArray1OfInteger) NbCoeff =
1179 new (TColStd_HArray1OfInteger) (1,2);
1180 NbCoeff->SetValue(1, myNbCoeffInU);
1181 NbCoeff->SetValue(2, myNbCoeffInV);
1182
1183// Conversion
1184 Convert_GridPolynomialToPoles
1185 Conv (Cond.ULimit()-1,
1186 Cond.VLimit()-1,
1187 NbCoeff,
1188 SousEquation,
1189 Intervalle,
1190 Intervalle);
1191
1192 return Conv.Poles();
1193}
1194
1195
1196//============================================================================
1197//function : Coefficients
1198//purpose : retourne les coeff. de l'equation de l'approximation polynomiale
1199//============================================================================
1200
1201Handle(TColStd_HArray1OfReal)
1202AdvApp2Var_Patch::Coefficients(const Standard_Integer SSPIndex,
1203 const AdvApp2Var_Context & Cond) const
1204{
1205 Handle(TColStd_HArray1OfReal) SousEquation;
1206 if ( Cond.TotalNumberSSP( ) == 1 && SSPIndex == 1 ) {
1207 SousEquation = myEquation;
1208 }
1209 else {
1210 Standard_ConstructionError::Raise
1211 ("AdvApp2Var_Patch::Poles : SSPIndex out of range");
1212 }
1213 return SousEquation;
1214}
1215
1216
1217//============================================================================
1218//function : CritValue
1219//purpose :
1220//============================================================================
1221
1222Standard_Real AdvApp2Var_Patch::CritValue() const
1223{
1224 return myCritValue;
1225}
1226
1227
1228//============================================================================
1229//function : SetCritValue
1230//purpose :
1231//============================================================================
1232
1233void AdvApp2Var_Patch::SetCritValue(const Standard_Real dist)
1234{
1235 myCritValue = dist;
1236}
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247