| 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 |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 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. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 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 | |
| 25 | #include <AdvApp2Var_Patch.ixx> |
| 26 | #include <AdvApp2Var_Node.hxx> |
| 27 | #include <AdvApp2Var_Iso.hxx> |
| 28 | #include <gp_Pnt.hxx> |
| 29 | #include <TColgp_HArray2OfPnt.hxx> |
| 30 | #include <TColgp_Array2OfPnt.hxx> |
| 31 | #include <TColStd_HArray1OfInteger.hxx> |
| 32 | #include <TColStd_HArray1OfReal.hxx> |
| 33 | #include <TColStd_HArray2OfReal.hxx> |
| 34 | #include <TColStd_Array2OfReal.hxx> |
| 35 | #include <Convert_GridPolynomialToPoles.hxx> |
| 36 | #include <Standard_ConstructionError.hxx> |
| 37 | |
| 38 | #include <AdvApp2Var_ApproxF2var.hxx> |
| 39 | #include <AdvApp2Var_MathBase.hxx> |
| 40 | |
| 41 | |
| 42 | //============================================================================ |
| 43 | //function : AdvApp2Var_Patch |
| 44 | //purpose : |
| 45 | //============================================================================ |
| 46 | |
| 47 | AdvApp2Var_Patch::AdvApp2Var_Patch() : |
| 48 | myU0(0.), |
| 49 | myU1(1.), |
| 50 | myV0(0.), |
| 51 | myV1(1.), |
| 52 | myOrdInU(0), |
| 53 | myOrdInV(0), |
| 54 | myNbCoeffInU(0), |
| 55 | myNbCoeffInV(0), |
| 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), |
| 81 | myNbCoeffInU(0), |
| 82 | myNbCoeffInV(0), |
| 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 | |
| 111 | // data stored in the Context |
| 112 | Standard_Integer NDIMEN, ISOFAV; |
| 113 | NDIMEN = Conditions.TotalDimension(); |
| 114 | // Attention : works only for 3D |
| 115 | ISOFAV = Conditions.FavorIso(); |
| 116 | |
| 117 | // data related to the patch to be discretized |
| 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 | |
| 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) |
| 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++) { |
| 143 | // factor of normalization |
| 144 | rho = pow(du,iu)*pow(dv,iv); |
| 145 | |
| 146 | // F(U0,V0) and its derivatives normalized on (-1,1) |
| 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 | |
| 154 | // F(U1,V0) and its derivatives normalized on (-1,1) |
| 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 | |
| 162 | // F(U0,V1) and its derivatives normalized on (-1,1) |
| 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 | |
| 170 | // F(U1,V1) and its derivatives normalized on (-1,1) |
| 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 | |
| 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 |
| 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 | |
| 211 | // normalization |
| 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 | |
| 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 |
| 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 | |
| 286 | // SOSOTB and DIDITB are dimensioned in FORTRAN at |
| 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 | |
| 302 | // SODITB and DISOTB are dimensioned in FORTRAN at |
| 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 | |
| 320 | // discretization of polynoms of interpolation |
| 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 | |
| 325 | // discretization of the square |
| 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 | |
| 363 | // the results are stored |
| 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 | { |
| 404 | // data stored in the Context |
| 405 | Standard_Integer NDIMEN; |
| 406 | Standard_Integer IERCOD, NCFLMU, NCFLMV, NDegU, NDegV; |
| 407 | NDIMEN = Conditions.TotalDimension(); |
| 408 | // Attention : works only for 3D |
| 409 | NCFLMU = Conditions.ULimit(); |
| 410 | NCFLMV = Conditions.VLimit(); |
| 411 | NDegU = NCFLMU - 1; |
| 412 | NDegV = NCFLMV - 1; |
| 413 | |
| 414 | // data relative to the patch |
| 415 | Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV; |
| 416 | Standard_Real *PATCAN = |
| 417 | (Standard_Real *) &myEquation ->ChangeArray1()(myEquation ->Lower()); |
| 418 | |
| 419 | // curves of approximation of Isos U |
| 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 | |
| 445 | // normalization of Isos U |
| 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 | |
| 460 | // curves of approximation of Isos V |
| 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 | |
| 486 | // normalization of Isos V |
| 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 | |
| 497 | // add constraints to constant V |
| 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) { |
| 505 | Standard_ConstructionError::Raise |
| 506 | ("AdvApp2Var_Patch::AddConstraints : Error in FORTRAN"); |
| 507 | } |
| 508 | AdvApp2Var_ApproxF2var::mma2ac2_(&NDIMEN, |
| 509 | &NDegU, |
| 510 | &NDegV, |
| 511 | &IORDRV, |
| 512 | &NCFLMU, |
| 513 | NCFV0, |
| 514 | IsoV0, |
| 515 | NCFV1, |
| 516 | IsoV1, |
| 517 | HermV, |
| 518 | PATCAN); |
| 519 | } |
| 520 | |
| 521 | // add constraints to constant U |
| 522 | Handle (TColStd_HArray1OfReal) HHERMU |
| 523 | = new TColStd_HArray1OfReal(1,(2*IORDRU+2)*(2*IORDRU+2)); |
| 524 | Standard_Real *HermU = |
| 525 | (Standard_Real *) &HHERMU ->ChangeArray1()(HHERMU ->Lower()); |
| 526 | if (IORDRU>=0) { |
| 527 | AdvApp2Var_ApproxF2var::mma1her_(&IORDRU,HermU,&IERCOD); |
| 528 | if (IERCOD!=0) { |
| 529 | Standard_ConstructionError::Raise |
| 530 | ("AdvApp2Var_Patch::AddConstraints : Error in FORTRAN"); |
| 531 | } |
| 532 | AdvApp2Var_ApproxF2var::mma2ac3_(&NDIMEN,&NDegU,&NDegV,&IORDRU,&NCFLMV, |
| 533 | NCFU0,IsoU0,NCFU1,IsoU1,HermU,PATCAN); |
| 534 | } |
| 535 | |
| 536 | // add constraints at the corners |
| 537 | Standard_Integer ideb; |
| 538 | SIZE=NDIMEN*(IORDRU+2)*(IORDRV+2); |
| 539 | Handle (TColStd_HArray1OfReal) HCOINS = |
| 540 | new TColStd_HArray1OfReal(1,SIZE*4); |
| 541 | |
| 542 | for (iu=0;iu<=myOrdInU;iu++) { |
| 543 | for (iv=0;iv<=myOrdInV;iv++) { |
| 544 | rho = pow(du,iu)*pow(dv,iv); |
| 545 | |
| 546 | // -F(U0,V0) and its derivatives normalized on (-1,1) |
| 547 | ideb = HCOINS->Lower() + NDIMEN*iu+NDIMEN*(IORDRU+2)*iv - 1; |
| 548 | valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).X(); |
| 549 | HCOINS->SetValue( 1+ideb , valnorm ); |
| 550 | valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Y(); |
| 551 | HCOINS->SetValue( 2+ideb , valnorm ); |
| 552 | valnorm = -rho * ((Constraints.Node(myU0,myV0)).Point(iu,iv)).Z(); |
| 553 | HCOINS->SetValue( 3+ideb , valnorm ); |
| 554 | |
| 555 | // -F(U1,V0) and its derivatives normalized on (-1,1) |
| 556 | ideb += SIZE; |
| 557 | valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).X(); |
| 558 | HCOINS->SetValue( 1+ideb , valnorm ); |
| 559 | valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Y(); |
| 560 | HCOINS->SetValue( 2+ideb , valnorm ); |
| 561 | valnorm = -rho * ((Constraints.Node(myU1,myV0)).Point(iu,iv)).Z(); |
| 562 | HCOINS->SetValue( 3+ideb , valnorm ); |
| 563 | |
| 564 | // -F(U0,V1) and its derivatives normalized on (-1,1) |
| 565 | ideb += SIZE; |
| 566 | valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).X(); |
| 567 | HCOINS->SetValue( 1+ideb , valnorm ); |
| 568 | valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Y(); |
| 569 | HCOINS->SetValue( 2+ideb , valnorm ); |
| 570 | valnorm = -rho * ((Constraints.Node(myU0,myV1)).Point(iu,iv)).Z(); |
| 571 | HCOINS->SetValue( 3+ideb , valnorm ); |
| 572 | |
| 573 | // -F(U1,V1) and its derivatives normalized on (-1,1) |
| 574 | ideb += SIZE; |
| 575 | valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).X(); |
| 576 | HCOINS->SetValue( 1+ideb , valnorm ); |
| 577 | valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Y(); |
| 578 | HCOINS->SetValue( 2+ideb , valnorm ); |
| 579 | valnorm = -rho * ((Constraints.Node(myU1,myV1)).Point(iu,iv)).Z(); |
| 580 | HCOINS->SetValue( 3+ideb , valnorm ); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // tables required for FORTRAN |
| 585 | Standard_Integer IORDMX = Max(IORDRU,IORDRV); |
| 586 | Handle (TColStd_HArray1OfReal) HEXTR = |
| 587 | new TColStd_HArray1OfReal(1,2*IORDMX+2); |
| 588 | Standard_Real *EXTR = |
| 589 | (Standard_Real *) &HEXTR ->ChangeArray1()(HEXTR ->Lower()); |
| 590 | Handle (TColStd_HArray1OfReal) HFACT = |
| 591 | new TColStd_HArray1OfReal(1,IORDMX+1); |
| 592 | Standard_Real *FACT = |
| 593 | (Standard_Real *) &HFACT ->ChangeArray1()(HFACT ->Lower()); |
| 594 | |
| 595 | Standard_Integer idim,ncf0,ncf1,iun=1; |
| 596 | Standard_Real *Is; |
| 597 | |
| 598 | // add extremities of isos U |
| 599 | for (iu=1;iu<=IORDRU+1;iu++) { |
| 600 | ncf0 = HCFU0->Value(HCFU0->Lower()+iu-1); |
| 601 | ncf1 = HCFU1->Value(HCFU1->Lower()+iu-1); |
| 602 | for (idim=1;idim<=NDIMEN;idim++) { |
| 603 | Is = IsoU0 + NCFLMV*(idim-1) + NCFLMV*NDIMEN*(iu-1); |
| 604 | AdvApp2Var_MathBase::mmdrc11_(&IORDRV,&iun,&ncf0,Is,EXTR,FACT); |
| 605 | for (iv=1;iv<=IORDRV+1;iv++) { |
| 606 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; |
| 607 | HCOINS->ChangeValue(idim+ideb) += HEXTR->Value(1+2*(iv-1)); |
| 608 | HCOINS->ChangeValue(2*SIZE+idim+ideb) += HEXTR->Value(2+2*(iv-1)); |
| 609 | } |
| 610 | Is = IsoU1 + NCFLMV*(idim-1) + NCFLMV*NDIMEN*(iu-1); |
| 611 | AdvApp2Var_MathBase::mmdrc11_(&IORDRV,&iun,&ncf1,Is,EXTR,FACT); |
| 612 | for (iv=1;iv<=IORDRV+1;iv++) { |
| 613 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; |
| 614 | HCOINS->ChangeValue(SIZE+idim+ideb) += HEXTR->Value(1+2*(iv-1)); |
| 615 | HCOINS->ChangeValue(3*SIZE+idim+ideb) += HEXTR->Value(2+2*(iv-1)); |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | // add extremities of isos V |
| 621 | for (iv=1;iv<=IORDRV+1;iv++) { |
| 622 | ncf0 = HCFV0->Value(HCFV0->Lower()+iv-1); |
| 623 | ncf1 = HCFV1->Value(HCFV1->Lower()+iv-1); |
| 624 | for (idim=1;idim<=NDIMEN;idim++) { |
| 625 | Is = IsoV0 + NCFLMU*(idim-1) + NCFLMU*NDIMEN*(iv-1); |
| 626 | AdvApp2Var_MathBase::mmdrc11_(&IORDRU,&iun,&ncf0,Is,EXTR,FACT); |
| 627 | for (iu=1;iu<=IORDRU+1;iu++) { |
| 628 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; |
| 629 | HCOINS->ChangeValue(idim+ideb) += HEXTR->Value(1+2*(iu-1)); |
| 630 | HCOINS->ChangeValue(SIZE+idim+ideb) += HEXTR->Value(2+2*(iu-1)); |
| 631 | } |
| 632 | Is = IsoV1 + NCFLMU*(idim-1) + NCFLMU*NDIMEN*(iv-1); |
| 633 | AdvApp2Var_MathBase::mmdrc11_(&IORDRU,&iun,&ncf1,Is,EXTR,FACT); |
| 634 | for (iu=1;iu<=IORDRU+1;iu++) { |
| 635 | ideb = HCOINS->Lower() + NDIMEN*(iu-1)+NDIMEN*(IORDRU+2)*(iv-1) - 1; |
| 636 | HCOINS->ChangeValue(2*SIZE+idim+ideb) += HEXTR->Value(1+2*(iu-1)); |
| 637 | HCOINS->ChangeValue(3*SIZE+idim+ideb) += HEXTR->Value(2+2*(iu-1)); |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | // add all to PATCAN |
| 643 | Standard_Real *C1 = |
| 644 | (Standard_Real *) &HCOINS ->ChangeArray1()(HCOINS ->Lower()); |
| 645 | Standard_Real *C2 = C1 + SIZE; |
| 646 | Standard_Real *C3 = C2 + SIZE; |
| 647 | Standard_Real *C4 = C3 + SIZE; |
| 648 | if ( IORDRU>=0 && IORDRV>=0 ) { |
| 649 | AdvApp2Var_ApproxF2var::mma2ac1_(&NDIMEN,&NDegU,&NDegV,&IORDRU,&IORDRV, |
| 650 | C1,C2,C3,C4,HermU,HermV,PATCAN); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | //============================================================================ |
| 655 | //function : AddErrors |
| 656 | //purpose : |
| 657 | //============================================================================ |
| 658 | |
| 659 | void AdvApp2Var_Patch::AddErrors(const AdvApp2Var_Framework& Constraints) |
| 660 | { |
| 661 | Standard_Integer NBSESP = 1, iesp; |
| 662 | Standard_Integer iu,iv; |
| 663 | |
| 664 | Standard_Real errU,errV,error,hmax[4]; |
| 665 | hmax[0] = 0; |
| 666 | hmax[1] = 1; |
| 667 | hmax[2] = 1.5; |
| 668 | hmax[3] = 1.75; |
| 669 | |
| 670 | for (iesp=1;iesp<=NBSESP;iesp++) { |
| 671 | // error max in sub-space iesp |
| 672 | errU=0.; |
| 673 | for (iv=1;iv<=myOrdInV+1;iv++) { |
| 674 | error = ((Constraints.IsoV(myU0,myU1,myV0)).MaxErrors())->Value(iesp,iv); |
| 675 | errU = Max(errU,error); |
| 676 | error = ((Constraints.IsoV(myU0,myU1,myV1)).MaxErrors())->Value(iesp,iv); |
| 677 | errU = Max(errU,error); |
| 678 | } |
| 679 | errV=0.; |
| 680 | for (iu=1;iu<=myOrdInU+1;iu++) { |
| 681 | error = ((Constraints.IsoU(myU0,myV0,myV1)).MaxErrors())->Value(iesp,iu); |
| 682 | errV = Max(errV,error); |
| 683 | error = ((Constraints.IsoU(myU1,myV0,myV1)).MaxErrors())->Value(iesp,iu); |
| 684 | errV = Max(errV,error); |
| 685 | } |
| 686 | myMaxErrors->ChangeValue(iesp) += |
| 687 | errU * hmax[myOrdInV+1] + errV * hmax[myOrdInU+1]; |
| 688 | |
| 689 | // average error in sub-space iesp |
| 690 | errU=0.; |
| 691 | for (iv=1;iv<=myOrdInV+1;iv++) { |
| 692 | error = ((Constraints.IsoV(myU0,myU1,myV0)).MoyErrors())->Value(iesp,iv); |
| 693 | errU = Max(errU,error); |
| 694 | error = ((Constraints.IsoV(myU0,myU1,myV1)).MoyErrors())->Value(iesp,iv); |
| 695 | errU = Max(errU,error); |
| 696 | } |
| 697 | errV=0.; |
| 698 | for (iu=1;iu<=myOrdInU+1;iu++) { |
| 699 | error = ((Constraints.IsoU(myU0,myV0,myV1)).MoyErrors())->Value(iesp,iu); |
| 700 | errV = Max(errV,error); |
| 701 | error = ((Constraints.IsoU(myU1,myV0,myV1)).MoyErrors())->Value(iesp,iu); |
| 702 | errV = Max(errV,error); |
| 703 | } |
| 704 | error = myMoyErrors->Value(iesp); |
| 705 | error *= error; |
| 706 | error += errU*hmax[myOrdInV+1] * errU*hmax[myOrdInV+1] |
| 707 | + errV*hmax[myOrdInU+1] * errV*hmax[myOrdInU+1]; |
| 708 | myMoyErrors->SetValue(iesp,Sqrt(error)); |
| 709 | |
| 710 | // max errors at iso-borders |
| 711 | Handle (TColStd_HArray2OfReal) HERISO |
| 712 | = new TColStd_HArray2OfReal(1,NBSESP,1,4); |
| 713 | HERISO->SetValue(iesp,1, |
| 714 | ((Constraints.IsoV(myU0,myU1,myV0)).MaxErrors())->Value(iesp,1)); |
| 715 | HERISO->SetValue(iesp,2, |
| 716 | ((Constraints.IsoV(myU0,myU1,myV1)).MaxErrors())->Value(iesp,1)); |
| 717 | HERISO->SetValue(iesp,3, |
| 718 | ((Constraints.IsoU(myU0,myV0,myV1)).MaxErrors())->Value(iesp,1)); |
| 719 | HERISO->SetValue(iesp,4, |
| 720 | ((Constraints.IsoU(myU1,myV0,myV1)).MaxErrors())->Value(iesp,1)); |
| 721 | |
| 722 | // calculate max errors at the corners |
| 723 | Standard_Real emax1=0.,emax2=0.,emax3=0.,emax4=0.,err1,err2,err3,err4; |
| 724 | for (iu=0;iu<=myOrdInU;iu++) { |
| 725 | for (iv=0;iv<=myOrdInV;iv++) { |
| 726 | error = (Constraints.Node(myU0,myV0)).Error(iu,iv); |
| 727 | emax1 = Max(emax1,error); |
| 728 | error = (Constraints.Node(myU1,myV0)).Error(iu,iv); |
| 729 | emax2 = Max(emax2,error); |
| 730 | error = (Constraints.Node(myU0,myV1)).Error(iu,iv); |
| 731 | emax3 = Max(emax3,error); |
| 732 | error = (Constraints.Node(myU1,myV1)).Error(iu,iv); |
| 733 | emax4 = Max(emax4,error); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | // calculate max errors on borders |
| 738 | err1 = Max(emax1,emax2); |
| 739 | err2 = Max(emax3,emax4); |
| 740 | err3 = Max(emax1,emax3); |
| 741 | err4 = Max(emax2,emax4); |
| 742 | |
| 743 | // calculate final errors on internal isos |
| 744 | if ( (Constraints.IsoV(myU0,myU1,myV0)).Position() == 0 ) { |
| 745 | HERISO ->ChangeValue(iesp,1) += err1*hmax[myOrdInU+1]; |
| 746 | } |
| 747 | if ( (Constraints.IsoV(myU0,myU1,myV1)).Position() == 0 ) { |
| 748 | HERISO ->ChangeValue(iesp,2) += err2*hmax[myOrdInU+1]; |
| 749 | } |
| 750 | if ( (Constraints.IsoU(myU0,myV0,myV1)).Position() == 0 ) { |
| 751 | HERISO ->ChangeValue(iesp,3) += err3*hmax[myOrdInV+1]; |
| 752 | } |
| 753 | if ( (Constraints.IsoU(myU1,myV0,myV1)).Position() == 0 ) { |
| 754 | HERISO ->ChangeValue(iesp,4) += err4*hmax[myOrdInV+1]; |
| 755 | } |
| 756 | myIsoErrors = HERISO; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | //============================================================================ |
| 761 | //function : MakeApprox |
| 762 | //purpose : |
| 763 | //============================================================================ |
| 764 | |
| 765 | void AdvApp2Var_Patch::MakeApprox(const AdvApp2Var_Context& Conditions, |
| 766 | const AdvApp2Var_Framework& Constraints, |
| 767 | const Standard_Integer NumDec) |
| 768 | { |
| 769 | |
| 770 | // data stored in the Context |
| 771 | Standard_Integer NDIMEN, NBSESP, NDIMSE; |
| 772 | Standard_Integer NBPNTU, NBPNTV, NCFLMU, NCFLMV, NDJACU, NDJACV; |
| 773 | Standard_Integer NDegU, NDegV, NJacU, NJacV; |
| 774 | NDIMEN = Conditions.TotalDimension(); |
| 775 | NBSESP = Conditions.TotalNumberSSP(); |
| 776 | NDIMSE = 3; |
| 777 | NBPNTU = (Conditions.URoots())->Length(); |
| 778 | if (myOrdInU>-1) NBPNTU -= 2; |
| 779 | NBPNTV = (Conditions.VRoots())->Length(); |
| 780 | if (myOrdInV>-1) NBPNTV -= 2; |
| 781 | NCFLMU = Conditions.ULimit(); |
| 782 | NCFLMV = Conditions.VLimit(); |
| 783 | NDegU = NCFLMU - 1; |
| 784 | NDegV = NCFLMV - 1; |
| 785 | NDJACU = Conditions.UJacDeg(); |
| 786 | NDJACV = Conditions.VJacDeg(); |
| 787 | NJacU = NDJACU + 1; |
| 788 | NJacV = NDJACV + 1; |
| 789 | |
| 790 | // data relative to the processed patch |
| 791 | Standard_Integer IORDRU = myOrdInU, IORDRV = myOrdInV, |
| 792 | NDMINU = 1, NDMINV = 1, NCOEFU, NCOEFV; |
| 793 | // NDMINU and NDMINV depend on the nb of coeff of neighboring isos |
| 794 | // and of the required order of continuity |
| 795 | NDMINU = Max(1,2*IORDRU+1); |
| 796 | NCOEFU = (Constraints.IsoV(myU0,myU1,myV0)).NbCoeff()-1; |
| 797 | NDMINU = Max(NDMINU,NCOEFU); |
| 798 | NCOEFU = (Constraints.IsoV(myU0,myU1,myV1)).NbCoeff()-1; |
| 799 | NDMINU = Max(NDMINU,NCOEFU); |
| 800 | |
| 801 | NDMINV = Max(1,2*IORDRV+1); |
| 802 | NCOEFV = (Constraints.IsoU(myU0,myV0,myV1)).NbCoeff()-1; |
| 803 | NDMINV = Max(NDMINV,NCOEFV); |
| 804 | NCOEFV = (Constraints.IsoU(myU1,myV0,myV1)).NbCoeff()-1; |
| 805 | NDMINV = Max(NDMINV,NCOEFV); |
| 806 | |
| 807 | // tables of approximations |
| 808 | Handle (TColStd_HArray1OfReal) HEPSAPR = |
| 809 | new TColStd_HArray1OfReal(1,NBSESP); |
| 810 | Handle (TColStd_HArray1OfReal) HEPSFRO = |
| 811 | new TColStd_HArray1OfReal(1,NBSESP*8); |
| 812 | Standard_Integer iesp; |
| 813 | for (iesp=1;iesp<=NBSESP;iesp++) { |
| 814 | HEPSAPR->SetValue(iesp,(Conditions.IToler())->Value(iesp)); |
| 815 | HEPSFRO->SetValue(iesp,(Conditions.FToler())->Value(iesp,1)); |
| 816 | HEPSFRO->SetValue(iesp+NBSESP,(Conditions.FToler())->Value(iesp,2)); |
| 817 | HEPSFRO->SetValue(iesp+2*NBSESP,(Conditions.FToler())->Value(iesp,3)); |
| 818 | HEPSFRO->SetValue(iesp+3*NBSESP,(Conditions.FToler())->Value(iesp,4)); |
| 819 | HEPSFRO->SetValue(iesp+4*NBSESP,(Conditions.CToler())->Value(iesp,1)); |
| 820 | HEPSFRO->SetValue(iesp+5*NBSESP,(Conditions.CToler())->Value(iesp,2)); |
| 821 | HEPSFRO->SetValue(iesp+6*NBSESP,(Conditions.CToler())->Value(iesp,3)); |
| 822 | HEPSFRO->SetValue(iesp+7*NBSESP,(Conditions.CToler())->Value(iesp,4)); |
| 823 | } |
| 824 | Standard_Real *EPSAPR = |
| 825 | (Standard_Real *) &HEPSAPR ->ChangeArray1()(HEPSAPR ->Lower()); |
| 826 | Standard_Real *EPSFRO = |
| 827 | (Standard_Real *) &HEPSFRO ->ChangeArray1()(HEPSFRO ->Lower()); |
| 828 | |
| 829 | Standard_Integer SIZE=(1+NDJACU)*(1+NDJACV)*NDIMEN; |
| 830 | Handle (TColStd_HArray1OfReal) HPJAC = |
| 831 | new TColStd_HArray1OfReal(1,SIZE); |
| 832 | Standard_Real *PATJAC = |
| 833 | (Standard_Real *) &HPJAC ->ChangeArray1()(HPJAC ->Lower()); |
| 834 | SIZE=2*SIZE; |
| 835 | Handle (TColStd_HArray1OfReal) HPAUX = |
| 836 | new TColStd_HArray1OfReal(1,SIZE); |
| 837 | Standard_Real *PATAUX = |
| 838 | (Standard_Real *) &HPAUX ->ChangeArray1()(HPAUX ->Lower()); |
| 839 | SIZE=NCFLMU*NCFLMV*NDIMEN; |
| 840 | Handle (TColStd_HArray1OfReal) HPCAN = |
| 841 | new TColStd_HArray1OfReal(1,SIZE); |
| 842 | Standard_Real *PATCAN = |
| 843 | (Standard_Real *) &HPCAN ->ChangeArray1()(HPCAN ->Lower()); |
| 844 | Handle (TColStd_HArray1OfReal) HERRMAX = |
| 845 | new TColStd_HArray1OfReal(1,NBSESP); |
| 846 | Standard_Real *ERRMAX = |
| 847 | (Standard_Real *) &HERRMAX ->ChangeArray1()(HERRMAX ->Lower()); |
| 848 | Handle (TColStd_HArray1OfReal) HERRMOY = |
| 849 | new TColStd_HArray1OfReal(1,NBSESP); |
| 850 | Standard_Real *ERRMOY = |
| 851 | (Standard_Real *) &HERRMOY ->ChangeArray1()(HERRMOY ->Lower()); |
| 852 | |
| 853 | // tables of discretization of the square |
| 854 | Standard_Real *SOSOTB = |
| 855 | (Standard_Real *) &mySosoTab ->ChangeArray1()(mySosoTab ->Lower()); |
| 856 | Standard_Real *DISOTB = |
| 857 | (Standard_Real *) &myDisoTab ->ChangeArray1()(myDisoTab ->Lower()); |
| 858 | Standard_Real *SODITB = |
| 859 | (Standard_Real *) &mySodiTab ->ChangeArray1()(mySodiTab ->Lower()); |
| 860 | Standard_Real *DIDITB = |
| 861 | (Standard_Real *) &myDidiTab ->ChangeArray1()(myDidiTab ->Lower()); |
| 862 | |
| 863 | // approximation |
| 864 | Standard_Integer ITYDEC=0, IERCOD=0; |
| 865 | Standard_Integer iun=1,itrois=3; |
| 866 | NCOEFU=0; |
| 867 | NCOEFV=0; |
| 868 | AdvApp2Var_ApproxF2var::mma2ce1_((integer *)&NumDec, |
| 869 | &NDIMEN, |
| 870 | &NBSESP, |
| 871 | &NDIMSE, |
| 872 | &NDMINU, |
| 873 | &NDMINV, |
| 874 | &NDegU, |
| 875 | &NDegV, |
| 876 | &NDJACU, |
| 877 | &NDJACV, |
| 878 | &IORDRU, |
| 879 | &IORDRV, |
| 880 | &NBPNTU, |
| 881 | &NBPNTV, |
| 882 | EPSAPR, |
| 883 | SOSOTB, |
| 884 | DISOTB, |
| 885 | SODITB, |
| 886 | DIDITB, |
| 887 | PATJAC, |
| 888 | ERRMAX, |
| 889 | ERRMOY, |
| 890 | &NCOEFU, |
| 891 | &NCOEFV, |
| 892 | &ITYDEC, |
| 893 | &IERCOD); |
| 894 | |
| 895 | // results |
| 896 | myCutSense = ITYDEC; |
| 897 | if (ITYDEC == 0 && IERCOD<=0) { |
| 898 | myHasResult = Standard_True; |
| 899 | myApprIsDone = (IERCOD==0); |
| 900 | myNbCoeffInU = NCOEFU+1; |
| 901 | myNbCoeffInV = NCOEFV+1; |
| 902 | myMaxErrors = HERRMAX; |
| 903 | myMoyErrors = HERRMOY; |
| 904 | |
| 905 | // Passage to canonic on [-1,1] |
| 906 | AdvApp2Var_MathBase::mmfmca9_(&NJacU,&NJacV,&NDIMEN,&myNbCoeffInU,&myNbCoeffInV, |
| 907 | &NDIMEN,PATJAC,PATJAC); |
| 908 | AdvApp2Var_ApproxF2var::mma2can_(&NCFLMU,&NCFLMV,&NDIMEN, |
| 909 | &myOrdInU,&myOrdInV,&myNbCoeffInU, |
| 910 | &myNbCoeffInV, |
| 911 | PATJAC,PATAUX,PATCAN,&IERCOD); |
| 912 | if (IERCOD !=0) { |
| 913 | Standard_ConstructionError::Raise |
| 914 | ("AdvApp2Var_Patch::MakeApprox : Error in FORTRAN"); |
| 915 | } |
| 916 | myEquation = HPCAN; |
| 917 | |
| 918 | // Add constraints and errors |
| 919 | AddConstraints(Conditions,Constraints); |
| 920 | AddErrors(Constraints); |
| 921 | |
| 922 | // Reduction of degrees if possible |
| 923 | PATCAN = (Standard_Real *) |
| 924 | &myEquation->ChangeArray1()(myEquation ->Lower()); |
| 925 | |
| 926 | AdvApp2Var_ApproxF2var::mma2fx6_(&NCFLMU, |
| 927 | &NCFLMV, |
| 928 | &NDIMEN, |
| 929 | &NBSESP, |
| 930 | &itrois, |
| 931 | &iun, |
| 932 | &iun, |
| 933 | &IORDRU, |
| 934 | &IORDRV, |
| 935 | EPSAPR, |
| 936 | EPSFRO, |
| 937 | PATCAN, |
| 938 | ERRMAX, |
| 939 | &myNbCoeffInU, |
| 940 | &myNbCoeffInV); |
| 941 | |
| 942 | // transposition (NCFLMU,NCFLMV,NDIMEN)Fortran-C++ |
| 943 | Standard_Integer aIU, aIN, dim, ii, jj; |
| 944 | for (dim=1; dim<=NDIMEN; dim++){ |
| 945 | aIN = (dim-1)*NCFLMU*NCFLMV; |
| 946 | for (ii=1; ii<=NCFLMU; ii++) { |
| 947 | aIU = (ii-1)*NDIMEN*NCFLMV; |
| 948 | for (jj=1; jj<=NCFLMV; jj++) { |
| 949 | HPAUX->SetValue(dim+NDIMEN*(jj-1)+aIU , |
| 950 | myEquation->Value(ii+NCFLMU*(jj-1)+aIN) ); |
| 951 | } |
| 952 | } |
| 953 | } |
| 954 | myEquation = HPAUX; |
| 955 | } |
| 956 | else { |
| 957 | myApprIsDone = Standard_False; |
| 958 | myHasResult = Standard_False; |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | //============================================================================ |
| 963 | //function : ChangeDomain |
| 964 | //purpose : |
| 965 | //============================================================================ |
| 966 | |
| 967 | void AdvApp2Var_Patch::ChangeDomain(const Standard_Real a, |
| 968 | const Standard_Real b, |
| 969 | const Standard_Real c, |
| 970 | const Standard_Real d) |
| 971 | { |
| 972 | myU0 = a; |
| 973 | myU1 = b; |
| 974 | myV0 = c; |
| 975 | myV1 = d; |
| 976 | } |
| 977 | |
| 978 | //============================================================================ |
| 979 | //function : ResetApprox |
| 980 | //purpose : allows removing a result when it is necessary to cut |
| 981 | //============================================================================ |
| 982 | |
| 983 | void AdvApp2Var_Patch::ResetApprox() |
| 984 | { |
| 985 | myApprIsDone = Standard_False; |
| 986 | myHasResult = Standard_False; |
| 987 | } |
| 988 | |
| 989 | //============================================================================ |
| 990 | //function : OverwriteApprox |
| 991 | //purpose : allows preserving a result even if the precision is not satisfactory |
| 992 | //============================================================================ |
| 993 | |
| 994 | void AdvApp2Var_Patch::OverwriteApprox() |
| 995 | { |
| 996 | if (myHasResult) myApprIsDone = Standard_True; |
| 997 | } |
| 998 | |
| 999 | //============================================================================ |
| 1000 | //function : U0 |
| 1001 | //purpose : |
| 1002 | //============================================================================ |
| 1003 | |
| 1004 | Standard_Real AdvApp2Var_Patch::U0() const |
| 1005 | { |
| 1006 | return myU0; |
| 1007 | } |
| 1008 | |
| 1009 | //============================================================================ |
| 1010 | //function : U1 |
| 1011 | //purpose : |
| 1012 | //============================================================================ |
| 1013 | |
| 1014 | Standard_Real AdvApp2Var_Patch::U1() const |
| 1015 | { |
| 1016 | return myU1; |
| 1017 | } |
| 1018 | |
| 1019 | //============================================================================ |
| 1020 | //function : V0 |
| 1021 | //purpose : |
| 1022 | //============================================================================ |
| 1023 | |
| 1024 | Standard_Real AdvApp2Var_Patch::V0() const |
| 1025 | { |
| 1026 | return myV0; |
| 1027 | } |
| 1028 | |
| 1029 | //============================================================================ |
| 1030 | //function : V1 |
| 1031 | //purpose : |
| 1032 | //============================================================================ |
| 1033 | |
| 1034 | Standard_Real AdvApp2Var_Patch::V1() const |
| 1035 | { |
| 1036 | return myV1; |
| 1037 | } |
| 1038 | |
| 1039 | //============================================================================ |
| 1040 | //function : UOrder |
| 1041 | //purpose : |
| 1042 | //============================================================================ |
| 1043 | |
| 1044 | Standard_Integer AdvApp2Var_Patch::UOrder() const |
| 1045 | { |
| 1046 | return myOrdInU; |
| 1047 | } |
| 1048 | |
| 1049 | |
| 1050 | //============================================================================ |
| 1051 | //function : VOrder |
| 1052 | //purpose : |
| 1053 | //============================================================================ |
| 1054 | |
| 1055 | Standard_Integer AdvApp2Var_Patch::VOrder() const |
| 1056 | { |
| 1057 | return myOrdInV; |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | //============================================================================ |
| 1062 | //function : CutSense without Critere |
| 1063 | //purpose : 0 : OK; 1 : required cut by U; |
| 1064 | // 2 : required cut by V; 3 : required cut by U and by V |
| 1065 | //============================================================================ |
| 1066 | |
| 1067 | Standard_Integer AdvApp2Var_Patch::CutSense() const |
| 1068 | { |
| 1069 | return myCutSense; |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | //============================================================================ |
| 1074 | //function : CutSense with critere |
| 1075 | //purpose : 0 : OK; 1 : required cut by U; |
| 1076 | // 2 : required cut by V; 3 : required cut by U and by V |
| 1077 | //============================================================================ |
| 1078 | |
| 1079 | Standard_Integer AdvApp2Var_Patch::CutSense(const AdvApp2Var_Criterion& Crit, |
| 1080 | const Standard_Integer NumDec) const |
| 1081 | { |
| 1082 | Standard_Boolean CritRel = (Crit.Type() == AdvApp2Var_Relative); |
| 1083 | if ( CritRel && !IsApproximated()) { |
| 1084 | return myCutSense; |
| 1085 | } |
| 1086 | else { |
| 1087 | if (Crit.IsSatisfied(*this)) { |
| 1088 | return 0; |
| 1089 | } |
| 1090 | else { |
| 1091 | return NumDec; |
| 1092 | } |
| 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | |
| 1097 | //============================================================================ |
| 1098 | //function : NbCoeffInU |
| 1099 | //purpose : |
| 1100 | //============================================================================ |
| 1101 | |
| 1102 | Standard_Integer AdvApp2Var_Patch::NbCoeffInU() const |
| 1103 | { |
| 1104 | return myNbCoeffInU; |
| 1105 | } |
| 1106 | |
| 1107 | //============================================================================ |
| 1108 | //function : NbCoeffInV |
| 1109 | //purpose : |
| 1110 | //============================================================================ |
| 1111 | |
| 1112 | Standard_Integer AdvApp2Var_Patch::NbCoeffInV() const |
| 1113 | { |
| 1114 | return myNbCoeffInV; |
| 1115 | } |
| 1116 | |
| 1117 | //============================================================================ |
| 1118 | //function : ChangeNbCoeff |
| 1119 | //purpose : allows increasing the nb of coeff (cf Network) |
| 1120 | //============================================================================ |
| 1121 | |
| 1122 | void AdvApp2Var_Patch::ChangeNbCoeff(const Standard_Integer NbCoeffU, |
| 1123 | const Standard_Integer NbCoeffV) |
| 1124 | { |
| 1125 | if (myNbCoeffInU<NbCoeffU) myNbCoeffInU = NbCoeffU; |
| 1126 | if (myNbCoeffInV<NbCoeffV) myNbCoeffInV = NbCoeffV; |
| 1127 | } |
| 1128 | |
| 1129 | //============================================================================ |
| 1130 | //function : MaxErrors |
| 1131 | //purpose : returns max errors of polynomial approximation |
| 1132 | //============================================================================ |
| 1133 | |
| 1134 | Handle(TColStd_HArray1OfReal) |
| 1135 | AdvApp2Var_Patch::MaxErrors() const |
| 1136 | { |
| 1137 | return myMaxErrors; |
| 1138 | } |
| 1139 | |
| 1140 | //============================================================================ |
| 1141 | //function : AverageErrors |
| 1142 | //purpose : returns average errors of polynomial approximation |
| 1143 | //============================================================================ |
| 1144 | |
| 1145 | Handle(TColStd_HArray1OfReal) |
| 1146 | AdvApp2Var_Patch::AverageErrors() const |
| 1147 | { |
| 1148 | return myMoyErrors; |
| 1149 | } |
| 1150 | |
| 1151 | //============================================================================ |
| 1152 | //function : IsoErrors |
| 1153 | //purpose : returns max errors on borders of polynomial approximation |
| 1154 | //============================================================================ |
| 1155 | |
| 1156 | Handle(TColStd_HArray2OfReal) |
| 1157 | AdvApp2Var_Patch::IsoErrors() const |
| 1158 | { |
| 1159 | return myIsoErrors; |
| 1160 | } |
| 1161 | |
| 1162 | //============================================================================ |
| 1163 | //function : Poles |
| 1164 | //purpose : returns poles of the polynomial approximation |
| 1165 | //============================================================================ |
| 1166 | |
| 1167 | Handle(TColgp_HArray2OfPnt) |
| 1168 | AdvApp2Var_Patch::Poles(const Standard_Integer SSPIndex, |
| 1169 | const AdvApp2Var_Context & Cond) const |
| 1170 | { |
| 1171 | Handle(TColStd_HArray1OfReal) SousEquation; |
| 1172 | if ( Cond.TotalNumberSSP( ) == 1 && SSPIndex == 1 ) { |
| 1173 | SousEquation = myEquation; |
| 1174 | } |
| 1175 | else { |
| 1176 | Standard_ConstructionError::Raise |
| 1177 | ("AdvApp2Var_Patch::Poles : SSPIndex out of range"); |
| 1178 | } |
| 1179 | Handle(TColStd_HArray1OfReal) Intervalle = |
| 1180 | new (TColStd_HArray1OfReal) (1,2); |
| 1181 | Intervalle->SetValue(1, -1); |
| 1182 | Intervalle->SetValue(2, 1); |
| 1183 | |
| 1184 | |
| 1185 | Handle(TColStd_HArray1OfInteger) NbCoeff = |
| 1186 | new (TColStd_HArray1OfInteger) (1,2); |
| 1187 | NbCoeff->SetValue(1, myNbCoeffInU); |
| 1188 | NbCoeff->SetValue(2, myNbCoeffInV); |
| 1189 | |
| 1190 | // Conversion |
| 1191 | Convert_GridPolynomialToPoles |
| 1192 | Conv (Cond.ULimit()-1, |
| 1193 | Cond.VLimit()-1, |
| 1194 | NbCoeff, |
| 1195 | SousEquation, |
| 1196 | Intervalle, |
| 1197 | Intervalle); |
| 1198 | |
| 1199 | return Conv.Poles(); |
| 1200 | } |
| 1201 | |
| 1202 | |
| 1203 | //============================================================================ |
| 1204 | //function : Coefficients |
| 1205 | //purpose : returns coeff. of the equation of polynomial approximation |
| 1206 | //============================================================================ |
| 1207 | |
| 1208 | Handle(TColStd_HArray1OfReal) |
| 1209 | AdvApp2Var_Patch::Coefficients(const Standard_Integer SSPIndex, |
| 1210 | const AdvApp2Var_Context & Cond) const |
| 1211 | { |
| 1212 | Handle(TColStd_HArray1OfReal) SousEquation; |
| 1213 | if ( Cond.TotalNumberSSP( ) == 1 && SSPIndex == 1 ) { |
| 1214 | SousEquation = myEquation; |
| 1215 | } |
| 1216 | else { |
| 1217 | Standard_ConstructionError::Raise |
| 1218 | ("AdvApp2Var_Patch::Poles : SSPIndex out of range"); |
| 1219 | } |
| 1220 | return SousEquation; |
| 1221 | } |
| 1222 | |
| 1223 | |
| 1224 | //============================================================================ |
| 1225 | //function : CritValue |
| 1226 | //purpose : |
| 1227 | //============================================================================ |
| 1228 | |
| 1229 | Standard_Real AdvApp2Var_Patch::CritValue() const |
| 1230 | { |
| 1231 | return myCritValue; |
| 1232 | } |
| 1233 | |
| 1234 | |
| 1235 | //============================================================================ |
| 1236 | //function : SetCritValue |
| 1237 | //purpose : |
| 1238 | //============================================================================ |
| 1239 | |
| 1240 | void AdvApp2Var_Patch::SetCritValue(const Standard_Real dist) |
| 1241 | { |
| 1242 | myCritValue = dist; |
| 1243 | } |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | |
| 1253 | |
| 1254 | |