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