From 71958f7db20660967e0c4851bdc8a9ec85bcbc38 Mon Sep 17 00:00:00 2001 From: nbv Date: Wed, 28 Oct 2015 10:10:37 +0300 Subject: [PATCH] 0026699: Wrong section curves 1. Algorithm of Restriction line processing has been improved in IntTools_FaceFace.cxx file. 2. Algorithm of checking, if Restriction line and Walking line are coincided has been improved in IntPatch_ImpPrmIntersection.cxx file. 3. Algorithm of extending check if starting point of Walking line is a tangent point has been added. Small correction of some test cases. Creation of test case for issue #0026699. Small correction of test case for issue CR26699 --- src/IntPatch/IntPatch_ImpPrmIntersection.cxx | 29 ++++--- src/IntTools/IntTools_FaceFace.cxx | 24 ++++-- src/IntTools/IntTools_FaceFace.hxx | 5 +- src/IntWalk/IntWalk_IWalking_1.gxx | 90 +++++++++++++++----- tests/bugs/modalg_5/bug25416_1 | 27 +----- tests/bugs/modalg_5/bug25416_2 | 29 ++----- tests/bugs/modalg_6/bug26699 | 39 +++++++++ 7 files changed, 157 insertions(+), 86 deletions(-) create mode 100644 tests/bugs/modalg_6/bug26699 diff --git a/src/IntPatch/IntPatch_ImpPrmIntersection.cxx b/src/IntPatch/IntPatch_ImpPrmIntersection.cxx index 6cd1bc7c22..ebc4cbe82a 100644 --- a/src/IntPatch/IntPatch_ImpPrmIntersection.cxx +++ b/src/IntPatch/IntPatch_ImpPrmIntersection.cxx @@ -1351,7 +1351,8 @@ void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur }// if (NbSegm) // // on traite les restrictions de la surface implicite - for (Standard_Integer i=1; i<=slin.Length(); i++) + + for (Standard_Integer i=1, aNbLin = slin.Length(); i<=aNbLin; i++) { Handle(IntPatch_Line)& aL = slin(i); @@ -1359,8 +1360,20 @@ void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang); else IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang); + + if(aL->ArcType() == IntPatch_Walking) + { + const Handle(IntPatch_WLine) aWL = Handle(IntPatch_WLine)::DownCast(aL); + slin.Append(aWL); + slin.Remove(i); + i--; + aNbLin--; + } } + // Now slin is filled as follows: lower indices correspond to Restriction line, + // after (higher indices) - only Walking-line. + const Standard_Real aUPeriodOfSurf1 = Surf1->IsUPeriodic() ? Surf1->UPeriod() : 0.0, aUPeriodOfSurf2 = Surf2->IsUPeriodic() ? Surf2->UPeriod() : 0.0, aVPeriodOfSurf1 = Surf1->IsVPeriodic() ? Surf1->VPeriod() : 0.0, @@ -1378,21 +1391,13 @@ void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur Handle(IntPatch_RLine) aRL1 = Handle(IntPatch_RLine)::DownCast(aL1); Handle(IntPatch_RLine) aRL2 = Handle(IntPatch_RLine)::DownCast(aL2); - if(aRL1.IsNull() && aRL2.IsNull()) + if(aRL1.IsNull()) {//If Walking-Walking continue; } - else if(aRL1.IsNull()) - {// i-th line is not restriction, - // but j-th is restriction - slin.Append(aL1); - slin.SetValue(i, aL2); - slin.Remove(j); - j--; - continue; - } - //Here aL1 (i-th line) is Restriction-line and aL2 (j-th line) is not Restriction + //Here aL1 (i-th line) is Restriction-line and aL2 (j-th line) is + //Restriction or Walking if(aBRL.IsVoid()) {//Fill aBRL diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx index 889eef2ab2..349393db33 100644 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -657,7 +657,7 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, // const Standard_Integer aNbLinIntersector = myIntersector.NbLines(); for (Standard_Integer i=1; i <= aNbLinIntersector; ++i) { - MakeCurve(i, dom1, dom2); + MakeCurve(i, dom1, dom2, TolArc); } // ComputeTolReached3d(); @@ -841,9 +841,10 @@ Standard_Real IntTools_FaceFace::ComputeTolerance() //function : MakeCurve //purpose : //======================================================================= - void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, - const Handle(Adaptor3d_TopolTool)& dom1, - const Handle(Adaptor3d_TopolTool)& dom2) +void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, + const Handle(Adaptor3d_TopolTool)& dom1, + const Handle(Adaptor3d_TopolTool)& dom2, + const Standard_Real theToler) { Standard_Boolean bDone, rejectSurface, reApprox, bAvoidLineConstructor; Standard_Boolean ok, bPCurvesOk; @@ -2050,16 +2051,27 @@ Standard_Real IntTools_FaceFace::ComputeTolerance() GeomInt_IntSS:: TrimILineOnSurfBoundaries(aC2d1, aC2d2, aBox1, aBox2, anArrayOfParameters); + //Intersect with true boundaries. After that, enlarge bounding-boxes in order to + //correct definition, if point on curve is inscribed in the box. + aBox1.Enlarge(theToler); + aBox2.Enlarge(theToler); + const Standard_Integer aNbIntersSolutionsm1 = anArrayOfParameters.Length() - 1; //Trim RLine found. for(Standard_Integer anInd = 0; anInd < aNbIntersSolutionsm1; anInd++) { - const Standard_Real aParF = anArrayOfParameters(anInd), - aParL = anArrayOfParameters(anInd+1); + Standard_Real &aParF = anArrayOfParameters(anInd), + &aParL = anArrayOfParameters(anInd+1); if((aParL - aParF) <= Precision::PConfusion()) + { + //In order to more precise extending to the boundaries of source curves. + if(anInd < aNbIntersSolutionsm1-1) + aParL = aParF; + continue; + } const Standard_Real aPar = 0.5*(aParF + aParL); gp_Pnt2d aPt; diff --git a/src/IntTools/IntTools_FaceFace.hxx b/src/IntTools/IntTools_FaceFace.hxx index 78fd265857..412be1ccfa 100644 --- a/src/IntTools/IntTools_FaceFace.hxx +++ b/src/IntTools/IntTools_FaceFace.hxx @@ -117,7 +117,10 @@ public: protected: - Standard_EXPORT void MakeCurve (const Standard_Integer Index, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_TopolTool)& D2); + Standard_EXPORT void MakeCurve (const Standard_Integer Index, + const Handle(Adaptor3d_TopolTool)& D1, + const Handle(Adaptor3d_TopolTool)& D2, + const Standard_Real theToler); Standard_EXPORT void ComputeTolReached3d(); diff --git a/src/IntWalk/IntWalk_IWalking_1.gxx b/src/IntWalk/IntWalk_IWalking_1.gxx index b960c5afa9..9ee234cb51 100644 --- a/src/IntWalk/IntWalk_IWalking_1.gxx +++ b/src/IntWalk/IntWalk_IWalking_1.gxx @@ -21,6 +21,54 @@ OSD_Chronometer Chronrsnld; #include #include +//================================================================================== +// function : IsTangentExtCheck +// purpose : Additional check if the point (theU, theV) in parametric surface +// is a tangent point. +// If that is TRUE then we can go along any (!) direction in order to +// obtain next intersection point. At present, this case is difficult +// for processing. Therefore, we will return an empty intersection line +// in this case. +//================================================================================== +static Standard_Boolean IsTangentExtCheck(TheIWFunction& theFunc, + const Standard_Real theU, + const Standard_Real theV, + const Standard_Real theStepU, + const Standard_Real theStepV, + const Standard_Real theUinf, + const Standard_Real theUsup, + const Standard_Real theVinf, + const Standard_Real theVsup) +{ + //Factor 2.0 is chosen because we compare distance(s) between TWO faces + const Standard_Real aTol = 2.0*Precision::Confusion(); + const Standard_Integer aNbItems = 4; + const Standard_Real aParU[aNbItems] = { Min(theU + theStepU, theUsup), + Max(theU - theStepU, theUinf), + theU, theU}; + const Standard_Real aParV[aNbItems] = { theV, theV, + Min(theV + theStepV, theVsup), + Max(theV - theStepV, theVinf)}; + + math_Vector aX(1, 2), aVal(1, 1); + + for(Standard_Integer i = 0; i < aNbItems; i++) + { + aX.Value(1) = aParU[i]; + aX.Value(2) = aParV[i]; + + if(!theFunc.Value(aX, aVal)) + continue; + + if(aVal(1) > aTol) + return Standard_False; + } + + return Standard_True; +} + + + IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment ) : @@ -85,7 +133,6 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, const Standard_Boolean Reversed) { - Standard_Integer I; Standard_Boolean Rajout = Standard_False; Standard_Integer nbPnts1 = Pnts1.Length(); @@ -95,6 +142,23 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, Clear(); reversed = Reversed; + Um = ThePSurfaceTool::FirstUParameter(Caro); + Vm = ThePSurfaceTool::FirstVParameter(Caro); + UM = ThePSurfaceTool::LastUParameter(Caro); + VM = ThePSurfaceTool::LastVParameter(Caro); + + if (UM < Um) { + Standard_Real utemp = UM; + UM = Um; + Um = utemp; + } + if (VM < Vm) { + Standard_Real vtemp = VM; + VM = Vm; + Vm = vtemp; + } + + const Standard_Real aStepU = pas*(UM-Um), aStepV = pas*(VM-Vm); // Loading of etat1 and etat2 as well as ustart and vstart. @@ -132,30 +196,18 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, wd2.reserve (nbPnts2); for (I = 1; I <= nbPnts2; I++) { IntWalk_WalkingData aWD2; - aWD2.etat = 13; - ThePointOfLoopTool::Value2d(Pnts2.Value(I), aWD2.ustart, aWD2.vstart); + aWD2.etat = 1; + const IntSurf_InteriorPoint& anIP = Pnts2.Value(I); + ThePointOfLoopTool::Value2d(anIP, aWD2.ustart, aWD2.vstart); + if (!IsTangentExtCheck(Func, aWD2.ustart, aWD2.vstart, aStepU, aStepV, Um, UM, Vm, VM)) + aWD2.etat = 13; + wd2.push_back (aWD2); } tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion()); tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion()); - Um = ThePSurfaceTool::FirstUParameter(Caro); - Vm = ThePSurfaceTool::FirstVParameter(Caro); - UM = ThePSurfaceTool::LastUParameter(Caro); - VM = ThePSurfaceTool::LastVParameter(Caro); - - if (UM < Um) { - Standard_Real utemp = UM; - UM = Um; - Um = utemp; - } - if (VM < Vm) { - Standard_Real vtemp = VM; - VM = Vm; - Vm = vtemp; - } - Func.Set(Caro); // calculation of all open lines diff --git a/tests/bugs/modalg_5/bug25416_1 b/tests/bugs/modalg_5/bug25416_1 index 8f3ce0678e..9e35bf13a1 100644 --- a/tests/bugs/modalg_5/bug25416_1 +++ b/tests/bugs/modalg_5/bug25416_1 @@ -23,10 +23,8 @@ set log [bopcurves f1 f2 -2d] regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv -#This value must be equal to the analogical value in bug25292_31 and bug25292_32 of "bugs modalg_5" testgrid. set MaxTol 1.e-7 -#This value must be equal to the analogical value in bug25292_31 and bug25292_32 of "bugs modalg_5" testgrid. set GoodNbCurv 1 if {${Toler} > ${MaxTol}} { @@ -44,30 +42,11 @@ mksurface s2 f2 erase s1 s2 for {set i 1} {$i <= ${NbCurv}} {incr i} { - set log [dump c_$i] - set dumptrimres [regexp {Trimmed curve\nParameters : +([-0-9.+eE]+) +([-0-9.+eE]+)} ${log} full U1 U2] + bounds c_$i U1 U2 - if {${dumptrimres} == 0} { - 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 "U1=${U1}" - puts "U2=${U2}" + dump U1 U2 - if {[expr {$U2 - $U1}] < 1.0e-20} { + if {[dval $U2-$U1] < 1.0e-20} { puts "Error: Wrong curve's range!" } diff --git a/tests/bugs/modalg_5/bug25416_2 b/tests/bugs/modalg_5/bug25416_2 index 055e4f2282..06b5c69b3d 100644 --- a/tests/bugs/modalg_5/bug25416_2 +++ b/tests/bugs/modalg_5/bug25416_2 @@ -27,7 +27,7 @@ mkface ff1 s1 donly ff1 f2 ############################# -set log [bopcurves ff1 f2] +set log [bopcurves ff1 f2 -2d] ############################# regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv @@ -48,33 +48,14 @@ if {${NbCurv} != ${GoodNbCurv}} { #------------- for {set i 1} {$i <= ${NbCurv}} {incr i} { - set log [dump c_$i] - set dumptrimres [regexp {Trimmed curve\nParameters : +([-0-9.+eE]+) +([-0-9.+eE]+)} ${log} full U1 U2] + bounds c_$i U1 U2 - if {${dumptrimres} == 0} { - 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 "U1=${U1}" - puts "U2=${U2}" + dump U1 U2 - if {[expr {$U2 - $U1}] < 1.0e-20} { + if {[dval $U2-$U1] < 1.0e-20} { puts "Error: Wrong curve's range!" } - + xdistcs c_$i s1 ${U1} ${U2} 10 1e-7 xdistcs c_$i s2 ${U1} ${U2} 10 1e-7 } diff --git a/tests/bugs/modalg_6/bug26699 b/tests/bugs/modalg_6/bug26699 new file mode 100644 index 0000000000..1683d93773 --- /dev/null +++ b/tests/bugs/modalg_6/bug26699 @@ -0,0 +1,39 @@ +puts "================" +puts "OCC26699" +puts "================" +puts "" +####################################################################### +# Wrong section curves +####################################################################### + +set MaxTol 1.e-7 +set GoodNbCurv 2 + +restore [locate_data_file bug26699_f1.brep] f1 +restore [locate_data_file bug26699_f2.brep] f2 + +set log [bopcurves f1 f2 -2d] + +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv + +if {${Toler} > ${MaxTol}} { + puts "Error: Tolerance is too big!" +} + +if {${NbCurv} != ${GoodNbCurv}} { + puts "Error: Curve Number is bad!" +} + +set expL1 3.0 +set expL2 3.0 + +regexp {The length c_1 is ([-0-9.+eE]+)} [length c_1] full ll1 +regexp {The length c_2 is ([-0-9.+eE]+)} [length c_2] full ll2 + +checkreal "length c_1 " ${ll1} $expL1 0.0 1.0e-6 +checkreal "length c_2 " ${ll2} $expL1 0.0 1.0e-6 + +axo +donly f* c_* +fit +set only_screen_axo 1 -- 2.39.5