summaryrefslogtreecommitdiff
path: root/src/AdvApp2Var/AdvApp2Var_Context.cxx
blob: 45047ec5618230b1fef3c61b8dcbe0b8aa1e24c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
// File:	AdvApp2Var_Context.cxx
// Created:	Tue Jul  2 10:31:42 1996
// Author:	Joelle CHAUVET
//		<jct@sgi38>
// Modified:	Mon Dec  9 11:39:13 1996
//   by:	Joelle CHAUVET
//		G1135 : empty constructor
//		G1134 : option 0 for precision code
//   by         PMN
//              PRO9093 on remplace MA1NPB par une gestion contextuelle
//              pour determiner le degree de Jacobbi.

#include <AdvApp2Var_Context.ixx>
#include <Standard_ConstructionError.hxx>
#include <AdvApp2Var_ApproxF2var.hxx>

// Calcul des parametres
static Standard_Boolean lesparam(const Standard_Integer iordre,
				 const Standard_Integer ncflim, 
				 const Standard_Integer icodeo, 
				 Standard_Integer& nbpnts, 
				 Standard_Integer& ndgjac)
{
  // degree de jacobi
  ndgjac = ncflim; // il toujours garder un coeff en reserve
  if (icodeo< 0) return Standard_False;
  if (icodeo > 0) {
    ndgjac += (9 - (iordre+1)); //iordre decale les frequences vers le haut
    ndgjac += (icodeo-1)*10;
  }
  // ---> Nbre mini de points necessaires.
  if (ndgjac < 8) { nbpnts = 8;  } 
  else if (ndgjac < 10) { nbpnts = 10; }
  //  else if (ndgjac < 15) { nbpnt = 15; } Bug Nombre impairs
  else if (ndgjac < 20) { nbpnts = 20;}
  //  else if (ndgjac < 25) { nbpnt = 25; } Bug Nombre impairs
  else if (ndgjac < 30) { nbpnts = 30;}
  else if (ndgjac < 40) { nbpnts = 40;}
  else if (ndgjac < 50) { nbpnts = 50;}
  //  else if (*ndgjac < 61) { nbpnt = 61;} Bug Nombre impairs
  else {
    nbpnts = 50;
#if DEB
    cout << "F(U, V) : Pas assez de point de discretisation" << endl; 
#endif
  }

  // Si contraintes aux bords, cela fait 2 points de plus
  if (iordre>-1) {  nbpnts += 2;}

  return Standard_True;
}
//============================================================================
//function : AdvApp2Var_Context
//purpose  :
//============================================================================

 AdvApp2Var_Context::
AdvApp2Var_Context()
{
}

//============================================================================
//function : AdvApp2Var_Context
//purpose  :
//============================================================================

 AdvApp2Var_Context::
AdvApp2Var_Context(const Standard_Integer ifav,
		   const Standard_Integer iu,
		   const Standard_Integer iv, 
		   const Standard_Integer nlimu,
		   const Standard_Integer nlimv, 
		   const Standard_Integer iprecis,
		   const Standard_Integer nb1Dss,
		   const Standard_Integer nb2Dss,
		   const Standard_Integer nb3Dss,
		   const Handle(TColStd_HArray1OfReal)& tol1D,
		   const Handle(TColStd_HArray1OfReal)& tol2D,
		   const Handle(TColStd_HArray1OfReal)& tol3D,
		   const Handle(TColStd_HArray2OfReal)& tof1D,
		   const Handle(TColStd_HArray2OfReal)& tof2D,
		   const Handle(TColStd_HArray2OfReal)& tof3D) :
