1 // Created on: 1996-07-02
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <AdvApp2Var_Context.ixx>
18 #include <Standard_ConstructionError.hxx>
19 #include <AdvApp2Var_ApproxF2var.hxx>
21 // Calculaton of parameters
22 static 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)
29 ndgjac = ncflim; // it always keeps a reserve coefficient
30 if (icodeo< 0) return Standard_False;
32 ndgjac += (9 - (iordre+1)); //iordre rescales the frequences upwards
33 ndgjac += (icodeo-1)*10;
35 // ---> Min Number of required pointss.
36 if (ndgjac < 8) { nbpnts = 8; }
37 else if (ndgjac < 10) { nbpnts = 10; }
38 // else if (ndgjac < 15) { nbpnt = 15; } Bug Uneven number
39 else if (ndgjac < 20) { nbpnts = 20;}
40 // else if (ndgjac < 25) { nbpnt = 25; } Bug Uneven number
41 else if (ndgjac < 30) { nbpnts = 30;}
42 else if (ndgjac < 40) { nbpnts = 40;}
43 else if (ndgjac < 50) { nbpnts = 50;}
44 // else if (*ndgjac < 61) { nbpnt = 61;} Bug Uneven number
48 cout << "F(U, V) : Not enough points of discretization" << endl;
52 // If constraints are on borders, this adds 2 points
53 if (iordre>-1) { nbpnts += 2;}
57 //============================================================================
58 //function : AdvApp2Var_Context
60 //============================================================================
67 //============================================================================
68 //function : AdvApp2Var_Context
70 //============================================================================
73 AdvApp2Var_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) :
97 Standard_Integer ErrorCode=0,NbPntU=0,JDegU=0,NbPntV=0,JDegV=0;
98 Standard_Integer ncfl;
102 if (ncfl<2*iu+2) ncfl = 2*iu+2;
103 if (!lesparam(iu,ncfl,iprecis,NbPntU,JDegU) )
104 { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
107 if (iu>-1) NbPntU = myNbURoot - 2;
110 Standard_Integer i,j,size = JDegU-2*iu-1;
111 Handle (TColStd_HArray1OfReal) JMaxU =
112 new TColStd_HArray1OfReal(1,size);
113 Standard_Real *JU_array =
114 (Standard_Real *) &JMaxU->ChangeArray1()(JMaxU->Lower());
115 AdvApp2Var_ApproxF2var::mma2jmx_(&JDegU,(integer *)&iu,JU_array);
120 if (ncfl<2*iv+2) ncfl = 2*iv+2;
121 //Ma1nbp(&iv,&ncfl,&iprec,&NbPntV,&JDegV,&ErrorCode);
122 if (!lesparam(iv, ncfl, iprecis, NbPntV, JDegV) )
123 { Standard_ConstructionError::Raise("AdvApp2Var_Context");}
126 if (iv>-1) NbPntV = myNbVRoot - 2;
130 Handle (TColStd_HArray1OfReal) JMaxV =
131 new TColStd_HArray1OfReal(1,size);
132 Standard_Real *JV_array =
133 (Standard_Real *) &JMaxV->ChangeArray1()(JMaxV->Lower());
134 AdvApp2Var_ApproxF2var::mma2jmx_(&JDegV,(integer *)&iv,JV_array);
137 // myURoots, myVRoots
138 Handle (TColStd_HArray1OfReal) URoots =
139 new TColStd_HArray1OfReal(1,myNbURoot);
140 Standard_Real *U_array =
141 (Standard_Real *) &URoots->ChangeArray1()(URoots->Lower());
142 Handle (TColStd_HArray1OfReal) VRoots =
143 new TColStd_HArray1OfReal(1,myNbVRoot);
144 Standard_Real *V_array =
145 (Standard_Real *) &VRoots->ChangeArray1()(VRoots->Lower());
146 AdvApp2Var_ApproxF2var::mma2roo_(&NbPntU,&NbPntV,U_array,V_array);
151 size = (NbPntU/2+1)*(myJDegU-2*iu-1);
152 Handle (TColStd_HArray1OfReal) UGauss =
153 new TColStd_HArray1OfReal(1,size);
154 Standard_Real *UG_array =
155 (Standard_Real *) &UGauss->ChangeArray1()(UGauss->Lower());
156 AdvApp2Var_ApproxF2var::mmapptt_(&JDegU,&NbPntU,&iu,UG_array,&ErrorCode);
157 if (ErrorCode != 0 ) {
158 Standard_ConstructionError::Raise("AdvApp2Var_Context : Error in FORTRAN");
163 size = (NbPntV/2+1)*(myJDegV-2*iv-1);
164 Handle (TColStd_HArray1OfReal) VGauss =
165 new TColStd_HArray1OfReal(1,size);
166 Standard_Real *VG_array =
167 (Standard_Real *) &VGauss->ChangeArray1()(VGauss->Lower());
168 AdvApp2Var_ApproxF2var::mmapptt_(&JDegV,&NbPntV,&iv,VG_array,&ErrorCode);
169 if (ErrorCode != 0 ) {
170 Standard_ConstructionError::Raise("AdvApp2Var_Context : Error in FORTRAN");
174 //myInternalTol, myFrontierTol, myCuttingTol
175 Standard_Integer nbss = nb1Dss + nb2Dss + nb3Dss;
176 Handle (TColStd_HArray1OfReal) ITol =
177 new TColStd_HArray1OfReal(1,nbss);
178 for (i=1;i<=nb1Dss;i++) {
179 ITol->SetValue(i,tol1D->Value(i));
181 for (i=1;i<=nb2Dss;i++) {
182 ITol->SetValue(i+nb1Dss,tol2D->Value(i));
184 for (i=1;i<=nb3Dss;i++) {
185 ITol->SetValue(i+nb1Dss+nb2Dss,tol3D->Value(i));
188 for (i=1;i<=nbss;i++) { ITol->SetValue(i,ITol->Value(i)/2); }
190 Handle (TColStd_HArray2OfReal) FTol =
191 new TColStd_HArray2OfReal(1,nbss,1,4);
192 Handle (TColStd_HArray2OfReal) CTol =
193 new TColStd_HArray2OfReal(1,nbss,1,4);
194 for (i=1;i<=nb1Dss;i++) {
196 FTol->SetValue(i,j,tof1D->Value(i,j));
197 CTol->SetValue(i,j,0);
200 for (i=1;i<=nb2Dss;i++) {
202 FTol->SetValue(nb1Dss+i,j,tof2D->Value(i,j));
203 CTol->SetValue(nb1Dss+i,j,0);
206 for (i=1;i<=nb3Dss;i++) {
208 FTol->SetValue(nb1Dss+nb2Dss+i,j,tof3D->Value(i,j));
209 CTol->SetValue(nb1Dss+nb2Dss+i,j,0);
213 Standard_Real tolmin, poids, hmax[4];
218 poids = hmax[iu+1]*hmax[iv+1] + hmax[iu+1] + hmax[iv+1];
219 for (i=1;i<=nbss;i++) {
221 tolmin = (ITol->Value(i))/poids;
222 if (tolmin<FTol->Value(i,j)) FTol->SetValue(i,j,tolmin);
223 CTol->SetValue(i,j,tolmin);
227 myInternalTol = ITol;
228 myFrontierTol = FTol;
232 //============================================================================
233 //function : TotalDimension
235 //============================================================================
237 Standard_Integer AdvApp2Var_Context::TotalDimension() const
239 return myNb1DSS + 2*myNb2DSS + 3*myNb3DSS;
242 //============================================================================
243 //function : TotalNumberSSP
245 //============================================================================
247 Standard_Integer AdvApp2Var_Context::TotalNumberSSP() const
249 return myNb1DSS + myNb2DSS + myNb3DSS;
252 //============================================================================
253 //function : FavorIso
254 //purpose : return 1 for IsoU, 2 for IsoV, 2 by default
255 //============================================================================
257 Standard_Integer AdvApp2Var_Context::FavorIso() const
262 //============================================================================
264 //purpose : return the order of continuity requested in U
265 //============================================================================
267 Standard_Integer AdvApp2Var_Context::UOrder() const
272 //============================================================================
274 //purpose : return the order of continuity requested in V
275 //============================================================================
277 Standard_Integer AdvApp2Var_Context::VOrder() const
282 //============================================================================
284 //purpose : return the max number of coeff. in U of the polynomial approx.
285 //============================================================================
287 Standard_Integer AdvApp2Var_Context::ULimit() const
292 //============================================================================
294 //purpose : return the max number of coeff. in V of the polynomial approx.
295 //============================================================================
297 Standard_Integer AdvApp2Var_Context::VLimit() const
302 //============================================================================
304 //purpose : return the max degree of the Jacobi functions for U parameter
305 //============================================================================
307 Standard_Integer AdvApp2Var_Context::UJacDeg() const
312 //============================================================================
314 //purpose : return the max degree of the Jacobi functions for V parameter
315 //============================================================================
317 Standard_Integer AdvApp2Var_Context::VJacDeg() const
322 //============================================================================
324 //purpose : return the max value of the Jacobi functions for U parameter
325 //============================================================================
327 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UJacMax() const
332 //============================================================================
334 //purpose : return the max value of the Jacobi functions for V parameter
335 //============================================================================
337 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VJacMax() const
342 //============================================================================
344 //purpose : return Legendre roots for U parameter
345 //============================================================================
347 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::URoots() const
352 //============================================================================
354 //purpose : return Legendre roots for V parameter
355 //============================================================================
357 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VRoots() const
362 //============================================================================
364 //purpose : return Gauss roots for U parameter
365 //============================================================================
367 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UGauss() const
372 //============================================================================
374 //purpose : return Gauss roots for V parameter
375 //============================================================================
377 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VGauss() const
382 //============================================================================
384 //purpose : return tolerances for the approximation of patches
385 //============================================================================
387 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::IToler() const
389 return myInternalTol;
392 //============================================================================
394 //purpose : return tolerances for the approximation of frontiers
395 //============================================================================
397 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::FToler() const
399 return myFrontierTol;
402 //============================================================================
404 //purpose : return tolerances for the approximation of cutting lines
405 //============================================================================
407 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::CToler() const