From d07a6c39cf5ede434111a0aae845f7ed76a25d48 Mon Sep 17 00:00:00 2001 From: nbv Date: Thu, 13 Oct 2016 13:48:38 +0300 Subject: [PATCH] 0027930: XMT file conversion loops infinitely Now, the algorithm tries to estimate U- and V-ranges of future intersection curve(s) on the surface. This information is used in stop-criterium of the algorithm instead of full surface range used earlier. It allows reducing dependencies of intersection result on the surface ranges. Tuning of test case bugs/modalg_6/bug27937_1 --- src/Contap/Contap_TheIWalking.hxx | 3 ++ src/IntPatch/IntPatch_TheIWalking.hxx | 3 ++ src/IntWalk/IntWalk_IWalking_1.gxx | 26 +++++++++ src/IntWalk/IntWalk_IWalking_2.gxx | 10 ++-- tests/bugs/modalg_6/bug27937_1 | 76 ++++++++++++++++++++++++++ tests/bugs/modalg_6/bug27937_2 | 77 +++++++++++++++++++++++++++ 6 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 tests/bugs/modalg_6/bug27937_1 create mode 100644 tests/bugs/modalg_6/bug27937_2 diff --git a/src/Contap/Contap_TheIWalking.hxx b/src/Contap/Contap_TheIWalking.hxx index d61312ba1c..0919a42b63 100644 --- a/src/Contap/Contap_TheIWalking.hxx +++ b/src/Contap/Contap_TheIWalking.hxx @@ -37,6 +37,7 @@ #include #include #include +#include class StdFail_NotDone; class Standard_OutOfRange; class IntSurf_PathPoint; @@ -166,6 +167,8 @@ private: IntWalk_VectorOfWalkingData wd1; IntWalk_VectorOfWalkingData wd2; IntWalk_VectorOfInteger nbMultiplicities; + Bnd_Range mySRangeU; // Estimated U-range for section curve + Bnd_Range mySRangeV; // Estimated V-range for section curve Standard_Real Um; Standard_Real UM; Standard_Real Vm; diff --git a/src/IntPatch/IntPatch_TheIWalking.hxx b/src/IntPatch/IntPatch_TheIWalking.hxx index 98f16f13ee..fce79efbe2 100644 --- a/src/IntPatch/IntPatch_TheIWalking.hxx +++ b/src/IntPatch/IntPatch_TheIWalking.hxx @@ -37,6 +37,7 @@ #include #include #include +#include class StdFail_NotDone; class Standard_OutOfRange; class IntSurf_PathPoint; @@ -166,6 +167,8 @@ private: IntWalk_VectorOfWalkingData wd1; IntWalk_VectorOfWalkingData wd2; IntWalk_VectorOfInteger nbMultiplicities; + Bnd_Range mySRangeU; // Estimated U-range for section curve + Bnd_Range mySRangeV; // Estimated V-range for section curve Standard_Real Um; Standard_Real UM; Standard_Real Vm; diff --git a/src/IntWalk/IntWalk_IWalking_1.gxx b/src/IntWalk/IntWalk_IWalking_1.gxx index 88ba783e8d..5d8ab33685 100644 --- a/src/IntWalk/IntWalk_IWalking_1.gxx +++ b/src/IntWalk/IntWalk_IWalking_1.gxx @@ -183,6 +183,9 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, } ThePointOfPathTool::Value2d(PathPnt, aWD1.ustart, aWD1.vstart); + mySRangeU.Add(aWD1.ustart); + mySRangeV.Add(aWD1.vstart); + wd1.push_back (aWD1); Standard_Integer aNbMult = ThePointOfPathTool::Multiplicity(PathPnt); nbMultiplicities.push_back(aNbMult); @@ -200,6 +203,9 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, aWD2.etat = 1; const IntSurf_InteriorPoint& anIP = Pnts2.Value(I); ThePointOfLoopTool::Value2d(anIP, aWD2.ustart, aWD2.vstart); + mySRangeU.Add(aWD2.ustart); + mySRangeV.Add(aWD2.vstart); + if (!IsTangentExtCheck(Func, aWD2.ustart, aWD2.vstart, aStepU, aStepV, Um, UM, Vm, VM)) aWD2.etat = 13; @@ -211,6 +217,26 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, Func.Set(Caro); + if (mySRangeU.Delta() > Max(tolerance(1), Precision::PConfusion())) + { + mySRangeU.Enlarge(mySRangeU.Delta()); + mySRangeU.Common(Bnd_Range(Um, UM)); + } + else + { + mySRangeU = Bnd_Range(Um, UM); + } + + if (mySRangeV.Delta() > Max(tolerance(2), Precision::PConfusion())) + { + mySRangeV.Enlarge(mySRangeV.Delta()); + mySRangeV.Common(Bnd_Range(Vm, VM)); + } + else + { + mySRangeV = Bnd_Range(Vm, VM); + } + // calculation of all open lines if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout); diff --git a/src/IntWalk/IntWalk_IWalking_2.gxx b/src/IntWalk/IntWalk_IWalking_2.gxx index 30f8bb3928..69db4cd3ed 100644 --- a/src/IntWalk/IntWalk_IWalking_2.gxx +++ b/src/IntWalk/IntWalk_IWalking_2.gxx @@ -14,6 +14,7 @@ //-- IntWalk_IWalking_2.gxx +#include #include #ifndef OCCT_DEBUG @@ -389,11 +390,10 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage Standard_Real UV2=UV(2); - //-- Put everything in one box 0 1 x 0 1 - //-- actually it is necessary to carry out tests in 3D - - Standard_Real deltau=UM-Um; - Standard_Real deltav=VM-Vm; + //Normalizing factor. If it is less than 1.0 then the range will be expanded. + //This is no good for computation. Therefore, it is limited. + const Standard_Real deltau = mySRangeU.IsVoid() ? UM - Um : Max(mySRangeU.Delta(), 1.0); + const Standard_Real deltav = mySRangeV.IsVoid() ? VM - Vm : Max(mySRangeV.Delta(), 1.0); Up/=deltau; UV1/=deltau; Vp/=deltav; UV2/=deltav; diff --git a/tests/bugs/modalg_6/bug27937_1 b/tests/bugs/modalg_6/bug27937_1 new file mode 100644 index 0000000000..d4337ee9a9 --- /dev/null +++ b/tests/bugs/modalg_6/bug27937_1 @@ -0,0 +1,76 @@ +puts "================" +puts "OCC27937" +puts "================" +puts "" +####################################################################### +# 0027937: Intersector loops infinitely while proceeding two simple surfaces +####################################################################### + +cpulimit 100 + +# Attention!!! +# The test on performance meter. +# See issue #27937 for detail. +set GoodNbCurv 4 + +restore [locate_data_file bug27937_int1.draw] s1 +restore [locate_data_file bug27937_int2.draw] s2 + +intersect result s1 s2 + +set che [whatis result] +set ind [string first "3d curve" $che] +if {${ind} >= 0} { + #Only variable "result" exists + renamevar result result_1 +} + +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 + + dump U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" + } + + xdistcs result_$ic s1 U1 U2 10 3.0e-5 + xdistcs result_$ic s2 U1 U2 10 1.0e-5 + + 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" + } + } + + 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!" +} + +smallview +don result* +fit +clear +don s1 s2 result* +checkview -screenshot -2d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27937_2 b/tests/bugs/modalg_6/bug27937_2 new file mode 100644 index 0000000000..00032ca121 --- /dev/null +++ b/tests/bugs/modalg_6/bug27937_2 @@ -0,0 +1,77 @@ +puts "================" +puts "OCC27937" +puts "================" +puts "" +####################################################################### +# 0027937: Intersector loops infinitely while proceeding two simple surfaces +####################################################################### + +cpulimit 100 + +# Attention!!! +# The test on performance meter. +# See issue #27937 for detail. +set GoodNbCurv 4 + +ellipse c1 0 0 0 0 0 1 6.03031367203927 3.11993062568844 +extsurf s1 c1 0 0 1 +cylinder s2 0 0 0 1 0 0 0.249128788767645 + +intersect result s1 s2 + +set che [whatis result] +set ind [string first "3d curve" $che] +if {${ind} >= 0} { + #Only variable "result" exists + renamevar result result_1 +} + +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 + + dump U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong curve's range!" + } + + xdistcs result_$ic s1 U1 U2 10 4.0e-5 + xdistcs result_$ic s2 U1 U2 10 1.0e-5 + + 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" + } + } + + 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!" +} + +smallview +don result* +fit +clear +don s1 s2 result* +checkview -screenshot -2d -path ${imagedir}/${test_image}.png \ No newline at end of file