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.
18 #include <AdvApp2Var_ApproxF2var.hxx>
19 #include <AdvApp2Var_Context.hxx>
20 #include <Standard_ConstructionError.hxx>
22 // Calculaton of parameters
23 static Standard_Boolean lesparam(const Standard_Integer iordre,
24 const Standard_Integer ncflim,
25 const Standard_Integer icodeo,
26 Standard_Integer& nbpnts,
27 Standard_Integer& ndgjac)
30 ndgjac = ncflim; // it always keeps a reserve coefficient
31 if (icodeo< 0) return Standard_False;
33 ndgjac += (9 - (iordre+1)); //iordre rescales the frequences upwards
34 ndgjac += (icodeo-1)*10;
36 // ---> Min Number of required pointss.
37 if (ndgjac < 8) { nbpnts = 8; }
38 else if (ndgjac < 10) { nbpnts = 10; }
39 // else if (ndgjac < 15) { nbpnt = 15; } Bug Uneven number
40 else if (ndgjac < 20) { nbpnts = 20;}
41 // else if (ndgjac < 25) { nbpnt = 25; } Bug Uneven number
42 else if (ndgjac < 30) { nbpnts = 30;}
43 else if (ndgjac < 40) { nbpnts = 40;}
44 else if (ndgjac < 50) { nbpnts = 50;}
45 // else if (*ndgjac < 61) { nbpnt = 61;} Bug Uneven number
49 std::cout << "F(U, V) : Not enough points of discretization" << std::endl;
53 // If constraints are on borders, this adds 2 points
54 if (iordre>-1) { nbpnts += 2;}
58 //============================================================================
59 //function : AdvApp2Var_Context
61 //============================================================================
80 //============================================================================
81 //function : AdvApp2Var_Context
83 //============================================================================
86 AdvApp2Var_Context(const Standard_Integer ifav,
87 const Standard_Integer iu,
88 const Standard_Integer iv,
89 const Standard_Integer nlimu,
90 const Standard_Integer nlimv,
91 const Standard_Integer iprecis,
92 const Standard_Integer nb1Dss,
93 const Standard_Integer nb2Dss,
94 const Standard_Integer nb3Dss,
95 const Handle(TColStd_HArray1OfReal)& tol1D,
96 const Handle(TColStd_HArray1OfReal)& tol2D,
97 const Handle(TColStd_HArray1OfReal)& tol3D,
98 const Handle(TColStd_HArray2OfReal)& tof1D,
99 const Handle(TColStd_HArray2OfReal)& tof2D,
100 const Handle(TColStd_HArray2OfReal)& tof3D) :
110 Standard_Integer ErrorCode=0,NbPntU=0,JDegU=0,NbPntV=0,JDegV=0;
111 Standard_Integer ncfl;
115 if (ncfl<2*iu+2) ncfl = 2*iu+2;
116 if (!lesparam(iu,ncfl,iprecis,NbPntU,JDegU) )
117 { throw Standard_ConstructionError("AdvApp2Var_Context");}
120 if (iu>-1) NbPntU = myNbURoot - 2;
123 Standard_Integer i,j,size = JDegU-2*iu-1;
124 Handle (TColStd_HArray1OfReal) JMaxU =
125 new TColStd_HArray1OfReal(1,size);
126 Standard_Real *JU_array =
127 (Standard_Real *) &JMaxU->ChangeArray1()(JMaxU->Lower());
128 AdvApp2Var_ApproxF2var::mma2jmx_(&JDegU,(integer *)&iu,JU_array);
133 if (ncfl<2*iv+2) ncfl = 2*iv+2;
134 //Ma1nbp(&iv,&ncfl,&iprec,&NbPntV,&JDegV,&ErrorCode);
135 if (!lesparam(iv, ncfl, iprecis, NbPntV, JDegV) )
136 { throw Standard_ConstructionError("AdvApp2Var_Context");}
139 if (iv>-1) NbPntV = myNbVRoot - 2;
143 Handle (TColStd_HArray1OfReal) JMaxV =
144 new TColStd_HArray1OfReal(1,size);
145 Standard_Real *JV_array =
146 (Standard_Real *) &JMaxV->ChangeArray1()(JMaxV->Lower());
147 AdvApp2Var_ApproxF2var::mma2jmx_(&JDegV,(integer *)&iv,JV_array);
150 // myURoots, myVRoots
151 Handle (TColStd_HArray1OfReal) URoots =
152 new TColStd_HArray1OfReal(1,myNbURoot);
153 Standard_Real *U_array =
154 (Standard_Real *) &URoots->ChangeArray1()(URoots->Lower());
155 Handle (TColStd_HArray1OfReal) VRoots =
156 new TColStd_HArray1OfReal(1,myNbVRoot);
157 Standard_Real *V_array =
158 (Standard_Real *) &VRoots->ChangeArray1()(VRoots->Lower());
159 AdvApp2Var_ApproxF2var::mma2roo_(&NbPntU,&NbPntV,U_array,V_array);
164 size = (NbPntU/2+1)*(myJDegU-2*iu-1);
165 Handle (TColStd_HArray1OfReal) UGauss =
166 new TColStd_HArray1OfReal(1,size);
167 Standard_Real *UG_array =
168 (Standard_Real *) &UGauss->ChangeArray1()(UGauss->Lower());
169 AdvApp2Var_ApproxF2var::mmapptt_(&JDegU,&NbPntU,&iu,UG_array,&ErrorCode);
170 if (ErrorCode != 0 ) {
171 throw Standard_ConstructionError("AdvApp2Var_Context : Error in FORTRAN");
176 size = (NbPntV/2+1)*(myJDegV-2*iv-1);
177 Handle (TColStd_HArray1OfReal) VGauss =
178 new TColStd_HArray1OfReal(1,size);
179 Standard_Real *VG_array =
180 (Standard_Real *) &VGauss->ChangeArray1()(VGauss->Lower());
181 AdvApp2Var_ApproxF2var::mmapptt_(&JDegV,&NbPntV,&iv,VG_array,&ErrorCode);
182 if (ErrorCode != 0 ) {
183 throw Standard_ConstructionError("AdvApp2Var_Context : Error in FORTRAN");
187 //myInternalTol, myFrontierTol, myCuttingTol
188 Standard_Integer nbss = nb1Dss + nb2Dss + nb3Dss;
189 Handle (TColStd_HArray1OfReal) ITol =
190 new TColStd_HArray1OfReal(1,nbss);
191 for (i=1;i<=nb1Dss;i++) {
192 ITol->SetValue(i,tol1D->Value(i));
194 for (i=1;i<=nb2Dss;i++) {
195 ITol->SetValue(i+nb1Dss,tol2D->Value(i));
197 for (i=1;i<=nb3Dss;i++) {
198 ITol->SetValue(i+nb1Dss+nb2Dss,tol3D->Value(i));
201 for (i=1;i<=nbss;i++) { ITol->SetValue(i,ITol->Value(i)/2); }
203 Handle (TColStd_HArray2OfReal) FTol =
204 new TColStd_HArray2OfReal(1,nbss,1,4);
205 Handle (TColStd_HArray2OfReal) CTol =
206 new TColStd_HArray2OfReal(1,nbss,1,4);
207 for (i=1;i<=nb1Dss;i++) {
209 FTol->SetValue(i,j,tof1D->Value(i,j));
210 CTol->SetValue(i,j,0);
213 for (i=1;i<=nb2Dss;i++) {
215 FTol->SetValue(nb1Dss+i,j,tof2D->Value(i,j));
216 CTol->SetValue(nb1Dss+i,j,0);
219 for (i=1;i<=nb3Dss;i++) {
221 FTol->SetValue(nb1Dss+nb2Dss+i,j,tof3D->Value(i,j));
222 CTol->SetValue(nb1Dss+nb2Dss+i,j,0);
226 Standard_Real tolmin, poids, hmax[4];
231 poids = hmax[iu+1]*hmax[iv+1] + hmax[iu+1] + hmax[iv+1];
232 for (i=1;i<=nbss;i++) {
234 tolmin = (ITol->Value(i))/poids;
235 if (tolmin<FTol->Value(i,j)) FTol->SetValue(i,j,tolmin);
236 CTol->SetValue(i,j,tolmin);
240 myInternalTol = ITol;
241 myFrontierTol = FTol;
245 //============================================================================
246 //function : TotalDimension
248 //============================================================================
250 Standard_Integer AdvApp2Var_Context::TotalDimension() const
252 return myNb1DSS + 2*myNb2DSS + 3*myNb3DSS;
255 //============================================================================
256 //function : TotalNumberSSP
258 //============================================================================
260 Standard_Integer AdvApp2Var_Context::TotalNumberSSP() const
262 return myNb1DSS + myNb2DSS + myNb3DSS;
265 //============================================================================
266 //function : FavorIso
267 //purpose : return 1 for IsoU, 2 for IsoV, 2 by default
268 //============================================================================
270 Standard_Integer AdvApp2Var_Context::FavorIso() const
275 //============================================================================
277 //purpose : return the order of continuity requested in U
278 //============================================================================
280 Standard_Integer AdvApp2Var_Context::UOrder() const
285 //============================================================================
287 //purpose : return the order of continuity requested in V
288 //============================================================================
290 Standard_Integer AdvApp2Var_Context::VOrder() const
295 //============================================================================
297 //purpose : return the max number of coeff. in U of the polynomial approx.
298 //============================================================================
300 Standard_Integer AdvApp2Var_Context::ULimit() const
305 //============================================================================
307 //purpose : return the max number of coeff. in V of the polynomial approx.
308 //============================================================================
310 Standard_Integer AdvApp2Var_Context::VLimit() const
315 //============================================================================
317 //purpose : return the max degree of the Jacobi functions for U parameter
318 //============================================================================
320 Standard_Integer AdvApp2Var_Context::UJacDeg() const
325 //============================================================================
327 //purpose : return the max degree of the Jacobi functions for V parameter
328 //============================================================================
330 Standard_Integer AdvApp2Var_Context::VJacDeg() const
335 //============================================================================
337 //purpose : return the max value of the Jacobi functions for U parameter
338 //============================================================================
340 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UJacMax() const
345 //============================================================================
347 //purpose : return the max value of the Jacobi functions for V parameter
348 //============================================================================
350 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VJacMax() const
355 //============================================================================
357 //purpose : return Legendre roots for U parameter
358 //============================================================================
360 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::URoots() const
365 //============================================================================
367 //purpose : return Legendre roots for V parameter
368 //============================================================================
370 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VRoots() const
375 //============================================================================
377 //purpose : return Gauss roots for U parameter
378 //============================================================================
380 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::UGauss() const
385 //============================================================================
387 //purpose : return Gauss roots for V parameter
388 //============================================================================
390 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::VGauss() const
395 //============================================================================
397 //purpose : return tolerances for the approximation of patches
398 //============================================================================
400 Handle(TColStd_HArray1OfReal) AdvApp2Var_Context::IToler() const
402 return myInternalTol;
405 //============================================================================
407 //purpose : return tolerances for the approximation of frontiers
408 //============================================================================
410 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::FToler() const
412 return myFrontierTol;
415 //============================================================================
417 //purpose : return tolerances for the approximation of cutting lines
418 //============================================================================
420 Handle(TColStd_HArray2OfReal) AdvApp2Var_Context::CToler() const