0022312: Translation of french commentaries in OCCT files
[occt.git] / src / AdvApp2Var / AdvApp2Var_Context.cxx
1 // File:        AdvApp2Var_Context.cxx
2 // Created:     Tue Jul  2 10:31:42 1996
3 // Author:      Joelle CHAUVET
4 //              <jct@sgi38>
5
6
7 #include <AdvApp2Var_Context.ixx>
8 #include <Standard_ConstructionError.hxx>
9 #include <AdvApp2Var_ApproxF2var.hxx>
10
11 // Calculaton of parameters
12 static Standard_Boolean lesparam(const Standard_Integer iordre,
13                                  const Standard_Integer ncflim, 
14                                  const Standard_Integer icodeo, 
15                                  Standard_Integer& nbpnts, 
16                                  Standard_Integer& ndgjac)
17 {
18   // jacobi degree
19   ndgjac = ncflim; // it always keeps a reserve coefficient
20   if (icodeo< 0) return Standard_False;
21   if (icodeo > 0) {
22     ndgjac += (9 - (iordre+1)); //iordre rescales the frequences upwards
23     ndgjac += (icodeo-1)*10;
24   }
25   // ---> Min Number of required pointss.
26   if (ndgjac < 8) { nbpnts = 8;  } 
27   else if (ndgjac < 10) { nbpnts = 10; }
28   //  else if (ndgjac < 15) { nbpnt = 15; } Bug Uneven number
29   else if (ndgjac < 20) { nbpnts = 20;}
30   //  else if (ndgjac < 25) { nbpnt = 25; } Bug Uneven number
31   else if (ndgjac < 30) { nbpnts = 30;}
32   else if (ndgjac < 40) { nbpnts = 40;}
33   else if (ndgjac < 50) { nbpnts = 50;}
34   //  else if (*ndgjac < 61) { nbpnt = 61;} Bug Uneven number
35   else {
36     nbpnts = 50;
37 #if DEB
38     cout << "F(U, V) : Not enough points of discretization" << endl; 
39 #endif
40   }
41
42   // If constraints are on borders, this adds 2 points
43   if (iordre>-1) {  nbpnts += 2;}
44
45   return Standard_True;
46 }
47 //============================================================================
48 //function : AdvApp2Var_Context
49 //purpose  :
50 //============================================================================
51
52  AdvApp2Var_Context::
53 AdvApp2Var_Context()
54 {
55 }
56
57 //============================================================================
58 //function : AdvApp2Var_Context
59 //purpose  :
60 //============================================================================
61
62  AdvApp2Var_Context::
63 AdvApp2Var_Context(const Standard_Integer ifav,
64                    const Standard_Integer iu,
65                    const Standard_Integer iv, 
66                    const Standard_Integer nlimu,
67                    const Standard_Integer nlimv, 
68                    const Standard_Integer iprecis,
69                    const Standard_Integer nb1Dss,
70                    const Standard_Integer nb2Dss,
71                    const Standard_Integer nb3Dss,
72                    const Handle(TColStd_HArray1OfReal)& tol1D,
73                    const Handle(TColStd_HArray1OfReal)& tol2D,
74                    const Handle(TColStd_HArray1OfReal)& tol3D,
75                    const Handle(TColStd_HArray2OfReal)& tof1D,
76                    const Handle(TColStd_HArray2OfReal)& tof2D,
77                    const Handle(TColStd_HArray2OfReal)& tof3D) :
78 myFav(ifav),
79 myOrdU(iu),
80 myOrdV(iv),
81 myLimU(nlimu),
82 myLimV(nlimv),
83 myNb1DSS(nb1Dss),
84 myNb2DSS(nb2Dss),
85 myNb3DSS(nb3Dss)
86 {
87 Standard_Integer ErrorCode=0,NbPntU=0,JDegU=0,NbPntV=0,JDegV=0;
88 Standard_Integer ncfl;
89
90 // myNbURoot,myJDegU
91 ncfl = nlimu;
92 if (ncfl<2*iu+2) ncfl = 2*iu+2;
93 if (!lesparam(iu,ncfl,iprecis,NbPntU,JDegU) )
94   { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
95 myNbURoot = NbPntU;
96 myJDegU = JDegU;
97 if (iu>-1) NbPntU = myNbURoot - 2;
98
99 // myJMaxU
100 Standard_Integer i,j,size = JDegU-2*iu-1;
101 Handle (TColStd_HArray1OfReal) JMaxU =
102   new TColStd_HArray1OfReal(1,size);
103 Standard_Real *JU_array =
104   (Standard_Real *) &JMaxU->ChangeArray1()(JMaxU->Lower());
105 AdvApp2Var_ApproxF2var::mma2jmx_(&JDegU,(integer *)&iu,JU_array);
106 myJMaxU = JMaxU;
107
108 // myNbVRoot,myJDegV
109 ncfl = nlimv;
110 if (ncfl<2*iv+2) ncfl = 2*iv+2;
111 //Ma1nbp(&iv,&ncfl,&iprec,&NbPntV,&JDegV,&ErrorCode);
112 if (!lesparam(iv, ncfl, iprecis, NbPntV, JDegV) )
113   { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
114 myNbVRoot = NbPntV;
115 myJDegV = JDegV;
116 if (iv>-1) NbPntV = myNbVRoot - 2;
117
118 // myJMaxV
119 size = JDegV-2*iv-1;
120 Handle (TColStd_HArray1OfReal) JMaxV =
121   new TColStd_HArray1OfReal(1,size);
122 Standard_Real *JV_array =
123   (Standard_Real *) &JMaxV->ChangeArray1()(JMaxV->Lower());
124 AdvApp2Var_ApproxF2var::mma2jmx_(&JDegV,(integer *)&iv,JV_array);
125 myJMaxV = JMaxV;
126
127 // myURoots, myVRoots
128 Handle (TColStd_HArray1OfReal) URoots =
129   new TColStd_HArray1OfReal(1,myNbURoot);
130 Standard_Real *U_array =
131   (Standard_Real *) &URoots->ChangeArray1()(URoots->Lower());
132 Handle (TColStd_HArray1OfReal) VRoots =
133   new TColStd_HArray1OfReal(1,myNbVRoot);
134 Standard_Real *V_array =
135   (Standard_Real *) &VRoots->ChangeArray1()(VRoots->Lower());
136 AdvApp2Var_ApproxF2var::mma2roo_(&NbPntU,&NbPntV,U_array,V_array);
137 myURoots = URoots;
138 myVRoots = VRoots;
139
140 // myUGauss
141 size = (NbPntU/2+1)*(myJDegU-2*iu-1);
142 Handle (TColStd_HArray1OfReal) UGauss =
143   new TColStd_HArray1OfReal(1,size);
144 Standard_Real *UG_array =
145   (Standard_Real *) &UGauss->ChangeArray1()(UGauss->Lower());
146 AdvApp2Var_ApproxF2var::mmapptt_(&JDegU,&NbPntU,&iu,UG_array,&ErrorCode);
147 if (ErrorCode != 0 ) {
148   Standard_ConstructionError::Raise("AdvApp2Var_Context : Error in FORTRAN");
149 }
150 myUGauss = UGauss;
151
152 // myVGauss
153 size = (NbPntV/2+1)*(myJDegV-2*iv-1);
154 Handle (TColStd_HArray1OfReal) VGauss =
155   new TColStd_HArray1OfReal(1,size);
156 Standard_Real *VG_array =
157   (Standard_Real *) &VGauss->ChangeArray1()(VGauss->Lower());
158 AdvApp2Var_ApproxF2var::mmapptt_(&JDegV,&NbPntV,&iv,VG_array,&ErrorCode);
159 if (ErrorCode != 0 ) {
160   Standard_ConstructionError::Raise("AdvApp2Var_Context : Error in FORTRAN");
161 }
162 myVGauss = VGauss;
163
164 //myInternalTol, myFrontierTol, myCuttingTol
165 Standard_Integer nbss = nb1Dss + nb2Dss + nb3Dss;
166 Handle (TColStd_HArray1OfReal) ITol =
167   new TColStd_HArray1OfReal(1,nbss);
168 for (i=1;i<=nb1Dss;i++) {
169   ITol->SetValue(i,tol1D->Value(i));
170 }
171 for (i=1;i<=nb2Dss;i++) {
172   ITol->SetValue(i+nb1Dss,tol2D->Value(i));
173 }
174 for (i=1;i<=nb3Dss;i++) {
175   ITol->SetValue(i+nb1Dss+nb2Dss,tol3D->Value(i));
176 }
177 if (iu>-1||iv>-1) {
178   for (i=1;i<=nbss;i++) { ITol->SetValue(i,ITol->Value(i)/2); }
179 }
180 Handle (TColStd_HArray2OfReal) FTol =
181   new TColStd_HArray2OfReal(1,nbss,1,4);
182 Handle (TColStd_HArray2OfReal) CTol =
183   new TColStd_HArray2OfReal(1,nbss,1,4);
184 for (i=1;i<=nb1Dss;i++) {
185 for (j=1;j<=4;j++) {
186   FTol->SetValue(i,j,tof1D->Value(i,j));
187   CTol->SetValue(i,j,0);
188 }
189 }
190 for (i=1;i<=nb2Dss;i++) {
191 for (j=1;j<=4;j++) {
192   FTol->SetValue(nb1Dss+i,j,tof2D->Value(i,j));
193   CTol->SetValue(nb1Dss+i,j,0);
194 }
195 }
196 for (i=1;i<=nb3Dss;i++) {
197 for (j=1;j<=4;j++) {
198   FTol->SetValue(nb1Dss+nb2Dss+i,j,tof3D->Value(i,j));
199   CTol->SetValue(nb1Dss+nb2Dss+i,j,0);
200 }
201 }
202 if (iu>-1||iv>-1) {
203   Standard_Real tolmin, poids, hmax[4];
204   hmax[0] = 0;
205   hmax[1] = 1;
206   hmax[2] = 1.5;
207   hmax[3] = 1.75;
208   poids = hmax[iu+1]*hmax[iv+1] + hmax[iu+1] + hmax[iv+1];
209   for (i=1;i<=nbss;i++) {
210     for (j=1;j<=4;j++) {
211       tolmin = (ITol->Value(i))/poids;
212       if (tolmin<FTol->Value(i,j)) FTol->SetValue(i,j,tolmin);
213       CTol->SetValue(i,j,tolmin);
214     }
215   }
216 }
217 myInternalTol = ITol;
218 myFrontierTol = FTol;
219 myCuttingTol = CTol;
220 }
221
222 //============================================================================
223 //function : TotalDimension
224 //purpose  : 
225 //============================================================================
226
227 Standard_Integer AdvApp2Var_Context::TotalDimension() const 
228 {
229   return myNb1DSS + 2*myNb2DSS + 3*myNb3DSS; 
230 }
231
232 //============================================================================
233 //function : TotalNumberSSP
234 //purpose  :
235 //============================================================================
236
237 Standard_Integer AdvApp2Var_Context::TotalNumberSSP() const 
238 {
239   return myNb1DSS + myNb2DSS + myNb3DSS; 
240 }
241
242 //============================================================================
243 //function : FavorIso
244 //purpose  : return 1 for IsoU, 2 for IsoV, 2 by default
245 //============================================================================
246
247 Standard_Integer AdvApp2Var_Context::FavorIso() const 
248 {
249   return myFav; 
250 }
251
252 //============================================================================
253 //function : UOrder
254 //purpose  : return the order of continuity requested in U
255 //============================================================================
256
257 Standard_Integer AdvApp2Var_Context::UOrder() const 
258 {
259   return myOrdU; 
260 }
261
262 //============================================================================
263 //function : VOrder
264 //purpose  : return the order of continuity requested in V
265 //============================================================================
266
267 Standard_Integer AdvApp2Var_Context::VOrder() const 
268 {
269   return myOrdV; 
270 }
271
272 //============================================================================
273 //function : ULimit
274 //purpose  : return the max number of coeff. in U of the polynomial approx.
275 //============================================================================
276
277 Standard_Integer AdvApp2Var_Context::ULimit() const 
278 {
279   return myLimU; 
280 }
281
282 //============================================================================
283 //function : VLimit
284 //purpose  : return the max number of coeff. in V of the polynomial approx.
285 //============================================================================
286
287 Standard_Integer AdvApp2Var_Context::VLimit() const 
288 {
289   return myLimV;
290 }
291
292 //============================================================================
293 //function : UJacDeg
294 //purpose  : return the max degree of the Jacobi functions for U parameter
295 //============================================================================
296
297 Standard_Integer AdvApp2Var_Context::UJacDeg() const 
298 {
299   return myJDegU; 
300 }
301
302 //============================================================================
303 //function : VJacDeg
304 //purpose  : return the max degree of the Jacobi functions for V parameter
305 //============================================================================
306
307 Standard_Integer AdvApp2Var_Context::VJacDeg() const 
308 {
309   return myJDegV; 
310 }
311
312 //============================================================================
313 //function : UJacMax
314 //purpose  : return the max value of the Jacobi functions for U parameter
315 //============================================================================
316
317 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UJacMax() const 
318 {
319   return myJMaxU;
320 }
321
322 //============================================================================
323 //function : VJacMax
324 //purpose  : return the max value of the Jacobi functions for V parameter
325 //============================================================================
326
327 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VJacMax() const 
328 {
329   return myJMaxV;
330 }
331
332 //============================================================================
333 //function : URoots
334 //purpose  : return Legendre roots for U parameter
335 //============================================================================
336
337 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::URoots() const 
338 {
339   return myURoots;
340 }
341
342 //============================================================================
343 //function : VRoots
344 //purpose  : return Legendre roots for V parameter
345 //============================================================================
346
347 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VRoots() const 
348 {
349   return myVRoots;
350 }
351
352 //============================================================================
353 //function : UGauss
354 //purpose  : return Gauss roots for U parameter
355 //============================================================================
356
357 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UGauss() const 
358 {
359   return myUGauss;
360 }
361
362 //============================================================================
363 //function : VGauss
364 //purpose  : return Gauss roots for V parameter
365 //============================================================================
366
367 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VGauss() const 
368 {
369   return myVGauss;
370 }
371
372 //============================================================================
373 //function : IToler
374 //purpose  : return tolerances for the approximation of patches
375 //============================================================================
376
377 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::IToler() const 
378 {
379   return myInternalTol;
380 }
381
382 //============================================================================
383 //function : FToler
384 //purpose  : return tolerances for the approximation of frontiers
385 //============================================================================
386
387 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::FToler() const 
388 {
389   return myFrontierTol;
390 }
391
392 //============================================================================
393 //function : CToler
394 //purpose  : return tolerances for the approximation of cutting lines
395 //============================================================================
396
397 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::CToler() const 
398 {
399   return myCuttingTol;
400 }
401