Commit | Line | Data |
---|---|---|
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. | |
b311480e | 16 | |
7fd59977 | 17 | // Modified: Wed Jan 15 10:04:41 1997 |
18 | // by: Joelle CHAUVET | |
19 | // G1135 : Methods CutSense with criterion, Coefficients, | |
20 | // CritValue, SetCritValue | |
21 | // Modified: Tue May 19 10:22:44 1998 | |
22 | // by: Joelle CHAUVET / Jean-Marc LACHAUME | |
23 | // Initialisation de myCritValue pour OSF | |
24 | ||
42cf5bc1 | 25 | #include <AdvApp2Var_ApproxF2var.hxx> |
26 | #include <AdvApp2Var_Context.hxx> | |
27 | #include <AdvApp2Var_Criterion.hxx> | |
28 | #include <AdvApp2Var_Framework.hxx> | |
7fd59977 | 29 | #include <AdvApp2Var_Iso.hxx> |
42cf5bc1 | 30 | #include <AdvApp2Var_MathBase.hxx> |
31 | #include <AdvApp2Var_Node.hxx> | |
32 | #include <AdvApp2Var_Patch.hxx> | |
33 | #include <Convert_GridPolynomialToPoles.hxx> | |
7fd59977 | 34 | #include <gp_Pnt.hxx> |
42cf5bc1 | 35 | #include <Standard_ConstructionError.hxx> |
7fd59977 | 36 | #include <TColgp_Array2OfPnt.hxx> |
42cf5bc1 | 37 | #include <TColgp_HArray2OfPnt.hxx> |
38 | #include <TColStd_Array2OfReal.hxx> | |
7fd59977 | 39 | #include <TColStd_HArray1OfInteger.hxx> |
40 | #include <TColStd_HArray1OfReal.hxx> | |
41 | #include <TColStd_HArray2OfReal.hxx> | |
7fd59977 | 42 | |
43 | //============================================================================ | |
44 | //function : AdvApp2Var_Patch | |
45 | //purpose : | |
46 | //============================================================================ | |
7fd59977 | 47 | AdvApp2Var_Patch::AdvApp2Var_Patch() : |
48 | myU0(0.), | |
49 | myU1(1.), | |
50 | myV0(0.), | |
51 | myV1(1.), | |
52 | myOrdInU(0), | |
53 | myOrdInV(0), | |
7c97b4a3 KS |
54 | myNbCoeffInU(0), |
55 | myNbCoeffInV(0), | |
7fd59977 | 56 | myApprIsDone(Standard_False), |
57 | myHasResult(Standard_False), | |
58 | myCutSense(0), | |
59 | myDiscIsDone(Standard_False), | |
60 | myCritValue(0.) | |
61 | { | |
62 | } | |
63 | ||
64 | //============================================================================ | |
65 | //function : AdvApp2Var_Patch | |
66 | //purpose : | |
67 | //============================================================================ | |
68 | ||
69 | AdvApp2Var_Patch::AdvApp2Var_Patch(const Standard_Real U0, | |
70 | const Standard_Real U1, | |
71 | const Standard_Real V0, | |
72 | const Standard_Real V1, | |
73 | const Standard_Integer iu, | |
74 | const Standard_Integer iv) : | |
75 | myU0(U0), | |
76 | myU1(U1), | |
77 | myV0(V0), | |
78 | myV1(V1), | |
79 | myOrdInU(iu), | |
80 | myOrdInV(iv), | |
7c97b4a3 KS |
81 | myNbCoeffInU(0), |
82 | myNbCoeffInV(0), | |
7fd59977 | 83 | myApprIsDone(Standard_False), |
84 | myHasResult(Standard_False), | |
85 | myCutSense(0), | |
86 | myDiscIsDone(Standard_False), | |
87 | myCritValue(0.) | |
88 | { | |
89 | } | |
90 | ||
91 | //============================================================================ | |
92 | //function : IsDiscretised | |
93 | //purpose : | |
94 | //============================================================================ | |
95 | ||
96 | Standard_Boolean AdvApp2Var_Patch::IsDiscretised() const | |
97 | { | |
98 | return myDiscIsDone; | |
99 | } | |
100 | ||
101 | //============================================================================ | |
102 | //function : Discretise | |
103 | //purpose : | |
104 | //============================================================================ | |
105 | ||
106 | void AdvApp2Var_Patch::Discretise(const AdvApp2Var_Context& Conditions, | |
107 | const AdvApp2Var_Framework& Constraints, | |
108 | const AdvApp2Var_EvaluatorFunc2Var& Func) | |
109 | { | |
110 | ||
0d969553 | 111 | // data stored in the Context |
96a95605 | 112 | Standard_Integer NDIMEN, ISOFAV; |
7fd59977 | 113 | NDIMEN = Conditions.TotalDimension(); |
0d969553 | 114 | // Attention : works only for 3D |
7fd59977 | 115 | ISOFAV = Conditions.FavorIso(); |
116 | ||
0d969553 | 117 | // data related to the patch to be discretized |
7fd59977 | 118 | Standard_Integer NBPNTU, NBPNTV; |
119 | Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV; | |
120 | Handle (TColStd_HArray1OfReal) HUROOT = Conditions.URoots(); | |
121 | Handle (TColStd_HArray1OfReal) HVROOT = Conditions.VRoots(); | |
122 | Standard_Real * UROOT; | |
123 | UROOT = (Standard_Real *) &HUROOT ->ChangeArray1()(HUROOT ->Lower()); | |
124 | NBPNTU = (Conditions.URoots())->Length(); | |
125 | if (myOrdInU>-1) NBPNTU -= 2; | |
126 | Standard_Real * VROOT; | |
127 | VROOT = (Standard_Real *) &HVROOT ->ChangeArray1()(HVROOT ->Lower()); | |
128 | NBPNTV = (Conditions.VRoots())->Length(); | |
129 | if (myOrdInV>-1) NBPNTV -= 2; | |
130 | ||
0d969553 Y |
131 | // data stored in the Framework Constraints cad Nodes and Isos |
132 | // C1, C2, C3 and C4 are dimensionnes in FORTRAN with (NDIMEN,IORDRU+2,IORDRV+2) | |
7fd59977 | 133 | Standard_Integer SIZE=NDIMEN*(IORDRU+2)*(IORDRV+2); |
134 | Handle (TColStd_HArray1OfReal) HCOINS = | |
135 | new TColStd_HArray1OfReal(1,SIZE*4); | |
136 | HCOINS->Init(0.); | |
137 | ||
138 | Standard_Integer iu,iv; | |
139 | Standard_Real du=(myU1-myU0)/2,dv=(myV1-myV0)/2,rho,valnorm; | |
140 | ||
141 | for (iu=0;iu<=myOrdInU;iu++) { | |
142 | for (iv=0;iv<=myOrdInV;iv++) { | |
0d969553 | 143 | // factor of normalization |
7fd59977 | 144 | rho = pow(du,iu)*pow(dv,iv); |
145 | ||
0d969553 | 146 | // F(U0,V0) and its derivatives normalized on (-1,1) |
7fd59977 | 147 | valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X(); |
148 | HCOINS->SetValue( 1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv , valnorm ); | |
149 | valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y(); | |
150 | HCOINS->SetValue( 2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
151 | valnorm = rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z(); | |
152 | HCOINS->SetValue( 3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
153 | ||
0d969553 | 154 | // F(U1,V0) and its derivatives normalized on (-1,1) |
7fd59977 | 155 | valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X(); |
156 | HCOINS->SetValue( SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
157 | valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y(); | |
158 | HCOINS->SetValue( SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
159 | valnorm = rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z(); | |
160 | HCOINS->SetValue( SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
161 | ||
0d969553 | 162 | // F(U0,V1) and its derivatives normalized on (-1,1) |
7fd59977 | 163 | valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X(); |
164 | HCOINS->SetValue( 2*SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
165 | valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y(); | |
166 | HCOINS->SetValue( 2*SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
167 | valnorm = rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z(); | |
168 | HCOINS->SetValue( 2*SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
169 | ||
0d969553 | 170 | // F(U1,V1) and its derivatives normalized on (-1,1) |
7fd59977 | 171 | valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X(); |
172 | HCOINS->SetValue( 3*SIZE+1+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
173 | valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y(); | |
174 | HCOINS->SetValue( 3*SIZE+2+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
175 | valnorm = rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z(); | |
176 | HCOINS->SetValue( 3*SIZE+3+NDIMEN*iu+NDIMEN*(IORDRU+2)*iv, valnorm ); | |
177 | } | |
178 | } | |
179 | Standard_Real *C1 = | |
180 | (Standard_Real *) &HCOINS ->ChangeArray1()(HCOINS ->Lower()); | |
181 | Standard_Real *C2 = C1 + SIZE; | |
182 | Standard_Real *C3 = C2 + SIZE; | |
183 | Standard_Real *C4 = C3 + SIZE; | |
184 | ||
0d969553 Y |
185 | // tables SomTab and Diftab of discretization of isos U=U0 and U=U1 |
186 | // SU0, SU1, DU0 and DU1 are dimensioned in FORTRAN to | |
7fd59977 | 187 | // (1+NBPNTV/2)*NDIMEN*(IORDRU+1) |
188 | ||
189 | SIZE = (1+NBPNTV/2)*NDIMEN; | |
190 | ||
191 | Handle (TColStd_HArray1OfReal) HSU0 | |
192 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1)); | |
193 | HSU0 ->ChangeArray1() = | |
194 | ( (Constraints.IsoU(myU0,myV0,myV1)).SomTab() ) ->Array1(); | |
195 | ||
196 | Handle (TColStd_HArray1OfReal) HDU0 | |
197 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1)); | |
198 | HDU0 ->ChangeArray1() = | |
199 | ( (Constraints.IsoU(myU0,myV0,myV1)).DifTab() ) ->Array1(); | |
200 | ||
201 | Handle (TColStd_HArray1OfReal) HSU1 | |
202 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1)); | |
203 | HSU1 ->ChangeArray1() = | |
204 | ( (Constraints.IsoU(myU1,myV0,myV1)).SomTab() ) ->Array1(); | |
205 | ||
206 | Handle (TColStd_HArray1OfReal) HDU1 | |
207 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1)); | |
208 | HDU1 ->ChangeArray1() = | |
209 | ( (Constraints.IsoU(myU1,myV0,myV1)).DifTab() ) ->Array1(); | |
210 | ||
0d969553 | 211 | // normalization |
7fd59977 | 212 | Standard_Integer ideb1,ideb2,ideb3,ideb4,jj; |
213 | for (iu=1;iu<=IORDRU;iu++) { | |
214 | rho = pow(du,iu); | |
215 | ideb1 = HSU0->Lower() + iu*SIZE -1; | |
216 | ideb2 = HDU0->Lower() + iu*SIZE -1; | |
217 | ideb3 = HSU1->Lower() + iu*SIZE -1; | |
218 | ideb4 = HDU1->Lower() + iu*SIZE -1; | |
219 | for (jj=1;jj<=SIZE;jj++) { | |
220 | HSU0 ->SetValue(ideb1+jj,rho*HSU0->Value(ideb1+jj)); | |
221 | HDU0 ->SetValue(ideb2+jj,rho*HDU0->Value(ideb2+jj)); | |
222 | HSU1 ->SetValue(ideb3+jj,rho*HSU1->Value(ideb3+jj)); | |
223 | HDU1 ->SetValue(ideb4+jj,rho*HDU1->Value(ideb4+jj)); | |
224 | } | |
225 | } | |
226 | ||
227 | Standard_Real *SU0 = | |
228 | (Standard_Real *) &HSU0 ->ChangeArray1()(HSU0 ->Lower()); | |
229 | Standard_Real *DU0 = | |
230 | (Standard_Real *) &HDU0 ->ChangeArray1()(HDU0 ->Lower()); | |
231 | Standard_Real *SU1 = | |
232 | (Standard_Real *) &HSU1 ->ChangeArray1()(HSU1 ->Lower()); | |
233 | Standard_Real *DU1 = | |
234 | (Standard_Real *) &HDU1 ->ChangeArray1()(HDU1 ->Lower()); | |
235 | ||
0d969553 Y |
236 | // tables SomTab and Diftab of discretization of isos V=V0 and V=V1 |
237 | // SU0, SU1, DU0 and DU1 are dimensioned in FORTRAN at | |
7fd59977 | 238 | // (1+NBPNTU/2)*NDIMEN*(IORDRV+1) |
239 | ||
240 | SIZE = (1+NBPNTU/2)*NDIMEN; | |
241 | ||
242 | Handle (TColStd_HArray1OfReal) HSV0 | |
243 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1)); | |
244 | HSV0 ->ChangeArray1() = | |
245 | ( (Constraints.IsoV(myU0,myU1,myV0)).SomTab() ) ->Array1(); | |
246 | ||
247 | Handle (TColStd_HArray1OfReal) HDV0 | |
248 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1)); | |
249 | HDV0 ->ChangeArray1() = | |
250 | ( (Constraints.IsoV(myU0,myU1,myV0)).DifTab() ) ->Array1(); | |
251 | ||
252 | Handle (TColStd_HArray1OfReal) HSV1 | |
253 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1)); | |
254 | HSV1 ->ChangeArray1() = | |
255 | ( (Constraints.IsoV(myU0,myU1,myV1)).SomTab() ) ->Array1(); | |
256 | ||
257 | Handle (TColStd_HArray1OfReal) HDV1 | |
258 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1)); | |
259 | HDV1 ->ChangeArray1() = | |
260 | ( (Constraints.IsoV(myU0,myU1,myV1)).DifTab() ) ->Array1(); | |
261 | ||
262 | // normalisation | |
263 | for (iv=1;iv<=IORDRV;iv++) { | |
264 | rho = pow(dv,iv); | |
265 | ideb1 = HSV0->Lower() + iv*SIZE -1; | |
266 | ideb2 = HDV0->Lower() + iv*SIZE -1; | |
267 | ideb3 = HSV1->Lower() + iv*SIZE -1; | |
268 | ideb4 = HDV1->Lower() + iv*SIZE -1; | |
269 | for (jj=1;jj<=SIZE;jj++) { | |
270 | HSV0 ->SetValue(ideb1+jj,rho*HSV0->Value(ideb1+jj)); | |
271 | HDV0 ->SetValue(ideb2+jj,rho*HDV0->Value(ideb2+jj)); | |
272 | HSV1 ->SetValue(ideb3+jj,rho*HSV1->Value(ideb3+jj)); | |
273 | HDV1 ->SetValue(ideb4+jj,rho*HDV1->Value(ideb4+jj)); | |
274 | } | |
275 | } | |
276 | ||
277 | Standard_Real *SV0 = | |
278 | (Standard_Real *) &HSV0 ->ChangeArray1()(HSV0 ->Lower()); | |
279 | Standard_Real *DV0 = | |
280 | (Standard_Real *) &HDV0 ->ChangeArray1()(HDV0 ->Lower()); | |
281 | Standard_Real *SV1 = | |
282 | (Standard_Real *) &HSV1 ->ChangeArray1()(HSV1 ->Lower()); | |
283 | Standard_Real *DV1 = | |
284 | (Standard_Real *) &HDV1 ->ChangeArray1()(HDV1 ->Lower()); | |
285 | ||
0d969553 | 286 | // SOSOTB and DIDITB are dimensioned in FORTRAN at |
7fd59977 | 287 | // (0:NBPNTU/2,0:NBPNTV/2,NDIMEN) |
288 | ||
289 | SIZE=(1+NBPNTU/2)*(1+NBPNTV/2)*NDIMEN; | |
290 | ||
291 | Handle (TColStd_HArray1OfReal) HSOSO = | |
292 | new TColStd_HArray1OfReal(1,SIZE); | |
293 | Standard_Real *SOSOTB = | |
294 | (Standard_Real *) &HSOSO ->ChangeArray1()(HSOSO ->Lower()); | |
295 | HSOSO->Init(0.); | |
296 | Handle (TColStd_HArray1OfReal) HDIDI = | |
297 | new TColStd_HArray1OfReal(1,SIZE); | |
298 | Standard_Real *DIDITB = | |
299 | (Standard_Real *) &HDIDI ->ChangeArray1()(HDIDI ->Lower()); | |
300 | HDIDI->Init(0.); | |
301 | ||
0d969553 | 302 | // SODITB and DISOTB are dimensioned in FORTRAN at |
7fd59977 | 303 | // (1:NBPNTU/2,1:NBPNTV/2,NDIMEN) |
304 | ||
305 | SIZE=(NBPNTU/2)*(NBPNTV/2)*NDIMEN; | |
306 | ||
307 | Handle (TColStd_HArray1OfReal) HSODI = | |
308 | new TColStd_HArray1OfReal(1,SIZE); | |
309 | Standard_Real *SODITB = | |
310 | (Standard_Real *) &HSODI ->ChangeArray1()(HSODI ->Lower()); | |
311 | HSODI->Init(0.); | |
312 | Handle (TColStd_HArray1OfReal) HDISO = | |
313 | new TColStd_HArray1OfReal(1,SIZE); | |
314 | Standard_Real *DISOTB = | |
315 | (Standard_Real *) &HDISO ->ChangeArray1()(HDISO ->Lower()); | |
316 | HDISO->Init(0.); | |
317 | ||
318 | Standard_Integer IERCOD=0; | |
319 | ||
0d969553 | 320 | // discretization of polynoms of interpolation |
7fd59977 | 321 | AdvApp2Var_ApproxF2var::mma2cdi_(&NDIMEN,&NBPNTU,UROOT,&NBPNTV,VROOT,&IORDRU,&IORDRV, |
322 | C1,C2,C3,C4,SU0,SU1,DU0,DU1,SV0,SV1,DV0,DV1, | |
323 | SOSOTB,SODITB,DISOTB,DIDITB,&IERCOD); | |
324 | ||
0d969553 | 325 | // discretization of the square |
7fd59977 | 326 | Standard_Real UDBFN[2],VDBFN[2]; |
327 | UDBFN[0] = myU0; | |
328 | UDBFN[1] = myU1; | |
329 | VDBFN[0] = myV0; | |
330 | VDBFN[1] = myV1; | |
331 | ||
332 | SIZE = Max(NBPNTU,NBPNTV); | |
333 | Handle (TColStd_HArray1OfReal) HTABLE = | |
334 | new TColStd_HArray1OfReal(1,SIZE); | |
335 | Standard_Real *TAB = | |
336 | (Standard_Real *) &HTABLE ->ChangeArray1()(HTABLE ->Lower()); | |
337 | ||
338 | Handle (TColStd_HArray1OfReal) HPOINTS = | |
339 | new TColStd_HArray1OfReal(1,SIZE*NDIMEN); | |
340 | Standard_Real *PTS = | |
341 | (Standard_Real *) &HPOINTS ->ChangeArray1()(HPOINTS ->Lower()); | |
342 | ||
343 | // GCC 3.0 would not accept this line without the void | |
344 | // pointer cast. Perhaps the real problem is a definition | |
345 | // somewhere that has a void * in it. | |
346 | AdvApp2Var_ApproxF2var::mma2ds1_(&NDIMEN, | |
347 | UDBFN, | |
348 | VDBFN, | |
349 | /*(void *)*/Func, | |
350 | &NBPNTU, | |
351 | &NBPNTV, | |
352 | UROOT, | |
353 | VROOT, | |
354 | &ISOFAV, | |
355 | SOSOTB, | |
356 | DISOTB, | |
357 | SODITB, | |
358 | DIDITB, | |
359 | PTS, | |
360 | TAB, | |
361 | &IERCOD); | |
362 | ||
0d969553 | 363 | // the results are stored |
7fd59977 | 364 | if (IERCOD == 0) { |
365 | myDiscIsDone = Standard_True; | |
366 | mySosoTab = HSOSO; | |
367 | myDisoTab = HDISO; | |
368 | mySodiTab = HSODI; | |
369 | myDidiTab = HDIDI; | |
370 | } | |
371 | else { | |
372 | myDiscIsDone = Standard_False; | |
373 | } | |
374 | } | |
375 | ||
376 | //============================================================================ | |
377 | //function : HasResult | |
378 | //purpose : | |
379 | //============================================================================ | |
380 | ||
381 | Standard_Boolean AdvApp2Var_Patch::HasResult() const | |
382 | { | |
383 | return myHasResult; | |
384 | } | |
385 | ||
386 | //============================================================================ | |
387 | //function : IsApproximated | |
388 | //purpose : | |
389 | //============================================================================ | |
390 | ||
391 | Standard_Boolean AdvApp2Var_Patch::IsApproximated() const | |
392 | { | |
393 | return myApprIsDone; | |
394 | } | |
395 | ||
396 | //============================================================================ | |
397 | //function : AddConstraints | |
398 | //purpose : | |
399 | //============================================================================ | |
400 | ||
401 | void AdvApp2Var_Patch::AddConstraints(const AdvApp2Var_Context& Conditions, | |
402 | const AdvApp2Var_Framework& Constraints) | |
403 | { | |
0d969553 | 404 | // data stored in the Context |
96a95605 | 405 | Standard_Integer NDIMEN; |
7fd59977 | 406 | Standard_Integer IERCOD, NCFLMU, NCFLMV, NDegU, NDegV; |
407 | NDIMEN = Conditions.TotalDimension(); | |
0d969553 | 408 | // Attention : works only for 3D |
7fd59977 | 409 | NCFLMU = Conditions.ULimit(); |
410 | NCFLMV = Conditions.VLimit(); | |
411 | NDegU = NCFLMU - 1; | |
412 | NDegV = NCFLMV - 1; | |
413 | ||
0d969553 | 414 | // data relative to the patch |
7fd59977 | 415 | Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV; |
416 | Standard_Real *PATCAN = | |
417 | (Standard_Real *) &myEquation ->ChangeArray1()(myEquation ->Lower()); | |
418 | ||
0d969553 | 419 | // curves of approximation of Isos U |
7fd59977 | 420 | Standard_Integer SIZE = NCFLMV*NDIMEN; |
421 | Handle (TColStd_HArray1OfReal) HIsoU0 | |
422 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1)); | |
423 | HIsoU0 -> ChangeArray1() = | |
424 | (Constraints.IsoU(myU0,myV0,myV1)).Polynom() -> Array1(); | |
425 | Standard_Real *IsoU0 = | |
426 | (Standard_Real *) &HIsoU0 ->ChangeArray1()(HIsoU0 ->Lower()); | |
427 | Handle (TColStd_HArray1OfInteger) HCFU0 | |
428 | = new TColStd_HArray1OfInteger(1,IORDRU+1); | |
429 | Standard_Integer *NCFU0 = | |
430 | (Standard_Integer *) &HCFU0 ->ChangeArray1()(HCFU0 ->Lower()); | |
431 | HCFU0->Init( (Constraints.IsoU(myU0,myV0,myV1)).NbCoeff() ); | |
432 | ||
433 | Handle (TColStd_HArray1OfReal) HIsoU1 | |
434 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRU+1)); | |
435 | HIsoU1 -> ChangeArray1() = | |
436 | (Constraints.IsoU(myU1,myV0,myV1)).Polynom() -> Array1(); | |
437 | Standard_Real *IsoU1 = | |
438 | (Standard_Real *) &HIsoU1 ->ChangeArray1()(HIsoU1 ->Lower()); | |
439 | Handle (TColStd_HArray1OfInteger) HCFU1 | |
440 | = new TColStd_HArray1OfInteger(1,IORDRU+1); | |
441 | Standard_Integer *NCFU1 = | |
442 | (Standard_Integer *) &HCFU1 ->ChangeArray1()(HCFU1 ->Lower()); | |
443 | HCFU1->Init( (Constraints.IsoU(myU1,myV0,myV1)).NbCoeff() ); | |
444 | ||
0d969553 | 445 | // normalization of Isos U |
7fd59977 | 446 | Standard_Integer iu,iv; |
447 | Standard_Real du=(myU1-myU0)/2,dv=(myV1-myV0)/2,rho,valnorm; | |
448 | Standard_Integer ideb0,ideb1,jj; | |
449 | ||
450 | for (iu=1;iu<=IORDRU;iu++) { | |
451 | rho = pow(du,iu); | |
452 | ideb0 = HIsoU0->Lower() + iu*SIZE -1; | |
453 | ideb1 = HIsoU1->Lower() + iu*SIZE -1; | |
454 | for (jj=1;jj<=SIZE;jj++) { | |
455 | HIsoU0->SetValue(ideb0+jj,rho*HIsoU0->Value(ideb0+jj)); | |
456 | HIsoU1->SetValue(ideb1+jj,rho*HIsoU1->Value(ideb1+jj)); | |
457 | } | |
458 | } | |
459 | ||
0d969553 | 460 | // curves of approximation of Isos V |
7fd59977 | 461 | SIZE = NCFLMU*NDIMEN; |
462 | Handle (TColStd_HArray1OfReal) HIsoV0 | |
463 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1)); | |
464 | HIsoV0 -> ChangeArray1() = | |
465 | (Constraints.IsoV(myU0,myU1,myV0)).Polynom() -> Array1(); | |
466 | Standard_Real *IsoV0 = | |
467 | (Standard_Real *) &HIsoV0 ->ChangeArray1()(HIsoV0 ->Lower()); | |
468 | Handle (TColStd_HArray1OfInteger) HCFV0 | |
469 | = new TColStd_HArray1OfInteger(1,IORDRV+1); | |
470 | Standard_Integer *NCFV0 = | |
471 | (Standard_Integer *) &HCFV0 ->ChangeArray1()(HCFV0 ->Lower()); | |
472 | HCFV0->Init( (Constraints.IsoV(myU0,myU1,myV0)).NbCoeff() ); | |
473 | ||
474 | Handle (TColStd_HArray1OfReal) HIsoV1 | |
475 | = new TColStd_HArray1OfReal(1,SIZE*(IORDRV+1)); | |
476 | HIsoV1 -> ChangeArray1() = | |
477 | (Constraints.IsoV(myU0,myU1,myV1)).Polynom() -> Array1(); | |
478 | Standard_Real *IsoV1 = | |
479 | (Standard_Real *) &HIsoV1 ->ChangeArray1()(HIsoV1 ->Lower()); | |
480 | Handle (TColStd_HArray1OfInteger) HCFV1 | |
481 | = new TColStd_HArray1OfInteger(1,IORDRV+1); | |
482 | Standard_Integer *NCFV1 = | |
483 | (Standard_Integer *) &HCFV1 ->ChangeArray1()(HCFV1 ->Lower()); | |
484 | HCFV1->Init( (Constraints.IsoV(myU0,myU1,myV1)).NbCoeff() ); | |
485 | ||
0d969553 | 486 | // normalization of Isos V |
7fd59977 | 487 | for (iv=1;iv<=IORDRV;iv++) { |
488 | rho = pow(dv,iv); | |
489 | ideb0 = HIsoV0->Lower() + iv*SIZE -1; | |
490 | ideb1 = HIsoV1->Lower() + iv*SIZE -1; | |
491 | for (jj=1;jj<=SIZE;jj++) { | |
492 | HIsoV0 ->SetValue(ideb0+jj,rho*HIsoV0->Value(ideb0+jj)); | |
493 | HIsoV1->SetValue(ideb1+jj,rho*HIsoV1->Value(ideb1+jj)); | |
494 | } | |
495 | } | |
496 | ||
0d969553 | 497 | // add constraints to constant V |
7fd59977 | 498 | Handle (TColStd_HArray1OfReal) HHERMV |
499 | = new TColStd_HArray1OfReal(1,(2*IORDRV+2)*(2*IORDRV+2)); | |
500 | Standard_Real *HermV = | |
501 | (Standard_Real *) &HHERMV ->ChangeArray1()(HHERMV ->Lower()); | |
502 | if (IORDRV>=0) { | |
503 | AdvApp2Var_ApproxF2var::mma1her_(&IORDRV,HermV,&IERCOD); | |
504 | if (IERCOD!=0) { | |
9775fa61 | 505 | throw Standard_ConstructionError("AdvApp2Var_Patch::AddConstraints : Error in FORTRAN"); |
7fd59977 | 506 | } |
507 | AdvApp2Var_ApproxF2var::mma2ac2_(&NDIMEN, | |
508 | &NDegU, | |
509 | &NDegV, | |
510 | &IORDRV, | |
511 | &NCFLMU, | |
512 | NCFV0, | |
513 | IsoV0, | |
514 | NCFV1, | |
515 | IsoV1, | |
516 | HermV, | |
517 | PATCAN); | |
518 | } | |
519 | ||
0d969553 | 520 | // add constraints to constant U |
7fd59977 | 521 | Handle (TColStd_HArray1OfReal) HHERMU |
522 | = new TColStd_HArray1OfReal(1,(2*IORDRU+2)*(2*IORDRU+2)); | |
523 | Standard_Real *HermU = | |
524 | (Standard_Real *) &HHERMU ->ChangeArray1()(HHERMU ->Lower()); | |
525 | if (IORDRU>=0) { | |
526 | AdvApp2Var_ApproxF2var::mma1her_(&IORDRU,HermU,&IERCOD); | |
527 | if (IERCOD!=0) { | |
9775fa61 | 528 | throw Standard_ConstructionError("AdvApp2Var_Patch::AddConstraints : Error in FORTRAN"); |
7fd59977 | 529 | } |
530 | AdvApp2Var_ApproxF2var::mma2ac3_(&NDIMEN,&NDegU,&NDegV,&IORDRU,&NCFLMV, | |
531 | NCFU0,IsoU0,NCFU1,IsoU1,HermU,PATCAN); | |
532 | } | |
533 | ||
0d969553 | 534 | // add constraints at the corners |
7fd59977 | 535 | Standard_Integer ideb; |
536 | SIZE=NDIMEN*(IORDRU+2)*(IORDRV+2); | |
537 | Handle (TColStd_HArray1OfReal) HCOINS = | |
538 | new TColStd_HArray1OfReal(1,SIZE*4); | |
539 | ||
540 | for (iu=0;iu<=myOrdInU;iu++) { | |
541 | for (iv=0;iv<=myOrdInV;iv++) { | |
542 | rho = pow(du,iu)*pow(dv,iv); | |
543 | ||
0d969553 | 544 | // -F(U0,V0) and its derivatives normalized on (-1,1) |
7fd59977 | 545 | ideb = HCOINS->Lower() + NDIMEN*iu+NDIMEN*(IORDRU+2)*iv - 1; |
546 | valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X(); | |
547 | HCOINS->SetValue( 1+ideb , valnorm ); | |
548 | valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y(); | |
549 | HCOINS->SetValue( 2+ideb , valnorm ); | |
550 | valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z(); | |
551 | HCOINS->SetValue( 3+ideb , valnorm ); | |
552 | ||
0d969553 | 553 | // -F(U1,V0) and its derivatives normalized on (-1,1) |
7fd59977 | 554 | ideb += SIZE; |
555 | valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X(); | |
556 | HCOINS->SetValue( 1+ideb , valnorm ); | |
557 | valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y(); | |
558 | HCOINS->SetValue( 2+ideb , valnorm ); | |
559 | valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z(); | |
560 | HCOINS->SetValue( 3+ideb , valnorm ); | |
561 | ||
0d969553 | 562 | // -F(U0,V1) and its derivatives normalized on (-1,1) |
7fd59977 | 563 | ideb += SIZE; |
564 | valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X(); | |
565 | HCOINS->SetValue( 1+ideb , valnorm ); | |
566 | valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y(); | |
567 | HCOINS->SetValue( 2+ideb , valnorm ); | |
568 | valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z(); | |
569 | HCOINS->SetValue( 3+ideb , valnorm ); | |
570 | ||
0d969553 | 571 | // -F(U1,V1) and its derivatives normalized on (-1,1) |
7fd59977 | 572 | ideb += SIZE; |
573 | valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X(); | |
574 | HCOINS->SetValue( 1+ideb , valnorm ); | |
575 | valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y(); | |
576 | HCOINS->SetValue( 2+ideb , valnorm ); | |
577 | valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z(); | |
578 | HCOINS->SetValue( 3+ideb , valnorm ); | |
579 | } | |
580 | } | |
581 | ||
0d969553 | 582 | // tables required for FORTRAN |
7fd59977 | 583 | Standard_Integer IORDMX = Max(IORDRU,IORDRV); |
584 | Handle (TColStd_HArray1OfReal) HEXTR = | |
585 | new TColStd_HArray1OfReal(1,2*IORDMX+2); | |
586 | Standard_Real *EXTR = | |
587 | (Standard_Real *) &HEXTR ->ChangeArray1()(HEXTR ->Lower()); | |
588 | Handle (TColStd_HArray1OfReal) HFACT = | |
589 | new TColStd_HArray1OfReal(1,IORDMX+1); | |
590 | Standard_Real *FACT = | |
591 | (Standard_Real *) &HFACT ->ChangeArray1()(HFACT ->Lower()); | |
592 | ||
593 | Standard_Integer idim,ncf0,ncf1,iun=1; | |
594 | Standard_Real *Is; | |
595 | ||
0d969553 | 596 | // add extremities of isos U |
7fd59977 | 597 | for (iu=1;iu<=IORDRU+1;iu++) { |
598 | ncf0 = HCFU0->Value(HCFU0->Lower()+iu-1); | |
599 | ncf1 = HCFU1->Value(HCFU1->Lower()+iu-1); | |
600 | for (idim=1;idim<=NDIMEN;idim++) { | |
601 | Is = IsoU0 + NCFLMV*(idim-1) + NCFLMV*NDIMEN*(iu-1); | |
602 | AdvApp2Var_MathBase::mmdrc11_(&IORDRV,&iun,&ncf0,Is,EXTR,FACT); | |
603 | for (iv=1;iv<=IORDRV+1;iv++) { | |
604 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; | |
605 | HCOINS->ChangeValue(idim+ideb) += HEXTR->Value(1+2*(iv-1)); | |
606 | HCOINS->ChangeValue(2*SIZE+idim+ideb) += HEXTR->Value(2+2*(iv-1)); | |
607 | } | |
608 | Is = IsoU1 + NCFLMV*(idim-1) + NCFLMV*NDIMEN*(iu-1); | |
609 | AdvApp2Var_MathBase::mmdrc11_(&IORDRV,&iun,&ncf1,Is,EXTR,FACT); | |
610 | for (iv=1;iv<=IORDRV+1;iv++) { | |
611 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; | |
612 | HCOINS->ChangeValue(SIZE+idim+ideb) += HEXTR->Value(1+2*(iv-1)); | |
613 | HCOINS->ChangeValue(3*SIZE+idim+ideb) += HEXTR->Value(2+2*(iv-1)); | |
614 | } | |
615 | } | |
616 | } | |
617 | ||
0d969553 | 618 | // add extremities of isos V |
7fd59977 | 619 | for (iv=1;iv<=IORDRV+1;iv++) { |
620 | ncf0 = HCFV0->Value(HCFV0->Lower()+iv-1); | |
621 | ncf1 = HCFV1->Value(HCFV1->Lower()+iv-1); | |
622 | for (idim=1;idim<=NDIMEN;idim++) { | |
623 | Is = IsoV0 + NCFLMU*(idim-1) + NCFLMU*NDIMEN*(iv-1); | |
624 | AdvApp2Var_MathBase::mmdrc11_(&IORDRU,&iun,&ncf0,Is,EXTR,FACT); | |
625 | for (iu=1;iu<=IORDRU+1;iu++) { | |
626 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; | |
627 | HCOINS->ChangeValue(idim+ideb) += HEXTR->Value(1+2*(iu-1)); | |
628 | HCOINS->ChangeValue(SIZE+idim+ideb) += HEXTR->Value(2+2*(iu-1)); | |
629 | } | |
630 | Is = IsoV1 + NCFLMU*(idim-1) + NCFLMU*NDIMEN*(iv-1); | |
631 | AdvApp2Var_MathBase::mmdrc11_(&IORDRU,&iun,&ncf1,Is,EXTR,FACT); | |
632 | for (iu=1;iu<=IORDRU+1;iu++) { | |
633 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; | |
634 | HCOINS->ChangeValue(2*SIZE+idim+ideb) += HEXTR->Value(1+2*(iu-1)); | |
635 | HCOINS->ChangeValue(3*SIZE+idim+ideb) += HEXTR->Value(2+2*(iu-1)); | |
636 | } | |
637 | } | |
638 | } | |
639 | ||
0d969553 | 640 | // add all to PATCAN |
7fd59977 | 641 | Standard_Real *C1 = |
642 | (Standard_Real *) &HCOINS ->ChangeArray1()(HCOINS ->Lower()); | |
643 | Standard_Real *C2 = C1 + SIZE; | |
644 | Standard_Real *C3 = C2 + SIZE; | |
645 | Standard_Real *C4 = C3 + SIZE; | |
646 | if ( IORDRU>=0 && IORDRV>=0 ) { | |
647 | AdvApp2Var_ApproxF2var::mma2ac1_(&NDIMEN,&NDegU,&NDegV,&IORDRU,&IORDRV, | |
648 | C1,C2,C3,C4,HermU,HermV,PATCAN); | |
649 | } | |
650 | } | |
651 | ||
652 | //============================================================================ | |
653 | //function : AddErrors | |
654 | //purpose : | |
655 | //============================================================================ | |
656 | ||
657 | void AdvApp2Var_Patch::AddErrors(const AdvApp2Var_Framework& Constraints) | |
658 | { | |
659 | Standard_Integer NBSESP = 1, iesp; | |
660 | Standard_Integer iu,iv; | |
661 | ||
662 | Standard_Real errU,errV,error,hmax[4]; | |
663 | hmax[0] = 0; | |
664 | hmax[1] = 1; | |
665 | hmax[2] = 1.5; | |
666 | hmax[3] = 1.75; | |
667 | ||
668 | for (iesp=1;iesp<=NBSESP;iesp++) { | |
0d969553 | 669 | // error max in sub-space iesp |
7fd59977 | 670 | errU=0.; |
671 | for (iv=1;iv<=myOrdInV+1;iv++) { | |
672 | error = ((Constraints.IsoV(myU0,myU1,myV0)).MaxErrors())->Value(iesp,iv); | |
673 | errU = Max(errU,error); | |
674 | error = ((Constraints.IsoV(myU0,myU1,myV1)).MaxErrors())->Value(iesp,iv); | |
675 | errU = Max(errU,error); | |
676 | } | |
677 | errV=0.; | |
678 | for (iu=1;iu<=myOrdInU+1;iu++) { | |
679 | error = ((Constraints.IsoU(myU0,myV0,myV1)).MaxErrors())->Value(iesp,iu); | |
680 | errV = Max(errV,error); | |
681 | error = ((Constraints.IsoU(myU1,myV0,myV1)).MaxErrors())->Value(iesp,iu); | |
682 | errV = Max(errV,error); | |
683 | } | |
684 | myMaxErrors->ChangeValue(iesp) += | |
685 | errU * hmax[myOrdInV+1] + errV * hmax[myOrdInU+1]; | |
686 | ||
0d969553 | 687 | // average error in sub-space iesp |
7fd59977 | 688 | errU=0.; |
689 | for (iv=1;iv<=myOrdInV+1;iv++) { | |
690 | error = ((Constraints.IsoV(myU0,myU1,myV0)).MoyErrors())->Value(iesp,iv); | |
691 | errU = Max(errU,error); | |
692 | error = ((Constraints.IsoV(myU0,myU1,myV1)).MoyErrors())->Value(iesp,iv); | |
693 | errU = Max(errU,error); | |
694 | } | |
695 | errV=0.; | |
696 | for (iu=1;iu<=myOrdInU+1;iu++) { | |
697 | error = ((Constraints.IsoU(myU0,myV0,myV1)).MoyErrors())->Value(iesp,iu); | |
698 | errV = Max(errV,error); | |
699 | error = ((Constraints.IsoU(myU1,myV0,myV1)).MoyErrors())->Value(iesp,iu); | |
700 | errV = Max(errV,error); | |
701 | } | |
702 | error = myMoyErrors->Value(iesp); | |
703 | error *= error; | |
704 | error += errU*hmax[myOrdInV+1] * errU*hmax[myOrdInV+1] | |
705 | + errV*hmax[myOrdInU+1] * errV*hmax[myOrdInU+1]; | |
706 | myMoyErrors->SetValue(iesp,Sqrt(error)); | |
707 | ||
0d969553 | 708 | // max errors at iso-borders |
7fd59977 | 709 | Handle (TColStd_HArray2OfReal) HERISO |
710 | = new TColStd_HArray2OfReal(1,NBSESP,1,4); | |
711 | HERISO->SetValue(iesp,1, | |
712 | ((Constraints.IsoV(myU0,myU1,myV0)).MaxErrors())->Value(iesp,1)); | |
713 | HERISO->SetValue(iesp,2, | |
714 | ((Constraints.IsoV(myU0,myU1,myV1)).MaxErrors())->Value(iesp,1)); | |
715 | HERISO->SetValue(iesp,3, | |
716 | ((Constraints.IsoU(myU0,myV0,myV1)).MaxErrors())->Value(iesp,1)); | |
717 | HERISO->SetValue(iesp,4, | |
718 | ((Constraints.IsoU(myU1,myV0,myV1)).MaxErrors())->Value(iesp,1)); | |
719 | ||
0d969553 | 720 | // calculate max errors at the corners |
7fd59977 | 721 | Standard_Real emax1=0.,emax2=0.,emax3=0.,emax4=0.,err1,err2,err3,err4; |
722 | for (iu=0;iu<=myOrdInU;iu++) { | |
723 | for (iv=0;iv<=myOrdInV;iv++) { | |
724 | error = (Constraints.Node(myU0,myV0)).Error(iu,iv); | |
725 | emax1 = Max(emax1,error); | |
726 | error = (Constraints.Node(myU1,myV0)).Error(iu,iv); | |
727 | emax2 = Max(emax2,error); | |
728 | error = (Constraints.Node(myU0,myV1)).Error(iu,iv); | |
729 | emax3 = Max(emax3,error); | |
730 | error = (Constraints.Node(myU1,myV1)).Error(iu,iv); | |
731 | emax4 = Max(emax4,error); | |
732 | } | |
733 | } | |
734 | ||
0d969553 | 735 | // calculate max errors on borders |
7fd59977 | 736 | err1 = Max(emax1,emax2); |
737 | err2 = Max(emax3,emax4); | |
738 | err3 = Max(emax1,emax3); | |
739 | err4 = Max(emax2,emax4); | |
740 | ||
0d969553 | 741 | // calculate final errors on internal isos |
7fd59977 | 742 | if ( (Constraints.IsoV(myU0,myU1,myV0)).Position() == 0 ) { |
743 | HERISO ->ChangeValue(iesp,1) += err1*hmax[myOrdInU+1]; | |
744 | } | |
745 | if ( (Constraints.IsoV(myU0,myU1,myV1)).Position() == 0 ) { | |
746 | HERISO ->ChangeValue(iesp,2) += err2*hmax[myOrdInU+1]; | |
747 | } | |
748 | if ( (Constraints.IsoU(myU0,myV0,myV1)).Position() == 0 ) { | |
749 | HERISO ->ChangeValue(iesp,3) += err3*hmax[myOrdInV+1]; | |
750 | } | |
751 | if ( (Constraints.IsoU(myU1,myV0,myV1)).Position() == 0 ) { | |
752 | HERISO ->ChangeValue(iesp,4) += err4*hmax[myOrdInV+1]; | |
753 | } | |
754 | myIsoErrors = HERISO; | |
755 | } | |
756 | } | |
757 | ||
758 | //============================================================================ | |
759 | //function : MakeApprox | |
760 | //purpose : | |
761 | //============================================================================ | |
762 | ||
763 | void AdvApp2Var_Patch::MakeApprox(const AdvApp2Var_Context& Conditions, | |
764 | const AdvApp2Var_Framework& Constraints, | |
765 | const Standard_Integer NumDec) | |
766 | { | |
767 | ||
0d969553 | 768 | // data stored in the Context |
7fd59977 | 769 | Standard_Integer NDIMEN, NBSESP, NDIMSE; |
770 | Standard_Integer NBPNTU, NBPNTV, NCFLMU, NCFLMV, NDJACU, NDJACV; | |
771 | Standard_Integer NDegU, NDegV, NJacU, NJacV; | |
772 | NDIMEN = Conditions.TotalDimension(); | |
773 | NBSESP = Conditions.TotalNumberSSP(); | |
774 | NDIMSE = 3; | |
775 | NBPNTU = (Conditions.URoots())->Length(); | |
776 | if (myOrdInU>-1) NBPNTU -= 2; | |
777 | NBPNTV = (Conditions.VRoots())->Length(); | |
778 | if (myOrdInV>-1) NBPNTV -= 2; | |
779 | NCFLMU = Conditions.ULimit(); | |
780 | NCFLMV = Conditions.VLimit(); | |
781 | NDegU = NCFLMU - 1; | |
782 | NDegV = NCFLMV - 1; | |
783 | NDJACU = Conditions.UJacDeg(); | |
784 | NDJACV = Conditions.VJacDeg(); | |
785 | NJacU = NDJACU + 1; | |
786 | NJacV = NDJACV + 1; | |
787 | ||
0d969553 | 788 | // data relative to the processed patch |
7fd59977 | 789 | Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV, |
790 | NDMINU = 1, NDMINV = 1, NCOEFU, NCOEFV; | |
0d969553 Y |
791 | // NDMINU and NDMINV depend on the nb of coeff of neighboring isos |
792 | // and of the required order of continuity | |
7fd59977 | 793 | NDMINU = Max(1,2*IORDRU+1); |
794 | NCOEFU = (Constraints.IsoV(myU0,myU1,myV0)).NbCoeff()-1; | |
795 | NDMINU = Max(NDMINU,NCOEFU); | |
796 | NCOEFU = (Constraints.IsoV(myU0,myU1,myV1)).NbCoeff()-1; | |
797 | NDMINU = Max(NDMINU,NCOEFU); | |
798 | ||
799 | NDMINV = Max(1,2*IORDRV+1); | |
800 | NCOEFV = (Constraints.IsoU(myU0,myV0,myV1)).NbCoeff()-1; | |
801 | NDMINV = Max(NDMINV,NCOEFV); | |
802 | NCOEFV = (Constraints.IsoU(myU1,myV0,myV1)).NbCoeff()-1; | |
803 | NDMINV = Max(NDMINV,NCOEFV); | |
804 | ||
0d969553 | 805 | // tables of approximations |
7fd59977 | 806 | Handle (TColStd_HArray1OfReal) HEPSAPR = |
807 | new TColStd_HArray1OfReal(1,NBSESP); | |
808 | Handle (TColStd_HArray1OfReal) HEPSFRO = | |
809 | new TColStd_HArray1OfReal(1,NBSESP*8); | |
810 | Standard_Integer iesp; | |
811 | for (iesp=1;iesp<=NBSESP;iesp++) { | |
812 | HEPSAPR->SetValue(iesp,(Conditions.IToler())->Value(iesp)); | |
813 | HEPSFRO->SetValue(iesp,(Conditions.FToler())->Value(iesp,1)); | |
814 | HEPSFRO->SetValue(iesp+NBSESP,(Conditions.FToler())->Value(iesp,2)); | |
815 | HEPSFRO->SetValue(iesp+2*NBSESP,(Conditions.FToler())->Value(iesp,3)); | |
816 | HEPSFRO->SetValue(iesp+3*NBSESP,(Conditions.FToler())->Value(iesp,4)); | |
817 | HEPSFRO->SetValue(iesp+4*NBSESP,(Conditions.CToler())->Value(iesp,1)); | |
818 | HEPSFRO->SetValue(iesp+5*NBSESP,(Conditions.CToler())->Value(iesp,2)); | |
819 | HEPSFRO->SetValue(iesp+6*NBSESP,(Conditions.CToler())->Value(iesp,3)); | |
820 | HEPSFRO->SetValue(iesp+7*NBSESP,(Conditions.CToler())->Value(iesp,4)); | |
821 | } | |
822 | Standard_Real *EPSAPR = | |
823 | (Standard_Real *) &HEPSAPR ->ChangeArray1()(HEPSAPR ->Lower()); | |
824 | Standard_Real *EPSFRO = | |
825 | (Standard_Real *) &HEPSFRO ->ChangeArray1()(HEPSFRO ->Lower()); | |
826 | ||
827 | Standard_Integer SIZE=(1+NDJACU)*(1+NDJACV)*NDIMEN; | |
828 | Handle (TColStd_HArray1OfReal) HPJAC = | |
829 | new TColStd_HArray1OfReal(1,SIZE); | |
830 | Standard_Real *PATJAC = | |
831 | (Standard_Real *) &HPJAC ->ChangeArray1()(HPJAC ->Lower()); | |
832 | SIZE=2*SIZE; | |
833 | Handle (TColStd_HArray1OfReal) HPAUX = | |
834 | new TColStd_HArray1OfReal(1,SIZE); | |
835 | Standard_Real *PATAUX = | |
836 | (Standard_Real *) &HPAUX ->ChangeArray1()(HPAUX ->Lower()); | |
837 | SIZE=NCFLMU*NCFLMV*NDIMEN; | |
838 | Handle (TColStd_HArray1OfReal) HPCAN = | |
839 | new TColStd_HArray1OfReal(1,SIZE); | |
840 | Standard_Real *PATCAN = | |
841 | (Standard_Real *) &HPCAN ->ChangeArray1()(HPCAN ->Lower()); | |
842 | Handle (TColStd_HArray1OfReal) HERRMAX = | |
843 | new TColStd_HArray1OfReal(1,NBSESP); | |
844 | Standard_Real *ERRMAX = | |
845 | (Standard_Real *) &HERRMAX ->ChangeArray1()(HERRMAX ->Lower()); | |
846 | Handle (TColStd_HArray1OfReal) HERRMOY = | |
847 | new TColStd_HArray1OfReal(1,NBSESP); | |
848 | Standard_Real *ERRMOY = | |
849 | (Standard_Real *) &HERRMOY ->ChangeArray1()(HERRMOY ->Lower()); | |
850 | ||
0d969553 | 851 | // tables of discretization of the square |
7fd59977 | 852 | Standard_Real *SOSOTB = |
853 | (Standard_Real *) &mySosoTab ->ChangeArray1()(mySosoTab ->Lower()); | |
854 | Standard_Real *DISOTB = | |
855 | (Standard_Real *) &myDisoTab ->ChangeArray1()(myDisoTab ->Lower()); | |
856 | Standard_Real *SODITB = | |
857 | (Standard_Real *) &mySodiTab ->ChangeArray1()(mySodiTab ->Lower()); | |
858 | Standard_Real *DIDITB = | |
859 | (Standard_Real *) &myDidiTab ->ChangeArray1()(myDidiTab ->Lower()); | |
860 | ||
861 | // approximation | |
862 | Standard_Integer ITYDEC=0, IERCOD=0; | |
863 | Standard_Integer iun=1,itrois=3; | |
864 | NCOEFU=0; | |
865 | NCOEFV=0; | |
866 | AdvApp2Var_ApproxF2var::mma2ce1_((integer *)&NumDec, | |
867 | &NDIMEN, | |
868 | &NBSESP, | |
869 | &NDIMSE, | |
870 | &NDMINU, | |
871 | &NDMINV, | |
872 | &NDegU, | |
873 | &NDegV, | |
874 | &NDJACU, | |
875 | &NDJACV, | |
876 | &IORDRU, | |
877 | &IORDRV, | |
878 | &NBPNTU, | |
879 | &NBPNTV, | |
880 | EPSAPR, | |
881 | SOSOTB, | |
882 | DISOTB, | |
883 | SODITB, | |
884 | DIDITB, | |
885 | PATJAC, | |
886 | ERRMAX, | |
887 | ERRMOY, | |
888 | &NCOEFU, | |
889 | &NCOEFV, | |
890 | &ITYDEC, | |
891 | &IERCOD); | |
892 | ||
0d969553 | 893 | // results |
7fd59977 | 894 | myCutSense = ITYDEC; |
895 | if (ITYDEC == 0 && IERCOD<=0) { | |
896 | myHasResult = Standard_True; | |
897 | myApprIsDone = (IERCOD==0); | |
898 | myNbCoeffInU = NCOEFU+1; | |
899 | myNbCoeffInV = NCOEFV+1; | |
900 | myMaxErrors = HERRMAX; | |
901 | myMoyErrors = HERRMOY; | |
902 | ||
0d969553 | 903 | // Passage to canonic on [-1,1] |
7fd59977 | 904 | AdvApp2Var_MathBase::mmfmca9_(&NJacU,&NJacV,&NDIMEN,&myNbCoeffInU,&myNbCoeffInV, |
905 | &NDIMEN,PATJAC,PATJAC); | |
906 | AdvApp2Var_ApproxF2var::mma2can_(&NCFLMU,&NCFLMV,&NDIMEN, | |
907 | &myOrdInU,&myOrdInV,&myNbCoeffInU, | |
908 | &myNbCoeffInV, | |
909 | PATJAC,PATAUX,PATCAN,&IERCOD); | |
910 | if (IERCOD !=0) { | |
9775fa61 | 911 | throw Standard_ConstructionError("AdvApp2Var_Patch::MakeApprox : Error in FORTRAN"); |
7fd59977 | 912 | } |
913 | myEquation = HPCAN; | |
914 | ||
0d969553 | 915 | // Add constraints and errors |
7fd59977 | 916 | AddConstraints(Conditions,Constraints); |
917 | AddErrors(Constraints); | |
918 | ||
0d969553 | 919 | // Reduction of degrees if possible |
7fd59977 | 920 | PATCAN = (Standard_Real *) |
921 | &myEquation->ChangeArray1()(myEquation ->Lower()); | |
922 | ||
923 | AdvApp2Var_ApproxF2var::mma2fx6_(&NCFLMU, | |
924 | &NCFLMV, | |
925 | &NDIMEN, | |
926 | &NBSESP, | |
927 | &itrois, | |
928 | &iun, | |
929 | &iun, | |
930 | &IORDRU, | |
931 | &IORDRV, | |
932 | EPSAPR, | |
933 | EPSFRO, | |
934 | PATCAN, | |
935 | ERRMAX, | |
936 | &myNbCoeffInU, | |
937 | &myNbCoeffInV); | |
938 | ||
939 | // transposition (NCFLMU,NCFLMV,NDIMEN)Fortran-C++ | |
940 | Standard_Integer aIU, aIN, dim, ii, jj; | |
941 | for (dim=1; dim<=NDIMEN; dim++){ | |
942 | aIN = (dim-1)*NCFLMU*NCFLMV; | |
943 | for (ii=1; ii<=NCFLMU; ii++) { | |
944 | aIU = (ii-1)*NDIMEN*NCFLMV; | |
945 | for (jj=1; jj<=NCFLMV; jj++) { | |
946 | HPAUX->SetValue(dim+NDIMEN*(jj-1)+aIU , | |
947 | myEquation->Value(ii+NCFLMU*(jj-1)+aIN) ); | |
948 | } | |
949 | } | |
950 | } | |
951 | myEquation = HPAUX; | |
952 | } | |
953 | else { | |
954 | myApprIsDone = Standard_False; | |
955 | myHasResult = Standard_False; | |
956 | } | |
957 | } | |
958 | ||
959 | //============================================================================ | |
960 | //function : ChangeDomain | |
961 | //purpose : | |
962 | //============================================================================ | |
963 | ||
964 | void AdvApp2Var_Patch::ChangeDomain(const Standard_Real a, | |
965 | const Standard_Real b, | |
966 | const Standard_Real c, | |
967 | const Standard_Real d) | |
968 | { | |
969 | myU0 = a; | |
970 | myU1 = b; | |
971 | myV0 = c; | |
972 | myV1 = d; | |
973 | } | |
974 | ||
975 | //============================================================================ | |
976 | //function : ResetApprox | |
0d969553 | 977 | //purpose : allows removing a result when it is necessary to cut |
7fd59977 | 978 | //============================================================================ |
979 | ||
980 | void AdvApp2Var_Patch::ResetApprox() | |
981 | { | |
982 | myApprIsDone = Standard_False; | |
983 | myHasResult = Standard_False; | |
984 | } | |
985 | ||
986 | //============================================================================ | |
987 | //function : OverwriteApprox | |
0d969553 | 988 | //purpose : allows preserving a result even if the precision is not satisfactory |
7fd59977 | 989 | //============================================================================ |
990 | ||
991 | void AdvApp2Var_Patch::OverwriteApprox() | |
992 | { | |
993 | if (myHasResult) myApprIsDone = Standard_True; | |
994 | } | |
995 | ||
996 | //============================================================================ | |
997 | //function : U0 | |
998 | //purpose : | |
999 | //============================================================================ | |
1000 | ||
1001 | Standard_Real AdvApp2Var_Patch::U0() const | |
1002 | { | |
1003 | return myU0; | |
1004 | } | |
1005 | ||
1006 | //============================================================================ | |
1007 | //function : U1 | |
1008 | //purpose : | |
1009 | //============================================================================ | |
1010 | ||
1011 | Standard_Real AdvApp2Var_Patch::U1() const | |
1012 | { | |
1013 | return myU1; | |
1014 | } | |
1015 | ||
1016 | //============================================================================ | |
1017 | //function : V0 | |
1018 | //purpose : | |
1019 | //============================================================================ | |
1020 | ||
1021 | Standard_Real AdvApp2Var_Patch::V0() const | |
1022 | { | |
1023 | return myV0; | |
1024 | } | |
1025 | ||
1026 | //============================================================================ | |
1027 | //function : V1 | |
1028 | //purpose : | |
1029 | //============================================================================ | |
1030 | ||
1031 | Standard_Real AdvApp2Var_Patch::V1() const | |
1032 | { | |
1033 | return myV1; | |
1034 | } | |
1035 | ||
1036 | //============================================================================ | |
1037 | //function : UOrder | |
1038 | //purpose : | |
1039 | //============================================================================ | |
1040 | ||
1041 | Standard_Integer AdvApp2Var_Patch::UOrder() const | |
1042 | { | |
1043 | return myOrdInU; | |
1044 | } | |
1045 | ||
1046 | ||
1047 | //============================================================================ | |
1048 | //function : VOrder | |
1049 | //purpose : | |
1050 | //============================================================================ | |
1051 | ||
1052 | Standard_Integer AdvApp2Var_Patch::VOrder() const | |
1053 | { | |
1054 | return myOrdInV; | |
1055 | } | |
1056 | ||
1057 | ||
1058 | //============================================================================ | |
0d969553 Y |
1059 | //function : CutSense without Critere |
1060 | //purpose : 0 : OK; 1 : required cut by U; | |
1061 | // 2 : required cut by V; 3 : required cut by U and by V | |
7fd59977 | 1062 | //============================================================================ |
1063 | ||
1064 | Standard_Integer AdvApp2Var_Patch::CutSense() const | |
1065 | { | |
1066 | return myCutSense; | |
1067 | } | |
1068 | ||
1069 | ||
1070 | //============================================================================ | |
0d969553 Y |
1071 | //function : CutSense with critere |
1072 | //purpose : 0 : OK; 1 : required cut by U; | |
1073 | // 2 : required cut by V; 3 : required cut by U and by V | |
7fd59977 | 1074 | //============================================================================ |
1075 | ||
1076 | Standard_Integer AdvApp2Var_Patch::CutSense(const AdvApp2Var_Criterion& Crit, | |
1077 | const Standard_Integer NumDec) const | |
1078 | { | |
1079 | Standard_Boolean CritRel = (Crit.Type() == AdvApp2Var_Relative); | |
1080 | if ( CritRel && !IsApproximated()) { | |
1081 | return myCutSense; | |
1082 | } | |
1083 | else { | |
1084 | if (Crit.IsSatisfied(*this)) { | |
1085 | return 0; | |
1086 | } | |
1087 | else { | |
1088 | return NumDec; | |
1089 | } | |
1090 | } | |
1091 | } | |
1092 | ||
1093 | ||
1094 | //============================================================================ | |
1095 | //function : NbCoeffInU | |
1096 | //purpose : | |
1097 | //============================================================================ | |
1098 | ||
1099 | Standard_Integer AdvApp2Var_Patch::NbCoeffInU() const | |
1100 | { | |
1101 | return myNbCoeffInU; | |
1102 | } | |
1103 | ||
1104 | //============================================================================ | |
1105 | //function : NbCoeffInV | |
1106 | //purpose : | |
1107 | //============================================================================ | |
1108 | ||
1109 | Standard_Integer AdvApp2Var_Patch::NbCoeffInV() const | |
1110 | { | |
1111 | return myNbCoeffInV; | |
1112 | } | |
1113 | ||
1114 | //============================================================================ | |
1115 | //function : ChangeNbCoeff | |
0d969553 | 1116 | //purpose : allows increasing the nb of coeff (cf Network) |
7fd59977 | 1117 | //============================================================================ |
1118 | ||
1119 | void AdvApp2Var_Patch::ChangeNbCoeff(const Standard_Integer NbCoeffU, | |
1120 | const Standard_Integer NbCoeffV) | |
1121 | { | |
1122 | if (myNbCoeffInU<NbCoeffU) myNbCoeffInU = NbCoeffU; | |
1123 | if (myNbCoeffInV<NbCoeffV) myNbCoeffInV = NbCoeffV; | |
1124 | } | |
1125 | ||
1126 | //============================================================================ | |
1127 | //function : MaxErrors | |
0d969553 | 1128 | //purpose : returns max errors of polynomial approximation |
7fd59977 | 1129 | //============================================================================ |
1130 | ||
1131 | Handle(TColStd_HArray1OfReal) | |
1132 | AdvApp2Var_Patch::MaxErrors() const | |
1133 | { | |
1134 | return myMaxErrors; | |
1135 | } | |
1136 | ||
1137 | //============================================================================ | |
1138 | //function : AverageErrors | |
0d969553 | 1139 | //purpose : returns average errors of polynomial approximation |
7fd59977 | 1140 | //============================================================================ |
1141 | ||
1142 | Handle(TColStd_HArray1OfReal) | |
1143 | AdvApp2Var_Patch::AverageErrors() const | |
1144 | { | |
1145 | return myMoyErrors; | |
1146 | } | |
1147 | ||
1148 | //============================================================================ | |
1149 | //function : IsoErrors | |
0d969553 | 1150 | //purpose : returns max errors on borders of polynomial approximation |
7fd59977 | 1151 | //============================================================================ |
1152 | ||
1153 | Handle(TColStd_HArray2OfReal) | |
1154 | AdvApp2Var_Patch::IsoErrors() const | |
1155 | { | |
1156 | return myIsoErrors; | |
1157 | } | |
1158 | ||
1159 | //============================================================================ | |
1160 | //function : Poles | |
0d969553 | 1161 | //purpose : returns poles of the polynomial approximation |
7fd59977 | 1162 | //============================================================================ |
1163 | ||
1164 | Handle(TColgp_HArray2OfPnt) | |
1165 | AdvApp2Var_Patch::Poles(const Standard_Integer SSPIndex, | |
1166 | const AdvApp2Var_Context & Cond) const | |
1167 | { | |
1168 | Handle(TColStd_HArray1OfReal) SousEquation; | |
1169 | if ( Cond.TotalNumberSSP( ) == 1 && SSPIndex == 1 ) { | |
1170 | SousEquation = myEquation; | |
1171 | } | |
1172 | else { | |
9775fa61 | 1173 | throw Standard_ConstructionError("AdvApp2Var_Patch::Poles : SSPIndex out of range"); |
7fd59977 | 1174 | } |
1175 | Handle(TColStd_HArray1OfReal) Intervalle = | |
1176 | new (TColStd_HArray1OfReal) (1,2); | |
1177 | Intervalle->SetValue(1, -1); | |
1178 | Intervalle->SetValue(2, 1); | |
1179 | ||
1180 | ||
1181 | Handle(TColStd_HArray1OfInteger) NbCoeff = | |
1182 | new (TColStd_HArray1OfInteger) (1,2); | |
1183 | NbCoeff->SetValue(1, myNbCoeffInU); | |
1184 | NbCoeff->SetValue(2, myNbCoeffInV); | |
1185 | ||
1186 | // Conversion | |
1187 | Convert_GridPolynomialToPoles | |
1188 | Conv (Cond.ULimit()-1, | |
1189 | Cond.VLimit()-1, | |
1190 | NbCoeff, | |
1191 | SousEquation, | |
1192 | Intervalle, | |
1193 | Intervalle); | |
1194 | ||
1195 | return Conv.Poles(); | |
1196 | } | |
1197 | ||
1198 | ||
1199 | //============================================================================ | |
1200 | //function : Coefficients | |
0d969553 | 1201 | //purpose : returns coeff. of the equation of polynomial approximation |
7fd59977 | 1202 | //============================================================================ |
1203 | ||
1204 | Handle(TColStd_HArray1OfReal) | |
1205 | AdvApp2Var_Patch::Coefficients(const Standard_Integer SSPIndex, | |
1206 | const AdvApp2Var_Context & Cond) const | |
1207 | { | |
1208 | Handle(TColStd_HArray1OfReal) SousEquation; | |
1209 | if ( Cond.TotalNumberSSP( ) == 1 && SSPIndex == 1 ) { | |
1210 | SousEquation = myEquation; | |
1211 | } | |
1212 | else { | |
9775fa61 | 1213 | throw Standard_ConstructionError("AdvApp2Var_Patch::Poles : SSPIndex out of range"); |
7fd59977 | 1214 | } |
1215 | return SousEquation; | |
1216 | } | |
1217 | ||
1218 | ||
1219 | //============================================================================ | |
1220 | //function : CritValue | |
1221 | //purpose : | |
1222 | //============================================================================ | |
1223 | ||
1224 | Standard_Real AdvApp2Var_Patch::CritValue() const | |
1225 | { | |
1226 | return myCritValue; | |
1227 | } | |
1228 | ||
1229 | ||
1230 | //============================================================================ | |
1231 | //function : SetCritValue | |
1232 | //purpose : | |
1233 | //============================================================================ | |
1234 | ||
1235 | void AdvApp2Var_Patch::SetCritValue(const Standard_Real dist) | |
1236 | { | |
1237 | myCritValue = dist; | |
1238 | } | |
1239 | ||
1240 | ||
1241 | ||
1242 | ||
1243 | ||
1244 | ||
1245 | ||
1246 | ||
1247 | ||
1248 | ||
1249 |