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