diff --git a/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cdl b/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cdl index 9a3312769b..45413275ac 100755 --- a/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cdl +++ b/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cdl @@ -49,25 +49,7 @@ class ApproxAFunc2Var from AdvApp2Var -- and Num3DSS must be equal to 1. -- Warning: -- the Function of type EvaluatorFunc2Var from Approx - -- must be an extern "C" function - -- - -- The evaluator Function has the following type : - -- typedef void (* AdvApp2Var_EvaluatorFunc2Var) - -- (Standard_Integer *, // Total Dimension - -- Standard_Real *, // StartEndInU[2] - -- Standard_Real *, // StartEndInV[2] - -- Standard_Integer *, // 1 for U = cte - -- // 2 for V = cte - -- Standard_Real *, // Value of cte - -- Standard_Integer *, // Number N of parameters - -- Standard_Real *, // Tab[N] of parameters at - -- // which evaluation - -- // should take place - -- Standard_Integer *, // U-Derivative Request - -- Standard_Integer *, // V-Derivative Request - -- Standard_Real *, // Result[Dimension,N] - -- Standard_Integer * // Error Code - -- ) ; + -- must be a subclass of AdvApp2Var_EvaluatorFunc2Var -- -- the result should be formatted in the following way : -- <--Num1DSS--> <--2 * Num2DSS--> <--3 * Num3DSS--> @@ -379,8 +361,6 @@ fields myMaxPatches : Integer ; -- maximum of patches allowed -- - myEvaluator : EvaluatorFunc2Var from AdvApp2Var ; - -- external function -- myConditions : Context from AdvApp2Var; myResult : Network from AdvApp2Var; diff --git a/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx b/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx index e4a8786950..c1d0ae0f6a 100755 --- a/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx +++ b/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx @@ -78,7 +78,6 @@ myPrecisionCode(PrecisCode), myMaxDegInU(MaxDegInU), myMaxDegInV(MaxDegInV), myMaxPatches(MaxPatch), -myEvaluator(Func), myDone(Standard_False), myHasResult(Standard_False) { @@ -86,7 +85,7 @@ myHasResult(Standard_False) myNumSubSpaces[1] = Num2DSS; myNumSubSpaces[2] = Num3DSS; Init(); - Perform(UChoice,VChoice,Func); + Perform(UChoice, VChoice, Func); ConvertBS(); } @@ -137,7 +136,6 @@ myPrecisionCode(PrecisCode), myMaxDegInU(MaxDegInU), myMaxDegInV(MaxDegInV), myMaxPatches(MaxPatch), -myEvaluator(Func), myDone(Standard_False), myHasResult(Standard_False) { @@ -145,7 +143,7 @@ myHasResult(Standard_False) myNumSubSpaces[1] = Num2DSS; myNumSubSpaces[2] = Num3DSS; Init(); - Perform(UChoice,VChoice,Func,Crit); + Perform(UChoice, VChoice, Func, Crit); ConvertBS(); } diff --git a/src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx b/src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx index ef083f3166..fe1975d27f 100755 --- a/src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx +++ b/src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx @@ -130,19 +130,7 @@ static int mma2ds2_(integer *ndimen, doublereal *uintfn, doublereal *vintfn, - void (*foncnp) ( - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, integer *nbpntu, integer *nbpntv, doublereal *urootb, @@ -162,19 +150,7 @@ int mma2ds2_(integer *ndimen, static int mma1fdi_(integer *ndimen, doublereal *uvfonc, - void (*foncnp) (// see AdvApp2Var_EvaluatorFunc2Var.hxx for details - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, integer *isofav, doublereal *tconst, integer *nbroot, @@ -293,7 +269,7 @@ int mma1cdi_(integer *ndimen, somtab_dim1, somtab_offset, diftab_dim1, diftab_offset, fpntab_dim1, fpntab_offset, hermit_dim1, hermit_offset, i__1, i__2, i__3; - + /* Local variables */ static integer nroo2, ncfhe, nd, ii, kk; static integer ibb, kkm, kkp; @@ -512,12 +488,12 @@ int mma1cnt_(integer *ndimen, integer contr1_dim1, contr1_offset, contr2_dim1, contr2_offset, hermit_dim1, hermit_offset, crvjac_dim1, crvjac_offset, i__1, i__2, i__3; - + /* Local variables */ static integer nd, ii, jj, ibb; static doublereal bid; - - + + /* *********************************************************************** */ @@ -631,19 +607,7 @@ int mma1cnt_(integer *ndimen, //======================================================================= int mma1fdi_(integer *ndimen, doublereal *uvfonc, - void (*foncnp) (// see AdvApp2Var_EvaluatorFunc2Var.hxx for details - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, integer *isofav, doublereal *tconst, integer *nbroot, @@ -662,13 +626,13 @@ int mma1fdi_(integer *ndimen, diftab_offset, contr1_dim1, contr1_offset, contr2_dim1, contr2_offset, i__1, i__2; doublereal d__1; - + /* Local variables */ static integer ideb, ifin, nroo2, ideru, iderv; static doublereal renor; static integer ii, nd, ibb, iim, nbp, iip; static doublereal bid1, bid2; - + /* ********************************************************************** */ @@ -819,7 +783,7 @@ int mma1fdi_(integer *ndimen, /* ---------------------- Legendre polynom of degree NBROOT ------------------- */ - (*foncnp)(ndimen, + foncnp.Evaluate (ndimen, &uvfonc[3], &uvfonc[5], isofav, @@ -891,8 +855,8 @@ int mma1fdi_(integer *ndimen, bid1 = (uvfonc[6] - uvfonc[5]) / 2.; i__1 = *iordre; for (iderv = 1; iderv <= i__1; ++iderv) { - (*foncnp)(ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, & - nbp, ttable, &ideru, &iderv, &contr1[(iderv + 1) * + foncnp.Evaluate (ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, + &nbp, ttable, &ideru, &iderv, &contr1[(iderv + 1) * contr1_dim1 + 1], iercod); if (*iercod > 0) { goto L9999; @@ -901,8 +865,8 @@ int mma1fdi_(integer *ndimen, } i__1 = *iordre; for (iderv = 1; iderv <= i__1; ++iderv) { - (*foncnp)(ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, & - nbp, &ttable[*nbroot + 1], &ideru, &iderv, &contr2[( + foncnp.Evaluate (ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, + &nbp, &ttable[*nbroot + 1], &ideru, &iderv, &contr2[( iderv + 1) * contr2_dim1 + 1], iercod); if (*iercod > 0) { goto L9999; @@ -915,8 +879,8 @@ int mma1fdi_(integer *ndimen, bid1 = (uvfonc[4] - uvfonc[3]) / 2.; i__1 = *iordre; for (ideru = 1; ideru <= i__1; ++ideru) { - (*foncnp)(ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, & - nbp, ttable, &ideru, &iderv, &contr1[(ideru + 1) * + foncnp.Evaluate (ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, + &nbp, ttable, &ideru, &iderv, &contr1[(ideru + 1) * contr1_dim1 + 1], iercod); if (*iercod > 0) { goto L9999; @@ -925,8 +889,8 @@ int mma1fdi_(integer *ndimen, } i__1 = *iordre; for (ideru = 1; ideru <= i__1; ++ideru) { - (*foncnp)(ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, & - nbp, &ttable[*nbroot + 1], &ideru, &iderv, &contr2[( + foncnp.Evaluate (ndimen, &uvfonc[3], &uvfonc[5], isofav, tconst, + &nbp, &ttable[*nbroot + 1], &ideru, &iderv, &contr2[( ideru + 1) * contr2_dim1 + 1], iercod); if (*iercod > 0) { goto L9999; @@ -986,12 +950,12 @@ int mma1fer_(integer *,//ndimen, { /* System generated locals */ integer crvjac_dim1, crvjac_offset, i__1, i__2; - + /* Local variables */ static integer idim, ncfja, ncfnw, ndses, ii, kk, ibb, ier; static integer nbr0; - - + + /* *********************************************************************** */ @@ -1101,7 +1065,7 @@ int mma1fer_(integer *,//ndimen, if (ncfnw <= *ncflim) { mmaperm_(&ncfja, &ndses, &ncfja, iordre, &crvjac[idim * crvjac_dim1], &ncfnw, &errmoy[ii]); - *ncoeff = max(ncfnw,*ncoeff); + *ncoeff = advapp_max(ncfnw,*ncoeff); /* ------------- Set the declined coefficients to 0.D0 ----------- -------- */ @@ -1180,10 +1144,10 @@ int AdvApp2Var_ApproxF2var::mma1her_(const integer *iordre, { /* System generated locals */ integer hermit_dim1, hermit_offset; - + /* Local variables */ static integer ibb; - + /* ********************************************************************** @@ -1348,7 +1312,7 @@ int mma1jak_(integer *ndimen, /* System generated locals */ integer somtab_dim1, somtab_offset, diftab_dim1, diftab_offset, crvjac_dim1, crvjac_offset, cgauss_dim1; - + /* Local variables */ static integer ibb; @@ -1463,8 +1427,7 @@ int mma1noc_(doublereal *dfuvin, /* System generated locals */ integer i__1; doublereal d__1; - - + /* Local variables */ static doublereal rider, riord; static integer nd, ibb; @@ -1597,12 +1560,10 @@ int mma1nop_(integer *nbroot, { /* System generated locals */ integer i__1; - + /* Local variables */ static doublereal alinu, blinu, alinv, blinv; static integer ii, ibb; - - /* *********************************************************************** */ @@ -1718,15 +1679,13 @@ int AdvApp2Var_ApproxF2var::mma2ac1_(integer const *ndimen, contr4_dim1, contr4_dim2, contr4_offset, uhermt_dim1, uhermt_offset, vhermt_dim1, vhermt_offset, patjac_dim1, patjac_dim2, patjac_offset, i__1, i__2, i__3, i__4, i__5; - + /* Local variables */ static logical ldbg; static integer ndgu, ndgv; static doublereal bidu1, bidu2, bidv1, bidv2; static integer ioru1, iorv1, ii, nd, jj, ku, kv; static doublereal cnt1, cnt2, cnt3, cnt4; - - /* ********************************************************************** */ @@ -1885,7 +1844,7 @@ int AdvApp2Var_ApproxF2var::mma2ac2_(const integer *ndimen, integer crbiv1_dim1, crbiv1_dim2, crbiv1_offset, crbiv2_dim1, crbiv2_dim2, crbiv2_offset, patjac_dim1, patjac_dim2, patjac_offset, vhermt_dim1, vhermt_offset, i__1, i__2, i__3, i__4; - + /* Local variables */ static logical ldbg; static integer ndgv1, ndgv2, ii, jj, nd, kk; @@ -2031,14 +1990,11 @@ int AdvApp2Var_ApproxF2var::mma2ac3_(const integer *ndimen, integer crbiu1_dim1, crbiu1_dim2, crbiu1_offset, crbiu2_dim1, crbiu2_dim2, crbiu2_offset, patjac_dim1, patjac_dim2, patjac_offset, uhermt_dim1, uhermt_offset, i__1, i__2, i__3, i__4; - + /* Local variables */ static logical ldbg; static integer ndgu1, ndgu2, ii, jj, nd, kk; static doublereal bid1, bid2; - - - /* ********************************************************************** */ @@ -2180,13 +2136,10 @@ int AdvApp2Var_ApproxF2var::mma2can_(const integer *ncfmxu, /* System generated locals */ integer patjac_dim1, patjac_dim2, patjac_offset, patcan_dim1, patcan_dim2, patcan_offset, i__1, i__2; - + /* Local variables */ static logical ldbg; static integer ilon1, ilon2, ii, nd; - - - /* ********************************************************************** */ @@ -2339,7 +2292,7 @@ int mma2cd1_(integer *ndimen, { static integer c__1 = 1; - + /* System generated locals */ integer contr1_dim1, contr1_dim2, contr1_offset, contr2_dim1, contr2_dim2, contr2_offset, contr3_dim1, contr3_dim2, contr3_offset, @@ -2357,9 +2310,6 @@ int mma2cd1_(integer *ndimen, static doublereal bid1, bid2, bid3, bid4; static doublereal diu1, diu2, div1, div2, sou1, sou2, sov1, sov2; - - - /* ********************************************************************** */ @@ -2710,7 +2660,7 @@ int mma2cd2_(integer *ndimen, sosotb_dim2, sosotb_offset, diditb_dim1, diditb_dim2, diditb_offset, soditb_dim1, soditb_dim2, soditb_offset, disotb_dim1, disotb_dim2, disotb_offset, i__1, i__2, i__3, i__4; - + /* Local variables */ static integer ncfhv, nuroo, nvroo, ii, nd, jj, kk, ibb, jjm, jjp; static doublereal bid1, bid2, bid3, bid4; @@ -3014,7 +2964,7 @@ int mma2cd3_(integer *ndimen, { static integer c__1 = 1; - + /* System generated locals */ integer sotbu1_dim1, sotbu1_dim2, sotbu1_offset, sotbu2_dim1, sotbu2_dim2, sotbu2_offset, ditbu1_dim1, ditbu1_dim2, ditbu1_offset, @@ -4437,12 +4387,12 @@ L400: L600: /* Computing MAX */ - i__1 = 1, i__2 = (*iordru << 1) + 1, i__1 = max(i__1,i__2); - minu = max(i__1,*ndminu); + i__1 = 1, i__2 = (*iordru << 1) + 1, i__1 = advapp_max(i__1,i__2); + minu = advapp_max(i__1,*ndminu); maxu = *ndguli; /* Computing MAX */ - i__1 = 1, i__2 = (*iordrv << 1) + 1, i__1 = max(i__1,i__2); - minv = max(i__1,*ndminv); + i__1 = 1, i__2 = (*iordrv << 1) + 1, i__1 = advapp_max(i__1,i__2); + minv = advapp_max(i__1,*ndminv); maxv = *ndgvli; idim = 1; i__1 = *nbsesp; @@ -4482,8 +4432,8 @@ L600: } /* --> Return the nb of coeffs of approximation. */ - *ndegpu = max(*ndegpu,nu); - *ndegpv = max(*ndegpv,nv); + *ndegpu = advapp_max(*ndegpu,nu); + *ndegpv = advapp_max(*ndegpv,nv); idim += ndses; /* L610: */ } @@ -4575,12 +4525,12 @@ L600: } else { /* Computing MAX */ - i__2 = 1, i__3 = (*iordru << 1) + 1, i__2 = max(i__2,i__3); - minu = max(i__2,*ndminu); + i__2 = 1, i__3 = (*iordru << 1) + 1, i__2 = advapp_max(i__2,i__3); + minu = advapp_max(i__2,*ndminu); maxu = *ndguli; /* Computing MAX */ - i__2 = 1, i__3 = (*iordrv << 1) + 1, i__2 = max(i__2,i__3); - minv = max(i__2,*ndminv); + i__2 = 1, i__3 = (*iordrv << 1) + 1, i__2 = advapp_max(i__2,i__3); + minv = advapp_max(i__2,*ndminv); maxv = *ndgvli; if (maxu >= (*iordru + 1) << 1 && maxv >= (*iordrv + 1) << 1) { mma2er2_(ndjacu, ndjacv, &ndses, &minu, &maxu, &minv, & @@ -4623,8 +4573,8 @@ L600: /* --------------- Return the nb of coeff of approximation --- -------- */ - *ndegpu = max(*ndegpu,nu); - *ndegpv = max(*ndegpv,nv); + *ndegpu = advapp_max(*ndegpu,nu); + *ndegpv = advapp_max(*ndegpv,nv); idim += ndses; /* L730: */ } @@ -4707,13 +4657,12 @@ int mma2cfu_(integer *ndujac, /* System generated locals */ integer sosotb_dim1, disotb_dim1, disotb_offset, soditb_dim1, soditb_offset, diditb_dim1, i__1, i__2; - + /* Local variables */ static logical ldbg; static integer nptu2, nptv2, ii, jj; static doublereal bid0, bid1, bid2; - /* ********************************************************************** */ @@ -4924,12 +4873,11 @@ int mma2cfv_(integer *ndvjac, /* System generated locals */ integer chpair_dim1, chpair_offset, chimpr_dim1, chimpr_offset, patjac_offset, i__1, i__2; - + /* Local variables */ static logical ldbg; static integer nptv2, ii, jj; static doublereal bid1; - /* ********************************************************************** */ @@ -5063,19 +5011,7 @@ int mma2cfv_(integer *ndvjac, int AdvApp2Var_ApproxF2var::mma2ds1_(integer *ndimen, doublereal *uintfn, doublereal *vintfn, - void (*foncnp) ( - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, integer *nbpntu, integer *nbpntv, doublereal *urootb, @@ -5101,8 +5037,6 @@ int AdvApp2Var_ApproxF2var::mma2ds1_(integer *ndimen, static integer ibid1, ibid2, iuouv, nd; static integer isz1, isz2; - - /* ********************************************************************** */ @@ -5397,19 +5331,7 @@ L9999: int mma2ds2_(integer *ndimen, doublereal *uintfn, doublereal *vintfn, - void (*foncnp) ( - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, integer *nbpntu, integer *nbpntv, doublereal *urootb, @@ -5664,8 +5586,8 @@ int mma2ds2_(integer *ndimen, i__1 = nvroo; for (iv = 1; iv <= i__1; ++iv) { tcons = blinv + alinv * vrootb[iv]; - (*foncnp)(ndimen, dbfn1, dbfn2, iiuouv, &tcons, nbpntu, & - ttable[1], &c__0, &c__0, &fpntab[fpntab_offset], iercod); + foncnp.Evaluate (ndimen, dbfn1, dbfn2, iiuouv, &tcons, nbpntu, + &ttable[1], &c__0, &c__0, &fpntab[fpntab_offset], iercod); if (*iercod > 0) { goto L9999; } @@ -5705,8 +5627,8 @@ int mma2ds2_(integer *ndimen, if (*nbpntv % 2 != 0) { tcons = blinv; - (*foncnp)(ndimen, dbfn1, dbfn2, iiuouv, &tcons, nbpntu, & - ttable[1], &c__0, &c__0, &fpntab[fpntab_offset], iercod); + foncnp.Evaluate (ndimen, dbfn1, dbfn2, iiuouv, &tcons, nbpntu, + &ttable[1], &c__0, &c__0, &fpntab[fpntab_offset], iercod); if (*iercod > 0) { goto L9999; } @@ -5735,8 +5657,8 @@ int mma2ds2_(integer *ndimen, i__1 = nvroo; for (iv = 1; iv <= i__1; ++iv) { tcons = alinv * vrootb[(*nbpntv + 1) / 2 + iv] + blinv; - (*foncnp)(ndimen, dbfn1, dbfn2, iiuouv, &tcons, nbpntu, & - ttable[1], &c__0, &c__0, &fpntab[fpntab_offset], iercod); + foncnp.Evaluate (ndimen, dbfn1, dbfn2, iiuouv, &tcons, nbpntu, + &ttable[1], &c__0, &c__0, &fpntab[fpntab_offset], iercod); if (*iercod > 0) { goto L9999; } @@ -5803,7 +5725,7 @@ int mma2er1_(integer *ndjacu, /* System generated locals */ integer patjac_dim1, patjac_dim2, patjac_offset, i__1, i__2, i__3; doublereal d__1; - + /* Local variables */ static logical ldbg; static integer minu, minv; @@ -5811,7 +5733,6 @@ int mma2er1_(integer *ndjacu, static integer ii, nd, jj; static doublereal bid0, bid1; - /* ********************************************************************** */ @@ -5916,7 +5837,7 @@ int mma2er1_(integer *ndjacu, i__3 = *maxdgu; for (ii = *mindgu; ii <= i__3; ++ii) { bid0 += (d__1 = patjac[ii + (jj + nd * patjac_dim2) * - patjac_dim1], abs(d__1)) * xmaxju[ii - minu]; + patjac_dim1], advapp_abs(d__1)) * xmaxju[ii - minu]; /* L300: */ } bid1 = bid0 * xmaxjv[jj - minv] + bid1; @@ -5970,7 +5891,7 @@ int mma2er2_(integer *ndjacu, /* System generated locals */ integer patjac_dim1, patjac_dim2, patjac_offset, i__1, i__2; doublereal d__1; - + /* Local variables */ static logical ldbg; static doublereal vaux[2]; @@ -5979,7 +5900,6 @@ int mma2er2_(integer *ndjacu, static integer ii, nd, jj, nu, nv; static doublereal bid0, bid1; - /* ********************************************************************** */ @@ -6101,7 +6021,7 @@ L1001: i__2 = nu; for (ii = i2rdu; ii <= i__2; ++ii) { bid1 += (d__1 = patjac[ii + (nv + nd * patjac_dim2) * - patjac_dim1], abs(d__1)) * xmaxju[ii - i2rdu] * bid0; + patjac_dim1], advapp_abs(d__1)) * xmaxju[ii - i2rdu] * bid0; /* L200: */ } vecerr[nd] = bid1; @@ -6126,7 +6046,7 @@ L1001: i__2 = nv; for (jj = i2rdv; jj <= i__2; ++jj) { bid1 += (d__1 = patjac[nu + (jj + nd * patjac_dim2) * - patjac_dim1], abs(d__1)) * xmaxjv[jj - i2rdv] * bid0; + patjac_dim1], advapp_abs(d__1)) * xmaxjv[jj - i2rdv] * bid0; /* L400: */ } vecerr[nd] = bid1; @@ -6169,8 +6089,8 @@ L1001: */ L2001: - *newdgu = max(nu,1); - *newdgv = max(nv,1); + *newdgu = advapp_max(nu,1); + *newdgv = advapp_max(nv,1); /* ----------------------------------- The end -------------------------- */ @@ -6189,19 +6109,7 @@ int AdvApp2Var_ApproxF2var::mma2fnc_(integer *ndimen, integer *nbsesp, integer *ndimse, doublereal *uvfonc, - void (*foncnp) ( - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, doublereal *tconst, integer *isofav, integer *nbroot, @@ -6463,10 +6371,10 @@ int AdvApp2Var_ApproxF2var::mma2fnc_(integer *ndimen, */ AdvApp2Var_MathBase::mmveps3_(&eps3); - if ((d__1 = uvfonc[4] - uvfonc[3], abs(d__1)) < eps3) { + if ((d__1 = uvfonc[4] - uvfonc[3], advapp_abs(d__1)) < eps3) { goto L9100; } - if ((d__1 = uvfonc[6] - uvfonc[5], abs(d__1)) < eps3) { + if ((d__1 = uvfonc[6] - uvfonc[5], advapp_abs(d__1)) < eps3) { goto L9100; } @@ -6488,9 +6396,9 @@ int AdvApp2Var_ApproxF2var::mma2fnc_(integer *ndimen, /* the auxiliary curve for MMAPCMP */ ibid1 = *ndimen * (*nbroot + 2); ibid2 = ((*iordre + 1) << 1) * *nbroot; - isz2 = max(ibid1,ibid2); + isz2 = advapp_max(ibid1,ibid2); ibid1 = (((*ncflim - 1) / 2 + 1) << 1) * *ndimen; - isz2 = max(ibid1,isz2); + isz2 = advapp_max(ibid1,isz2); /* --> To return the polynoms of hermit. */ isz3 = ((*iordre + 1) << 2) * (*iordre + 1); /* --> For the Gauss coeff. of integration. */ @@ -6783,12 +6691,12 @@ int AdvApp2Var_ApproxF2var::mma2fx6_(integer *ncfmxu, errmax_offset, ncoefu_dim1, ncoefu_offset, ncoefv_dim1, ncoefv_offset, i__1, i__2, i__3, i__4, i__5; doublereal d__1, d__2; - + /* Local variables */ static integer idim, ncfu, ncfv, id, ii, nd, jj, ku, kv, ns, ibb; static doublereal bid; static doublereal tol; - + /* ********************************************************************** */ @@ -6899,30 +6807,30 @@ L200: tol = epsapr[ns]; /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 9]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 10]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 11]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 12]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); if (ii == 1 || ii == *nbupat || jj == 1 || jj == *nbvpat) { /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 5]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 6]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 7]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + (epsfro_dim1 << 3)]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); } bid = 0.; @@ -6933,7 +6841,7 @@ L200: for (kv = 1; kv <= i__5; ++kv) { bid += (d__1 = patcan[ncfu + (kv + (id + (ii + jj * patcan_dim4) * patcan_dim3) * - patcan_dim2) * patcan_dim1], abs(d__1)); + patcan_dim2) * patcan_dim1], advapp_abs(d__1)); /* L230: */ } /* L220: */ @@ -6964,30 +6872,30 @@ L300: tol = epsapr[ns]; /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 9]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 10]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 11]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 12]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); if (ii == 1 || ii == *nbupat || jj == 1 || jj == *nbvpat) { /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 5]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 6]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + epsfro_dim1 * 7]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); /* Computing MIN */ d__1 = tol, d__2 = epsfro[ns + (epsfro_dim1 << 3)]; - tol = min(d__1,d__2); + tol = advapp_min(d__1,d__2); } bid = 0.; @@ -6998,7 +6906,7 @@ L300: for (ku = 1; ku <= i__5; ++ku) { bid += (d__1 = patcan[ku + (ncfv + (id + (ii + jj * patcan_dim4) * patcan_dim3) * - patcan_dim2) * patcan_dim1], abs(d__1)); + patcan_dim2) * patcan_dim1], advapp_abs(d__1)); /* L330: */ } /* L320: */ @@ -7019,8 +6927,8 @@ L300: /* --- Return the nbs of coeff. and pass to the next square --- */ L400: - ncoefu[ii + jj * ncoefu_dim1] = max(ncfu,2); - ncoefv[ii + jj * ncoefv_dim1] = max(ncfv,2); + ncoefu[ii + jj * ncoefu_dim1] = advapp_max(ncfu,2); + ncoefv[ii + jj * ncoefv_dim1] = advapp_max(ncfv,2); /* L110: */ } /* L100: */ @@ -7400,8 +7308,8 @@ int mma2moy_(integer *ndgumx, idebu = (*iordru + 1) << 1; idebv = (*iordrv + 1) << 1; - minu = max(idebu,*mindgu); - minv = max(idebv,*mindgv); + minu = advapp_max(idebu,*mindgu); + minv = advapp_max(idebv,*mindgv); bid0 = 0.; *errmoy = 0.; @@ -7465,7 +7373,7 @@ int AdvApp2Var_ApproxF2var::mma2roo_(integer *nbpntu, { /* System generated locals */ integer i__1; - + /* Local variables */ static integer ii, ibb; @@ -7571,13 +7479,11 @@ int mmmapcoe_(integer *ndim, /* System generated locals */ integer somtab_dim1, somtab_offset, diftab_dim1, diftab_offset, crvjac_dim1, crvjac_offset, gsstab_dim1, i__1, i__2, i__3; - + /* Local variables */ static integer igss, ikdeb; static doublereal bidon; static integer nd, ik, ir, nbroot, ibb; - - /* ********************************************************************** */ @@ -7739,8 +7645,6 @@ int mmaperm_(integer *ncofmx, static doublereal bidj; static integer i__, ia, nd, ncfcut, ibb; static doublereal bid; - - /* ********************************************************************** */ @@ -7845,11 +7749,9 @@ int AdvApp2Var_ApproxF2var::mmapptt_(const integer *ndgjac, { /* System generated locals */ integer cgauss_dim1, i__1; - + /* Local variables */ static integer kjac, iptt, ipdb0, infdg, iptdb, mxjac, ilong, ibb; - - /* ********************************************************************** */ diff --git a/src/AdvApp2Var/AdvApp2Var_ApproxF2var.hxx b/src/AdvApp2Var/AdvApp2Var_ApproxF2var.hxx index 37f840d7b6..039394d015 100755 --- a/src/AdvApp2Var/AdvApp2Var_ApproxF2var.hxx +++ b/src/AdvApp2Var/AdvApp2Var_ApproxF2var.hxx @@ -11,6 +11,7 @@ #include #include +#include // class AdvApp2Var_ApproxF2var { public: @@ -19,19 +20,7 @@ Standard_EXPORT static int mma2fnc_(integer *ndimen, integer *nbsesp, integer *ndimse, doublereal *uvfonc, - void(*foncnp) ( - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, doublereal *tconst, integer *isofav, integer *nbroot, @@ -100,19 +89,7 @@ Standard_EXPORT static int mma2cdi_(integer *ndimen, Standard_EXPORT static int mma2ds1_(integer *ndimen, doublereal *uintfn, doublereal *vintfn, - void (*foncnp) ( - int *, - double *, - double *, - int *, - double *, - int *, - double *, - int *, - int *, - double *, - int * - ), + const AdvApp2Var_EvaluatorFunc2Var& foncnp, integer *nbpntu, integer *nbpntv, doublereal *urootb, diff --git a/src/AdvApp2Var/AdvApp2Var_Data_f2c.hxx b/src/AdvApp2Var/AdvApp2Var_Data_f2c.hxx index f2bbaa5d6e..ce5d0861f3 100755 --- a/src/AdvApp2Var/AdvApp2Var_Data_f2c.hxx +++ b/src/AdvApp2Var/AdvApp2Var_Data_f2c.hxx @@ -155,12 +155,12 @@ struct Namelist { }; typedef struct Namelist Namelist; -#define abs(x) ((x) >= 0 ? (x) : -(x)) -#define dabs(x) (doublereal)abs(x) -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#define max(a,b) ((a) >= (b) ? (a) : (b)) -#define dmin(a,b) (doublereal)min(a,b) -#define dmax(a,b) (doublereal)max(a,b) +#define advapp_abs(x) ((x) >= 0 ? (x) : -(x)) +#define dabs(x) (doublereal)advapp_abs(x) +#define advapp_min(a,b) ((a) <= (b) ? (a) : (b)) +#define advapp_max(a,b) ((a) >= (b) ? (a) : (b)) +#define dmin(a,b) (doublereal)advapp_min(a,b) +#define dmax(a,b) (doublereal)advapp_max(a,b) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) diff --git a/src/AdvApp2Var/AdvApp2Var_EvaluatorFunc2Var.hxx b/src/AdvApp2Var/AdvApp2Var_EvaluatorFunc2Var.hxx index bc7fd86de5..fde17b6a66 100755 --- a/src/AdvApp2Var/AdvApp2Var_EvaluatorFunc2Var.hxx +++ b/src/AdvApp2Var/AdvApp2Var_EvaluatorFunc2Var.hxx @@ -3,7 +3,6 @@ // Author: Joelle CHAUVET // - #ifndef _Standard_Integer_HeaderFile #include #endif @@ -14,36 +13,59 @@ #include #endif - #ifndef AdvApp2Var_EvaluatorFunc2Var_HeaderFile #define AdvApp2Var_EvaluatorFunc2Var_HeaderFile -extern "C" { -typedef void (* AdvApp2Var_EvaluatorFunc2Var) (Standard_Integer *, - // Dimension - Standard_Real *, - // StartEnd[2] in U - Standard_Real *, - // StartEnd[2] in V - Standard_Integer *, - // Choice of constante, 1 for U, 2 for V - Standard_Real *, - // Value of constant parameter - Standard_Integer *, - // Number of parameters - Standard_Real *, - // Values of parameters, - Standard_Integer *, - // Derivative Request in U - Standard_Integer *, - // Derivative Request in V - Standard_Real *, - // Result[Dimension] - Standard_Integer *) ; - // Error Code +// History - the C function pointer converted to a virtual class +// in order to get rid of usage of static functions and static data +class AdvApp2Var_EvaluatorFunc2Var +{ +public: + //! Empty constructor + AdvApp2Var_EvaluatorFunc2Var() {} -} + //! Destructor should be declared as virtual + virtual ~AdvApp2Var_EvaluatorFunc2Var () {} + //! Function evaluation method to be defined by descendant + virtual void Evaluate (Standard_Integer* theDimension, + Standard_Real* theUStartEnd, + Standard_Real* theVStartEnd, + Standard_Integer* theFavorIso, //!< Choice of constante, 1 for U, 2 for V + Standard_Real* theConstParam, //!< Value of constant parameter + Standard_Integer* theNbParams, //!< Number of parameters N + Standard_Real* theParameters, //!< Values of parameters, + Standard_Integer* theUOrder, //!< Derivative Request in U + Standard_Integer* theVOrder, //!< Derivative Request in V + Standard_Real* theResult, //!< Result[Dimension,N] + Standard_Integer* theErrorCode) const = 0; + + //! Shortcut for function-call style usage + void operator() (Standard_Integer* theDimension, + Standard_Real* theUStartEnd, + Standard_Real* theVStartEnd, + Standard_Integer* theFavorIso, + Standard_Real* theConstParam, + Standard_Integer* theNbParams, + Standard_Real* theParameters, + Standard_Integer* theUOrder, + Standard_Integer* theVOrder, + Standard_Real* theResult, + Standard_Integer* theErrorCode) const + { + Evaluate (theDimension, theUStartEnd, theVStartEnd, theFavorIso, + theConstParam, theNbParams, + theParameters, theUOrder, theVOrder, theResult, theErrorCode); + } + +private: + + //! Copy constructor is declared private to forbid copying + AdvApp2Var_EvaluatorFunc2Var (const AdvApp2Var_EvaluatorFunc2Var& ) {} + + //! Assignment operator is declared private to forbid copying + void operator= (const AdvApp2Var_EvaluatorFunc2Var& ) {} +}; #endif diff --git a/src/AdvApp2Var/AdvApp2Var_MathBase.cxx b/src/AdvApp2Var/AdvApp2Var_MathBase.cxx index d8f91e87e4..dafb852c33 100755 --- a/src/AdvApp2Var/AdvApp2Var_MathBase.cxx +++ b/src/AdvApp2Var/AdvApp2Var_MathBase.cxx @@ -255,7 +255,7 @@ int AdvApp2Var_MathBase::mdsptpt_(integer *ndimen, /* System generated locals */ integer i__1; doublereal d__1; - + /* Local variables */ static integer i__; static doublereal differ[100]; @@ -405,12 +405,10 @@ int AdvApp2Var_MathBase::mmapcmp_(integer *ndim, /* System generated locals */ integer crvold_dim1, crvold_offset, crvnew_dim1, crvnew_offset, i__1, i__2; - + /* Local variables */ static integer ipair, nd, ndegre, impair, ibb, idg; //extern int mgsomsg_();//mgenmsg_(), - - /* ********************************************************************** */ @@ -523,12 +521,11 @@ int mmaper0_(integer *ncofmx, /* System generated locals */ integer crvlgd_dim1, crvlgd_offset, i__1, i__2; doublereal d__1; - + /* Local variables */ static integer ncut; - static doublereal bidon; + static doublereal bidon; static integer ii, nd; - /* *********************************************************************** */ @@ -608,7 +605,7 @@ int mmaper0_(integer *ncofmx, i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvlgd[ii + nd * crvlgd_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvlgd[ii + nd * crvlgd_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -776,7 +773,7 @@ int mmaper2_(integer *ncofmx, idec = 3; /* Computing MAX */ i__1 = idec, i__2 = *ncfnew + 1; - ncut = max(i__1,i__2); + ncut = advapp_max(i__1,i__2); /* -------------- Removal of coefficients of high degree ----------- */ @@ -789,7 +786,7 @@ int mmaper2_(integer *ncofmx, bidon = xmaxj[ii - idec]; i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvjac[ii + nd * crvjac_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvjac[ii + nd * crvjac_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -962,7 +959,7 @@ int mmaper4_(integer *ncofmx, idec = 5; /* Computing MAX */ i__1 = idec, i__2 = *ncfnew + 1; - ncut = max(i__1,i__2); + ncut = advapp_max(i__1,i__2); /* -------------- Removal of high degree coefficients ----------- */ @@ -975,7 +972,7 @@ int mmaper4_(integer *ncofmx, bidon = xmaxj[ii - idec]; i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvjac[ii + nd * crvjac_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvjac[ii + nd * crvjac_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -1139,7 +1136,7 @@ int mmaper6_(integer *ncofmx, idec = 7; /* Computing MAX */ i__1 = idec, i__2 = *ncfnew + 1; - ncut = max(i__1,i__2); + ncut = advapp_max(i__1,i__2); /* -------------- Removal of high degree coefficients ----------- */ @@ -1152,7 +1149,7 @@ int mmaper6_(integer *ncofmx, bidon = xmaxj[ii - idec]; i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvjac[ii + nd * crvjac_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvjac[ii + nd * crvjac_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -1187,10 +1184,9 @@ int AdvApp2Var_MathBase::mmaperx_(integer *ncofmx, { /* System generated locals */ integer crvjac_dim1, crvjac_offset; - + /* Local variables */ static integer jord; - /* ********************************************************************** */ @@ -1604,7 +1600,7 @@ int AdvApp2Var_MathBase::mmarcin_(integer *ndimax, /* At zero machine it is tested if the output interval is not null */ AdvApp2Var_MathBase::mmveps3_(&eps3); - if ((d__1 = *u1 - *u0, abs(d__1)) < eps3) { + if ((d__1 = *u1 - *u0, advapp_abs(d__1)) < eps3) { *iercod = 13; goto L9999; } @@ -2393,7 +2389,7 @@ L5000: /* ------ Take into account DIF - Test of convergence */ ++iter; - dif = (d__1 = sottc - oldso, abs(d__1)); + dif = (d__1 = sottc - oldso, advapp_abs(d__1)); /* ------ If DIF is OK, leave..., otherwise: */ @@ -2578,7 +2574,7 @@ int mmchole_(integer *,//mxcoef, /* Computing MAX */ i__2 = i__ - aposit[(i__ << 1) + 1], i__3 = j - aposit[(j << 1) + 1]; - kmin = max(i__2,i__3); + kmin = advapp_max(i__2,i__3); i__2 = j - 1; for (k = kmin; k <= i__2; ++k) { somme += chomat[aposit[(i__ << 1) + 2] - (i__ - k)] * chomat[ @@ -5192,12 +5188,12 @@ int mmherm0_(doublereal *debfin, --debfin; /* Function Body */ - d1 = abs(debfin[1]); + d1 = advapp_abs(debfin[1]); if (d1 > (float)100.) { goto L9101; } - d2 = abs(debfin[2]); + d2 = advapp_abs(debfin[2]); if (d2 > (float)100.) { goto L9101; } @@ -5207,7 +5203,7 @@ int mmherm0_(doublereal *debfin, goto L9101; } - d1 = (d__1 = debfin[2] - debfin[1], abs(d__1)); + d1 = (d__1 = debfin[2] - debfin[1], advapp_abs(d__1)); if (d1 / d2 < (float).01) { goto L9101; } @@ -5229,7 +5225,7 @@ int mmherm0_(doublereal *debfin, /* IS IT ALREADY INITIALIZED ? */ - d1 = abs(debfin[1]) + abs(debfin[2]); + d1 = advapp_abs(debfin[1]) + advapp_abs(debfin[2]); d1 *= 16111959; if (debfin[1] != mmcmher_.tdebut) { @@ -5370,7 +5366,7 @@ L100: mmcmher_.tdebut = debfin[1]; mmcmher_.tfinal = debfin[2]; - d1 = abs(debfin[1]) + abs(debfin[2]); + d1 = advapp_abs(debfin[1]) + advapp_abs(debfin[2]); mmcmher_.verifi = d1 * 16111959; @@ -5563,7 +5559,7 @@ int mmherm1_(doublereal *debfin, /* IS-IT CORRECTLY INITIALIZED ? */ - d1 = abs(debfin[1]) + abs(debfin[2]); + d1 = advapp_abs(debfin[1]) + advapp_abs(debfin[2]); d1 *= 16111959; /* OTHERWISE IT IS INITIALIZED */ @@ -6465,7 +6461,7 @@ int mmloncv_(integer *ndimax, /* ****** Calculate the optimal degree ** */ kk = *ncoeff / 4 + 1; - kk = min(kk,10); + kk = advapp_min(kk,10); /* ****** Return the coefficients for the integral (DEGRE=4*KK) */ /* if KK <> KGAR. */ @@ -6739,7 +6735,7 @@ L9900: /* Computing MAX */ i__1 = iorjac + 1; - nwcof = max(i__1,1); + nwcof = advapp_max(i__1,1); AdvApp2Var_SysBase::mvriraz_((integer *)&nwcof, (char *)wpoly); wpoly[0] = 1.; @@ -8117,7 +8113,7 @@ int mmrslw_(integer *normax, kpiv = 0; i__2 = *nordre; for (jj = kk; jj <= i__2; ++jj) { - akj = (d__1 = abmatr[kk + jj * abmatr_dim1], abs(d__1)); + akj = (d__1 = abmatr[kk + jj * abmatr_dim1], advapp_abs(d__1)); if (akj > pivot) { pivot = akj; kpiv = jj; @@ -8610,11 +8606,11 @@ L1000: */ L2000: - if ((d__1 = *tparam - tablev[ideb], abs(d__1)) < *epsil) { + if ((d__1 = *tparam - tablev[ideb], advapp_abs(d__1)) < *epsil) { *itypen = 1; goto L9999; } - if ((d__1 = *tparam - tablev[ifin], abs(d__1)) < *epsil) { + if ((d__1 = *tparam - tablev[ifin], advapp_abs(d__1)) < *epsil) { *itypen = 2; goto L9999; } @@ -8877,7 +8873,7 @@ int mmtrpj0_(integer *ncofmx, bidon = sqrt(bidon); i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -9061,7 +9057,7 @@ int mmtrpj2_(integer *ncofmx, bidon = xmaxj[i__ - ncut]; i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -9089,7 +9085,7 @@ L400: bid = 0.; i__1 = *ndimen; for (nd = 1; nd <= i__1; ++nd) { - bid += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)); + bid += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)); /* L600: */ } if (bid > eps1) { @@ -9266,7 +9262,7 @@ int mmtrpj4_(integer *ncofmx, bidon = xmaxj[i__ - ncut]; i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -9294,7 +9290,7 @@ L400: bid = 0.; i__1 = *ndimen; for (nd = 1; nd <= i__1; ++nd) { - bid += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)); + bid += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)); /* L600: */ } if (bid > eps1) { @@ -9469,7 +9465,7 @@ int mmtrpj6_(integer *ncofmx, bidon = xmaxj[i__ - ncut]; i__2 = *ndimen; for (nd = 1; nd <= i__2; ++nd) { - ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)) * + ycvmax[nd] += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)) * bidon; /* L310: */ } @@ -9497,7 +9493,7 @@ L400: bid = 0.; i__1 = *ndimen; for (nd = 1; nd <= i__1; ++nd) { - bid += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], abs(d__1)); + bid += (d__1 = crvlgd[i__ + nd * crvlgd_dim1], advapp_abs(d__1)); /* L600: */ } if (bid > eps1) { @@ -9716,7 +9712,7 @@ L9999: i__1 = *ndimen; for (ii = 1; ii <= i__1; ++ii) { vecnrm[ii] = vector[ii] / vnorm; - if ((d__1 = vecnrm[ii], abs(d__1)) <= eps0) { + if ((d__1 = vecnrm[ii], advapp_abs(d__1)) <= eps0) { ++izero; } else { iunit = ii; @@ -11251,7 +11247,7 @@ L9900: irmax = 1; i__1 = *ndimen; for (i__ = 2; i__ <= i__1; ++i__) { - if ((d__1 = vecteu[irmax], abs(d__1)) < (d__2 = vecteu[i__], abs(d__2) + if ((d__1 = vecteu[irmax], advapp_abs(d__1)) < (d__2 = vecteu[i__], advapp_abs(d__2) )) { irmax = i__; } @@ -11260,7 +11256,7 @@ L9900: /* ___ Calculate the norme */ - if ((d__1 = vecteu[irmax], abs(d__1)) < 1.) { + if ((d__1 = vecteu[irmax], advapp_abs(d__1)) < 1.) { xsom = 0.; i__1 = *ndimen; for (i__ = 1; i__ <= i__1; ++i__) { @@ -11283,7 +11279,7 @@ L9900: } /* L300: */ } - ret_val = (d__1 = vecteu[irmax], abs(d__1)) * sqrt(xsom); + ret_val = (d__1 = vecteu[irmax], advapp_abs(d__1)) * sqrt(xsom); } /* *********************************************************************** diff --git a/src/AdvApp2Var/AdvApp2Var_SysBase.cxx b/src/AdvApp2Var/AdvApp2Var_SysBase.cxx index 58c0f0bfaa..0642700416 100755 --- a/src/AdvApp2Var/AdvApp2Var_SysBase.cxx +++ b/src/AdvApp2Var/AdvApp2Var_SysBase.cxx @@ -3016,7 +3016,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit, mcrgene_.icore[mcrgene_.ncore * 12 - 10]; /* Computing MAX */ i__1 = mcrstac_.mbyte[ksys - 1], i__2 = mcrstac_.nbyte[ksys - 1]; - mcrstac_.mbyte[ksys - 1] = max(i__1,i__2); + mcrstac_.mbyte[ksys - 1] = advapp_max(i__1,i__2); goto L9900; diff --git a/src/Approx/Approx_ComputeLine.cdl b/src/Approx/Approx_ComputeLine.cdl index 78e3dd93ab..5cf887d3e2 100755 --- a/src/Approx/Approx_ComputeLine.cdl +++ b/src/Approx/Approx_ComputeLine.cdl @@ -270,5 +270,7 @@ mysquares: Boolean from Standard; myitermax: Integer from Standard; myfirstC: Constraint from AppParCurves; mylastC: Constraint from AppParCurves; +myMultiLineNb: Integer from Standard; +myIsClear : Boolean from Standard; end ComputeLine; diff --git a/src/Approx/Approx_ComputeLine.gxx b/src/Approx/Approx_ComputeLine.gxx index 49ca4d6272..0788363242 100755 --- a/src/Approx/Approx_ComputeLine.gxx +++ b/src/Approx/Approx_ComputeLine.gxx @@ -23,9 +23,6 @@ #include -static Standard_Boolean IsClear = Standard_False; -static Standard_Integer nbML = 0; - #ifdef DEB static Standard_Boolean mydebug = Standard_False; @@ -391,6 +388,8 @@ Approx_ComputeLine::Approx_ComputeLine const Standard_Integer NbIterations, const Standard_Boolean cutting, const Standard_Boolean Squares) +: myMultiLineNb (0), + myIsClear (Standard_False) { myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(), Parameters.Upper()); @@ -422,6 +421,8 @@ Approx_ComputeLine::Approx_ComputeLine const Standard_Integer NbIterations, const Standard_Boolean cutting, const Standard_Boolean Squares) +: myMultiLineNb (0), + myIsClear (Standard_False) { myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(), Parameters.Upper()); @@ -451,6 +452,8 @@ Approx_ComputeLine::Approx_ComputeLine const Standard_Boolean cutting, const Approx_ParametrizationType parametrization, const Standard_Boolean Squares) +: myMultiLineNb (0), + myIsClear (Standard_False) { myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2); Par = parametrization; @@ -477,6 +480,8 @@ Approx_ComputeLine::Approx_ComputeLine const Standard_Boolean cutting, const Approx_ParametrizationType parametrization, const Standard_Boolean Squares) +: myMultiLineNb (0), + myIsClear (Standard_False) { myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2); alldone = Standard_False; @@ -501,14 +506,15 @@ void Approx_ComputeLine::Perform(const MultiLine& Line) #ifdef DEB if (mydebug) DUMP(Line); #endif - if (!IsClear) { + if (!myIsClear) + { myMultiCurves.Clear(); myPar.Clear(); Tolers3d.Clear(); Tolers2d.Clear(); - nbML = 0; + myMultiLineNb = 0; } - else IsClear = Standard_False; + else myIsClear = Standard_False; Standard_Integer i, nbp, Thefirstpt, Thelastpt, oldlastpt; Standard_Boolean Finish = Standard_False, @@ -613,8 +619,8 @@ void Approx_ComputeLine::Perform(const MultiLine& Line) -LineTool::LastPoint(OtherLine); //-- Si MakeML a echoue on retourne une ligne vide - - if( (nbpdsotherligne == 0) || nbML >= 3) { + if ((nbpdsotherligne == 0) || myMultiLineNb >= 3) + { FailOnPointsAdded = Standard_True; //-- cout<<" ** ApproxComputeLine MakeML Echec ** LBR lbr "< #include -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO #include static OSD_Chronometer chr_total, chr_init, chr_approx; @@ -118,7 +118,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_ const Standard_Integer MaxDegree, const Standard_Integer MaxSegments) { -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO t_total = t_init = t_approx = t_uparam = 0; uparam_count = 0; InitChron(chr_total); @@ -131,11 +131,11 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_ Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS); ThreeDTol->Init(Tol); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_init); #endif Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C3D, Tol/10); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_init, t_init); #endif @@ -150,7 +150,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_ fonct->Intervals(CutPnts_C3,GeomAbs_C3); AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_approx); #endif @@ -161,7 +161,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_ MaxDegree, MaxSegments, evC, CutTool); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_approx, t_approx); #endif @@ -178,7 +178,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_ } myMaxError3d = aApprox.MaxError(3,1); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_total, t_total); cout<<" total reparametrization time = "<Init(Tol/2.); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_init); #endif Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C2D, Surf, Tol/20); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_init, t_init); #endif @@ -300,7 +300,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_ fonct->Intervals(CutPnts_C3,GeomAbs_C3); AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_approx); #endif @@ -311,7 +311,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_ MaxDegree, MaxSegments, evCOnS, CutTool); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_approx, t_approx); #endif @@ -339,7 +339,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_ myMaxError2d1 = Max (aApprox.MaxError(1,1),aApprox.MaxError(1,2)); myMaxError3d = aApprox.MaxError(3,1); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_total, t_total); cout<<" total reparametrization time = "<Init(Tol/2); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_init); #endif Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C2D1, C2D2, Surf1, Surf2, Tol/20); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_init, t_init); #endif @@ -465,7 +465,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_ fonct->Intervals(CutPnts_C3,GeomAbs_C3); AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_approx); #endif @@ -476,7 +476,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_ MaxDegree, MaxSegments, evCOn2S, CutTool); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_approx, t_approx); #endif @@ -512,7 +512,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_ myMaxError2d2 = Max (aApprox.MaxError(1,3),aApprox.MaxError(1,4)); myMaxError3d = aApprox.MaxError(3,1); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_total, t_total); cout<<" total reparametrization time = "< #include -static Standard_Real myPrevS, myPrevU; -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO #include static OSD_Chronometer chr_uparam; Standard_EXPORT Standard_Integer uparam_count; @@ -98,7 +97,9 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor3d_HCurve)& C, const myCase(1), myFirstS(0), myLastS(1), - myTolLen(Tol) + myTolLen(Tol), + myPrevS (0.0), + myPrevU (0.0) { Init(); } @@ -109,7 +110,9 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_HCurve2d)& C2D, co myCase(2), myFirstS(0), myLastS(1), - myTolLen(Tol) + myTolLen(Tol), + myPrevS (0.0), + myPrevU (0.0) { Init(); } @@ -122,7 +125,9 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_HCurve2d)& C2D1, c myCase(3), myFirstS(0), myLastS(1), - myTolLen(Tol) + myTolLen(Tol), + myPrevS (0.0), + myPrevU (0.0) { Init(); } @@ -206,8 +211,9 @@ void Approx_CurvlinFunc::Init(Adaptor3d_Curve& C, Handle(TColStd_HArray1OfReal)& for(i = Si->Lower(); i<= Si->Upper(); i++) Si->ChangeValue(i) /= Len; - myPrevS = myFirstS; - myPrevU = FirstU; + // TODO - fields should be mutable + const_cast(this)->myPrevS = myFirstS; + const_cast(this)->myPrevU = FirstU; } void Approx_CurvlinFunc::SetTol(const Standard_Real Tol) @@ -431,7 +437,7 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C, Standard_Real deltaS, base, U, Length; Standard_Integer NbInt, NInterval, i; Handle(TColStd_HArray1OfReal) InitUArray, InitSArray; -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_uparam); #endif if(S < 0 || S > 1) Standard_ConstructionError::Raise("Approx_CurvlinFunc::GetUParameter"); @@ -477,10 +483,11 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C, U = GCPnts_AbscissaPoint(C, deltaS, base, UGuess, myTolLen).Parameter(); - myPrevS = S; - myPrevU = U; + // TODO - fields should be mutable + const_cast(this)->myPrevS = S; + const_cast(this)->myPrevU = U; -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_uparam, t_uparam); uparam_count++; #endif diff --git a/src/BRepAlgo/BRepAlgo_NormalProjection.cxx b/src/BRepAlgo/BRepAlgo_NormalProjection.cxx index 66a59a9bc5..afae0116dc 100755 --- a/src/BRepAlgo/BRepAlgo_NormalProjection.cxx +++ b/src/BRepAlgo/BRepAlgo_NormalProjection.cxx @@ -39,7 +39,7 @@ #include #include -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO #include OSD_Chronometer chr_total, chr_init, chr_approx, chr_booltool; @@ -184,7 +184,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams() void BRepAlgo_NormalProjection::Build() { -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO Standard_Integer init_count = 0, approx_count = 0, booltool_count = 0; t_total = 0; t_init = 0; @@ -255,12 +255,12 @@ void BRepAlgo_NormalProjection::SetDefaultParams() TolU = hsur->UResolution(myTol3d)/20; TolV = hsur->VResolution(myTol3d)/20; // Projection -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_init); #endif Projector = ProjLib_CompProjectedCurve(hsur, hcur, TolU, TolV, myMaxDist); -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_init,t_init); init_count++; #endif @@ -348,13 +348,13 @@ void BRepAlgo_NormalProjection::SetDefaultParams() BB.UpdateVertex(TopExp::LastVertex(TopoDS::Edge(prj)),myTol3d); } else { -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_approx); #endif Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d, myContinuity, myMaxDegree, myMaxSeg, Only3d, Only2d); -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_approx,t_approx); approx_count++; @@ -460,7 +460,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams() if(myFaceBounds) { // Trimming edges by face bounds // if the solution is degenerated, use of BoolTool is avoided -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_booltool); #endif if(!Degenerated){ @@ -525,7 +525,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams() myAncestorMap.Bind(prj, Edges->Value(i)); myCorresp.Bind(prj, Faces->Value(j)); } -#ifdef DEBUG +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_booltool,t_booltool); booltool_count++; #endif @@ -550,7 +550,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams() myIsDone = Standard_True; -#if DEBUG +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_total,t_total); cout<<"Build - Total time : "< gives point index to search from and returns -- point index of succeseful search diff --git a/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx b/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx index 21eef49494..5f9ec0a55c 100755 --- a/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx +++ b/src/BRepClass3d/BRepClass3d_SolidExplorer.cxx @@ -42,9 +42,6 @@ #include #include //<-OCC454(apo) -static Standard_Integer numedg=0; -static gp_Vec staticd1u_gp_vec; -static gp_Vec staticd1v_gp_vec; //======================================================================= //function : FindAPointInTheFace @@ -56,8 +53,8 @@ static gp_Vec staticd1v_gp_vec; Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace (const TopoDS_Face& _face, gp_Pnt& APoint_, - Standard_Real& param_) -{ + Standard_Real& param_) +{ Standard_Real u,v; Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u,v,param_); return r; @@ -72,97 +69,113 @@ Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace (const TopoDS_Face& _face, gp_Pnt& APoint_, Standard_Real& u_, Standard_Real& v_, - Standard_Real& param_) -{ - TopoDS_Face face=_face; - face.Orientation(TopAbs_FORWARD); - - TopExp_Explorer faceexplorer; + Standard_Real& param_) +{ + gp_Vec aVecD1U, aVecD1V; + return FindAPointInTheFace (_face, APoint_, u_, v_, param_, aVecD1U, aVecD1V); +} + +//======================================================================= +//function : FindAPointInTheFace +//purpose : +//======================================================================= + +Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace +(const TopoDS_Face& _face, + gp_Pnt& APoint_, + Standard_Real& u_, Standard_Real& v_, + Standard_Real& param_, + gp_Vec& theVecD1U, + gp_Vec& theVecD1V) +{ + TopoDS_Face face = _face; + face.Orientation (TopAbs_FORWARD); + + TopExp_Explorer faceexplorer; BRepAdaptor_Curve2d c; gp_Vec2d T; gp_Pnt2d P; - //Standard_Boolean Ok = Standard_False; - Standard_Integer nedg=1; + for (faceexplorer.Init(face,TopAbs_EDGE); faceexplorer.More(); - faceexplorer.Next()) { - if(numedg==0 || nedg++==numedg) { - TopoDS_Edge Edge = TopoDS::Edge(faceexplorer.Current()); - c.Initialize(Edge,face); + faceexplorer.Next()) + { + TopoDS_Edge Edge = TopoDS::Edge (faceexplorer.Current()); + c.Initialize (Edge, face); #ifdef DEB - Standard_Integer nbinterval = + Standard_Integer nbinterval = #endif - c.NbIntervals(GeomAbs_C1); - c.D1((c.LastParameter() - c.FirstParameter()) * param_ + c.FirstParameter(),P,T); - - Standard_Real x=T.X(); - Standard_Real y=T.Y(); - if(Edge.Orientation() == TopAbs_FORWARD) { - T.SetCoord(-y,x); - } - else { - T.SetCoord(y,-x); - } - Standard_Real ParamInit = RealLast(); - Standard_Real TolInit = 0.00001; - Standard_Boolean APointExist = Standard_False; - - BRepClass_FacePassiveClassifier FClassifier; - - T.Normalize(); - P.SetCoord(P.X()+TolInit*T.X(),P.Y()+TolInit*T.Y()); - FClassifier.Reset(gp_Lin2d(P,T),ParamInit,RealEpsilon()); //-- Length and Tolerance ####### - - TopExp_Explorer otherfaceexplorer; -// Modified by Sergey KHROMOV - Tue Apr 1 11:32:51 2003 Begin - Standard_Integer aNbEdges = 0; - for (otherfaceexplorer.Init(face,TopAbs_EDGE); - otherfaceexplorer.More(); - otherfaceexplorer.Next(), aNbEdges++) { -// for (otherfaceexplorer.Init(face,TopAbs_EDGE); -// otherfaceexplorer.More(); -// otherfaceexplorer.Next()) { -// Modified by Sergey KHROMOV - Tue Apr 1 11:32:52 2003 End - TopoDS_Edge OtherEdge = TopoDS::Edge(otherfaceexplorer.Current()); - if((OtherEdge.Orientation() == TopAbs_EXTERNAL || - OtherEdge == Edge)) { - } - else { - BRepClass_Edge AEdge(OtherEdge,face); - FClassifier.Compare(AEdge,OtherEdge.Orientation()); - if(FClassifier.ClosestIntersection()) { - //-- cout<<" ---> Edge : "< FClassifier.Parameter()) { - ParamInit = FClassifier.Parameter(); - APointExist = Standard_True; - } - } - } - } -// Modified by Sergey KHROMOV - Tue Apr 1 11:34:36 2003 Begin - if (aNbEdges == 1) { - BRepClass_Edge AEdge(Edge,face); - FClassifier.Compare(AEdge,Edge.Orientation()); - if(FClassifier.ClosestIntersection()) { - if(ParamInit > FClassifier.Parameter()) { - ParamInit = FClassifier.Parameter(); - APointExist = Standard_True; - } - } - } -// Modified by Sergey KHROMOV - Tue Apr 1 11:34:36 2003 End - if(APointExist) { - ParamInit*=0.41234; - u_ = P.X() + ParamInit* T.X(); - v_ = P.Y() + ParamInit* T.Y(); - BRepAdaptor_Surface s; - s.Initialize(face,Standard_False); - s.D1(u_,v_,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); - return(Standard_True); + c.NbIntervals(GeomAbs_C1); + c.D1((c.LastParameter() - c.FirstParameter()) * param_ + c.FirstParameter(),P,T); + + Standard_Real x = T.X(); + Standard_Real y = T.Y(); + if (Edge.Orientation() == TopAbs_FORWARD) + { + T.SetCoord (-y, x); + } + else + { + T.SetCoord ( y, -x); + } + Standard_Real ParamInit = RealLast(); + Standard_Real TolInit = 0.00001; + Standard_Boolean APointExist = Standard_False; + + BRepClass_FacePassiveClassifier FClassifier; + + T.Normalize(); + P.SetCoord (P.X() + TolInit * T.X(), P.Y() + TolInit * T.Y()); + FClassifier.Reset (gp_Lin2d (P, T), ParamInit, RealEpsilon()); //-- Length and Tolerance ####### + + TopExp_Explorer otherfaceexplorer; + Standard_Integer aNbEdges = 0; + for (otherfaceexplorer.Init (face, TopAbs_EDGE); + otherfaceexplorer.More(); + otherfaceexplorer.Next(), ++aNbEdges) + { + TopoDS_Edge OtherEdge = TopoDS::Edge (otherfaceexplorer.Current()); + if (OtherEdge.Orientation() != TopAbs_EXTERNAL && OtherEdge != Edge) + { + BRepClass_Edge AEdge (OtherEdge, face); + FClassifier.Compare (AEdge, OtherEdge.Orientation()); + if (FClassifier.ClosestIntersection()) + { + if(ParamInit > FClassifier.Parameter()) + { + ParamInit = FClassifier.Parameter(); + APointExist = Standard_True; + } + } } } + + if (aNbEdges == 1) + { + BRepClass_Edge AEdge (Edge, face); + FClassifier.Compare (AEdge, Edge.Orientation()); + if (FClassifier.ClosestIntersection()) + { + if (ParamInit > FClassifier.Parameter()) + { + ParamInit = FClassifier.Parameter(); + APointExist = Standard_True; + } + } + } + + if (APointExist) + { + ParamInit *= 0.41234; + u_ = P.X() + ParamInit* T.X(); + v_ = P.Y() + ParamInit* T.Y(); + BRepAdaptor_Surface s; + s.Initialize (face, Standard_False); + s.D1 (u_, v_, APoint_, theVecD1U, theVecD1V); + return Standard_True; + } } - return(Standard_False); + return Standard_False; } //======================================================================= @@ -180,8 +193,32 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, - const Standard_Real V2 ) const -{ + const Standard_Real V2) const +{ + gp_Vec aVecD1U, aVecD1V; + return PointInTheFace (Face, APoint_, u_, v_, param_, IndexPoint, surf, + U1, V1, U2, V2, aVecD1U, aVecD1V); +} + +//======================================================================= +//function : PointInTheFace +//purpose : +//======================================================================= + +Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace +(const TopoDS_Face& Face, + gp_Pnt& APoint_, + Standard_Real& u_, Standard_Real& v_, + Standard_Real& param_, + Standard_Integer& IndexPoint, + const Handle(BRepAdaptor_HSurface)& surf, + const Standard_Real U1, + const Standard_Real V1, + const Standard_Real U2, + const Standard_Real V2, + gp_Vec& theVecD1U, + gp_Vec& theVecD1V) const +{ Standard_Real u,du = (U2-U1)/6.0; Standard_Real v,dv = (V2-V1)/6.0; if(du<1e-12) du=1e-12; @@ -202,8 +239,8 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace if(++NbPntCalc>=IndexPoint) { if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { u_=u; v_=v; - surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); - IndexPoint = NbPntCalc; + surf->D1 (u, v, APoint_, theVecD1U, theVecD1V); + IndexPoint = NbPntCalc; return(Standard_True); } } @@ -215,7 +252,7 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace if(++NbPntCalc>=IndexPoint) { if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { u_=u; v_=v; - surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); + surf->D1 (u, v, APoint_, theVecD1U, theVecD1V); IndexPoint = NbPntCalc; return(Standard_True); } @@ -227,7 +264,7 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace if(++NbPntCalc>=IndexPoint) { if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { u_=u; v_=v; - surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); + surf->D1 (u, v, APoint_, theVecD1U, theVecD1V); IndexPoint = NbPntCalc; return(Standard_True); } @@ -239,7 +276,7 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace if(++NbPntCalc>=IndexPoint) { if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { u_=u; v_=v; - surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); + surf->D1 (u, v, APoint_, theVecD1U, theVecD1V); IndexPoint = NbPntCalc; return(Standard_True); } @@ -257,7 +294,7 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace if(++NbPntCalc>=IndexPoint) { if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { u_=u; v_=v; - surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); + surf->D1 (u, v, APoint_, theVecD1U, theVecD1V); IndexPoint = NbPntCalc; return(Standard_True); } @@ -269,7 +306,7 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace if(++NbPntCalc>=IndexPoint) { if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { u_=u; v_=v; - surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec); + surf->D1 (u, v, APoint_, theVecD1U, theVecD1V); IndexPoint = NbPntCalc; return(Standard_True); } @@ -280,8 +317,9 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace else { //printf("BRepClass3d_SolidExplorer Face not found ds the map \n"); } - return(BRepClass3d_SolidExplorer::FindAPointInTheFace(Face,APoint_,u_,v_,param_)); - + + return BRepClass3d_SolidExplorer + ::FindAPointInTheFace (Face,APoint_, u_, v_, param_, theVecD1U, theVecD1V); } //======================================================================= @@ -350,10 +388,14 @@ static Standard_Integer IsInfiniteUV (Standard_Real& U1, Standard_Real& V1, Standard_Real& _Par) //modified by NIZNHY-PKV Thu Nov 14 14:34:10 2002 t { + const Standard_Real TolU = Precision::PConfusion(); + const Standard_Real TolV = TolU; + TopoDS_Face face; TopExp_Explorer faceexplorer; //TopExp_Explorer edgeexplorer; gp_Pnt APoint; + gp_Vec aVecD1U, aVecD1V; Standard_Real maxscal=0; Standard_Boolean ptfound=Standard_False; Standard_Real Par; @@ -404,7 +446,6 @@ static Standard_Integer IsInfiniteUV (Standard_Real& U1, Standard_Real& V1, // if(IsInfiniteUV(U1,V1,U2,V2)){//OCC454(apo)-> GeomAdaptor_Surface GA(BRep_Tool::Surface(face)); - static Standard_Real TolU = Precision::PConfusion(), TolV = TolU; Extrema_ExtPS Ext(P,GA,TolU,TolV); if (Ext.IsDone() && Ext.NbExt() > 0) { // evaluate the lower distance and its index; @@ -448,7 +489,6 @@ static Standard_Integer IsInfiniteUV (Standard_Real& U1, Standard_Real& V1, _Par = V.Magnitude(); L = gp_Lin(P,V); ptfound=Standard_True; - numedg=0; //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f //return ; return 0; @@ -461,36 +501,37 @@ static Standard_Integer IsInfiniteUV (Standard_Real& U1, Standard_Real& V1, // find point in a face not too far from a projection of P on face // Modified by skv - Tue Sep 16 15:25:00 2003 OCC578 End - do { - if(PointInTheFace(face,APoint,_u,_v,myParamOnEdge,++IndexPoint,surf,U1,V1,U2,V2)) { - NbPointsOK++; - gp_Vec V(P,APoint); - Par = V.Magnitude(); - if(Par > gp::Resolution()) { - gp_Vec Norm=staticd1u_gp_vec.Crossed(staticd1v_gp_vec); - Standard_Real tt = Norm.Magnitude(); - tt=Abs(Norm.Dot(V))/(tt*Par); - if(tt>maxscal) { - maxscal=tt; - L = gp_Lin(P,V); - _Par=Par; - ptfound=Standard_True; - if(maxscal>0.2) { - myParamOnEdge=svmyparam; - numedg=0; - //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f - //return ; - return 0; - //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t - } - } - } - } + do { + if (PointInTheFace (face, APoint, _u, _v, myParamOnEdge, ++IndexPoint, surf, + U1, V1, U2, V2, + aVecD1U, aVecD1V)) + { + ++NbPointsOK; + gp_Vec V (P, APoint); + Par = V.Magnitude(); + if (Par > gp::Resolution()) + { + gp_Vec Norm = aVecD1U.Crossed (aVecD1V); + Standard_Real tt = Norm.Magnitude(); + tt = Abs (Norm.Dot (V)) / (tt * Par); + if (tt > maxscal) + { + maxscal = tt; + L = gp_Lin (P, V); + _Par = Par; + ptfound = Standard_True; + if (maxscal>0.2) + { + myParamOnEdge=svmyparam; + return 0; + } + } + } + } } while(IndexPoint<200 && NbPointsOK<16); myParamOnEdge=svmyparam; - numedg=0; if(maxscal>0.2) { //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f //return ; diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index 13f03e4795..344d5d5c3c 100755 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -45,11 +45,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -72,6 +72,7 @@ #include +// TODO - not thread-safe static variables static Standard_Real thePrecision = Precision::Confusion(); static Handle(Geom_Plane) thePlane; @@ -753,12 +754,8 @@ static void SetEdgeTol(const TopoDS_Edge& E, else GP = Handle(Geom_Plane)::DownCast(S); - static Handle(GeomAdaptor_HCurve) HC; - static Handle(GeomAdaptor_HSurface) HS; - if (HC.IsNull()) { - HC = new GeomAdaptor_HCurve(); - HS = new GeomAdaptor_HSurface(); - } + Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(); + Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); TopLoc_Location LC; Standard_Real First, Last; @@ -942,14 +939,9 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge, const Standard_Integer NCONTROL = 22; - static Handle(GeomAdaptor_HCurve) HC; - static Handle(Geom2dAdaptor_HCurve) HC2d; - static Handle(GeomAdaptor_HSurface) HS; - if(HC.IsNull()){ - HC = new GeomAdaptor_HCurve(); - HC2d = new Geom2dAdaptor_HCurve(); - HS = new GeomAdaptor_HSurface(); - } + Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(); + Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve(); + Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); GeomAdaptor_Curve& GAC = HC->ChangeCurve(); Geom2dAdaptor_Curve& GAC2d = HC2d->ChangeCurve2d(); GeomAdaptor_Surface& GAS = HS->ChangeSurface(); diff --git a/src/BRepLib/BRepLib_MakeEdge.cxx b/src/BRepLib/BRepLib_MakeEdge.cxx index 7d9828b7a9..fe058087cd 100755 --- a/src/BRepLib/BRepLib_MakeEdge.cxx +++ b/src/BRepLib/BRepLib_MakeEdge.cxx @@ -100,11 +100,9 @@ static Standard_Boolean Project(const Handle(Geom2d_Curve)& C, Standard_Real Eps2 = BRep_Tool::Tolerance(V); Eps2 *= Eps2; - static Handle(Geom2dAdaptor_HCurve) HG2AHC; - if ( HG2AHC.IsNull() ) HG2AHC = new Geom2dAdaptor_HCurve(); + Handle(Geom2dAdaptor_HCurve) HG2AHC = new Geom2dAdaptor_HCurve(); HG2AHC->Set(C); - static Handle(GeomAdaptor_HSurface) HGAHS; - if ( HGAHS.IsNull() ) HGAHS = new GeomAdaptor_HSurface(); + Handle(GeomAdaptor_HSurface) HGAHS = new GeomAdaptor_HSurface(); HGAHS->Set(S); Adaptor3d_CurveOnSurface ACOS(HG2AHC,HGAHS); diff --git a/src/BSplCLib/BSplCLib.cxx b/src/BSplCLib/BSplCLib.cxx index 6fbfa550bd..7147f995ce 100755 --- a/src/BSplCLib/BSplCLib.cxx +++ b/src/BSplCLib/BSplCLib.cxx @@ -18,11 +18,9 @@ // in TangExtendToConstraint; Continuity can be equal to 0 // -#define No_Standard_RangeError -#define No_Standard_OutOfRange - #include #include +#include #include #include @@ -40,51 +38,22 @@ typedef TColStd_Array1OfInteger Array1OfInteger; class BSplCLib_LocalMatrix : public math_Matrix { - public: +public: BSplCLib_LocalMatrix (Standard_Integer DerivativeRequest, Standard_Integer Order) : math_Matrix (myBuffer, 1, DerivativeRequest + 1, 1, Order) { - if ( DerivativeRequest > BSplCLib::MaxDegree() || - Order > BSplCLib::MaxDegree()+1 || - BSplCLib::MaxDegree() > 25 ) - Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported"); + Standard_OutOfRange_Raise_if (DerivativeRequest > BSplCLib::MaxDegree() || + Order > BSplCLib::MaxDegree()+1 || BSplCLib::MaxDegree() > 25, + "BSplCLib: bspline degree is greater than maximum supported"); } - + private: // local buffer, to be sufficient for addressing by index [Degree+1][Degree+1] // (see math_Matrix implementation) Standard_Real myBuffer[27*27]; }; -//======================================================================= -//class : BSplCLib_LocalArray -//purpose: Auxiliary class optimizing creation of array buffer for -// evaluation of bspline (using stack allocation for small arrays) -//======================================================================= - -#define LOCARRAY_BUFFER 1024 -class BSplCLib_LocalArray -{ - public: - BSplCLib_LocalArray (Standard_Integer Size) - : myPtr(myBuffer) - { - if ( Size > LOCARRAY_BUFFER ) - myPtr = (Standard_Real*)Standard::Allocate (Size * sizeof(Standard_Real)); - } - - ~BSplCLib_LocalArray () - { - if ( myPtr != myBuffer ) - Standard::Free (*(Standard_Address*)&myPtr); - } - - Standard_Real& operator [] (int i) { return myPtr[i]; } - - private: - Standard_Real myBuffer[LOCARRAY_BUFFER]; - Standard_Real* myPtr; -}; +typedef PLib_LocalArray BSplCLib_LocalArray; //======================================================================= //function : Hunt @@ -4172,13 +4141,13 @@ void BSplCLib::Resolution( Standard_Real& Poles, // purpose : //======================================================================= +// array of flat knots for bezier curve of maximum 25 degree +static const Standard_Real knots[52] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; const Standard_Real& BSplCLib::FlatBezierKnots (const Standard_Integer Degree) { - if ( Degree < 1 || Degree > MaxDegree() || MaxDegree() != 25 ) - Standard_OutOfRange::Raise ("Bezier curve degree greater than maximal supported"); - - // array of flat knots for bezier curve of maximum 25 degree - static Standard_Real knots[52] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + Standard_OutOfRange_Raise_if (Degree < 1 || Degree > MaxDegree() || MaxDegree() != 25, + "Bezier curve degree greater than maximal supported"); + return knots[25-Degree]; } diff --git a/src/BSplCLib/BSplCLib_1.cxx b/src/BSplCLib/BSplCLib_1.cxx index 76de56224c..77b05c7c13 100755 --- a/src/BSplCLib/BSplCLib_1.cxx +++ b/src/BSplCLib/BSplCLib_1.cxx @@ -4,9 +4,6 @@ // BSpline Curve in 2d space // ************************** -#define No_Standard_RangeError -#define No_Standard_OutOfRange - #define Dimension_gen 2 #define Array1OfPoints TColgp_Array1OfPnt2d @@ -38,4 +35,3 @@ #define BSplCLib_DataContainer BSplCLib_DataContainer_2d #include - diff --git a/src/BSplCLib/BSplCLib_2.cxx b/src/BSplCLib/BSplCLib_2.cxx index 99f35e9730..d630064fb1 100755 --- a/src/BSplCLib/BSplCLib_2.cxx +++ b/src/BSplCLib/BSplCLib_2.cxx @@ -6,9 +6,6 @@ // EvalBsplineBasis, // EvalPolynomial : Horners method -#define No_Standard_RangeError -#define No_Standard_OutOfRange - #include #include @@ -30,10 +27,11 @@ struct BSplCLib_DataContainer { - BSplCLib_DataContainer(Standard_Integer Degree) + BSplCLib_DataContainer(Standard_Integer Degree) { - if ( Degree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25 ) - Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported"); + Standard_OutOfRange_Raise_if (Degree > BSplCLib::MaxDegree() || + BSplCLib::MaxDegree() > 25, + "BSplCLib: bspline degree is greater than maximum supported"); } Standard_Real poles[2*(25+1)]; @@ -918,11 +916,11 @@ void BSplCLib::FunctionMultiply for (ii = 1 ; ii <= num_new_poles ; ii++) { contact_order_array(ii) = 0 ; - (*FunctionPtr)(contact_order_array(ii), + FunctionPtr.Evaluate (contact_order_array(ii), start_end, parameters(ii), result, - error_code) ; + error_code); if (error_code) { Status = 1 ; goto FINISH ; @@ -1008,11 +1006,11 @@ void BSplCLib::FunctionReparameterise for (ii = 1 ; ii <= num_new_poles ; ii++) { contact_order_array(ii) = 0 ; - (*FunctionPtr)(contact_order_array(ii), + FunctionPtr.Evaluate (contact_order_array(ii), start_end, parameters(ii), result, - error_code) ; + error_code); if (error_code) { Status = 1 ; goto FINISH ; diff --git a/src/BSplCLib/BSplCLib_3.cxx b/src/BSplCLib/BSplCLib_3.cxx index 31d4e86dfd..0877541a8d 100755 --- a/src/BSplCLib/BSplCLib_3.cxx +++ b/src/BSplCLib/BSplCLib_3.cxx @@ -9,9 +9,6 @@ // BSpline Curve in 3d space // *************************** -#define No_Standard_RangeError -#define No_Standard_OutOfRange - #define Dimension_gen 3 #define Array1OfPoints TColgp_Array1OfPnt @@ -47,4 +44,3 @@ #define BSplCLib_DataContainer BSplCLib_DataContainer_3d #include - diff --git a/src/BSplCLib/BSplCLib_CurveComputation.gxx b/src/BSplCLib/BSplCLib_CurveComputation.gxx index ba3cdc04fc..8afba76e15 100755 --- a/src/BSplCLib/BSplCLib_CurveComputation.gxx +++ b/src/BSplCLib/BSplCLib_CurveComputation.gxx @@ -11,9 +11,6 @@ #include #include -#define No_Standard_RangeError -#define No_Standard_OutOfRange - //======================================================================= //struct : BSplCLib_DataContainer //purpose: Auxiliary structure providing buffers for poles and knots used in @@ -24,8 +21,9 @@ struct BSplCLib_DataContainer { BSplCLib_DataContainer(Standard_Integer Degree) { - if ( Degree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25 ) - Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported"); + Standard_OutOfRange_Raise_if (Degree > BSplCLib::MaxDegree() || + BSplCLib::MaxDegree() > 25, + "BSplCLib: bspline degree is greater than maximum supported"); } Standard_Real poles[(25+1)*(Dimension_gen+1)]; @@ -1412,4 +1410,3 @@ void BSplCLib::FunctionReparameterise array_of_new_poles[0], Status) ; } - diff --git a/src/BSplCLib/BSplCLib_EvaluatorFunction.hxx b/src/BSplCLib/BSplCLib_EvaluatorFunction.hxx index d2e9987cc8..d4f0e54b40 100755 --- a/src/BSplCLib/BSplCLib_EvaluatorFunction.hxx +++ b/src/BSplCLib/BSplCLib_EvaluatorFunction.hxx @@ -3,16 +3,9 @@ // Author: Xavier BENVENISTE // - #ifndef _BSplCLib_EvaluatorFunction_HeaderFile #define _BSplCLib_EvaluatorFunction_HeaderFile - -// File: AdvApprox_EvaluatorFunction.hxx -// Created: Mon May 29 17:04:50 1995 -// Author: Xavier BENVENISTE -// - #ifndef _Standard_Integer_HeaderFile #include #endif @@ -22,18 +15,43 @@ #ifndef _Standard_PrimitiveTypes_HeaderFile #include #endif -typedef void (* BSplCLib_EvaluatorFunction) (const Standard_Integer , - // Derivative Request - const Standard_Real *, - // StartEnd[2] - const Standard_Real , - // Parameter - Standard_Real &, - // Result - Standard_Integer & ) ; - // Error Code +// History - C function pointer converted to a virtual class +// in order to get rid of usage of static functions and static data +class BSplCLib_EvaluatorFunction +{ +public: + //! Empty constructor + BSplCLib_EvaluatorFunction () {} + //! Destructor should be declared as virtual + virtual ~BSplCLib_EvaluatorFunction () {} + + //! Function evaluation method to be defined by descendant + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real* theStartEnd, + const Standard_Real theParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const = 0; + + //! Shortcut for function-call style usage + void operator () (const Standard_Integer theDerivativeRequest, + const Standard_Real* theStartEnd, + const Standard_Real theParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + Evaluate (theDerivativeRequest, theStartEnd, theParameter, theResult, theErrorCode); + } + +private: + + //! Copy constructor is declared private to forbid copying + BSplCLib_EvaluatorFunction (const BSplCLib_EvaluatorFunction&) {} + + //! Assignment operator is declared private to forbid copying + void operator = (const BSplCLib_EvaluatorFunction&) {} +}; #endif diff --git a/src/BSplSLib/BSplSLib.cxx b/src/BSplSLib/BSplSLib.cxx index 120e6b16ef..3b38fb1411 100755 --- a/src/BSplSLib/BSplSLib.cxx +++ b/src/BSplSLib/BSplSLib.cxx @@ -9,11 +9,9 @@ // pmn 07-10-96 : Correction de DN dans le cas rationnal. // pmn 06-02-97 : Correction des poids dans RationalDerivative. (PRO700) -#define No_Standard_RangeError -#define No_Standard_OutOfRange - #include #include +#include #include #include #include @@ -23,7 +21,7 @@ #include // for null derivatives -static Standard_Real BSplSLib_zero[3] = {0.,0.,0.}; +static Standard_Real BSplSLib_zero[3] = {0.0, 0.0, 0.0}; #ifdef WNT #define M_SQRT2 1.4142135623730950488016887 #endif @@ -34,14 +32,13 @@ static Standard_Real BSplSLib_zero[3] = {0.,0.,0.}; // evaluation of bspline (allocated in the stack) //======================================================================= -struct BSplSLib_DataContainer +struct BSplSLib_DataContainer { - BSplSLib_DataContainer (Standard_Integer UDegree, Standard_Integer VDegree) + BSplSLib_DataContainer (Standard_Integer UDegree, Standard_Integer VDegree) { - if ( UDegree > BSplCLib::MaxDegree() || - VDegree > BSplCLib::MaxDegree() || - BSplCLib::MaxDegree() != 25 ) - Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported"); + Standard_OutOfRange_Raise_if (UDegree > BSplCLib::MaxDegree() || + VDegree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25, + "BSplSLib: bspline degree is greater than maximum supported"); } Standard_Real poles[4*(25+1)*(25+1)]; @@ -50,35 +47,7 @@ struct BSplSLib_DataContainer Standard_Real ders[48]; }; -//======================================================================= -//class : BSplSLib_LocalArray -//purpose: Auxiliary class optimizing creation of array buffer for -// evaluation of bspline (using stack allocation for small arrays) -//======================================================================= - -#define LOCARRAY_BUFFER 1024 -class BSplSLib_LocalArray -{ - public: - BSplSLib_LocalArray (Standard_Integer Size) - : myPtr(myBuffer) - { - if ( Size > LOCARRAY_BUFFER ) - myPtr = (Standard_Real*)Standard::Allocate (Size * sizeof(Standard_Real)); - } - - ~BSplSLib_LocalArray () - { - if ( myPtr != myBuffer ) - Standard::Free (*(Standard_Address*)&myPtr); - } - - operator Standard_Real* () { return myPtr; } - - private: - Standard_Real myBuffer[LOCARRAY_BUFFER]; - Standard_Real* myPtr; -}; +typedef PLib_LocalArray BSplSLib_LocalArray; //************************************************************************** // Evaluation methods @@ -211,8 +180,6 @@ void BSplSLib::RationalDerivative(const Standard_Integer UDeg, iiM1 = - M1; iiM3 = - M3; - PLib::Binomial(N); - PLib::Binomial(M); for (ii = 0 ; ii <= N ; ii++) { iiM1 += M1; @@ -3316,7 +3283,7 @@ void BSplSLib::FunctionMultiply NewDenominator(ii,jj), NewNumerator(ii,jj)) ; - Function(0, + Function.Evaluate (0, UParameters(ii), VParameters(jj), result, @@ -3345,4 +3312,3 @@ void BSplSLib::FunctionMultiply Standard_ConstructionError::Raise(); } } - diff --git a/src/BSplSLib/BSplSLib_EvaluatorFunction.hxx b/src/BSplSLib/BSplSLib_EvaluatorFunction.hxx index 4d9e0079df..cbcb590cf8 100755 --- a/src/BSplSLib/BSplSLib_EvaluatorFunction.hxx +++ b/src/BSplSLib/BSplSLib_EvaluatorFunction.hxx @@ -3,11 +3,9 @@ // Author: Xavier BENVENISTE // - #ifndef _BSplSLib_EvaluatorFunction_HeaderFile #define _BSplSLib_EvaluatorFunction_HeaderFile - #ifndef _Standard_Integer_HeaderFile #include #endif @@ -17,21 +15,43 @@ #ifndef _Standard_PrimitiveTypes_HeaderFile #include #endif -typedef void (* BSplSLib_EvaluatorFunction) (const Standard_Integer , - // Derivative Request - const Standard_Real , - // UParameter - const Standard_Real , - // VParameter - Standard_Real &, - // Result - Standard_Integer & ) ; - // Error Code +// Histroy - C function pointer converted to a virtual class +// in order to get rid of usage of static functions and static data +class BSplSLib_EvaluatorFunction +{ +public: + //! Empty constructor + BSplSLib_EvaluatorFunction () {} + //! Destructor should be declared as virtual + virtual ~BSplSLib_EvaluatorFunction () {} + //! Function evaluation method to be defined by descendant + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real theUParameter, + const Standard_Real theVParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const = 0; + //! Shortcut for function-call style usage + void operator () (const Standard_Integer theDerivativeRequest, + const Standard_Real theUParameter, + const Standard_Real theVParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + Evaluate (theDerivativeRequest, theUParameter, theVParameter, theResult, theErrorCode); + } +private: + + //! Copy constructor is declared private to forbid copying + BSplSLib_EvaluatorFunction (const BSplSLib_EvaluatorFunction&) {} + + //! Assignment operator is declared private to forbid copying + void operator = (const BSplSLib_EvaluatorFunction&) {} +}; #endif diff --git a/src/CSLib/CSLib.cxx b/src/CSLib/CSLib.cxx index 627d5322d7..e61263ed26 100755 --- a/src/CSLib/CSLib.cxx +++ b/src/CSLib/CSLib.cxx @@ -382,8 +382,6 @@ gp_Vec CSLib::DNNUV(const Standard_Integer Nu, { Standard_Integer i,j; gp_Vec D(0,0,0),VG,VD,PV; - PLib::Binomial(Nu); - PLib::Binomial(Nv); for(i=0;i<=Nu;i++) for(j=0;j<=Nv;j++){ VG=DerSurf.Value(i+1,j); @@ -406,8 +404,6 @@ gp_Vec CSLib::DNNUV(const Standard_Integer Nu, { Standard_Integer i,j; gp_Vec D(0,0,0),VG,VD,PV; - PLib::Binomial(Nu); - PLib::Binomial(Nv); for(i=0;i<=Nu;i++) for(j=0;j<=Nv;j++){ VG=DerSurf1.Value(i+1,j); @@ -441,8 +437,6 @@ DerVecNor.SetValue(0,0,DerNor); Dnorm=DerNUV.Value(Iduref,Idvref)*DerVecNor.Value(0,0); TabNorm.SetValue(0,0,Dnorm); TabScal.SetValue(0,0,0.); -PLib::Binomial(Kderiv + Iduref); -PLib::Binomial(Kderiv + Idvref); for ( Mderiv = 1;Mderiv <= Kderiv; Mderiv++) for ( Pderiv = 0 ; Pderiv <= Mderiv ; Pderiv++) { diff --git a/src/CSLib/CSLib_NormalPolyDef.cxx b/src/CSLib/CSLib_NormalPolyDef.cxx index 69f3be083d..2aba8e4128 100755 --- a/src/CSLib/CSLib_NormalPolyDef.cxx +++ b/src/CSLib/CSLib_NormalPolyDef.cxx @@ -27,7 +27,6 @@ Standard_Boolean CSLib_NormalPolyDef::Value(const Standard_Real X, Standard_Real co,si; co=cos(X); si=sin(X); - PLib::Binomial(myK0); for(Standard_Integer i=0;i<=myK0;i++){ F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i); diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index e48dd2163a..6ef2ffc88b 100755 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -473,33 +473,45 @@ const Convert_ParameterisationType Parameterisation) return TheCurve; } - - //======================================================================= -//function : law_evaluator +//class : law_evaluator //purpose : //======================================================================= -static Handle(Geom2d_BSplineCurve) Ancore = NULL ; +class Geom2dConvert_law_evaluator : public BSplCLib_EvaluatorFunction +{ + +public: + + Geom2dConvert_law_evaluator (const Handle(Geom2d_BSplineCurve)& theAncore) + : myAncore (theAncore) {} + + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real* theStartEnd, + const Standard_Real theParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + theErrorCode = 0; + if (!myAncore.IsNull() && + theParameter >= theStartEnd[0] && + theParameter <= theStartEnd[1] && + theDerivativeRequest == 0) + { + gp_Pnt2d aPoint; + myAncore->D0 (theParameter, aPoint); + theResult = aPoint.Coord (2); + } + else + theErrorCode = 1; + } + +private: + + Handle(Geom2d_BSplineCurve) myAncore; + +}; -static void law_evaluator(const Standard_Integer DerivativeRequest, - const Standard_Real *StartEnd, - const Standard_Real Parameter, - Standard_Real & Result, - Standard_Integer & ErrorCode) -{ErrorCode = 0 ; - if (!Ancore.IsNull() && - Parameter >= StartEnd[0] && - Parameter <= StartEnd[1] && - DerivativeRequest == 0){ - gp_Pnt2d a_point ; - Ancore->D0(Parameter, - a_point) ; - Result = a_point.Coord(2) ; - } - else - ErrorCode = 1 ; -} //======================================================================= //function : MultNumandDenom @@ -539,7 +551,7 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu a->Poles(aPoles); a->Multiplicities(aMults); BSplCLib::Reparametrize(BS->FirstParameter(),BS->LastParameter(),aKnots); - Ancore= new Geom2d_BSplineCurve(aPoles,aKnots,aMults,a->Degree()); + Handle(Geom2d_BSplineCurve) anAncore = new Geom2d_BSplineCurve (aPoles, aKnots, aMults, a->Degree()); BSplCLib::MergeBSplineKnots(tolerance,start_value,end_value, a->Degree(),aKnots,aMults, @@ -555,7 +567,7 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu for (jj=1;jj<=2;jj++) BSPoles(ii).SetCoord(jj,BSPoles(ii).Coord(jj)*BSWeights(ii)); //POP pour NT - BSplCLib_EvaluatorFunction ev = law_evaluator; + Geom2dConvert_law_evaluator ev (anAncore); BSplCLib::FunctionMultiply(ev, BS->Degree(), BSFlatKnots, @@ -899,27 +911,40 @@ static GeomAbs_Shape Continuity(const Handle(Geom2d_Curve)& C1, } //======================================================================= -//function :reparameterise_evaluator +//class :reparameterise_evaluator //purpose : //======================================================================= -static Standard_Real polynomial_coefficient[3] ; +class Geom2dConvert_reparameterise_evaluator : public BSplCLib_EvaluatorFunction +{ -static void reparameterise_evaluator( - const Standard_Integer DerivativeRequest, -// const Standard_Real *StartEnd, - const Standard_Real *, - const Standard_Real Parameter, - Standard_Real & Result, - Standard_Integer & ErrorCode) { - ErrorCode = 0 ; - PLib::EvalPolynomial(Parameter, - DerivativeRequest, - 2, - 1, - polynomial_coefficient[0], - Result) ; -} +public: + + Geom2dConvert_reparameterise_evaluator (const Standard_Real thePolynomialCoefficient[3]) + { + memcpy(myPolynomialCoefficient, thePolynomialCoefficient, sizeof(myPolynomialCoefficient)); + } + + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real* /*theStartEnd*/, + const Standard_Real theParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + theErrorCode = 0; + PLib::EvalPolynomial (theParameter, + theDerivativeRequest, + 2, + 1, + *((Standard_Real* )myPolynomialCoefficient), // function really only read values from this array + theResult); + } + +private: + + Standard_Real myPolynomialCoefficient[3]; + +}; //======================================================================= //function : ConcatG1 @@ -1001,6 +1026,8 @@ void Geom2dConvert::ConcatG1(TColGeom2d_Array1OfBSplineCurve& ArrayOf index=0; Pretreatment(ArrayOfCurves); + Standard_Real aPolynomialCoefficient[3]; + if ((nb_group==1) && (ClosedFlag)){ //traitement d'un cas particulier indexmin=Indexmin(ArrayOfCurves); if (indexmin!=(ArrayOfCurves.Length()-1)) @@ -1025,11 +1052,11 @@ void Geom2dConvert::ConcatG1(TColGeom2d_Array1OfBSplineCurve& ArrayOf umin=Curve1->FirstParameter(),umax=Curve1->LastParameter(); tmax=2*lambda*(umax-umin)/(1+lambda*lambda2); a=(lambda*lambda2-1)/(2*lambda*tmax); - polynomial_coefficient[2]=a; + aPolynomialCoefficient[2] = a; b=(1/lambda); - polynomial_coefficient[1]=b; + aPolynomialCoefficient[1] = b; c=umin; - polynomial_coefficient[0]=c; + aPolynomialCoefficient[0] = c; TColStd_Array1OfReal Curve1FlatKnots(1,Curve1->NbPoles()+Curve1->Degree()+1); TColStd_Array1OfInteger KnotC1Mults(1,Curve1->NbKnots()); Curve1->Multiplicities(KnotC1Mults); @@ -1056,7 +1083,7 @@ void Geom2dConvert::ConcatG1(TColGeom2d_Array1OfBSplineCurve& ArrayOf for (jj=1;jj<=2;jj++) Curve1Poles(ii).SetCoord(jj,Curve1Poles(ii).Coord(jj)*Curve1Weights(ii)); //POP pour NT - BSplCLib_EvaluatorFunction ev = reparameterise_evaluator; + Geom2dConvert_reparameterise_evaluator ev (aPolynomialCoefficient); BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), Curve1FlatKnots, @@ -1246,6 +1273,7 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf Standard_Integer k=0; index=0; Pretreatment(ArrayOfCurves); + Standard_Real aPolynomialCoefficient[3]; if ((nb_group==1) && (ClosedFlag)){ //traitement d'un cas particulier ArrayOfIndices->SetValue(0,0); @@ -1280,11 +1308,11 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf umin=Curve1->FirstParameter(),umax=Curve1->LastParameter(); tmax=2*lambda*(umax-umin)/(1+lambda*lambda2); a=(lambda*lambda2-1)/(2*lambda*tmax); - polynomial_coefficient[2]=a; + aPolynomialCoefficient[2] = a; b=(1/lambda); - polynomial_coefficient[1]=b; + aPolynomialCoefficient[1] = b; c=umin; - polynomial_coefficient[0]=c; + aPolynomialCoefficient[0] = c; TColStd_Array1OfReal Curve1FlatKnots(1,Curve1->NbPoles()+Curve1->Degree()+1); TColStd_Array1OfInteger KnotC1Mults(1,Curve1->NbKnots()); Curve1->Multiplicities(KnotC1Mults); @@ -1311,7 +1339,7 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf for (jj=1;jj<=2;jj++) Curve1Poles(ii).SetCoord(jj,Curve1Poles(ii).Coord(jj)*Curve1Weights(ii)); //POP pour NT - BSplCLib_EvaluatorFunction ev = reparameterise_evaluator; + Geom2dConvert_reparameterise_evaluator ev (aPolynomialCoefficient); // BSplCLib::FunctionReparameterise(reparameterise_evaluator, BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), diff --git a/src/GeomConvert/GeomConvert.cxx b/src/GeomConvert/GeomConvert.cxx index 836b4b164f..17e7f76eba 100755 --- a/src/GeomConvert/GeomConvert.cxx +++ b/src/GeomConvert/GeomConvert.cxx @@ -475,30 +475,43 @@ Handle(Geom_BSplineCurve) GeomConvert::CurveToBSplineCurve //======================================================================= -//function : law_evaluator +//class : law_evaluator //purpose : usefull to estimate the value of a function //======================================================================= -static Handle(Geom2d_BSplineCurve) Ancore = NULL ; +class GeomConvert_law_evaluator : public BSplCLib_EvaluatorFunction +{ -static void law_evaluator(const Standard_Integer DerivativeRequest, - const Standard_Real *StartEnd, - const Standard_Real Parameter, - Standard_Real & Result, - Standard_Integer & ErrorCode) -{ErrorCode = 0 ; - if (!Ancore.IsNull() && - Parameter >= StartEnd[0] && - Parameter <= StartEnd[1] && - DerivativeRequest == 0){ - gp_Pnt2d a_point ; - Ancore->D0(Parameter, - a_point) ; - Result = a_point.Coord(2) ; - } - else - ErrorCode = 1 ; -} +public: + + GeomConvert_law_evaluator (const Handle(Geom2d_BSplineCurve)& theAncore) + : myAncore (theAncore) {} + + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real* theStartEnd, + const Standard_Real theParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + theErrorCode = 0; + if (!myAncore.IsNull() && + theParameter >= theStartEnd[0] && + theParameter <= theStartEnd[1] && + theDerivativeRequest == 0) + { + gp_Pnt2d aPoint; + myAncore->D0 (theParameter, aPoint); + theResult = aPoint.Coord(2); + } + else + theErrorCode = 1; + } + +private: + + Handle(Geom2d_BSplineCurve) myAncore; + +}; //======================================================================= //function : MultNumandDenom @@ -540,7 +553,7 @@ static Handle(Geom_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCurv a->Poles(aPoles); a->Multiplicities(aMults); BSplCLib::Reparametrize(BS->FirstParameter(),BS->LastParameter(),aKnots); - Ancore= new Geom2d_BSplineCurve(aPoles,aKnots,aMults,a->Degree()); //call of the law-evaluator + Handle(Geom2d_BSplineCurve) anAncore = new Geom2d_BSplineCurve (aPoles, aKnots, aMults, a->Degree()); BSplCLib::MergeBSplineKnots(tolerance,start_value,end_value, //merge of the knots a->Degree(),aKnots,aMults, @@ -556,8 +569,8 @@ static Handle(Geom_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCurv for (jj=1;jj<=3;jj++) BSPoles(ii).SetCoord(jj,BSPoles(ii).Coord(jj)*BSWeights(ii)); //POP pour WNT - BSplCLib_EvaluatorFunction ev = law_evaluator; - + GeomConvert_law_evaluator ev (anAncore); + BSplCLib::FunctionMultiply(ev, BS->Degree(), BSFlatKnots, @@ -727,27 +740,40 @@ static void ReorderArrayOfG1Curves(TColGeom_Array1OfBSplineCurve& ArrayOfCurv } //======================================================================= -//function :reparameterise_evaluator -//purpose : +//class : reparameterise_evaluator +//purpose : //======================================================================= -static Standard_Real polynomial_coefficient[3] ; +class GeomConvert_reparameterise_evaluator : public BSplCLib_EvaluatorFunction +{ -static void reparameterise_evaluator( - const Standard_Integer DerivativeRequest, -// const Standard_Real *StartEnd, - const Standard_Real *, - const Standard_Real Parameter, - Standard_Real & Result, - Standard_Integer & ErrorCode) { - ErrorCode = 0 ; - PLib::EvalPolynomial(Parameter, - DerivativeRequest, - 2, - 1, - polynomial_coefficient[0], - Result) ; -} +public: + + GeomConvert_reparameterise_evaluator (const Standard_Real thePolynomialCoefficient[3]) + { + memcpy (myPolynomialCoefficient, thePolynomialCoefficient, sizeof(myPolynomialCoefficient)); + } + + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real* /*theStartEnd*/, + const Standard_Real theParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + theErrorCode = 0; + PLib::EvalPolynomial (theParameter, + theDerivativeRequest, + 2, + 1, + *((Standard_Real* )myPolynomialCoefficient), // function really only read values from this array + theResult); + } + +private: + + Standard_Real myPolynomialCoefficient[3]; + +}; //======================================================================= //function : ConcatG1 @@ -825,6 +851,7 @@ static void reparameterise_evaluator( index=0; Pretreatment(ArrayOfCurves); + Standard_Real aPolynomialCoefficient[3]; if ((nb_group==1) && (ClosedG1Flag)){ //treatment of a particular case indexmin=Indexmin(ArrayOfCurves); @@ -850,11 +877,11 @@ static void reparameterise_evaluator( umin=Curve1->FirstParameter(),umax=Curve1->LastParameter(); tmax=2*lambda*(umax-umin)/(1+lambda*lambda2); a=(lambda*lambda2-1)/(2*lambda*tmax); - polynomial_coefficient[2]=a; + aPolynomialCoefficient[2] = a; b=(1/lambda); - polynomial_coefficient[1]=b; + aPolynomialCoefficient[1] = b; c=umin; - polynomial_coefficient[0]=c; + aPolynomialCoefficient[0] = c; TColStd_Array1OfReal Curve1FlatKnots(1,Curve1->NbPoles()+Curve1->Degree()+1); TColStd_Array1OfInteger KnotC1Mults(1,Curve1->NbKnots()); Curve1->Multiplicities(KnotC1Mults); @@ -881,7 +908,7 @@ static void reparameterise_evaluator( for (jj=1;jj<=3;jj++) Curve1Poles(ii).SetCoord(jj,Curve1Poles(ii).Coord(jj)*Curve1Weights(ii)); //POP pour WNT - BSplCLib_EvaluatorFunction ev = reparameterise_evaluator; + GeomConvert_reparameterise_evaluator ev (aPolynomialCoefficient); // BSplCLib::FunctionReparameterise(reparameterise_evaluator, BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), @@ -1052,6 +1079,7 @@ void GeomConvert::ConcatC1(TColGeom_Array1OfBSplineCurve& ArrayOfCurv Standard_Integer k=0; index=0; Pretreatment(ArrayOfCurves); + Standard_Real aPolynomialCoefficient[3]; if ((nb_group==1) && (ClosedG1Flag)){ //treatment of a particular case ArrayOfIndices->SetValue(0,0); @@ -1085,11 +1113,11 @@ void GeomConvert::ConcatC1(TColGeom_Array1OfBSplineCurve& ArrayOfCurv umin=Curve1->FirstParameter(),umax=Curve1->LastParameter(); tmax=2*lambda*(umax-umin)/(1+lambda*lambda2); a=(lambda*lambda2-1)/(2*lambda*tmax); - polynomial_coefficient[2]=a; + aPolynomialCoefficient[2] = a; b=(1/lambda); - polynomial_coefficient[1]=b; + aPolynomialCoefficient[1] = b; c=umin; - polynomial_coefficient[0]=c; + aPolynomialCoefficient[0] = c; TColStd_Array1OfReal Curve1FlatKnots(1,Curve1->NbPoles()+Curve1->Degree()+1); TColStd_Array1OfInteger KnotC1Mults(1,Curve1->NbKnots()); Curve1->Multiplicities(KnotC1Mults); @@ -1116,7 +1144,7 @@ void GeomConvert::ConcatC1(TColGeom_Array1OfBSplineCurve& ArrayOfCurv for (jj=1;jj<=3;jj++) Curve1Poles(ii).SetCoord(jj,Curve1Poles(ii).Coord(jj)*Curve1Weights(ii)); //POP pour WNT - BSplCLib_EvaluatorFunction ev = reparameterise_evaluator; + GeomConvert_reparameterise_evaluator ev (aPolynomialCoefficient); BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), diff --git a/src/GeomConvert/GeomConvert_ApproxSurface.cxx b/src/GeomConvert/GeomConvert_ApproxSurface.cxx index aed97fb497..6bc60a8f07 100755 --- a/src/GeomConvert/GeomConvert_ApproxSurface.cxx +++ b/src/GeomConvert/GeomConvert_ApproxSurface.cxx @@ -8,9 +8,34 @@ #include #include -static Handle(Adaptor3d_HSurface) fonct; +class GeomConvert_ApproxSurface_Eval : public AdvApp2Var_EvaluatorFunc2Var +{ -extern "C" void mySurfEval1(Standard_Integer * Dimension, +public: + + GeomConvert_ApproxSurface_Eval (const Handle(Adaptor3d_HSurface)& theAdaptor) + : myAdaptor (theAdaptor) {} + + virtual void Evaluate (Standard_Integer* theDimension, + Standard_Real* theUStartEnd, + Standard_Real* theVStartEnd, + Standard_Integer* theFavorIso, + Standard_Real* theConstParam, + Standard_Integer* theNbParams, + Standard_Real* theParameters, + Standard_Integer* theUOrder, + Standard_Integer* theVOrder, + Standard_Real* theResult, + Standard_Integer* theErrorCode) const; + +private: + + mutable Handle(Adaptor3d_HSurface) myAdaptor; + +}; + + +void GeomConvert_ApproxSurface_Eval::Evaluate (Standard_Integer * Dimension, // Dimension Standard_Real * UStartEnd, // StartEnd[2] in U @@ -30,7 +55,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, // Derivative Request in V Standard_Real * Result, // Result[Dimension,N] - Standard_Integer * ErrorCode) + Standard_Integer * ErrorCode) const // Error Code { *ErrorCode = 0; @@ -71,8 +96,8 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, // Initialisation - fonct = fonct->UTrim(UStartEnd[0], UStartEnd[1], Precision::PConfusion()); - fonct = fonct->VTrim(VStartEnd[0], VStartEnd[1], Precision::PConfusion()); + myAdaptor = myAdaptor->UTrim (UStartEnd[0], UStartEnd[1], Precision::PConfusion()); + myAdaptor = myAdaptor->VTrim (VStartEnd[0], VStartEnd[1], Precision::PConfusion()); /* for (idim=1;idim<=*Dimension;idim++) { for (jpar=1;jpar<=*NbParams;jpar++) { @@ -91,7 +116,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 0 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - pnt = fonct->Value(Upar,Vpar); + pnt = myAdaptor->Value (Upar, Vpar); Result[(jpar-1)*(*Dimension)] = pnt.X(); Result[1+(jpar-1)*(*Dimension)] = pnt.Y(); Result[2+(jpar-1)*(*Dimension)] = pnt.Z(); @@ -100,7 +125,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 1 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - fonct->D1(Upar, Vpar, pnt, v1, v2); + myAdaptor->D1 (Upar, Vpar, pnt, v1, v2); if (*UOrder==1) { Result[(jpar-1)*(*Dimension)] = v1.X(); Result[1+(jpar-1)*(*Dimension)] = v1.Y(); @@ -116,7 +141,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 2 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - fonct->D2(Upar, Vpar, pnt, v1, v2, v3, v4, v5); + myAdaptor->D2 (Upar, Vpar, pnt, v1, v2, v3, v4, v5); if (*UOrder==2) { Result[(jpar-1)*(*Dimension)] = v3.X(); Result[1+(jpar-1)*(*Dimension)] = v3.Y(); @@ -137,7 +162,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 3 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - fonct->D3(Upar, Vpar, pnt, v1, v2, v3, v4, v5, v6, v7, v8, v9); + myAdaptor->D3 (Upar, Vpar, pnt, v1, v2, v3, v4, v5, v6, v7, v8, v9); if (*UOrder==2) { Result[(jpar-1)*(*Dimension)] = v8.X(); Result[1+(jpar-1)*(*Dimension)] = v8.Y(); @@ -153,7 +178,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 4 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - vect = fonct->DN(Upar, Vpar, *UOrder, *VOrder); + vect = myAdaptor->DN (Upar, Vpar, *UOrder, *VOrder); Result[(jpar-1)*(*Dimension)] = vect.X(); Result[1+(jpar-1)*(*Dimension)] = vect.Y(); Result[2+(jpar-1)*(*Dimension)] = vect.Z(); @@ -167,7 +192,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 0 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - pnt = fonct->Value(Upar,Vpar); + pnt = myAdaptor->Value (Upar, Vpar); Result[(jpar-1)*(*Dimension)] = pnt.X(); Result[1+(jpar-1)*(*Dimension)] = pnt.Y(); Result[2+(jpar-1)*(*Dimension)] = pnt.Z(); @@ -176,7 +201,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 1 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - fonct->D1(Upar, Vpar, pnt, v1, v2); + myAdaptor->D1 (Upar, Vpar, pnt, v1, v2); if (*UOrder==1) { Result[(jpar-1)*(*Dimension)] = v1.X(); Result[1+(jpar-1)*(*Dimension)] = v1.Y(); @@ -192,7 +217,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 2 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - fonct->D2(Upar, Vpar, pnt, v1, v2, v3, v4, v5); + myAdaptor->D2 (Upar, Vpar, pnt, v1, v2, v3, v4, v5); if (*UOrder==2) { Result[(jpar-1)*(*Dimension)] = v3.X(); Result[1+(jpar-1)*(*Dimension)] = v3.Y(); @@ -213,7 +238,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 3 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - fonct->D3(Upar, Vpar, pnt, v1, v2, v3, v4, v5, v6, v7, v8, v9); + myAdaptor->D3 (Upar, Vpar, pnt, v1, v2, v3, v4, v5, v6, v7, v8, v9); if (*UOrder==2) { Result[(jpar-1)*(*Dimension)] = v8.X(); Result[1+(jpar-1)*(*Dimension)] = v8.Y(); @@ -229,7 +254,7 @@ extern "C" void mySurfEval1(Standard_Integer * Dimension, case 4 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - vect = fonct->DN(Upar, Vpar, *UOrder, *VOrder); + vect = myAdaptor->DN (Upar, Vpar, *UOrder, *VOrder); Result[(jpar-1)*(*Dimension)] = vect.X(); Result[1+(jpar-1)*(*Dimension)] = vect.Y(); Result[2+(jpar-1)*(*Dimension)] = vect.Z(); @@ -255,9 +280,9 @@ GeomConvert_ApproxSurface::GeomConvert_ApproxSurface(const Handle(Geom_Surface)& const Standard_Integer MaxSegments, const Standard_Integer PrecisCode) { - Standard_Real U0, U1, V0, V1; + Standard_Real U0, U1, V0, V1; - fonct = new (GeomAdaptor_HSurface)(Surf); // Initialisation de la surface algorithmique + Handle(Adaptor3d_HSurface) aSurfAdaptor = new GeomAdaptor_HSurface (Surf); Surf->Bounds(U0, U1, V0, V1); // " Init des nombres de sous-espaces et des tolerances" @@ -285,27 +310,27 @@ GeomConvert_ApproxSurface::GeomConvert_ApproxSurface(const Handle(Geom_Surface)& GeomAbs_IsoType IsoType = GeomAbs_IsoV; Standard_Integer NbDec; - NbDec = fonct->NbUIntervals(GeomAbs_C2); + NbDec = aSurfAdaptor->NbUIntervals(GeomAbs_C2); TColStd_Array1OfReal UDec_C2(1, NbDec+1); - fonct->UIntervals(UDec_C2, GeomAbs_C2); - NbDec = fonct->NbVIntervals(GeomAbs_C2); + aSurfAdaptor->UIntervals(UDec_C2, GeomAbs_C2); + NbDec = aSurfAdaptor->NbVIntervals(GeomAbs_C2); TColStd_Array1OfReal VDec_C2(1, NbDec+1); - fonct->VIntervals(VDec_C2, GeomAbs_C2); + aSurfAdaptor->VIntervals(VDec_C2, GeomAbs_C2); - NbDec = fonct->NbUIntervals(GeomAbs_C3); + NbDec = aSurfAdaptor->NbUIntervals(GeomAbs_C3); TColStd_Array1OfReal UDec_C3(1, NbDec+1); - fonct->UIntervals(UDec_C3, GeomAbs_C3); + aSurfAdaptor->UIntervals(UDec_C3, GeomAbs_C3); - NbDec = fonct->NbVIntervals(GeomAbs_C3); + NbDec = aSurfAdaptor->NbVIntervals(GeomAbs_C3); TColStd_Array1OfReal VDec_C3(1, NbDec+1); - fonct->VIntervals(VDec_C3, GeomAbs_C3); + aSurfAdaptor->VIntervals(VDec_C3, GeomAbs_C3); // Approximation avec decoupe preferentiel // aux lieux de discontinuitees C2 AdvApprox_PrefAndRec pUDec(UDec_C2,UDec_C3); AdvApprox_PrefAndRec pVDec(VDec_C2,VDec_C3); //POP pour WNT - AdvApp2Var_EvaluatorFunc2Var ev = mySurfEval1; + GeomConvert_ApproxSurface_Eval ev (aSurfAdaptor); AdvApp2Var_ApproxAFunc2Var approx(nb1, nb2, nb3, nul1,nul1,eps3D, nul2,nul2,epsfr, diff --git a/src/GeomLib/GeomLib.cxx b/src/GeomLib/GeomLib.cxx index 26def6eeec..a7a94ec11d 100755 --- a/src/GeomLib/GeomLib.cxx +++ b/src/GeomLib/GeomLib.cxx @@ -1963,29 +1963,41 @@ static Standard_Boolean CanBeTreated(Handle(Geom_BSplineSurface)& BSurf) } //======================================================================= -//function : law_evaluator -//purpose : usefull to estimate the value of a function of 2 variables +//class : law_evaluator +//purpose : usefull to estimate the value of a function of 2 variables //======================================================================= -static GeomLib_DenominatorMultiplierPtr MyPtr = NULL ; +class law_evaluator : public BSplSLib_EvaluatorFunction +{ +public: -static void law_evaluator(const Standard_Integer DerivativeRequest, - const Standard_Real UParameter, - const Standard_Real VParameter, - Standard_Real & Result, - Standard_Integer & ErrorCode) { - - ErrorCode = 0 ; - - if ((!(MyPtr == NULL)) && - (DerivativeRequest == 0)) { - Result=MyPtr->Value(UParameter,VParameter); + law_evaluator (const GeomLib_DenominatorMultiplierPtr theDenominatorPtr) + : myDenominator (theDenominatorPtr) {} + + virtual void Evaluate (const Standard_Integer theDerivativeRequest, + const Standard_Real theUParameter, + const Standard_Real theVParameter, + Standard_Real& theResult, + Standard_Integer& theErrorCode) const + { + if ((myDenominator != NULL) && (theDerivativeRequest == 0)) + { + theResult = myDenominator->Value (theUParameter, theVParameter); + theErrorCode = 0; + } + else + { + theErrorCode = 1; + } } - else { - ErrorCode = 1 ; - } -} + +private: + + GeomLib_DenominatorMultiplierPtr myDenominator; + +}; + //======================================================================= //function : CheckIfKnotExists //purpose : true if the knot already exists in the knot sequence @@ -2128,8 +2140,7 @@ static void FunctionMultiply(Handle(Geom_BSplineSurface)& BSurf, TColStd_Array1OfReal FlatKnots(1,length); BSplCLib::KnotSequence(NewKnots->ChangeArray1(),NewMults->ChangeArray1(),FlatKnots); - GeomLib_DenominatorMultiplier local_denominator(BSurf,FlatKnots) ; - MyPtr = &local_denominator ; //definition of a(u,v) + GeomLib_DenominatorMultiplier aDenominator (BSurf, FlatKnots); BuildFlatKnot(surface_u_knots, surface_u_mults, @@ -2164,7 +2175,7 @@ static void FunctionMultiply(Handle(Geom_BSplineSurface)& BSurf, BSplCLib::KnotSequence(newuknots->ChangeArray1(),newumults->ChangeArray1(),newuflatknots); BSplCLib::KnotSequence(newvknots->ChangeArray1(),newvmults->ChangeArray1(),newvflatknots); //POP pour WNT - BSplSLib_EvaluatorFunction ev = law_evaluator; + law_evaluator ev (&aDenominator); // BSplSLib::FunctionMultiply(law_evaluator, //multiplication BSplSLib::FunctionMultiply(ev, //multiplication BSurf->UDegree(), diff --git a/src/GeomPlate/GeomPlate_MakeApprox.cxx b/src/GeomPlate/GeomPlate_MakeApprox.cxx index dd03ba18f1..8f85fe18dc 100755 --- a/src/GeomPlate/GeomPlate_MakeApprox.cxx +++ b/src/GeomPlate/GeomPlate_MakeApprox.cxx @@ -34,10 +34,33 @@ #include -static Handle(Geom_Surface) fonct = NULL; +class GeomPlate_MakeApprox_Eval : public AdvApp2Var_EvaluatorFunc2Var +{ +public: -extern "C" void myPlateSurfEval(Standard_Integer * Dimension, + GeomPlate_MakeApprox_Eval (const Handle(Geom_Surface)& theSurf) + : mySurf (theSurf) {} + + virtual void Evaluate (Standard_Integer* theDimension, + Standard_Real* theUStartEnd, + Standard_Real* theVStartEnd, + Standard_Integer* theFavorIso, + Standard_Real* theConstParam, + Standard_Integer* theNbParams, + Standard_Real* theParameters, + Standard_Integer* theUOrder, + Standard_Integer* theVOrder, + Standard_Real* theResult, + Standard_Integer* theErrorCode) const; + +private: + + Handle(Geom_Surface) mySurf; + +}; + +void GeomPlate_MakeApprox_Eval::Evaluate (Standard_Integer * Dimension, // Dimension Standard_Real * UStartEnd, // StartEnd[2] in U @@ -57,9 +80,9 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, // Derivative Request in V Standard_Real * Result, // Result[Dimension,N] - Standard_Integer * ErrorCode) + Standard_Integer * ErrorCode) const // Error Code -{ +{ *ErrorCode = 0; Standard_Integer idim,jpar; Standard_Real Upar,Vpar; @@ -114,7 +137,7 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, case 0 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - pnt = fonct->Value(Upar,Vpar); + pnt = mySurf->Value (Upar, Vpar); Result[(jpar-1)*(*Dimension)] = pnt.X(); Result[1+(jpar-1)*(*Dimension)] = pnt.Y(); Result[2+(jpar-1)*(*Dimension)] = pnt.Z(); @@ -123,7 +146,7 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, case 1 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - fonct->D1(Upar, Vpar, pnt, v1, v2); + mySurf->D1 (Upar, Vpar, pnt, v1, v2); if (*UOrder==1) { Result[(jpar-1)*(*Dimension)] = v1.X(); Result[1+(jpar-1)*(*Dimension)] = v1.Y(); @@ -139,7 +162,7 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, case 2 : for (jpar=1;jpar<=*NbParams;jpar++) { Vpar = Parameters[jpar-1]; - fonct->D2(Upar, Vpar, pnt, v1, v2, v3, v4, v5); + mySurf->D2 (Upar, Vpar, pnt, v1, v2, v3, v4, v5); if (*UOrder==2) { Result[(jpar-1)*(*Dimension)] = v3.X(); Result[1+(jpar-1)*(*Dimension)] = v3.Y(); @@ -165,7 +188,7 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, case 0 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - pnt = fonct->Value(Upar,Vpar); + pnt = mySurf->Value (Upar, Vpar); Result[(jpar-1)*(*Dimension)] = pnt.X(); Result[1+(jpar-1)*(*Dimension)] = pnt.Y(); Result[2+(jpar-1)*(*Dimension)] = pnt.Z(); @@ -174,7 +197,7 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, case 1 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - fonct->D1(Upar, Vpar, pnt, v1, v2); + mySurf->D1 (Upar, Vpar, pnt, v1, v2); if (*UOrder==1) { Result[(jpar-1)*(*Dimension)] = v1.X(); Result[1+(jpar-1)*(*Dimension)] = v1.Y(); @@ -190,7 +213,7 @@ extern "C" void myPlateSurfEval(Standard_Integer * Dimension, case 2 : for (jpar=1;jpar<=*NbParams;jpar++) { Upar = Parameters[jpar-1]; - fonct->D2(Upar, Vpar, pnt, v1, v2, v3, v4, v5); + mySurf->D2 (Upar, Vpar, pnt, v1, v2, v3, v4, v5); if (*UOrder==2) { Result[(jpar-1)*(*Dimension)] = v3.X(); Result[1+(jpar-1)*(*Dimension)] = v3.Y(); @@ -228,7 +251,6 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf const Standard_Real EnlargeCoeff) { myPlate = SurfPlate; - fonct = myPlate; Standard_Real U0=0., U1=0., V0=0., V1=0.; myPlate->RealBounds(U0, U1, V0, V1); @@ -256,7 +278,7 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf AdvApprox_DichoCutting myDec; //POP pour WNT - AdvApp2Var_EvaluatorFunc2Var ev = myPlateSurfEval; + GeomPlate_MakeApprox_Eval ev (myPlate); AdvApp2Var_ApproxAFunc2Var AppPlate(nb1, nb2, nb3, nul1,nul1,eps3D, nul2,nul2,epsfr, @@ -293,7 +315,6 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf const Standard_Real EnlargeCoeff) { myPlate = SurfPlate; - fonct = myPlate; TColgp_SequenceOfXY Seq2d; TColgp_SequenceOfXYZ Seq3d; @@ -311,13 +332,13 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf gp_Vec v1h,v2h,v3h; if (CritOrder==0) { // a l'ordre 0 - fonct->D0(P2d.X(),P2d.Y(),PP); + myPlate->D0 (P2d.X(), P2d.Y(), PP); gp_XYZ P3d(PP.X(),PP.Y(),PP.Z()); Seq3d.Append(P3d); } else { // a l'ordre 1 - fonct->D1(P2d.X(),P2d.Y(),PP,v1h,v2h); + myPlate->D1 (P2d.X(), P2d.Y(), PP, v1h, v2h); v3h=v1h^v2h; gp_XYZ P3d(v3h.X(),v3h.Y(),v3h.Z()); Seq3d.Append(P3d); @@ -367,7 +388,7 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf if (CritOrder==-1) { myPrec = 1; // POP pour NT - AdvApp2Var_EvaluatorFunc2Var ev = myPlateSurfEval; + GeomPlate_MakeApprox_Eval ev (myPlate); AdvApp2Var_ApproxAFunc2Var AppPlate(nb1, nb2, nb3, nul1,nul1,eps3D, nul2,nul2,epsfr, @@ -388,7 +409,7 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf else if (CritOrder==0) { GeomPlate_PlateG0Criterion Crit0(Seq2d,Seq3d,seuil); // POP pour NT - AdvApp2Var_EvaluatorFunc2Var ev = myPlateSurfEval; + GeomPlate_MakeApprox_Eval ev (myPlate); AdvApp2Var_ApproxAFunc2Var AppPlate(nb1, nb2, nb3, nul1,nul1,eps3D, nul2,nul2,epsfr, @@ -411,7 +432,7 @@ GeomPlate_MakeApprox::GeomPlate_MakeApprox(const Handle(GeomPlate_Surface)& Surf else if (CritOrder==1) { GeomPlate_PlateG1Criterion Crit1(Seq2d,Seq3d,seuil); // POP pour NT - AdvApp2Var_EvaluatorFunc2Var ev = myPlateSurfEval; + GeomPlate_MakeApprox_Eval ev (myPlate); AdvApp2Var_ApproxAFunc2Var AppPlate(nb1, nb2, nb3, nul1,nul1,eps3D, nul2,nul2,epsfr, diff --git a/src/IntCurve/IntCurve_IntPolyPolyGen.gxx b/src/IntCurve/IntCurve_IntPolyPolyGen.gxx index 38a71b4c42..12ae042ef1 100755 --- a/src/IntCurve/IntCurve_IntPolyPolyGen.gxx +++ b/src/IntCurve/IntCurve_IntPolyPolyGen.gxx @@ -44,7 +44,6 @@ //---------------------------------------------------------------------- -static Standard_Boolean AnErrorOccurred=Standard_False; @@ -77,7 +76,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1 ,const Standard_Real TheTol) { - AnErrorOccurred = Standard_False; + Standard_Boolean AnErrorOccurred = Standard_False; this->ResetFields(); DomainOnCurve1=D1; @@ -248,7 +247,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1 ,const Standard_Real TheTol) { - AnErrorOccurred = Standard_False; + Standard_Boolean AnErrorOccurred = Standard_False; this->ResetFields(); DomainOnCurve1=D1; @@ -354,6 +353,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1 gp_Pnt2d P1,P2; Standard_Integer nbsamples; done = Standard_False; + Standard_Boolean AnErrorOccurred = Standard_False; nbsamples = TheCurveTool::NbSamples(C1,D1.FirstParameter(),D1.LastParameter()); @@ -770,6 +770,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1 gp_Pnt2d P1,P2; Standard_Integer nbsamplesOnC1,nbsamplesOnC2; done = Standard_False; + Standard_Boolean AnErrorOccurred = Standard_False; if(NbIter>NBITER_MAX_POLYGON) return; diff --git a/src/IntCurveSurface/IntCurveSurface_CurveTool.gxx b/src/IntCurveSurface/IntCurveSurface_CurveTool.gxx index 72695b2125..716483552d 100755 --- a/src/IntCurveSurface/IntCurveSurface_CurveTool.gxx +++ b/src/IntCurveSurface/IntCurveSurface_CurveTool.gxx @@ -17,7 +17,7 @@ Standard_Integer IntCurveSurface_CurveTool::NbSamples (const CurveGen& C, const Standard_Real U0, const Standard_Real U1) { GeomAbs_CurveType typC = C.GetType(); - static Standard_Real nbsOther = 10.0; + const Standard_Real nbsOther = 10.0; Standard_Real nbs = nbsOther; if(typC == GeomAbs_Line) diff --git a/src/IntCurveSurface/IntCurveSurface_HCurveTool.gxx b/src/IntCurveSurface/IntCurveSurface_HCurveTool.gxx index 5315d508b3..5fd4fd225a 100755 --- a/src/IntCurveSurface/IntCurveSurface_HCurveTool.gxx +++ b/src/IntCurveSurface/IntCurveSurface_HCurveTool.gxx @@ -21,7 +21,7 @@ Standard_Integer IntCurveSurface_HCurveTool::NbSamples (const CurveGen& C, const Standard_Real U0, const Standard_Real U1) { GeomAbs_CurveType typC = C->GetType(); - static Standard_Real nbsOther = 10.0; + const Standard_Real nbsOther = 10.0; Standard_Real nbs = nbsOther; if(typC == GeomAbs_Line) @@ -47,7 +47,7 @@ void IntCurveSurface_HCurveTool::SamplePars (const CurveGen& C, const Standard_Integer NbMin, Handle(TColStd_HArray1OfReal)& Pars) { GeomAbs_CurveType typC = C->GetType(); - static Standard_Real nbsOther = 10.0; + const Standard_Real nbsOther = 10.0; Standard_Real nbs = nbsOther; if(typC == GeomAbs_Line) diff --git a/src/IntCurveSurface/IntCurveSurface_Inter.gxx b/src/IntCurveSurface/IntCurveSurface_Inter.gxx index 3c1a7d74b0..b28faa45ed 100755 --- a/src/IntCurveSurface/IntCurveSurface_Inter.gxx +++ b/src/IntCurveSurface/IntCurveSurface_Inter.gxx @@ -1195,7 +1195,7 @@ void IntCurveSurface_Inter::PerformConicSurf(const gp_Lin& Line, case GeomAbs_Cone: { //OCC516(apo)-> - static Standard_Real correction = 1.E+5*Precision::Angular(); + const Standard_Real correction = 1.E+5*Precision::Angular(); gp_Cone cn = TheSurfaceTool::Cone(surface); if(Abs(cn.SemiAngle()) < M_PI/2.0 - correction){ IntAna_IntConicQuad LinCone(Line,cn); diff --git a/src/IntCurveSurface/IntCurveSurface_Polyhedron.gxx b/src/IntCurveSurface/IntCurveSurface_Polyhedron.gxx index a5d8bf8381..d77403f0e8 100755 --- a/src/IntCurveSurface/IntCurveSurface_Polyhedron.gxx +++ b/src/IntCurveSurface/IntCurveSurface_Polyhedron.gxx @@ -104,7 +104,7 @@ void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface, const Standard_Real V0, const Standard_Real U1, const Standard_Real V1) { - static Standard_Integer DebugDump = 0; + const Standard_Integer DebugDump = 0; Standard_Integer i1,i2; Standard_Real U,V; Standard_Real U1mU0sNbdeltaU = (U1-U0)/(Standard_Real)nbdeltaU; @@ -190,7 +190,7 @@ void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface, void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface, const TColStd_Array1OfReal& Upars, const TColStd_Array1OfReal& Vpars) { - static Standard_Integer DebugDump = 0; + const Standard_Integer DebugDump = 0; Standard_Integer i1,i2; Standard_Real U,V; gp_Pnt TP; diff --git a/src/IntImp/IntImp_Int2S.gxx b/src/IntImp/IntImp_Int2S.gxx index 87bbe19caa..1da634ce54 100755 --- a/src/IntImp/IntImp_Int2S.gxx +++ b/src/IntImp/IntImp_Int2S.gxx @@ -82,8 +82,11 @@ IntImp_ConstIsoparametric IntImp_Int2S:: math_FunctionSetRoot& Rsnld, const IntImp_ConstIsoparametric ChoixIso ) { - static math_Vector BornInf(1,3),BornSup(1,3),Tolerance(1,3),UVap(1,3); - static TColStd_Array1OfReal Uvres(1,4); + Standard_Real BornInfBuf[3], BornSupBuf[3], ToleranceBuf[3], UVapBuf[3]; + Standard_Real UvresBuf[4]; + math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3), Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3); + TColStd_Array1OfReal Uvres (UvresBuf[0], 1, 4); + IntImp_ConstIsoparametric BestChoix; myZerParFunc.ComputeParameters(ChoixIso,Param,UVap, BornInf,BornSup,Tolerance); @@ -120,7 +123,8 @@ IntImp_ConstIsoparametric IntImp_Int2S:: Perform( gp_Vec DPUV[4]; gp_Pnt P1,P2; Standard_Real Epsuv[4]; - static TColStd_Array1OfReal Duv(1,4); + Standard_Real DuvBuf[4]; + TColStd_Array1OfReal Duv (DuvBuf[0], 1, 4); Standard_Real UVd[4],UVf[4]; IntImp_ConstIsoparametric ChoixIso[4]; IntImp_ConstIsoparametric BestChoix=ChoixRef[0]; @@ -230,6 +234,3 @@ IntImp_ConstIsoparametric IntImp_Int2S:: Perform( } return BestChoix; } - - - diff --git a/src/IntImp/IntImp_IntCS.gxx b/src/IntImp/IntImp_IntCS.gxx index b591d831b5..91ea79f963 100755 --- a/src/IntImp/IntImp_IntCS.gxx +++ b/src/IntImp/IntImp_IntCS.gxx @@ -74,10 +74,8 @@ void IntImp_IntCS::Perform(const Standard_Real U, const Standard_Real w0, const Standard_Real w1) { done = Standard_True; - static math_Vector UVap(1,3); - static math_Vector BornInf(1,3); - static math_Vector BornSup(1,3); - static math_Vector Tolerance(1,3); + Standard_Real BornInfBuf[3], BornSupBuf[3], ToleranceBuf[3], UVapBuf[3]; + math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3), Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3); UVap(1) = U; UVap(2) = V; UVap(3) = W; diff --git a/src/Intf/Intf_Interference.cxx b/src/Intf/Intf_Interference.cxx index bbf67521da..d026b6e6cb 100755 --- a/src/Intf/Intf_Interference.cxx +++ b/src/Intf/Intf_Interference.cxx @@ -12,8 +12,6 @@ //purpose : Initialize for a deferred interference. //======================================================================= -static Standard_Integer debug=0; - Intf_Interference::Intf_Interference (const Standard_Boolean Self) : SelfIntf(Self) {} @@ -114,21 +112,9 @@ Standard_Boolean Intf_Interference::Insert(const Intf_TangentZone& LaZone) Standard_Integer npcz=-1; // Number of points in the current zone Standard_Integer nplz=LaZone.NumberOfPoints(); // in the new zone - if (debug>0) { - cout << "Zone of insertion : \n"; - LaZone.Dump(2); - cout << endl; - } - // Loop on TangentZone : for (Standard_Integer Iz=1; Iz<=myTZones.Length(); Iz++) { - if (debug>0) { - cout << "Zone : "<< Iz << "\n"; - myTZones(Iz).Dump(2); - cout << endl; - } - // Loop on edges of the TangentZone : npcz=myTZones(Iz).NumberOfPoints(); Standard_Integer Ipz0, Ipz1, Ipz2; @@ -201,13 +187,6 @@ Standard_Boolean Intf_Interference::Insert(const Intf_TangentZone& LaZone) Inserted =Standard_False; } - if (debug>0) { - if (Inserted) { - cout << "Zone agrandie : "<< lzin <<" \n"; - myTZones(lzin).Dump(2); - cout << endl; - } - } if (Inserted) { Intf_TangentZone theNew=myTZones(lzin); myTZones.Remove(lzin); diff --git a/src/Intf/Intf_InterferencePolygon2d.cdl b/src/Intf/Intf_InterferencePolygon2d.cdl index 787fc968d1..6a4b4824ab 100755 --- a/src/Intf/Intf_InterferencePolygon2d.cdl +++ b/src/Intf/Intf_InterferencePolygon2d.cdl @@ -86,4 +86,10 @@ is ---Purpose: Computes the intersection between two segments -- et . +fields + oClos, tClos : Boolean from Standard; + iObje1, iObje2, nbso : Integer from Standard; + BeginOfNotClosedObje1: Boolean from Standard; + BeginOfNotClosedObje2: Boolean from Standard; + end InterferencePolygon2d; diff --git a/src/Intf/Intf_InterferencePolygon2d.gxx b/src/Intf/Intf_InterferencePolygon2d.gxx index f888e7a930..f72c721a17 100755 --- a/src/Intf/Intf_InterferencePolygon2d.gxx +++ b/src/Intf/Intf_InterferencePolygon2d.gxx @@ -12,11 +12,12 @@ #include #include -static Standard_Integer debug=0; - // Angular precision (sinus) below that value two right segments // are considered as having a potential zone of tangency. -static Standard_Real PRCANG=Precision::Angular(); +namespace +{ + static const Standard_Real PRCANG = Precision::Angular(); +}; //======================================================================= //function : Intf_InterferencePolygon2d @@ -24,7 +25,14 @@ static Standard_Real PRCANG=Precision::Angular(); //======================================================================= Intf_InterferencePolygon2d::Intf_InterferencePolygon2d() -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + oClos (Standard_False), + tClos (Standard_False), + iObje1 (0), + iObje2 (0), + nbso (0), + BeginOfNotClosedObje1 (Standard_False), + BeginOfNotClosedObje2 (Standard_False) {} //======================================================================= @@ -32,12 +40,16 @@ Intf_InterferencePolygon2d::Intf_InterferencePolygon2d() //purpose : Constructor of the interference beetween two Polygon. //======================================================================= -static Standard_Boolean oClos, tClos; -static Standard_Integer iObje1, iObje2, nbso; - Intf_InterferencePolygon2d::Intf_InterferencePolygon2d (const Polygon2d1& Obje1, const Polygon2d2& Obje2) -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + oClos (Standard_False), + tClos (Standard_False), + iObje1 (0), + iObje2 (0), + nbso (0), + BeginOfNotClosedObje1 (Standard_False), + BeginOfNotClosedObje2 (Standard_False) { if (!ToolPolygon2d1::Bounding(Obje1).IsOut (ToolPolygon2d2::Bounding(Obje2))) { @@ -61,7 +73,14 @@ Intf_InterferencePolygon2d::Intf_InterferencePolygon2d Intf_InterferencePolygon2d::Intf_InterferencePolygon2d (const Polygon2d1& Obje) -: Intf_Interference(Standard_True) +: Intf_Interference (Standard_True), + oClos (Standard_False), + tClos (Standard_False), + iObje1 (0), + iObje2 (0), + nbso (0), + BeginOfNotClosedObje1 (Standard_False), + BeginOfNotClosedObje2 (Standard_False) { Tolerance=ToolPolygon2d1::DeflectionOverEstimation(Obje)*2; if (Tolerance==0.) @@ -129,8 +148,6 @@ gp_Pnt2d Intf_InterferencePolygon2d::Pnt2dValue //function : Interference //purpose : //======================================================================= -static Standard_Boolean BeginOfNotClosedObje1; -static Standard_Boolean BeginOfNotClosedObje2; void Intf_InterferencePolygon2d::Interference (const Polygon2d1& Obje1, @@ -234,12 +251,6 @@ void Intf_InterferencePolygon2d::Clean() if (delta1<1. && delta2<1.) Only1Seg=Standard_True; if (delta1==0. || delta2==0.) Only1Seg=Standard_True; - if (debug==1) { - cout<<"\n tz("< and points ,. -fields IndexMin : Integer from Standard; - MinimalDist : Real from Standard; +fields IndexMin : Integer from Standard; + MinimalDist : Real from Standard; + iObje1, iObje2 : Integer from Standard; + beginOfNotClosedFirst: Boolean from Standard; + beginOfNotClosedSecon: Boolean from Standard; + end InterferencePolygon3d; diff --git a/src/Intf/Intf_InterferencePolygon3d.gxx b/src/Intf/Intf_InterferencePolygon3d.gxx index 749034c1df..4e476f6e90 100755 --- a/src/Intf/Intf_InterferencePolygon3d.gxx +++ b/src/Intf/Intf_InterferencePolygon3d.gxx @@ -18,7 +18,12 @@ //======================================================================= Intf_InterferencePolygon3d::Intf_InterferencePolygon3d() -: Intf_Interference(Standard_False), IndexMin(0) +: Intf_Interference (Standard_False), + IndexMin (0), + iObje1 (0), + iObje2 (0), + beginOfNotClosedFirst (Standard_True), + beginOfNotClosedSecon (Standard_True) {} //======================================================================= @@ -26,11 +31,14 @@ Intf_InterferencePolygon3d::Intf_InterferencePolygon3d() //purpose : Constructor of the interference beetween two Polygon. //======================================================================= -static Standard_Integer iObje1, iObje2; - Intf_InterferencePolygon3d::Intf_InterferencePolygon3d (const Polygon3d1& Obje1, const Polygon3d2& Obje2) -: Intf_Interference(Standard_False), IndexMin(0) +: Intf_Interference (Standard_False), + IndexMin (0), + iObje1 (0), + iObje2 (0), + beginOfNotClosedFirst (Standard_True), + beginOfNotClosedSecon (Standard_True) { Tolerance=ToolPolygon3d1::DeflectionOverEstimation(Obje1)+ ToolPolygon3d2::DeflectionOverEstimation(Obje2); @@ -46,7 +54,12 @@ Intf_InterferencePolygon3d::Intf_InterferencePolygon3d Intf_InterferencePolygon3d::Intf_InterferencePolygon3d (const Polygon3d1& Obje) -: Intf_Interference(Standard_True), IndexMin(0) +: Intf_Interference (Standard_True), + IndexMin(0), + iObje1 (0), + iObje2 (0), + beginOfNotClosedFirst (Standard_True), + beginOfNotClosedSecon (Standard_True) { Tolerance=ToolPolygon3d1::DeflectionOverEstimation(Obje)*2; Interference(Obje); @@ -139,9 +152,6 @@ Standard_Integer Intf_InterferencePolygon3d::MinimalResult () const //purpose : //======================================================================= -static Standard_Boolean beginOfNotClosedFirst=Standard_True; -static Standard_Boolean beginOfNotClosedSecon=Standard_True; - void Intf_InterferencePolygon3d::Interference (const Polygon3d1& Obje1, const Polygon3d2& Obje2) diff --git a/src/Intf/Intf_InterferencePolygonPolyhedron.cdl b/src/Intf/Intf_InterferencePolygonPolyhedron.cdl index 4a72ffaa6b..f100378798 100755 --- a/src/Intf/Intf_InterferencePolygonPolyhedron.cdl +++ b/src/Intf/Intf_InterferencePolygonPolyhedron.cdl @@ -170,4 +170,8 @@ is ---Purpose: Computes the intersection between the segment -- and the triangle of . +fields + BeginOfClosedPolygon: Boolean from Standard; + iLin : Integer from Standard; + end InterferencePolygonPolyhedron; diff --git a/src/Intf/Intf_InterferencePolygonPolyhedron.gxx b/src/Intf/Intf_InterferencePolygonPolyhedron.gxx index eb3078ae75..7bcd55f2fa 100755 --- a/src/Intf/Intf_InterferencePolygonPolyhedron.gxx +++ b/src/Intf/Intf_InterferencePolygonPolyhedron.gxx @@ -17,22 +17,11 @@ #include #include -#ifdef DEB -static Standard_Integer debug=0; -#endif -#if 0 -static Standard_Real PRCANG=0.1; -#endif - -//#ifndef DEB -static int Pourcent3[4]={0,1,2,0}; -//#else -//static Pourcent3[4]={0,1,2,0}; -//#endif - #include #include +static const int Pourcent3[4] = {0, 1, 2, 0}; + static Standard_Boolean IsInSegment(const gp_Vec& P1P2, const gp_Vec& P1P, const Standard_Real NP1P2, @@ -57,7 +46,9 @@ static Standard_Boolean IsInSegment(const gp_Vec& P1P2, //======================================================================= Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron() -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + BeginOfClosedPolygon (Standard_False), + iLin (0) {} //======================================================================= @@ -66,12 +57,11 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron() // and a Polyhedron. //======================================================================= -static Standard_Boolean BeginOfClosedPolygon; -static Standard_Integer iLin; - Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron (const Polygon3d& thePolyg, const Polyhedron& thePolyh) -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + BeginOfClosedPolygon (Standard_False), + iLin (0) { Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+ ToolPolyh::DeflectionOverEstimation(thePolyh); @@ -84,12 +74,12 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron } - - Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron (const Polygon3d& thePolyg, const Polyhedron& thePolyh, Bnd_BoundSortBox &PolyhGrid) -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + BeginOfClosedPolygon (Standard_False), + iLin (0) { Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+ ToolPolyh::DeflectionOverEstimation(thePolyh); @@ -109,7 +99,9 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron (const gp_Lin& theLin, const Polyhedron& thePolyh) -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + BeginOfClosedPolygon (Standard_False), + iLin (0) { Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh); if (Tolerance==0.) @@ -148,7 +140,9 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh) -: Intf_Interference(Standard_False) +: Intf_Interference (Standard_False), + BeginOfClosedPolygon (Standard_False), + iLin (0) { Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh); if (Tolerance==0.) @@ -636,19 +630,6 @@ void Intf_InterferencePolygonPolyhedron::Interference } - - - - - - - - - - - - - //======================================================================= //function : Intersect //purpose : Compute the intersection beetween the segment or the line @@ -787,23 +768,9 @@ void Intf_InterferencePolygonPolyhedron::Intersect Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance plan gp_XYZ segO=EndO.XYZ()-BegO.XYZ(); segO.Normalize(); -#if 0 - Standard_Real angl=triNor*segO; -#endif Standard_Boolean NoIntersectionWithTriangle = Standard_False; Standard_Boolean PolygonCutsPlane = Standard_True; - -#if 0 - if (((!Infinite && Abs(dBegTri)<=Tolerance && Abs(dEndTri)<=Tolerance) || - (Infinite && angl<=PRCANG)) || (dBegTri-dEndTri)==0.) { - // On est dans la Zone d influence calculer sur quel partie : - // !!cout<<" AAAA "; - // !!cout<<" Beg End :"<= 1.e-16 || t<=-1.e-16) @@ -829,39 +796,9 @@ void Intf_InterferencePolygonPolyhedron::Intersect if(NoIntersectionWithTriangle == Standard_False) { gp_XYZ spLieu=BegO.XYZ()+((EndO.XYZ()-BegO.XYZ())*param); Standard_Real dPiE[3], dPtPi[3], sigd; -#ifndef DEB - Standard_Integer is =0; -#else - Standard_Integer is; -#endif + Standard_Integer is = 0; Standard_Integer sEdge=-1; Standard_Integer sVertex=-1; - /* for (is=0; is<3; is++) { - gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[(is+1)%3]).XYZ()- - ToolPolyh::Point(thePolyh, pTri[is]).XYZ()); - gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[is]).XYZ()); - dPtPi[is]=vecP.Modulus(); - if (dPtPi[is]<=floatgap) { - sVertex=is; - break; - } - gp_XYZ segT_x_vecP(segT^vecP); - Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus(); - sigd = segT_x_vecP*triNor; - if(sigd>floatgap) - sigd = 1.0; - else if(sigd<-floatgap) - sigd = -1.0; - else { - sigd = 0.0; - } - dPiE[is]=sigd*(Modulus_segT_x_vecP/segT.Modulus()); - if (Abs(dPiE[is])<=floatgap) { - sEdge=is; - break; - } - } - */ Standard_Integer tbreak=0; { //-- is = 0 gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()- @@ -892,7 +829,7 @@ void Intf_InterferencePolygonPolyhedron::Intersect } } } - + if(tbreak==0) { //-- is = 1 gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()- ToolPolyh::Point(thePolyh, pTri[1]).XYZ()); @@ -1136,11 +1073,7 @@ void Intf_InterferencePolygonPolyhedron::Intersect if(NoIntersectionWithTriangle == Standard_False) { gp_XYZ spLieu=BegO.XYZ()+((EndO.XYZ()-BegO.XYZ())*param); Standard_Real dPiE[3], dPtPi[3], sigd; -#ifndef DEB - Standard_Integer is =0; -#else - Standard_Integer is; -#endif + Standard_Integer is = 0; Standard_Integer sEdge=-1; Standard_Integer sVertex=-1; Standard_Integer tbreak=0; @@ -1370,4 +1303,3 @@ void Intf_InterferencePolygonPolyhedron::Intersect } } } -// end of File: Intf_InterferencePolygonPolyhedron.gxx diff --git a/src/Intf/Intf_InterferencePolyhedron.cdl b/src/Intf/Intf_InterferencePolyhedron.cdl index 2282fb9235..2c56d2f77f 100755 --- a/src/Intf/Intf_InterferencePolyhedron.cdl +++ b/src/Intf/Intf_InterferencePolyhedron.cdl @@ -16,6 +16,7 @@ generic class InterferencePolyhedron from Intf -- self interference of a polyhedron. uses Pnt from gp, + XYZ from gp, Box from Bnd, SectionPoint from Intf, SeqOfSectionPoint from Intf, @@ -85,5 +86,17 @@ is ---Purpose: Computes the zone of tangence between the facet of -- and the facet of . + CoupleCharacteristics (me: in out; + FirstPol: Polyhedron1; + SeconPol: Polyhedron2) is private; +fields + OI : Integer from Standard[3]; -- index des sommets de l objet + TI : Integer from Standard[3]; -- index des sommets du tool + dpOpT : Real from Standard[3, 3]; -- distance point Objet - point Tool + dpOeT : Real from Standard[3, 3]; -- distance point Objet - edge Tool + deOpT : Real from Standard[3, 3]; -- distance edge Objet - point Tool + voo : XYZ from gp[3]; -- vecteur point point Obje + vtt : XYZ from gp[3]; -- vecteur point point Tool + Incidence: Real from Standard; -- angle entre les deux plans end InterferencePolyhedron; diff --git a/src/Intf/Intf_InterferencePolyhedron.gxx b/src/Intf/Intf_InterferencePolyhedron.gxx index 0aad5ee462..df53a6110a 100755 --- a/src/Intf/Intf_InterferencePolyhedron.gxx +++ b/src/Intf/Intf_InterferencePolyhedron.gxx @@ -18,9 +18,7 @@ #include #include -//static Pourcent3[9]={0,1,2,0,1,2,0,1,2}; -static int Pourcent3[9]={0,1,2,0,1,2,0,1,2}; - +static const int Pourcent3[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2}; //======================================================================= //function : Intf_InterferencePolyhedron @@ -36,8 +34,6 @@ Intf_InterferencePolyhedron::Intf_InterferencePolyhedron () //purpose : //======================================================================= -static Standard_Integer debug=0; - Intf_InterferencePolyhedron::Intf_InterferencePolyhedron (const Polyhedron1& FirstPol, const Polyhedron2& SeconPol) : Intf_Interference(Standard_False) @@ -108,8 +104,6 @@ void Intf_InterferencePolyhedron::Perform //purpose : //======================================================================= -static Standard_Integer iFirst, iSecon; - void Intf_InterferencePolyhedron::Interference (const Polyhedron1&) {} @@ -120,6 +114,7 @@ void Intf_InterferencePolyhedron::Interference Standard_Boolean gridOnFirst=Standard_True; Standard_Integer NbTrianglesFirstPol = ToolPolyhe1::NbTriangles(FirstPol); Standard_Integer NbTrianglesSecondPol = ToolPolyhe2::NbTriangles(SeconPol); + Standard_Integer iFirst, iSecon; //------------------------------------------------------------------------------------------ //-- the same number of triangles it is necessary to test better on @@ -196,18 +191,6 @@ void Intf_InterferencePolyhedron::Interference //purpose : Intersection of two triangles issue from two Polyhedron. //======================================================================= -void CoupleCharacteristics(const Polyhedron1& FirstPol, - const Polyhedron2& SeconPol); - -static Standard_Integer OI[3]; // index des sommets de l objet -static Standard_Integer TI[3]; // index des sommets du tool -static Standard_Real dpOpT[3][3]; // distance point Objet - point Tool -static Standard_Real dpOeT[3][3]; // distance point Objet - edge Tool -static Standard_Real deOpT[3][3]; // distance edge Objet - point Tool -static gp_XYZ voo[3]; // vecteur point point Obje -static gp_XYZ vtt[3]; // vecteur point point Tool -static Standard_Real Incidence; // angle entre les deux plans - void Intf_InterferencePolyhedron::Intersect (const Standard_Integer Tri1, const Polyhedron1& FirstPol, const Standard_Integer Tri2, const Polyhedron2& SeconPol) @@ -290,12 +273,8 @@ void Intf_InterferencePolyhedron::Intersect (Abs(dpOfT[0]+dpOfT[1]+dpOfT[2])!= Abs(dpOfT[0])+Abs(dpOfT[1])+Abs(dpOfT[2]))){ - if (TangentZoneValue(TheTZ, FirstPol, Tri1, SeconPol, Tri2)) { - if (debug==2) { - cout<< "Zone de tangence Couple Tri1, Tri2 : " - << Tri1 << ", " << Tri2 << " : " << endl; - TheTZ.Dump(2); - } + if (TangentZoneValue(TheTZ, FirstPol, Tri1, SeconPol, Tri2)) + { if (!Insert(TheTZ)) myTZones.Append(TheTZ); } } @@ -662,10 +641,6 @@ void Intf_InterferencePolyhedron::Intersect ifin=id[2]; // } else { - if(debug==2) { - cout << "Impossible calculation problem in pointersec!" - << endl; - } ideb=-999; // No line of section possible ifin=-999; } @@ -684,10 +659,6 @@ void Intf_InterferencePolyhedron::Intersect ifin=id[2]; // } else { - if(debug==2) { - cout << "Impossible calculation problem in pointersec !" - << endl; - } ideb=-999; // No line of section possible ifin=-999; } @@ -882,9 +853,6 @@ Standard_Boolean Intf_InterferencePolyhedron::TangentZoneValue deOpT[nob][nou]*deOpT[nob][nou2]<0.) { if (nbpInt>=6) { - if(debug==2) { - cout << "Nombre de P.I. > 6 dans une TZ ! " << endl; - } break; } else { @@ -926,12 +894,6 @@ Standard_Boolean Intf_InterferencePolyhedron::TangentZoneValue } } if (nbNoInserted>0) { - if(debug==2) { - cout << "Insertion impossible ! \n"; - cout << " La Zone : \n"; - TheTZ.Dump(4); - cout << " Le(s) Point(s) : \n"; - } nob=nbNoInserted-1; while (nob>=0) { Tpi(piToInsert[nob--]).Dump(4); @@ -948,8 +910,8 @@ Standard_Boolean Intf_InterferencePolyhedron::TangentZoneValue //purpose : //======================================================================= -void CoupleCharacteristics(const Polyhedron1& FirstPol, - const Polyhedron2& SeconPol) +void Intf_InterferencePolyhedron::CoupleCharacteristics (const Polyhedron1& FirstPol, + const Polyhedron2& SeconPol) { Standard_Integer n1, n2; Standard_Real lg; @@ -994,22 +956,4 @@ void CoupleCharacteristics(const Polyhedron1& FirstPol, deOpT[n1][n2]=dpOpT[n1][n2]; } } -#if 0 - if (debug==1) { - cout<<"dpOpT: "< maxbinom and build the PASCAL triangle - -- on size N if necessary. - ---C++: inline - - InternalBinomial(N : Integer; - maxbinom : out Integer; - binom : out Address); - ---Purpose: only called by Binomial(N,P) + ---Purpose: Returns the Binomial Cnp. N should be <= BSplCLib::MaxDegree(). RationalDerivative(Degree : Integer; N : Integer; diff --git a/src/PLib/PLib.cxx b/src/PLib/PLib.cxx index 0447ed7ce5..d0bcffa635 100755 --- a/src/PLib/PLib.cxx +++ b/src/PLib/PLib.cxx @@ -6,10 +6,8 @@ // Modified: 18/06/1996 by PMN : NULL reference. // Modified: 19/02/1997 by JCT : EvalPoly2Var added -#define No_Standard_RangeError -#define No_Standard_OutOfRange - #include +#include #include #include #include @@ -41,70 +39,87 @@ #include #include -void PLib::InternalBinomial(const Standard_Integer N, - Standard_Integer& maxbinom, - Standard_Address& binom) +class BinomAllocator { - if (N > maxbinom) { - Standard_Integer i,im1,ip1,id2,md2,md3,j,k; - Standard_Integer np1 = N + 1; - Standard_Integer** nwbin = new Standard_Integer* [np1]; - if (maxbinom >= 0) { +public: - for (i = 0; i <= maxbinom; i++) nwbin[i] = - ((Standard_Integer**)binom)[i]; - delete [] ((Standard_Integer**)binom); - } - else { - maxbinom = 0; - nwbin[0] = new Standard_Integer [1]; - nwbin[0][0] = 1; - } - binom = nwbin; - - for (i = maxbinom + 1; i < np1; i++) { + //! Main constructor + BinomAllocator (const Standard_Integer theMaxBinom) + : myBinom (NULL), + myMaxBinom (theMaxBinom) + { + Standard_Integer i, im1, ip1, id2, md2, md3, j, k; + Standard_Integer np1 = myMaxBinom + 1; + myBinom = new Standard_Integer*[np1]; + myBinom[0] = new Standard_Integer[1]; + myBinom[0][0] = 1; + for (i = 1; i < np1; ++i) + { im1 = i - 1; ip1 = i + 1; id2 = i >> 1; md2 = im1 >> 1; md3 = ip1 >> 1; k = 0; - ((Standard_Integer**)binom)[i] = new Standard_Integer [ip1]; + myBinom[i] = new Standard_Integer[ip1]; - for (j = 0; j < id2; j++) { - ((Standard_Integer**)binom)[i][j] = - k + ((Standard_Integer**)binom)[im1][j]; - k = ((Standard_Integer**)binom)[im1][j]; + for (j = 0; j < id2; ++j) + { + myBinom[i][j] = k + myBinom[im1][j]; + k = myBinom[im1][j]; } j = id2; if (j > md2) j = im1 - j; - ((Standard_Integer**)binom)[i][id2] = - k + ((Standard_Integer**)binom)[im1][j]; + myBinom[i][id2] = k + myBinom[im1][j]; - for (j = ip1 - md3; j < ip1; j++) { - ((Standard_Integer**)binom)[i][j] = - ((Standard_Integer**)binom)[i][i - j]; + for (j = ip1 - md3; j < ip1; j++) + { + myBinom[i][j] = myBinom[i][i - j]; } } - maxbinom = N; } -} -static Standard_Integer storage_size = 0 ; -static Standard_Real *derivative_storage= NULL; -static Standard_Integer binomial_size = 0; -static Standard_Real *binomial_array = NULL; + //! Destructor + ~BinomAllocator() + { + // free memory + for (Standard_Integer i = 0; i <= myMaxBinom; ++i) + { + delete[] myBinom[i]; + } + delete[] myBinom; + } -static void LocalArray(const Standard_Integer newsize, - Standard_Integer& size, - Standard_Real** arr) + Standard_Real Value (const Standard_Integer N, + const Standard_Integer P) const + { + Standard_OutOfRange_Raise_if (N > myMaxBinom, + "PLib, BinomAllocator: requested degree is greater than maximum supported"); + return Standard_Real (myBinom[N][P]); + } + +private: + Standard_Integer** myBinom; + Standard_Integer myMaxBinom; + +}; + +namespace { - // update a local array - if (newsize > size) { - if (*arr) delete [] *arr; - size = newsize; - *arr = new Standard_Real [size]; - } + // we do not call BSplCLib here to avoid Cyclic dependency detection by WOK + //static BinomAllocator THE_BINOM (BSplCLib::MaxDegree() + 1); + static BinomAllocator THE_BINOM (25 + 1); +}; + +//======================================================================= +//function : Bin +//purpose : +//======================================================================= + +Standard_Real PLib::Bin(const Standard_Integer N, + const Standard_Integer P) +{ + return THE_BINOM.Value (N, P); } //======================================================================= @@ -161,29 +176,20 @@ void PLib::RationalDerivative(const Standard_Integer Degree, Standard_Real *RationalArray = &RDers; Standard_Real Factor ; Standard_Integer ii, Index, OtherIndex, Index1, Index2, jj; + PLib_LocalArray binomial_array; + PLib_LocalArray derivative_storage; if (Dimension == 3) { Standard_Integer DeRequest1 = DerivativeRequest + 1; Standard_Integer MinDegRequ = DerivativeRequest; if (MinDegRequ > Degree) MinDegRequ = Degree; - if (DeRequest1 > binomial_size) { - if (binomial_size > 0) { - delete [] binomial_array; - } - binomial_array = new Standard_Real [DeRequest1]; - binomial_size = DeRequest1; - } + binomial_array.Allocate (DeRequest1); for (ii = 0 ; ii < DeRequest1 ; ii++) { binomial_array[ii] = 1.0e0 ; } if (!All) { Standard_Integer DimDeRequ1 = (DeRequest1 << 1) + DeRequest1; - if (storage_size < DimDeRequ1) { - if (storage_size > 0) - delete [] derivative_storage ; - derivative_storage = new Standard_Real [DimDeRequ1]; - storage_size = DimDeRequ1; - } + derivative_storage.Allocate (DimDeRequ1); RationalArray = derivative_storage ; } @@ -258,25 +264,14 @@ void PLib::RationalDerivative(const Standard_Integer Degree, Standard_Integer DeRequest1 = DerivativeRequest + 1; Standard_Integer MinDegRequ = DerivativeRequest; if (MinDegRequ > Degree) MinDegRequ = Degree; - if (DeRequest1 > binomial_size) { - if (binomial_size > 0) { - delete [] binomial_array; - } - binomial_array = new Standard_Real [DeRequest1]; - binomial_size = DeRequest1; - } + binomial_array.Allocate (DeRequest1); for (ii = 0 ; ii < DeRequest1 ; ii++) { binomial_array[ii] = 1.0e0 ; } if (!All) { Standard_Integer DimDeRequ1 = Dimension * DeRequest1; - if (storage_size < DimDeRequ1) { - if (storage_size > 0) - delete [] derivative_storage ; - derivative_storage = new Standard_Real [DimDeRequ1]; - storage_size = DimDeRequ1; - } + derivative_storage.Allocate (DimDeRequ1); RationalArray = derivative_storage ; } @@ -401,13 +396,8 @@ void PLib::RationalDerivatives(const Standard_Integer DerivativeRequest, Standard_Integer ii, Index, Index1, Index2, jj; Standard_Integer DeRequest1 = DerivativeRequest + 1; - if (DeRequest1 > binomial_size) { - if (binomial_size > 0) { - delete [] binomial_array; - } - binomial_array = new Standard_Real [DeRequest1]; - binomial_size = DeRequest1; - } + PLib_LocalArray binomial_array (DeRequest1); + PLib_LocalArray derivative_storage; for (ii = 0 ; ii < DeRequest1 ; ii++) { binomial_array[ii] = 1.0e0 ; @@ -1938,9 +1928,8 @@ PLib::EvalLagrange(const Standard_Real Parameter, ResultArray = &Results ; if (local_request >= Degree) { local_request = Degree ; - } - LocalArray((Degree + 1) * Dimension, - storage_divided, ÷d_differences_array) ; + } + PLib_LocalArray divided_differences_array ((Degree + 1) * Dimension); // // Build the divided differences array // @@ -2070,8 +2059,7 @@ Standard_Integer PLib::EvalCubicHermite if (local_request >= Degree) { local_request = Degree ; } - LocalArray((Degree + 1) * Dimension, - storage_size, ÷d_differences_array) ; + PLib_LocalArray divided_differences_array ((Degree + 1) * Dimension); for (ii = 0, jj = 0 ; ii < 2 ; ii++, jj+= 2) { ParametersArray[jj] = @@ -2305,8 +2293,6 @@ void PLib::CoefficientsPoles (const Standard_Integer dim, } Standard_Real Cnp; - PLib::Binomial(reflen - 1); - for (i = 2; i < reflen; i++ ) { Cnp = PLib::Bin(reflen - 1, i - 1); if (rat) Weights (lowp + i - 1) = WCoefs (lowc + i - 1) / Cnp; @@ -2478,7 +2464,6 @@ void PLib::CoefficientsPoles (const TColgp_Array2OfPnt& Coefs, Standard_Integer I1, I2; Standard_Integer NPoleu , NPolev; gp_XYZ Temp; - PLib::Binomial(RowLength - 1); for (NPoleu = LowerRow; NPoleu <= UpperRow; NPoleu++){ Poles (NPoleu, LowerCol) = Coefs (NPoleu, LowerCol); @@ -2510,7 +2495,6 @@ void PLib::CoefficientsPoles (const TColgp_Array2OfPnt& Coefs, } } } - PLib::Binomial(ColLength - 1); for (NPolev = LowerCol; NPolev <= UpperCol; NPolev++){ diff --git a/src/PLib/PLib.lxx b/src/PLib/PLib.lxx index dd3c39c7a7..0b5bdffaff 100755 --- a/src/PLib/PLib.lxx +++ b/src/PLib/PLib.lxx @@ -3,26 +3,12 @@ // Author: Laurent BOURESCHE // -static Standard_Integer maxbinom = -1; -static Standard_Address binom; - -inline TColStd_Array1OfReal& PLib::NoWeights() +inline TColStd_Array1OfReal& PLib::NoWeights() { return (*((TColStd_Array1OfReal*) NULL )); } -inline TColStd_Array2OfReal& PLib::NoWeights2() +inline TColStd_Array2OfReal& PLib::NoWeights2() { return (*((TColStd_Array2OfReal*) NULL )); } - -inline Standard_Real PLib::Bin(const Standard_Integer N, - const Standard_Integer P) -{ - return (Standard_Real)((Standard_Integer**)binom)[N][P]; -} - -inline void PLib::Binomial(const Standard_Integer N) -{ - if (N > maxbinom) PLib::InternalBinomial(N,maxbinom,binom); -} diff --git a/src/PLib/PLib_HermitJacobi.cxx b/src/PLib/PLib_HermitJacobi.cxx index bc4657d6c5..f5077452aa 100755 --- a/src/PLib/PLib_HermitJacobi.cxx +++ b/src/PLib/PLib_HermitJacobi.cxx @@ -3,9 +3,9 @@ // Author: Sergey SOKOLOV // - #include #include +#include #include //======================================================================= @@ -133,13 +133,11 @@ void PLib_HermitJacobi::D0123(const Standard_Integer NDeriv, TColStd_Array1OfReal& BasisD2, TColStd_Array1OfReal& BasisD3) { -// Tableaux en static - static Standard_Real jac0[4*20]; - static Standard_Real jac1[4*20]; - static Standard_Real jac2[4*20]; - static Standard_Real jac3[4*20]; - static Standard_Real wvalues[4]; - + PLib_LocalArray jac0 (4 * 20); + PLib_LocalArray jac1 (4 * 20); + PLib_LocalArray jac2 (4 * 20); + PLib_LocalArray jac3 (4 * 20); + PLib_LocalArray wvalues (4); Standard_Integer i, j; Standard_Integer NivConstr = this->NivConstr(), @@ -293,4 +291,3 @@ void PLib_HermitJacobi::D3(const Standard_Real U, { D0123(3,U,BasisValue,BasisD1,BasisD2,BasisD3); } - diff --git a/src/PLib/PLib_LocalArray.hxx b/src/PLib/PLib_LocalArray.hxx new file mode 100644 index 0000000000..c853b4b6a7 --- /dev/null +++ b/src/PLib/PLib_LocalArray.hxx @@ -0,0 +1,68 @@ +// File: PLib_LocalArray.hxx +// Created: Wed Sep 23 2009 +// Copyright: Open CASCADE 2009 + +#ifndef _PLib_LocalArray_HeaderFile +#define _PLib_LocalArray_HeaderFile + +#include +#include + +//! Auxiliary class optimizing creation of array buffer for +//! evaluation of bspline (using stack allocation for small arrays) +class PLib_LocalArray +{ +public: + + // 1K * sizeof (double) = 8K + static const size_t MAX_ARRAY_SIZE = 1024; + + PLib_LocalArray (const size_t theSize) + : myPtr (myBuffer) + { + Allocate(theSize); + } + + PLib_LocalArray() + : myPtr (myBuffer) {} + + virtual ~PLib_LocalArray() + { + Deallocate(); + } + + void Allocate (const size_t theSize) + { + Deallocate(); + if (theSize > MAX_ARRAY_SIZE) + myPtr = (Standard_Real*)Standard::Allocate (theSize * sizeof(Standard_Real)); + else + myPtr = myBuffer; + } + + operator Standard_Real*() const + { + return myPtr; + } + +private: + + PLib_LocalArray (const PLib_LocalArray& ); + PLib_LocalArray& operator= (const PLib_LocalArray& ); + +protected: + + void Deallocate() + { + if (myPtr != myBuffer) + Standard::Free (*(Standard_Address*)&myPtr); + } + +protected: + + Standard_Real myBuffer[MAX_ARRAY_SIZE]; + Standard_Real* myPtr; + +}; + +#endif diff --git a/src/Plate/Plate_Plate.cdl b/src/Plate/Plate_Plate.cdl index 4bb3528f59..26a40523d2 100755 --- a/src/Plate/Plate_Plate.cdl +++ b/src/Plate/Plate_Plate.cdl @@ -139,5 +139,6 @@ fields ddu : Real[10]; ddv : Real[10]; maxConstraintOrder : Integer; - PolynomialPartOnly : Boolean; + PolynomialPartOnly : Boolean; + Uold, Vold, U2, R, L : Real; -- these fields should be mutable end; diff --git a/src/Plate/Plate_Plate.cxx b/src/Plate/Plate_Plate.cxx index 5edec7e8be..6b8a1d10e6 100755 --- a/src/Plate/Plate_Plate.cxx +++ b/src/Plate/Plate_Plate.cxx @@ -25,11 +25,15 @@ //purpose : //======================================================================= -Plate_Plate::Plate_Plate() : - order(0), n_el(0), n_dim(0), - solution(0),points(0),deru(0),derv(0), - OK(Standard_False),maxConstraintOrder(0) - +Plate_Plate::Plate_Plate() +: order(0), n_el(0), n_dim(0), + solution(0),points(0),deru(0),derv(0), + OK(Standard_False),maxConstraintOrder(0), + Uold (1.e20), + Vold (1.e20), + U2 (0.0), + R (0.0), + L (0.0) { PolynomialPartOnly = Standard_False; } @@ -39,10 +43,15 @@ Plate_Plate::Plate_Plate() : //purpose : //======================================================================= -Plate_Plate::Plate_Plate(const Plate_Plate& Ref) : - order(Ref.order),n_el(Ref.n_el),n_dim(Ref.n_dim), - solution(0),points(0),deru(0),derv(0), - OK(Ref.OK) +Plate_Plate::Plate_Plate(const Plate_Plate& Ref) +: order(Ref.order),n_el(Ref.n_el),n_dim(Ref.n_dim), + solution(0),points(0),deru(0),derv(0), + OK (Ref.OK), + Uold (1.e20), + Vold (1.e20), + U2 (0.0), + R (0.0), + L (0.0) { Standard_Integer i; if (Ref.OK) { @@ -1042,19 +1051,10 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte // of Laplcian at the power order //======================================================================= - static Standard_Real Uold = 1.e20; - static Standard_Real Vold = 1.e20; - static Standard_Real U2=0; - static Standard_Real R=0; - static Standard_Real L=0; - Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu, const Standard_Integer iv) const { -// Standard_Real U2; -// Standard_Real R; -// Standard_Real L; -// + Plate_Plate* aThis = const_cast(this); Standard_Real U,V; Standard_Integer IU,IV; @@ -1081,18 +1081,18 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu } else { - Uold = U; - Vold = V; - U2 = U*U; - R = U2+V*V; + aThis->Uold = U; + aThis->Vold = V; + aThis->U2 = U*U; + aThis->R = U2+V*V; if (R<1.e-20) return 0; - L = log(R); + aThis->L = log(R); } Standard_Real DUV = 0; Standard_Integer m = order; Standard_Integer mm1 = m-1; - Standard_Real &r = R; + Standard_Real &r = aThis->R; //Standard_Real pr = pow(R, mm1 - IU - IV); diff --git a/src/ProjLib/ProjLib_CompProjectedCurve.cdl b/src/ProjLib/ProjLib_CompProjectedCurve.cdl index 8a4e0388cf..6f98ceb6ca 100755 --- a/src/ProjLib/ProjLib_CompProjectedCurve.cdl +++ b/src/ProjLib/ProjLib_CompProjectedCurve.cdl @@ -188,30 +188,31 @@ is -- curve to project and surface returns Real raises NoSuchObject; - + -- Methods for debugging GetSequence(me) returns HSequenceOfHSequenceOfPnt from ProjLib ---C++: return const & is static; - + GetType(me) returns CurveType from GeomAbs ---Purpose: Returns the type of the curve in the current -- interval : Line, Circle, Ellipse, Hyperbola, -- Parabola, BezierCurve, BSplineCurve, OtherCurve. is redefined static; - + fields - mySurface : HSurface from Adaptor3d; - myCurve : HCurve from Adaptor3d; - myNbCurves : Integer from Standard; - mySequence : HSequenceOfHSequenceOfPnt from ProjLib; + mySurface : HSurface from Adaptor3d; + myCurve : HCurve from Adaptor3d; + myNbCurves : Integer from Standard; + mySequence : HSequenceOfHSequenceOfPnt from ProjLib; myTolU : Real from Standard; - myTolV : Real from Standard; - myMaxDist : Real from Standard; + myTolV : Real from Standard; + myMaxDist : Real from Standard; myUIso : HArray1OfBoolean from TColStd; myVIso : HArray1OfBoolean from TColStd; - mySnglPnts : HArray1OfBoolean from TColStd; - myMaxDistance : HArray1OfReal from TColStd; - + mySnglPnts : HArray1OfBoolean from TColStd; + myMaxDistance : HArray1OfReal from TColStd; + myTabInt : HArray1OfReal from TColStd; -- this field should be mutable + end CompProjectedCurve; diff --git a/src/ProjLib/ProjLib_CompProjectedCurve.cxx b/src/ProjLib/ProjLib_CompProjectedCurve.cxx index 62bcebee2c..ace00428cf 100755 --- a/src/ProjLib/ProjLib_CompProjectedCurve.cxx +++ b/src/ProjLib/ProjLib_CompProjectedCurve.cxx @@ -19,10 +19,9 @@ #include #include - #define FuncTol 1.e-10 -#if DEB +#ifdef __OCC_DEBUG_CHRONO #include static OSD_Chronometer chr_init_point, chr_dicho_bound; @@ -45,7 +44,6 @@ static void ResultChron( OSD_Chronometer & ch, Standard_Real & time) } #endif -static Handle(TColStd_HArray1OfReal) TabInt; //======================================================================= //function : d1 @@ -159,7 +157,7 @@ static void d1(const Standard_Real t, //purpose : computes first derivative of the 3d projected curve //======================================================================= -#ifdef DEB +#if 0 static void d1CurvOnSurf(const Standard_Real t, const Standard_Real u, const Standard_Real v, @@ -398,7 +396,7 @@ static void DichExactBound(gp_Pnt& Sol, const Handle(Adaptor3d_HCurve)& Curve, const Handle(Adaptor3d_HSurface)& Surface) { -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_dicho_bound); #endif @@ -426,7 +424,7 @@ static void DichExactBound(gp_Pnt& Sol, } else aNotSol = t; } -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_dicho_bound,t_dicho_bound); dicho_bound_count++; #endif @@ -533,7 +531,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, void ProjLib_CompProjectedCurve::Init() { - TabInt.Nullify(); + myTabInt.Nullify(); Standard_Real Tol;// Tolerance for ExactBound Standard_Integer i, Nend = 0; @@ -632,11 +630,11 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, if (!initpoint) { myCurve->D0(t,CPoint); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO InitChron(chr_init_point); #endif initpoint=InitialPoint(CPoint, t,myCurve,mySurface, myTolU, myTolV, U, V); -#ifdef DEB +#ifdef __OCC_DEBUG_CHRONO ResultChron(chr_init_point,t_init_point); init_point_count++; #endif @@ -1278,15 +1276,9 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, Standard_Integer ProjLib_CompProjectedCurve::NbIntervals(const GeomAbs_Shape S) const { - TabInt.Nullify(); + const_cast(this)->myTabInt.Nullify(); BuildIntervals(S); - Standard_Integer NbInt; - NbInt=TabInt->Length() - 1; - -#ifdef DEB -// cout<<"NbIntervals = "<Length() - 1; } //======================================================================= @@ -1296,16 +1288,8 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, void ProjLib_CompProjectedCurve::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const { - if(TabInt.IsNull()) BuildIntervals(S); - T = TabInt->Array1(); - -#if DEB -/* cout<<"Intervals = "; - for(Standard_Integer i = 1; i <= T.Length(); i++) - cout<Array1(); } //======================================================================= @@ -1315,11 +1299,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const { -#ifndef DEB GeomAbs_Shape SforS = GeomAbs_CN; -#else - GeomAbs_Shape SforS; -#endif switch(S) { case GeomAbs_C0: SforS = GeomAbs_C1; @@ -1512,9 +1492,9 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, BArr->ChangeValue(i) = Fusion(i); } - TabInt = new TColStd_HArray1OfReal(1, BArr->Length()); + const_cast(this)->myTabInt = new TColStd_HArray1OfReal(1, BArr->Length()); for(i = 1; i <= BArr->Length(); i++) - TabInt->ChangeValue(i) = BArr->Value(i); + myTabInt->ChangeValue(i) = BArr->Value(i); } @@ -1544,24 +1524,3 @@ GeomAbs_CurveType ProjLib_CompProjectedCurve::GetType() const { return GeomAbs_OtherCurve; } - - - - - - - - - - - - - - - - - - - - -