myFav(ifav),
myOrdU(iu),
myOrdV(iv),
myLimU(nlimu),
myLimV(nlimv),
myNb1DSS(nb1Dss),
myNb2DSS(nb2Dss),
myNb3DSS(nb3Dss)
{
Standard_Integer ErrorCode=0,NbPntU=0,JDegU=0,NbPntV=0,JDegV=0;
Standard_Integer ncfl;

// myNbURoot,myJDegU
ncfl = nlimu;
if (ncfl<2*iu+2) ncfl = 2*iu+2;
if (!lesparam(iu,ncfl,iprecis,NbPntU,JDegU) )
  { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
myNbURoot = NbPntU;
myJDegU = JDegU;
if (iu>-1) NbPntU = myNbURoot - 2;

// myJMaxU
Standard_Integer i,j,size = JDegU-2*iu-1;
Handle (TColStd_HArray1OfReal) JMaxU =
  new TColStd_HArray1OfReal(1,size);
Standard_Real *JU_array =
  (Standard_Real *) &JMaxU->ChangeArray1()(JMaxU->Lower());
AdvApp2Var_ApproxF2var::mma2jmx_(&JDegU,(integer *)&iu,JU_array);
myJMaxU = JMaxU;

// myNbVRoot,myJDegV
ncfl = nlimv;
if (ncfl<2*iv+2) ncfl = 2*iv+2;
//Ma1nbp(&iv,&ncfl,&iprec,&NbPntV,&JDegV,&ErrorCode);
if (!lesparam(iv, ncfl, iprecis, NbPntV, JDegV) )
  { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
myNbVRoot = NbPntV;
myJDegV = JDegV;
if (iv>-1) NbPntV = myNbVRoot - 2;

// myJMaxV
size = JDegV-2*iv-1;
Handle (TColStd_HArray1OfReal) JMaxV =
  new TColStd_HArray1OfReal(1,size);
Standard_Real *JV_array =
  (Standard_Real *) &JMaxV->ChangeArray1()(JMaxV->Lower());
AdvApp2Var_ApproxF2var::mma2jmx_(&JDegV,(integer *)&iv,JV_array);
myJMaxV = JMaxV;

// myURoots, myVRoots
Handle (TColStd_HArray1OfReal) URoots =
  new TColStd_HArray1OfReal(1,myNbURoot);
Standard_Real *U_array =
  (Standard_Real *) &URoots->ChangeArray1()(URoots->Lower());
Handle (TColStd_HArray1OfReal) VRoots =
  new TColStd_HArray1OfReal(1,myNbVRoot);
Standard_Real *V_array =
  (Standard_Real *) &VRoots->ChangeArray1()(VRoots->Lower());
AdvApp2Var_ApproxF2var::mma2roo_(&NbPntU,&NbPntV,U_array,V_array);
myURoots = URoots;
myVRoots = VRoots;

// myUGauss
size = (NbPntU/2+1)*(myJDegU-2*iu-1);
Handle (TColStd_HArray1OfReal) UGauss =
  new TColStd_HArray1OfReal(1,size);
Standard_Real *UG_array =
  (Standard_Real *) &UGauss->ChangeArray1()(UGauss->Lower());
AdvApp2Var_ApproxF2var::mmapptt_(&JDegU,&NbPntU,&iu,UG_array,&ErrorCode);
if (ErrorCode != 0 ) {
  Standard_ConstructionError::Raise("AdvApp2Var_Context : Error in FORTRAN");
}
myUGauss = UGauss;

// myVGauss
size = (NbPntV/2+1)*(myJDegV-2*iv-1);
Handle (TColStd_HArray1OfReal) VGauss =
  new TColStd_HArray1OfReal(1,size);
Standard_Real *VG_array =
  (Standard_Real *) &VGauss->ChangeArray1()(VGauss->Lower());
AdvApp2Var_ApproxF2var::mmapptt_(&JDegV,&NbPntV,&iv,VG_array,&ErrorCode);
if (ErrorCode != 0 ) {
  Standard_ConstructionError::Raise("AdvApp2Var_Context : Error in FORTRAN");
}
myVGauss = VGauss;

//myInternalTol, myFrontierTol, myCuttingTol
Standard_Integer nbss = nb1Dss + nb2Dss + nb3Dss;
Handle (TColStd_HArray1OfReal) ITol =
  new TColStd_HArray1OfReal(1,nbss);
for (i=1;i<=nb1Dss;i++) {
  ITol->SetValue(i,tol1D->Value(i));
}
for (i=1;i<=nb2Dss;i++) {
  ITol->SetValue(i+nb1Dss,tol2D->Value(i));
}
for (i=1;i<=nb3Dss;i++) {
  ITol->SetValue(i+nb1Dss+nb2Dss,tol3D->Value(i));
}
if (iu>-1||iv>-1) {
  for (i=1;i<=nbss;i++) { ITol->SetValue(i,ITol->Value(i)/2); }
}
Handle (TColStd_HArray2OfReal) FTol =
  new TColStd_HArray2OfReal(1,nbss,1,4);
Handle (TColStd_HArray2OfReal) CTol =
  new TColStd_HArray2OfReal(1,nbss,1,4);
for (i=1;i<=nb1Dss;i++) {
for (j=1;j<=4;j++) {
  FTol->SetValue(i,j,tof1D->Value(i,j));
  CTol->SetValue(i,j,0);
}
}
for (i=1;i<=nb2Dss;i++) {
for (j=1;j<=4;j++) {
  FTol->SetValue(nb1Dss+i,j,tof2D->Value(i,j));
  CTol->SetValue(nb1Dss+i,j,0);
}
}
for (i=1;i<=nb3Dss;i++) {
for (j=1;j<=4;j++) {
  FTol->SetValue(nb1Dss+nb2Dss+i,j,tof3D->Value(i,j));
  CTol->SetValue(nb1Dss+nb2Dss+i,j,0);
}
}
if (iu>-1||iv>-1) {
  Standard_Real tolmin, poids, hmax[4];
  hmax[0] = 0;
  hmax[1] = 1;
  hmax[2] = 1.5;
  hmax[3] = 1.75;
  poids = hmax[iu+1]*hmax[iv+1] + hmax[iu+1] + hmax[iv+1];
  for (i=1;i<=nbss;i++) {
    for (j=1;j<=4;j++) {
      tolmin = (ITol->Value(i))/poids;
      if (tolmin<FTol->Value(i,j)) FTol->SetValue(i,j,tolmin);
      CTol->SetValue(i,j,tolmin);
    }
  }
}
myInternalTol = ITol;
myFrontierTol = FTol;
myCuttingTol = CTol;
}

//============================================================================
//function : TotalDimension
//purpose  : 
//============================================================================

Standard_Integer AdvApp2Var_Context::TotalDimension() const 
{
  return myNb1DSS + 2*myNb2DSS + 3*myNb3DSS; 
}

//============================================================================
//function : TotalNumberSSP
//purpose  :
//============================================================================

Standard_Integer AdvApp2Var_Context::TotalNumberSSP() const 
{
  return myNb1DSS + myNb2DSS + myNb3DSS; 
}

//============================================================================
//function : FavorIso
//purpose  : return 1 for IsoU, 2 for IsoV, 2 by default
//============================================================================

Standard_Integer AdvApp2Var_Context::FavorIso() const 
{
  return myFav; 
}

//============================================================================
//function : UOrder
//purpose  : return the order of continuity requested in U
//============================================================================

Standard_Integer AdvApp2Var_Context::UOrder() const 
{
  return myOrdU; 
}

//============================================================================
//function : VOrder
//purpose  : return the order of continuity requested in V
//============================================================================

Standard_Integer AdvApp2Var_Context::VOrder() const 
{
  return myOrdV; 
}

//============================================================================
//function : ULimit
//purpose  : return the max number of coeff. in U of the polynomial approx.
//============================================================================

Standard_Integer AdvApp2Var_Context::ULimit() const 
{
  return myLimU; 
}

//============================================================================
//function : VLimit
//purpose  : return the max number of coeff. in V of the polynomial approx.
//============================================================================

Standard_Integer AdvApp2Var_Context::VLimit() const 
{
  return myLimV;
}

//============================================================================
//function : UJacDeg
//purpose  : return the max degree of the Jacobi functions for U parameter
//============================================================================

Standard_Integer AdvApp2Var_Context::UJacDeg() const 
{
  return myJDegU; 
}

//============================================================================
//function : VJacDeg
//purpose  : return the max degree of the Jacobi functions for V parameter
//============================================================================

Standard_Integer AdvApp2Var_Context::VJacDeg() const 
{
  return myJDegV; 
}

//============================================================================
//function : UJacMax
//purpose  : return the max value of the Jacobi functions for U parameter
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UJacMax() const 
{
  return myJMaxU;
}

//============================================================================
//function : VJacMax
//purpose  : return the max value of the Jacobi functions for V parameter
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VJacMax() const 
{
  return myJMaxV;
}

//============================================================================
//function : URoots
//purpose  : return Legendre roots for U parameter
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::URoots() const 
{
  return myURoots;
}

//============================================================================
//function : VRoots
//purpose  : return Legendre roots for V parameter
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VRoots() const 
{
  return myVRoots;
}

//============================================================================
//function : UGauss
//purpose  : return Gauss roots for U parameter
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UGauss() const 
{
  return myUGauss;
}

//============================================================================
//function : VGauss
//purpose  : return Gauss roots for V parameter
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VGauss() const 
{
  return myVGauss;
}

//============================================================================
//function : IToler
//purpose  : return tolerances for the approximation of patches
//============================================================================

Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::IToler() const 
{
  return myInternalTol;
}

//============================================================================
//function : FToler
//purpose  : return tolerances for the approximation of frontiers
//============================================================================

Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::FToler() const 
{
  return myFrontierTol;
}

//============================================================================
//function : CToler
//purpose  : return tolerances for the approximation of cutting lines
//============================================================================

Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::CToler() const 
{
  return myCuttingTol;
}