diff --git a/src/Contap/Contap_ArcFunction.hxx b/src/Contap/Contap_ArcFunction.hxx index 56814977b6..c121888564 100644 --- a/src/Contap/Contap_ArcFunction.hxx +++ b/src/Contap/Contap_ArcFunction.hxx @@ -73,7 +73,12 @@ public: Standard_EXPORT const IntSurf_Quadric& Quadric() const; + //! Returns mySurf field + const Handle(Adaptor3d_HSurface)& Surface() const; + //! Returns the point, which has been computed + //! while the last calling Value() method + const gp_Pnt& LastComputedPoint() const; protected: diff --git a/src/Contap/Contap_ArcFunction.lxx b/src/Contap/Contap_ArcFunction.lxx index 7a9057d3b5..91c9a32051 100644 --- a/src/Contap/Contap_ArcFunction.lxx +++ b/src/Contap/Contap_ArcFunction.lxx @@ -53,3 +53,13 @@ inline const gp_Pnt& Contap_ArcFunction::Valpoint { return seqpt(Index); } + +inline const Handle(Adaptor3d_HSurface)& Contap_ArcFunction::Surface() const +{ + return(mySurf); +} + +inline const gp_Pnt& Contap_ArcFunction::LastComputedPoint() const +{ + return solpt; +} diff --git a/src/IntPatch/IntPatch_ArcFunction.hxx b/src/IntPatch/IntPatch_ArcFunction.hxx index 178c0d802e..bf83dd7f29 100644 --- a/src/IntPatch/IntPatch_ArcFunction.hxx +++ b/src/IntPatch/IntPatch_ArcFunction.hxx @@ -68,6 +68,9 @@ public: const Handle(Adaptor3d_HSurface)& Surface() const; + //! Returns the point, which has been computed + //! while the last calling Value() method + const gp_Pnt& LastComputedPoint() const; diff --git a/src/IntPatch/IntPatch_ArcFunction.lxx b/src/IntPatch/IntPatch_ArcFunction.lxx index 87ee21c951..314eff9bab 100644 --- a/src/IntPatch/IntPatch_ArcFunction.lxx +++ b/src/IntPatch/IntPatch_ArcFunction.lxx @@ -51,3 +51,8 @@ inline const Handle(Adaptor3d_HSurface)& IntPatch_ArcFunction::Surface() const { return(mySurf); } + +inline const gp_Pnt& IntPatch_ArcFunction::LastComputedPoint() const +{ + return ptsol; +} diff --git a/src/IntStart/IntStart_SearchOnBoundaries.gxx b/src/IntStart/IntStart_SearchOnBoundaries.gxx index 1ad1368d99..0efe2b2745 100644 --- a/src/IntStart/IntStart_SearchOnBoundaries.gxx +++ b/src/IntStart/IntStart_SearchOnBoundaries.gxx @@ -12,6 +12,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include #include @@ -39,6 +40,11 @@ #include #include +#include +#include +#include +#include +#include static void FindVertex (const TheArc&, const Handle(TheTopolTool)&, @@ -76,6 +82,33 @@ static Standard_Integer TreatLC (const TheArc& A, static Standard_Boolean IsRegularity(const TheArc& A, const Handle(TheTopolTool)& aDomain); +class MinFunction : public math_Function +{ +public: + MinFunction(TheFunction &theFunc) : myFunc(&theFunc) {}; + + //returns value of the one-dimension-function when parameter + //is equal to theX + virtual Standard_Boolean Value(const Standard_Real theX, + Standard_Real& theFVal) + { + if(!myFunc->Value(theX, theFVal)) + return Standard_False; + + theFVal *= theFVal; + return Standard_True; + } + + //see analogical method for abstract owner class math_Function + virtual Standard_Integer GetStateNumber() + { + return 0; + } + +private: + TheFunction *myFunc; +}; + //======================================================================= //function : FindVertex @@ -116,6 +149,54 @@ void FindVertex (const TheArc& A, } } +class SolInfo +{ +public: + SolInfo() : myMathIndex(-1), myValue(RealLast()) + { + } + + void Init(const math_FunctionAllRoots& theSolution, const Standard_Integer theIndex) + { + myMathIndex = theIndex; + myValue = theSolution.GetPoint(theIndex); + } + + Standard_Real Value() const + { + return myValue; + } + + Standard_Integer Index() const + { + return myMathIndex; + } + + bool operator>(const SolInfo& theOther) const + { + return myValue > theOther.myValue; + } + + bool operator<(const SolInfo& theOther) const + { + return myValue < theOther.myValue; + } + + bool operator==(const SolInfo& theOther) const + { + return myValue == theOther.myValue; + } + + Standard_Real& ChangeValue() + { + return myValue; + } + +private: + Standard_Integer myMathIndex; + Standard_Real myValue; +}; + static void BoundedArc (const TheArc& A, const Handle(TheTopolTool)& Domain, @@ -129,18 +210,17 @@ void BoundedArc (const TheArc& A, Standard_Boolean& Arcsol, const Standard_Boolean RecheckOnRegularity) { - -// Recherche des points solutions et des bouts d arc solution sur un arc donne. -// On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour -// des arcs ayant un point debut et un point de fin (intervalle ferme de -// parametrage). + // Recherche des points solutions et des bouts d arc solution sur un arc donne. + // On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour + // des arcs ayant un point debut et un point de fin (intervalle ferme de + // parametrage). Standard_Integer i,Nbi,Nbp; gp_Pnt ptdeb,ptfin; Standard_Real pardeb = 0., parfin = 0.; Standard_Integer ideb,ifin,range,ranged,rangef; - + // Creer l echantillonage (math_FunctionSample ou classe heritant) // Appel a math_FunctionAllRoots @@ -156,10 +236,10 @@ void BoundedArc (const TheArc& A, //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - -// Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A); + + // Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A); Standard_Integer NbEchant = Func.NbSamples(); - + //-- Modif 24 Aout 93 ----------------------------- Standard_Real nTolTangency = TolTangency; if((Pfin - Pdeb) < (TolTangency*10.0)) { @@ -176,13 +256,12 @@ void BoundedArc (const TheArc& A, //-- if(NbEchant<3) NbEchant = 3; //-- lbr le 19 Avril 95 //-------------------------------------------------- Standard_Real para=0,dist,maxdist; -/* if(NbEchant<20) NbEchant = 20; //-- lbr le 22 Avril 96 - //-- Toujours des pbs -*/ - if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96 - //-- Toujours des pbs - - + /* if(NbEchant<20) NbEchant = 20; //-- lbr le 22 Avril 96 + //-- Toujours des pbs + */ + if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96 + //-- Toujours des pbs + //-------------------------------------------------------------- REJECTIONS le 15 oct 98 Standard_Boolean Rejection=Standard_True; Standard_Real maxdr,maxr,minr,ur,dur; @@ -222,7 +301,7 @@ void BoundedArc (const TheArc& A, if(Rejection==Standard_False) { math_FunctionSample Echant(Pdeb,Pfin,NbEchant); - + Standard_Boolean aelargir=Standard_True; //modified by NIZNHY-PKV Thu Apr 12 09:25:19 2001 f // @@ -241,11 +320,11 @@ void BoundedArc (const TheArc& A, if(!(aelargir && maxdist<0.01)) { maxdist = TolBoundary; } - + math_FunctionAllRoots Sol(Func,Echant,EpsX,maxdist,maxdist); //-- TolBoundary,nTolTangency); - + if (!Sol.IsDone()) {Standard_Failure::Raise();} - + Nbp=Sol.NbPoints(); // //jgv: build solution on the whole boundary @@ -255,11 +334,11 @@ void BoundedArc (const TheArc& A, //theTol += theTol; Standard_Real theTol = 5.e-4; math_FunctionAllRoots SolAgain(Func,Echant,EpsX,theTol,theTol); //-- TolBoundary,nTolTangency); - + if (!SolAgain.IsDone()) {Standard_Failure::Raise();} - + Standard_Integer Nbi_again = SolAgain.NbIntervals(); - + if (Nbi_again > 0) { Standard_Integer NbSamples = 10; @@ -286,19 +365,19 @@ void BoundedArc (const TheArc& A, newseg.SetValue(A); // Recuperer point debut et fin, et leur parametre. SolAgain.GetInterval(i,pardeb,parfin); - + if (Abs(pardeb - Pdeb) <= Precision::PConfusion()) pardeb = Pdeb; if (Abs(parfin - Pfin) <= Precision::PConfusion()) parfin = Pfin; - + SolAgain.GetIntervalState(i,ideb,ifin); - + //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "< aSI(1, Nbp); + + for(i=1;i<=Nbp;i++) + { + aSI(i).Init(Sol, i); } - Standard_Boolean ok; - do { - ok=Standard_True; - for(i=1;iTabSol[i+1]) { - ok=Standard_False; - para=TabSol[i]; TabSol[i]=TabSol[i+1]; TabSol[i+1]=para; - } - } - } - - while(ok==Standard_False); + + std::sort(aSI.begin(), aSI.end()); + //modified by NIZNHY-PKV Wed Mar 21 18:34:18 2001 f ////////////////////////////////////////////////////////// // The treatment of the situation when line(arc) that is @@ -345,105 +416,126 @@ void BoundedArc (const TheArc& A, // PKV Fri Mar 23 12:17:29 2001 Standard_Integer ip; const IntSurf_Quadric& aQuadric=Func.Quadric(); - + ip=TreatLC (A, Domain, aQuadric, TolBoundary, pnt); if (ip) { - ////////////////////////////////////////////////////////// - //modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t - // - // Using of old usual way proposed by Laurent - // - for(i=1;i 0.001) - aTol = 0.001; + Standard_Real param=(para+parap1)*0.5; + Standard_Real ym; + if(Func.Value(param,ym)) { + if(Abs(ym)= 0.) ? 1.e9 : -1.e9); - para = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9); - - Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol)); + // Compute the number of nodes. + Standard_Real aTol = TolBoundary*1000.0; + if(aTol > 0.001) + aTol = 0.001; - Standard_Real aVal = RealLast(); - //Standard_Integer aNbNodes = 23; - Standard_Real aDelta = (parap1 - para)/(aNbNodes + 1.); - Standard_Integer ii; - Standard_Real aCurPar; - Standard_Real aCurVal; + // fix floating point exception 569, chl-922-e9 + parap1 = (Abs(parap1) < 1.e9) ? parap1 : ((parap1 >= 0.) ? 1.e9 : -1.e9); + para = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9); - for (ii = 0; ii <= aNbNodes + 1; ii++) { - aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1; + Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol)); - if (Func.Value(aCurPar, aCurVal)) { - //if (aCurVal < aVal) { - if (Abs(aCurVal) < aVal) { - //aVal = aCurVal; - aVal = Abs(aCurVal); - param = aCurPar; - } - } + Standard_Real aVal = RealLast(); + //Standard_Integer aNbNodes = 23; + Standard_Real aDelta = (parap1 - para)/(aNbNodes + 1.); + Standard_Integer ii; + Standard_Real aCurPar; + Standard_Real aCurVal; + + for (ii = 0; ii <= aNbNodes + 1; ii++) { + aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1; + + if (Func.Value(aCurPar, aCurVal)) { + //if (aCurVal < aVal) { + if (Abs(aCurVal) < aVal) { + //aVal = aCurVal; + aVal = Abs(aCurVal); + param = aCurPar; + } + } + } + // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End + aSI(i).ChangeValue() = Pdeb - 1; + aSI(i + 1).ChangeValue() = param; } - // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End - TabSol[i]=Pdeb-1; - TabSol[i+1]=param; } } - } - - for (i=1; i<=Nbp; i++) { - para=TabSol[i]; - if((para-Pdeb) 0.1*Precision::Confusion()) + { + //Precise found points. It results in following: + // 1. Make the vertex nearer to the intersection line + // (see description to issue #27252 in order to + // understand necessity). + // 2. Merge two near vertices to single point. + + //All members in TabSol array has already been sorted in increase order. + //Now, we limit precise boundaries in order to avoid changing this order. + const Standard_Real aFPar = (i == 1) ? Pdeb : (para + aSI(i - 1).Value()) / 2.0; + const Standard_Real aLPar = (i == Nbp) ? Pfin : (para + aSI(i + 1).Value()) / 2.0; + + MinFunction aNewFunc(Func); + math_BrentMinimum aMin(Precision::Confusion()); + + aMin.Perform(aNewFunc, aFPar, para, aLPar); + if(aMin.IsDone()) + { + para = aMin.Location(); + const gp_Pnt2d aP2d(A->Value(para)); + aPnt = Func.Surface()->Value(aP2d.X(), aP2d.Y()); + } + } + + PointProcess(aPnt, para, A, Domain, pnt, TolBoundary, range); } - } - - if(TabSol) { - delete [] TabSol; - } - }// end ofif (ip) + }// end of if(ip) } // end of if(Nbp) // Pour chaque intervalle trouve faire // Traiter les extremites comme des points // Ajouter intervalle dans la liste des segments - + Nbi=Sol.NbIntervals(); @@ -453,7 +545,7 @@ void BoundedArc (const TheArc& A, } //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : Nbi : "< theEps) + { if (aF1 > aF2) { aB = aX2; aX2 = aX1; aF2 = aF1; - aX1 = aB - aCf * (aB - aA); + aX1 = aB-aCf*(aB-aA); aF1 = MaxDistance(theC, aX1, theProjPS); } else { aA = aX1; aX1 = aX2; aF1 = aF2; - aX2 = aA + aCf * (aB - aA); + aX2=aA+aCf*(aB-aA); aF2 = MaxDistance(theC, aX2, theProjPS); } } diff --git a/src/math/math_BrentMinimum.cxx b/src/math/math_BrentMinimum.cxx index b2c0f9ac41..df60527838 100644 --- a/src/math/math_BrentMinimum.cxx +++ b/src/math/math_BrentMinimum.cxx @@ -17,13 +17,20 @@ #include #include -#define CGOLD 0.3819660 -#ifdef MAX -#undef MAX -#endif -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define SIGN(a,b) ((b) > 0.0 ? fabs(a) : -fabs(a)) -#define SHFT(a,b,c,d) (a)=(b);(b)=(c);(c)=(d) +static const Standard_Real CGOLD = 0.3819660; //0.5*(3 - sqrt(5)); + + +//======================================================================= +//function : SHFT +//purpose : Shifts arguments +//======================================================================= +inline void SHFT(Standard_Real &theA, Standard_Real &theB, + Standard_Real &theC, Standard_Real &theD) +{ + theA = theB; + theB = theC; + theC = theD; +} //======================================================================= //function : math_BrentMinimum @@ -92,66 +99,66 @@ void math_BrentMinimum::Perform(math_Function& F, Standard_Real tol1, tol2, u, v, w, xm; Standard_Real e = 0.0; Standard_Real d = RealLast(); - + a = ((ax < cx) ? ax : cx); b = ((ax > cx) ? ax : cx); x = w = v = bx; if (!myF) { OK = F.Value(x, fx); - if(!OK) return; + if (!OK) return; } fw = fv = fx; - for(iter = 1; iter <= Itermax; iter++) { + for (iter = 1; iter <= Itermax; iter++) { xm = 0.5 * (a + b); tol1 = XTol * fabs(x) + EPSZ; tol2 = 2.0 * tol1; - if(IsSolutionReached(F)) { + if (IsSolutionReached(F)) { Done = Standard_True; return; } - if(fabs(e) > tol1) { + if (fabs(e) > tol1) { r = (x - w) * (fx - fv); q = (x - v) * (fx - fw); p = (x - v) * q - (x - w) * r; q = 2.0 * (q - r); - if(q > 0.0) p = -p; + if (q > 0.0) p = -p; q = fabs(q); etemp = e; e = d; - if(fabs(p) >= fabs(0.5 * q * etemp) - || p <= q * ( a - x) || p >= q * (b - x)) { - e = (x >= xm ? a - x : b - x); - d = CGOLD * e; + if (fabs(p) >= fabs(0.5 * q * etemp) + || p <= q * (a - x) || p >= q * (b - x)) { + e = (x >= xm ? a - x : b - x); + d = CGOLD * e; } else { - d = p / q; - u = x + d; - if(u - a < tol2 || b - u < tol2) d = SIGN(tol1, xm - x); + d = p / q; + u = x + d; + if (u - a < tol2 || b - u < tol2) d = Sign(tol1, xm - x); } } else { e = (x >= xm ? a - x : b - x); d = CGOLD * e; } - u = (fabs(d) >= tol1 ? x + d : x + SIGN(tol1, d)); + u = (fabs(d) >= tol1 ? x + d : x + Sign(tol1, d)); OK = F.Value(u, fu); - if(!OK) return; - if(fu <= fx) { - if(u >= x) a = x; else b = x; + if (!OK) return; + if (fu <= fx) { + if (u >= x) a = x; else b = x; SHFT(v, w, x, u); SHFT(fv, fw, fx, fu); } else { - if(u < x) a = u; else b = u; - if(fu <= fw || w == x) { - v = w; - w = u; - fv = fw; - fw = fu; + if (u < x) a = u; else b = u; + if (fu <= fw || w == x) { + v = w; + w = u; + fv = fw; + fw = fu; } - else if(fu <= fv || v == x || v == w) { - v = u; - fv = fu; + else if (fu <= fv || v == x || v == w) { + v = u; + fv = fu; } } } diff --git a/tests/bugs/modalg_2/bug497_3 b/tests/bugs/modalg_2/bug497_3 index 4b5bc90203..037e0fd150 100755 --- a/tests/bugs/modalg_2/bug497_3 +++ b/tests/bugs/modalg_2/bug497_3 @@ -1,5 +1,4 @@ puts "TODO OCC25735 ALL: Faulty shapes in variables faulty_1 to" -puts "TODO OCC26582 ALL: Error : The area of result shape is" puts "=========" puts " OCC497 " @@ -18,6 +17,6 @@ checkshape a_2 bcut result a_1 a_2 -checkprops result -s 2471.48 +checkprops result -s 1773.6 checkshape result checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_2/bug497_5 b/tests/bugs/modalg_2/bug497_5 index fe8897e8d0..32071d7004 100755 --- a/tests/bugs/modalg_2/bug497_5 +++ b/tests/bugs/modalg_2/bug497_5 @@ -1,5 +1,3 @@ -puts "TODO OCC24861 ALL: Error : The area of result shape is" - puts "=========" puts " OCC497 " puts "(case 5)" @@ -20,6 +18,6 @@ if [catch {bfuse result a_1 a_2 } catch_result] { } else { puts "OCC497 : function FUSE works without hangs up " } -checkprops result -s 3280.73 +checkprops result -s 3233.5 checkshape result checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_5/bug25292_36 b/tests/bugs/modalg_5/bug25292_36 index 52e3f20d69..a7a1d58f2f 100644 --- a/tests/bugs/modalg_5/bug25292_36 +++ b/tests/bugs/modalg_5/bug25292_36 @@ -6,27 +6,6 @@ puts "" # Face/Face intersection algorithm gives different results for different order of the arguments ####################################################################### -proc GetRange { curve } { - global U1 - global U2 - - set log [uplevel dump $curve] - - regexp {Degree +([-0-9.+eE]+), +([-0-9.+eE]+) Poles, +([-0-9.+eE]+)} ${log} full Degree Poles KnotsPoles - puts "Degree=${Degree}" - puts "Poles=${Poles}" - puts "KnotsPoles=${KnotsPoles}" - puts "" - - set Knot 1 - set exp_string "Knots :\n\n +${Knot} : +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)" - regexp ${exp_string} ${log} full U1 Mult1 - - set Knot ${KnotsPoles} - set exp_string " +${Knot} : +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)" - regexp ${exp_string} ${log} full U2 Mult2 -} - puts "##############################" puts "#!!!Search \"Attention\" keyword on this web-page for additional checking!!!" puts "##############################" @@ -59,57 +38,32 @@ set ind [string first "3d curve" $che] if {${ind} >= 0} { #Only variable "res" exists - if { $GoodNbCurv == 1 } { - puts "OK: Curve Number is good!" + copy res res_1 +} + +set ic 1 +set AllowRepeate 1 +while { $AllowRepeate != 0 } { + set che [whatis res_$ic] + set ind [string first "3d curve" $che] + if {${ind} < 0} { + set AllowRepeate 0 } else { - puts "Error: Curve Number is bad!" - } - - set U1 0.0 - set U2 0.0 - - GetRange res - - puts "U1 = ${U1}" - puts "U2 = ${U2}" - - if {[expr {$U2 - $U1}] < 1.0e-20} { - puts "Error: Wrong curve's range!" - } - - xdistcs res s1 ${U1} ${U2} 10 1e-7 - xdistcs res s2 ${U1} ${U2} 10 1e-7 -} else { - set ic 1 - set AllowRepeate 1 - while { $AllowRepeate != 0 } { - set che [whatis res_$ic] - set ind [string first "3d curve" $che] - if {${ind} < 0} { - set AllowRepeate 0 - } else { - set U1 0.0 - set U2 0.0 - - GetRange res_$ic - - puts "U1 = ${U1}" - puts "U2 = ${U2}" - - if {[expr {$U2 - $U1}] < 1.0e-20} { - puts "Error: Wrong curve's range!" - } - - xdistcs res_$ic s1 ${U1} ${U2} 10 1e-7 - xdistcs res_$ic s2 0 1 10 1e-7 - - incr ic + bounds res_$ic U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" } - } - - if {[expr {$ic - 1}] == $GoodNbCurv} { - puts "OK: Curve Number is good!" - } else { - puts "Error: Curve Number is bad!" + + xdistcs res_$ic s1 U1 U2 10 1e-7 + xdistcs res_$ic s2 U1 U2 10 1e-7 + + incr ic } } + +if {[expr {$ic - 1}] == $GoodNbCurv} { + puts "OK: Curve Number is good!" +} else { + puts "Error: Curve Number is bad!" +} diff --git a/tests/bugs/modalg_6/bug26841_1 b/tests/bugs/modalg_6/bug26841_1 index 5022332f73..c937feaccb 100644 --- a/tests/bugs/modalg_6/bug26841_1 +++ b/tests/bugs/modalg_6/bug26841_1 @@ -34,7 +34,7 @@ checknbshapes result -ref ${nbshapes_expected} -t -m "SECTION" regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance puts "MaxTolerance=$MaxTolerance" -set expected_MaxTolerance 4.8861509475438473e-005 +set expected_MaxTolerance 4.8861510463442802e-005 set tol_abs_MaxTolerance 0.0 set tol_rel_MaxTolerance 0.01 checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance} diff --git a/tests/bugs/modalg_6/bug26841_2 b/tests/bugs/modalg_6/bug26841_2 index 0cb0306c93..24dcad10f5 100644 --- a/tests/bugs/modalg_6/bug26841_2 +++ b/tests/bugs/modalg_6/bug26841_2 @@ -35,7 +35,7 @@ checknbshapes result -ref ${nbshapes_expected} -t -m "SECTION" regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance puts "MaxTolerance=$MaxTolerance" -set expected_MaxTolerance 0.00010145423883977269 +set expected_MaxTolerance 0.0001014542398395458 set tol_abs_MaxTolerance 0.0 set tol_rel_MaxTolerance 0.001 checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance} diff --git a/tests/bugs/modalg_6/bug27221 b/tests/bugs/modalg_6/bug27221 new file mode 100644 index 0000000000..697a1d6118 --- /dev/null +++ b/tests/bugs/modalg_6/bug27221 @@ -0,0 +1,23 @@ +puts "============" +puts "OCC27221" +puts "============" +puts "" +####################################################################### +# Regression vs. 6.7.0: bcut fails without notice +####################################################################### + +restore [locate_data_file bug27221.brep] a +explode a +mkplane f a_2 +prism p f -25 0 0 + +bcut result a_1 p + +checkprops result -v 56860.2 +checkprops result -s 72076 +checkshape result +bopargcheck result + +checknbshapes result -solid 1 -shell 1 -face 18 -t -m "NbShapes in result" + +checkview -display result -2d -v -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27252_1 b/tests/bugs/modalg_6/bug27252_1 new file mode 100644 index 0000000000..c2bf3c97d3 --- /dev/null +++ b/tests/bugs/modalg_6/bug27252_1 @@ -0,0 +1,37 @@ +puts "============" +puts "OCC27252" +puts "============" +puts "" +####################################################################### +# Implicit-implicit intersection (Cylinder-Plane) loses intersection curve +####################################################################### + +set GoodNbCurv 1 +set MaxTol 1.0e-7 + +restore [locate_data_file bug27221.brep] a +explode a +mkplane f a_2 +prism p f -25 0 0 +explode a_1 f +explode p f +don a_1_7 p_3 + +set log [bopcurves a_1_7 p_3 -2d] + +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv + +if {${NbCurv} != ${GoodNbCurv}} { + puts "Error: Curve Number is bad!" +} + +if {${Toler} > ${MaxTol}} { + puts "Error: Tolerance is too big!" +} + +smallview +don c_* +fit +display a_1_7 p_3 + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_6/bug27252_2 b/tests/bugs/modalg_6/bug27252_2 new file mode 100644 index 0000000000..3006392d57 --- /dev/null +++ b/tests/bugs/modalg_6/bug27252_2 @@ -0,0 +1,84 @@ +puts "=========" +puts "OCC24585" +puts "=========" +puts "" +########################################################### +# Wrong pcurve of the section curve +########################################################### + +set GoodNbCurv 1 +set GoodLength 0.9119608849931297 + +restore [locate_data_file bug27252_s351.draw] s1 +restore [locate_data_file bug27252_s352.draw] s2 + +set CheckID 0 + +foreach Toler { 1.0e-7 1.0e-4 } { + incr CheckID + + intersect result s1 s2 ${Toler} + + set che [whatis result] + set ind [string first "3d curve" $che] + if {${ind} >= 0} { + #Only variable "result" exists + renamevar result result_1 + } + + set clen 0.0 + + set ic 1 + set AllowRepeate 1 + while { $AllowRepeate != 0 } { + set che [whatis result_$ic] + set ind [string first "3d curve" $che] + if {${ind} < 0} { + set AllowRepeate 0 + } else { + display result_$ic + + bounds result_$ic U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" + } + + xdistcs result_$ic s1 U1 U2 10 1.0e-7 + xdistcs result_$ic s2 U1 U2 10 1.0e-7 + + for { set ip [expr $ic-1] } { $ip > 0 } { incr ip -1 } { + mkedge e1 result_$ic + mkedge e2 result_$ip + + set coe [checkoverlapedges e1 e2 5.0e-5] + + puts "result_$ic <-> result_$ip: $coe" + if { [regexp "Edges is not overlaped" $coe] != 1 } { + puts "Error: result_$ic and result_$ip are overlaped" + } + } + + regexp "The length result_$ic is +(\[-0-9.+eE\]+)" [length result_$ic] full ll + set clen [expr $clen+$ll] + + incr ic + } + } + + if {[expr {$ic - 1}] == $GoodNbCurv} { + puts "OK: Number of curves is good!" + } else { + puts "Error: $GoodNbCurv is expected but [expr {$ic - 1}] is found!" + } + + puts "Summary length = $clen" + checkreal SumLength $clen $GoodLength 0.0 1.0e-6 + + smallview + don result* + fit + clear + don s1 s2 result* + checkview -screenshot -2d -path ${imagedir}/${test_image}_${CheckID}.png +} \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27252_3 b/tests/bugs/modalg_6/bug27252_3 new file mode 100644 index 0000000000..89da745989 --- /dev/null +++ b/tests/bugs/modalg_6/bug27252_3 @@ -0,0 +1,84 @@ +puts "=========" +puts "OCC24585" +puts "=========" +puts "" +########################################################### +# Wrong pcurve of the section curve +########################################################### + +set GoodNbCurv 1 +set GoodLength 0.9119608849931374 + +restore [locate_data_file bug27252_s671.draw] s1 +restore [locate_data_file bug27252_s672.draw] s2 + +set CheckID 0 + +foreach Toler { 1.0e-7 1.0e-4 } { + incr CheckID + + intersect result s1 s2 ${Toler} + + set che [whatis result] + set ind [string first "3d curve" $che] + if {${ind} >= 0} { + #Only variable "result" exists + renamevar result result_1 + } + + set clen 0.0 + + set ic 1 + set AllowRepeate 1 + while { $AllowRepeate != 0 } { + set che [whatis result_$ic] + set ind [string first "3d curve" $che] + if {${ind} < 0} { + set AllowRepeate 0 + } else { + display result_$ic + + bounds result_$ic U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" + } + + xdistcs result_$ic s1 U1 U2 10 1.0e-7 + xdistcs result_$ic s2 U1 U2 10 1.0e-7 + + for { set ip [expr $ic-1] } { $ip > 0 } { incr ip -1 } { + mkedge e1 result_$ic + mkedge e2 result_$ip + + set coe [checkoverlapedges e1 e2 5.0e-5] + + puts "result_$ic <-> result_$ip: $coe" + if { [regexp "Edges is not overlaped" $coe] != 1 } { + puts "Error: result_$ic and result_$ip are overlaped" + } + } + + regexp "The length result_$ic is +(\[-0-9.+eE\]+)" [length result_$ic] full ll + set clen [expr $clen+$ll] + + incr ic + } + } + + if {[expr {$ic - 1}] == $GoodNbCurv} { + puts "OK: Number of curves is good!" + } else { + puts "Error: $GoodNbCurv is expected but [expr {$ic - 1}] is found!" + } + + puts "Summary length = $clen" + checkreal SumLength $clen $GoodLength 0.0 1.0e-6 + + smallview + don result* + fit + clear + don s1 s2 result* + checkview -screenshot -2d -path ${imagedir}/${test_image}_${CheckID}.png +} \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27252_4 b/tests/bugs/modalg_6/bug27252_4 new file mode 100644 index 0000000000..0117253ca4 --- /dev/null +++ b/tests/bugs/modalg_6/bug27252_4 @@ -0,0 +1,84 @@ +puts "=========" +puts "OCC24585" +puts "=========" +puts "" +########################################################### +# Wrong pcurve of the section curve +########################################################### + +set GoodNbCurv 1 +set GoodLength 0.9119608849931454 + +restore [locate_data_file bug27252_s1071.draw] s1 +restore [locate_data_file bug27252_s1072.draw] s2 + +set CheckID 0 + +foreach Toler { 1.0e-7 1.0e-4 } { + incr CheckID + + intersect result s1 s2 ${Toler} + + set che [whatis result] + set ind [string first "3d curve" $che] + if {${ind} >= 0} { + #Only variable "result" exists + renamevar result result_1 + } + + set clen 0.0 + + set ic 1 + set AllowRepeate 1 + while { $AllowRepeate != 0 } { + set che [whatis result_$ic] + set ind [string first "3d curve" $che] + if {${ind} < 0} { + set AllowRepeate 0 + } else { + display result_$ic + + bounds result_$ic U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" + } + + xdistcs result_$ic s1 U1 U2 10 1.0e-7 + xdistcs result_$ic s2 U1 U2 10 1.0e-7 + + for { set ip [expr $ic-1] } { $ip > 0 } { incr ip -1 } { + mkedge e1 result_$ic + mkedge e2 result_$ip + + set coe [checkoverlapedges e1 e2 5.0e-5] + + puts "result_$ic <-> result_$ip: $coe" + if { [regexp "Edges is not overlaped" $coe] != 1 } { + puts "Error: result_$ic and result_$ip are overlaped" + } + } + + regexp "The length result_$ic is +(\[-0-9.+eE\]+)" [length result_$ic] full ll + set clen [expr $clen+$ll] + + incr ic + } + } + + if {[expr {$ic - 1}] == $GoodNbCurv} { + puts "OK: Number of curves is good!" + } else { + puts "Error: $GoodNbCurv is expected but [expr {$ic - 1}] is found!" + } + + puts "Summary length = $clen" + checkreal SumLength $clen $GoodLength 0.0 1.0e-6 + + smallview + don result* + fit + clear + don s1 s2 result* + checkview -screenshot -2d -path ${imagedir}/${test_image}_${CheckID}.png +} \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27341_319 b/tests/bugs/modalg_6/bug27341_319 index a03d77fca8..d8f7b66f97 100644 --- a/tests/bugs/modalg_6/bug27341_319 +++ b/tests/bugs/modalg_6/bug27341_319 @@ -23,6 +23,6 @@ build3d result fit checkprops result -l 755.552 -checknbshapes result -vertex 376 -edge 188 +checknbshapes result -vertex 378 -edge 189 checkview -screenshot -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_6/bug27341_320 b/tests/bugs/modalg_6/bug27341_320 index ca1b112227..73e990c975 100644 --- a/tests/bugs/modalg_6/bug27341_320 +++ b/tests/bugs/modalg_6/bug27341_320 @@ -23,6 +23,6 @@ build3d result fit checkprops result -l 1726.77 -checknbshapes result -vertex 803 -edge 402 +checknbshapes result -vertex 807 -edge 404 checkview -screenshot -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_6/bug28210 b/tests/bugs/modalg_6/bug28210 new file mode 100644 index 0000000000..f6e6a8bd8d --- /dev/null +++ b/tests/bugs/modalg_6/bug28210 @@ -0,0 +1,29 @@ +puts "============" +puts "OCC28210" +puts "============" +puts "" +#################################################################################### +# Modeling Algorithms - Boolean cut operation produces incorrect result +#################################################################################### + +restore [locate_data_file bug28210_mhx_pmx_ws_pos3.brep] c +explode c So +bcut result c_1 c_2 + +checkshape result + +set nbshapes_expected " +Number of shapes in result + WIRE : 29 + FACE : 29 + SHELL : 1 + SOLID : 1 + COMPSOLID : 0 + COMPOUND : 1 +" + +checknbshapes result -ref ${nbshapes_expected} -t -m "Boolean cut operation" +checkprops result -v 213860 +checkprops result -s 25613.6 + +checkview -display result -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/moddata_2/bug569 b/tests/bugs/moddata_2/bug569 index 6035413da6..e929a7d3d5 100755 --- a/tests/bugs/moddata_2/bug569 +++ b/tests/bugs/moddata_2/bug569 @@ -1,5 +1,3 @@ -puts "TODO OCC12345 ALL: Faulty OCC569: function intersection works wrongly with trimmed plane and cone surfaces" - puts "========" puts "OCC569" puts "========" @@ -8,26 +6,57 @@ puts "" ## Can not intersect trimmed plane and cone surfaces ################################## +set GoodNbCurv 1 + restore [locate_data_file OCC569a.draw] s1 restore [locate_data_file OCC569b.draw] s2 +smallview +don s1 s2 +fit + if { [catch {intersect result s1 s2 } catch_result] } { - puts "Faulty OCC569 exception: function intersection works wrongly with trimmed plane and cone surfaces " + puts "Faulty OCC569 exception: function intersection works wrongly with trimmed plane and cone surfaces " } else { - set nom 0 - set j 1 - repeat 10 { - set err [lindex [whatis result_$j] 5] - if { $err != "curve"} { - break - } else { - set nom [expr $nom + 1] - } - incr j + checkview -screenshot -2d -path ${imagedir}/${test_image}.png + + set che [whatis result] + set ind [string first "3d curve" $che] + if {${ind} >= 0} { + #Only variable "res" exists + copy result result_1 + } + + trim s1 s1 + trim s2 s2 + + set ic 1 + set AllowRepeate 1 + while { $AllowRepeate != 0 } { + set che [whatis result_$ic] + set ind [string first "3d curve" $che] + if {${ind} < 0} { + set AllowRepeate 0 + break } - if { $nom == 0} { - puts "Faulty OCC569: function intersection works wrongly with trimmed plane and cone surfaces" - } else { - puts "OCC569 OK: function intersection works with trimmed plane and cone surfaces" + + bounds result_$ic U1 U2 + dump U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" } + + xdistcs result_$ic s1 U1 U2 10 1e-7 + xdistcs result_$ic s2 U1 U2 10 1e-7 + + incr ic + } } + +if {[expr {$ic - 1}] == $GoodNbCurv} { + puts "OCC569 OK: function intersection works with trimmed plane and cone surfaces" +} else { + puts "Faulty OCC569: function intersection works wrongly with trimmed plane and cone surfaces" +} +