]> OCCT Git - occt.git/commitdiff
0027930: XMT file conversion loops infinitely
authornbv <nbv@opencascade.com>
Thu, 13 Oct 2016 10:48:38 +0000 (13:48 +0300)
committerapn <apn@opencascade.com>
Thu, 13 Oct 2016 10:49:02 +0000 (13:49 +0300)
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
src/IntPatch/IntPatch_TheIWalking.hxx
src/IntWalk/IntWalk_IWalking_1.gxx
src/IntWalk/IntWalk_IWalking_2.gxx
tests/bugs/modalg_6/bug27937_1 [new file with mode: 0644]
tests/bugs/modalg_6/bug27937_2 [new file with mode: 0644]

index d61312ba1c0b3f4a14548fc459e84eec6e3849d9..0919a42b63710d10101b061da19c9deb1539132d 100644 (file)
@@ -37,6 +37,7 @@
 #include <Standard_Integer.hxx>
 #include <TColStd_SequenceOfReal.hxx>
 #include <IntWalk_StatusDeflection.hxx>
+#include <Bnd_Range.hxx>
 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;
index 98f16f13ee2a0a84321bc321f6f8fbadb27b3d32..fce79efbe2ca6bc0620e7e113cd64f9b5ee63b1d 100644 (file)
@@ -37,6 +37,7 @@
 #include <Standard_Integer.hxx>
 #include <TColStd_SequenceOfReal.hxx>
 #include <IntWalk_StatusDeflection.hxx>
+#include <Bnd_Range.hxx>
 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;
index 88ba783e8dba6b6304b33bd391d4ed38603346f1..5d8ab336858bd7a2aef102d9ac29208ae66aa7e3 100644 (file)
@@ -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); 
index 30f8bb3928ef09dc08ebb62d06426cef01c6c423..69db4cd3ed009d0b854c8d43aca275d9e74a84d0 100644 (file)
@@ -14,6 +14,7 @@
 
 //-- IntWalk_IWalking_2.gxx
 
+#include <Bnd_Range.hxx>
 #include <TColStd_MapOfInteger.hxx>
 
 #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 (file)
index 0000000..d4337ee
--- /dev/null
@@ -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 (file)
index 0000000..00032ca
--- /dev/null
@@ -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