1 // File: AdvApp2Var_Context.cxx
2 // Created: Tue Jul 2 10:31:42 1996
3 // Author: Joelle CHAUVET
7 #include <AdvApp2Var_Context.ixx>
8 #include <Standard_ConstructionError.hxx>
9 #include <AdvApp2Var_ApproxF2var.hxx>
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)
19 ndgjac = ncflim; // it always keeps a reserve coefficient
20 if (icodeo< 0) return Standard_False;
22 ndgjac += (9 - (iordre+1)); //iordre rescales the frequences upwards
23 ndgjac += (icodeo-1)*10;
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
38 cout << "F(U, V) : Not enough points of discretization" << endl;
42 // If constraints are on borders, this adds 2 points
43 if (iordre>-1) { nbpnts += 2;}
47 //============================================================================
48 //function : AdvApp2Var_Context
50 //============================================================================
57 //============================================================================
58 //function : AdvApp2Var_Context
60 //============================================================================
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) :
87 Standard_Integer ErrorCode=0,NbPntU=0,JDegU=0,NbPntV=0,JDegV=0;
88 Standard_Integer ncfl;
92 if (ncfl<2*iu+2) ncfl = 2*iu+2;
93 if (!lesparam(iu,ncfl,iprecis,NbPntU,JDegU) )
94 { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
97 if (iu>-1) NbPntU = myNbURoot - 2;
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);
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");}
116 if (iv>-1) NbPntV = myNbVRoot - 2;
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);
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);
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");
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");
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));
171 for (i=1;i<=nb2Dss;i++) {
172 ITol->SetValue(i+nb1Dss,tol2D->Value(i));
174 for (i=1;i<=nb3Dss;i++) {
175 ITol->SetValue(i+nb1Dss+nb2Dss,tol3D->Value(i));
178 for (i=1;i<=nbss;i++) { ITol->SetValue(i,ITol->Value(i)/2); }
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++) {
186 FTol->SetValue(i,j,tof1D->Value(i,j));
187 CTol->SetValue(i,j,0);
190 for (i=1;i<=nb2Dss;i++) {
192 FTol->SetValue(nb1Dss+i,j,tof2D->Value(i,j));
193 CTol->SetValue(nb1Dss+i,j,0);
196 for (i=1;i<=nb3Dss;i++) {
198 FTol->SetValue(nb1Dss+nb2Dss+i,j,tof3D->Value(i,j));
199 CTol->SetValue(nb1Dss+nb2Dss+i,j,0);
203 Standard_Real tolmin, poids, hmax[4];
208 poids = hmax[iu+1]*hmax[iv+1] + hmax[iu+1] + hmax[iv+1];
209 for (i=1;i<=nbss;i++) {
211 tolmin = (ITol->Value(i))/poids;
212 if (tolmin<FTol->Value(i,j)) FTol->SetValue(i,j,tolmin);
213 CTol->SetValue(i,j,tolmin);
217 myInternalTol = ITol;
218 myFrontierTol = FTol;
222 //============================================================================
223 //function : TotalDimension
225 //============================================================================
227 Standard_Integer AdvApp2Var_Context::TotalDimension() const
229 return myNb1DSS + 2*myNb2DSS + 3*myNb3DSS;
232 //============================================================================
233 //function : TotalNumberSSP
235 //============================================================================
237 Standard_Integer AdvApp2Var_Context::TotalNumberSSP() const
239 return myNb1DSS + myNb2DSS + myNb3DSS;
242 //============================================================================
243 //function : FavorIso
244 //purpose : return 1 for IsoU, 2 for IsoV, 2 by default
245 //============================================================================
247 Standard_Integer AdvApp2Var_Context::FavorIso() const
252 //============================================================================
254 //purpose : return the order of continuity requested in U
255 //============================================================================
257 Standard_Integer AdvApp2Var_Context::UOrder() const
262 //============================================================================
264 //purpose : return the order of continuity requested in V
265 //============================================================================
267 Standard_Integer AdvApp2Var_Context::VOrder() const
272 //============================================================================
274 //purpose : return the max number of coeff. in U of the polynomial approx.
275 //============================================================================
277 Standard_Integer AdvApp2Var_Context::ULimit() const
282 //============================================================================
284 //purpose : return the max number of coeff. in V of the polynomial approx.
285 //============================================================================
287 Standard_Integer AdvApp2Var_Context::VLimit() const
292 //============================================================================
294 //purpose : return the max degree of the Jacobi functions for U parameter
295 //============================================================================
297 Standard_Integer AdvApp2Var_Context::UJacDeg() const
302 //============================================================================
304 //purpose : return the max degree of the Jacobi functions for V parameter
305 //============================================================================
307 Standard_Integer AdvApp2Var_Context::VJacDeg() const
312 //============================================================================
314 //purpose : return the max value of the Jacobi functions for U parameter
315 //============================================================================
317 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UJacMax() const
322 //============================================================================
324 //purpose : return the max value of the Jacobi functions for V parameter
325 //============================================================================
327 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VJacMax() const
332 //============================================================================
334 //purpose : return Legendre roots for U parameter
335 //============================================================================
337 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::URoots() const
342 //============================================================================
344 //purpose : return Legendre roots for V parameter
345 //============================================================================
347 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VRoots() const
352 //============================================================================
354 //purpose : return Gauss roots for U parameter
355 //============================================================================
357 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UGauss() const
362 //============================================================================
364 //purpose : return Gauss roots for V parameter
365 //============================================================================
367 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VGauss() const
372 //============================================================================
374 //purpose : return tolerances for the approximation of patches
375 //============================================================================
377 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::IToler() const
379 return myInternalTol;
382 //============================================================================
384 //purpose : return tolerances for the approximation of frontiers
385 //============================================================================
387 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::FToler() const
389 return myFrontierTol;
392 //============================================================================
394 //purpose : return tolerances for the approximation of cutting lines
395 //============================================================================
397 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::CToler() const