From a2cb8561eb1d77db78bccf8296f9f729eaf8cb47 Mon Sep 17 00:00:00 2001 From: ifv Date: Tue, 24 Nov 2020 14:17:03 +0300 Subject: [PATCH] 0029441: Modeling Algorithms - Incorrect intersection curves between faces ApproxInt/ApproxInt_SvSurfaces.hxx : adding field myUseSolver in order to manage calculations of characteristics of intersection points. ApproxInt/ApproxInt_MultiLine.gxx : implementation of using myUseSolver for treatment points of MultiLine. ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx : implementation of using myUseSolver for case intersection of implicit and parametric surfaces. Test cases added --- src/ApproxInt/ApproxInt_Approx.gxx | 2 + src/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx | 33 +++++++++---- src/ApproxInt/ApproxInt_MultiLine.gxx | 19 +++++++- src/ApproxInt/ApproxInt_SvSurfaces.hxx | 24 ++++++++- tests/lowalgos/intss/bug29441_1 | 48 ++++++++++++++++++ tests/lowalgos/intss/bug29441_2 | 51 ++++++++++++++++++++ 6 files changed, 164 insertions(+), 13 deletions(-) create mode 100644 tests/lowalgos/intss/bug29441_1 create mode 100644 tests/lowalgos/intss/bug29441_2 diff --git a/src/ApproxInt/ApproxInt_Approx.gxx b/src/ApproxInt/ApproxInt_Approx.gxx index 63cec22986..7be8911cf0 100644 --- a/src/ApproxInt/ApproxInt_Approx.gxx +++ b/src/ApproxInt/ApproxInt_Approx.gxx @@ -359,6 +359,8 @@ void ApproxInt_Approx::Perform(const TheISurface& ISurf, isTheQuadFirst? ApproxInt_TheImpPrmSvSurfaces(ISurf, PSurf): ApproxInt_TheImpPrmSvSurfaces(PSurf, ISurf); + myImpPrmSvSurfaces.SetUseSolver(Standard_False); + const Standard_Integer nbpntbez = indicemax-indicemin; if(nbpntbez < aMinNbPointsForApprox) { diff --git a/src/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx b/src/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx index 985e8e72bf..f2c7ea9798 100644 --- a/src/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx +++ b/src/ApproxInt/ApproxInt_ImpPrmSvSurfaces.gxx @@ -336,6 +336,7 @@ ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces( const TheISurface& ISurf MyImplicitFirst(Standard_True), MyZerImpFunc(PSurf,ISurf) { + SetUseSolver(Standard_True); } //-------------------------------------------------------------------------------- ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces( const ThePSurface& PSurf @@ -347,6 +348,7 @@ ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces( const ThePSurface& PSurf MyImplicitFirst(Standard_False), MyZerImpFunc(PSurf,ISurf) { + SetUseSolver(Standard_True); } //-------------------------------------------------------------------------------- void ApproxInt_ImpPrmSvSurfaces::Pnt(const Standard_Real u1, @@ -517,15 +519,21 @@ Standard_Boolean ApproxInt_ImpPrmSvSurfaces::Compute( Standard_Real& u1, return(Standard_False); } + Standard_Boolean aRsnldIsDone = Standard_False; Standard_Real PourTesterU = X(1); Standard_Real PourTesterV = X(2); - - math_FunctionSetRoot Rsnld(MyZerImpFunc); - Rsnld.SetTolerance(Tolerance); - Rsnld.Perform(MyZerImpFunc,X,BornInf,BornSup); - if(Rsnld.IsDone()) { + if (GetUseSolver()) + { + math_FunctionSetRoot Rsnld(MyZerImpFunc); + Rsnld.SetTolerance(Tolerance); + Rsnld.Perform(MyZerImpFunc, X, BornInf, BornSup); + aRsnldIsDone = Rsnld.IsDone(); + if (aRsnldIsDone) + Rsnld.Root(X); + } + if(aRsnldIsDone || !GetUseSolver()) + { MyHasBeenComputed = Standard_True; - Rsnld.Root(X); Standard_Real DistAvantApresU = Abs(PourTesterU-X(1)); Standard_Real DistAvantApresV = Abs(PourTesterV-X(2)); @@ -907,10 +915,15 @@ ApproxInt_ImpPrmSvSurfaces::FillInitialVectorOfSolution(const Standard_Real u1, //---------------------------------------------------- //Make a small step from boundaries in order to avoid //finding "outboundaried" solution (Rsnld -> NotDone). - if(X(1)-0.0000000001 <= binfu) X(1)=X(1)+0.0000001; - if(X(1)+0.0000000001 >= bsupu) X(1)=X(1)-0.0000001; - if(X(2)-0.0000000001 <= binfv) X(2)=X(2)+0.0000001; - if(X(2)+0.0000000001 >= bsupv) X(2)=X(2)-0.0000001; + if (GetUseSolver()) + { + Standard_Real du = Max(Precision::Confusion(), ThePSurfaceTool::UResolution(aPSurf, Precision::Confusion())); + Standard_Real dv = Max(Precision::Confusion(), ThePSurfaceTool::VResolution(aPSurf, Precision::Confusion())); + if (X(1) - 0.0000000001 <= binfu) X(1) = X(1) + du; + if (X(1) + 0.0000000001 >= bsupu) X(1) = X(1) - du; + if (X(2) - 0.0000000001 <= binfv) X(2) = X(2) + dv; + if (X(2) + 0.0000000001 >= bsupv) X(2) = X(2) - dv; + } return Standard_True; } diff --git a/src/ApproxInt/ApproxInt_MultiLine.gxx b/src/ApproxInt/ApproxInt_MultiLine.gxx index ad8472b221..323c445668 100644 --- a/src/ApproxInt/ApproxInt_MultiLine.gxx +++ b/src/ApproxInt/ApproxInt_MultiLine.gxx @@ -317,6 +317,11 @@ ApproxInt_MultiLine //-- return(*this); } + Standard_Boolean aSaveUseSolver = ((TheSvSurfaces *)PtrOnmySvSurfaces)->GetUseSolver(); + if (!aSaveUseSolver) + { + ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(Standard_True); + } Standard_Integer NbPntsToInsert=aNbPntsToInsert; if(NbPntsToInsert<(High-Low)) NbPntsToInsert=(High-Low); Standard_Integer NbPnts = NbPntsToInsert + High - Low + 1; @@ -564,6 +569,7 @@ ApproxInt_MultiLine if((temp->NbPnts() >= NbPntsToInsert + High - Low + 1) && (CodeErreur==0)) { + ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver); return (ApproxInt_MultiLine( temp, (High-Low>10)? PtrOnmySvSurfaces : NULL, nbp3d, @@ -579,6 +585,7 @@ ApproxInt_MultiLine { //-- cout<<" ApproxInt_MultiLine "<> |dx|" + 2dcvalue c2d1_1 1 x y dx dy + set ex [expr abs([dval (x-1.012680192)])] + set edxdy [expr abs([dval dx/dy])] + if {$ex > 1.e-8 || $edxdy > 1.e-10} { + puts "Extremities of 1-st pcurve are wrong" + set OK 0 + } else { + puts "Extremities of 1-st pcurve are valid" + } +} else { + set OK 0 + puts "Error: 1-st pcurve is not exist" +} + +if { $OK > 0 } { + if {[isdraw c2d1_2]} { + puts "check extremity of 2-nd pcurve x ~ 1.0117170137, |dx| ~ 0, |dy| >> |dx|" + 2dcvalue c2d1_2 1 x y dx dy + set ex [expr abs([dval (x-1.0117170137)])] + set edxdy [expr abs([dval dx/dy])] + if {$ex > 1.e-8 || $edxdy > 1.e-10} { + puts "Extremities of 2-nd pcurve are wrong" + set OK 0 + } else { + puts "Extremities of 2-nd pcurve are valid" + } + } else { + set OK 0 + puts "Error: 2-nd pcurve is not exist" + } +} + +if { $OK < 1 } { + puts "Error: bad pcurves" +} diff --git a/tests/lowalgos/intss/bug29441_2 b/tests/lowalgos/intss/bug29441_2 new file mode 100644 index 0000000000..d2d2090046 --- /dev/null +++ b/tests/lowalgos/intss/bug29441_2 @@ -0,0 +1,51 @@ +puts "============" +puts "0029441: Modeling Algorithms - Incorrect intersection curves between faces" +puts "============" +puts "" + +binrestore [locate_data_file bug28892_tools.bin] b + +set OK 1 +explode b so +explode b_8 f; copy b_8_1 f1 +explode b_13 f; copy b_13_5 f2 +don f1 f2 +bopcurves f1 f2 -2d + +if {[isdraw c2d1_1]} { + puts "check extremity of 1-st pcurve x ~ 5.2714710662, |dx| ~ 0, |dy| >> |dx|" + 2dcvalue c2d1_1 1 x y dx dy + set ex [expr abs([dval (x-5.2714710662)])] + set edxdy [expr abs([dval dx/dy])] + if {$ex > 1.e-8 || $edxdy > 1.e-10} { + puts "Extremities of 1-st pcurve are wrong" + set OK 0 + } else { + puts "Extremities of 1-st pcurve are valid" + } +} else { + set OK 0 + puts "Error: 1-st pcurve is not exist" +} + +if { $OK > 0 } { + if {[isdraw c2d1_2]} { + puts "check extremity of 2-nd pcurve x ~ 5.2705066089, |dx| ~ 0, |dy| >> |dx|" + 2dcvalue c2d1_2 1 x y dx dy + set ex [expr abs([dval (x-5.2705066089)])] + set edxdy [expr abs([dval dx/dy])] + if {$ex > 1.e-8 || $edxdy > 1.e-10} { + puts "Extremities of 2-nd pcurve are wrong" + set OK 0 + } else { + puts "Extremities of 2-nd pcurve are valid" + } + } else { + set OK 0 + puts "Error: 2-nd pcurve is not exist" + } +} + +if { $OK < 1 } { + puts "Error: bad pcurves" +}