]> OCCT Git - occt.git/commitdiff
0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7...
authorazv <azv@opencascade.com>
Thu, 7 Apr 2022 11:28:03 +0000 (14:28 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 8 Apr 2022 15:50:30 +0000 (18:50 +0300)
Use precision depending on radii of participating circles.

src/Extrema/Extrema_ExtCC.cxx
tests/bugs/modalg_7/bug32874 [deleted file]
tests/bugs/modalg_7/bug32874_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug32874_2 [new file with mode: 0644]
tests/bugs/modalg_7/bug32874_3 [new file with mode: 0644]
tests/bugs/modalg_7/bug32874_4 [new file with mode: 0644]
tests/bugs/modalg_7/bug32874_5 [new file with mode: 0644]

index d6eb92a41c845c2debef0b4165dcd04e9582e2ac..def27cbe5e4f0ae6e5db462ca66b03d86b6150a8 100644 (file)
@@ -602,6 +602,9 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
     const Bnd_Range aRange(theUt21, theUt22);
     Bnd_Range aProjRng1;
 
+    // Precision of the calculation depends on circles radii
+    const Standard_Real aPrecision = Max(Epsilon(myC[0]->Circle().Radius()), Epsilon(myC[1]->Circle().Radius()));
+
     // Project arc of the 1st circle between points theUt11 and theUt12 to the
     // 2nd circle. It is necessary to chose correct arc from two possible ones.
 
@@ -678,7 +681,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
           aMinSqD = Min(aMinSqD, ExtPCir.SquareDistance(anExtID));
         }
 
-        if (aMinSqD <= aMinSquareDist + (1. + aMinSqD) * Epsilon(1. + aMinSqD))
+        if (aMinSqD <= aMinSquareDist + (1. + aMinSqD) * aPrecision)
         {
           ClearSolutions();
           mySqDist.Append(aMinSqD);
@@ -778,7 +781,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
             imin = k;
           }
         }
-        if (aDmin <= aMinSquareDist + (1. + aDmin) * Epsilon(1. + aDmin))
+        if (aDmin <= aMinSquareDist + (1. + aDmin) * aPrecision)
         {
           if (imin == 0)
           {
diff --git a/tests/bugs/modalg_7/bug32874 b/tests/bugs/modalg_7/bug32874
deleted file mode 100644 (file)
index e1085f1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-puts "================================================="
-puts "0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0"
-puts "================================================="
-puts ""
-
-set distExpected 10
-circle c1 0 0 0 100
-circle c2 0 0 0 100+$distExpected
-
-set nbSteps 72
-for {set i 1} {$i < $nbSteps} {incr i} {
-  trim cc1 c1 0 2.*pi/$nbSteps*$i
-  trim cc2 c2 0 2.*pi/$nbSteps*$i
-
-  set extr [extrema cc1 cc2]
-  if {[regexp {Infinite number of extremas, distance = ([-0-9.+eE]+)} $extr full dist]} {
-    if {[expr abs($dist - $distExpected)] < 1.e-7} {
-      puts "OK"
-    } else {
-      puts "Error: wrong distance $dist instead of $distExpected expected"
-    }
-  } else {
-    puts "Error: non-parallel curves"
-  }
-}
diff --git a/tests/bugs/modalg_7/bug32874_1 b/tests/bugs/modalg_7/bug32874_1
new file mode 100644 (file)
index 0000000..e1085f1
--- /dev/null
@@ -0,0 +1,25 @@
+puts "================================================="
+puts "0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0"
+puts "================================================="
+puts ""
+
+set distExpected 10
+circle c1 0 0 0 100
+circle c2 0 0 0 100+$distExpected
+
+set nbSteps 72
+for {set i 1} {$i < $nbSteps} {incr i} {
+  trim cc1 c1 0 2.*pi/$nbSteps*$i
+  trim cc2 c2 0 2.*pi/$nbSteps*$i
+
+  set extr [extrema cc1 cc2]
+  if {[regexp {Infinite number of extremas, distance = ([-0-9.+eE]+)} $extr full dist]} {
+    if {[expr abs($dist - $distExpected)] < 1.e-7} {
+      puts "OK"
+    } else {
+      puts "Error: wrong distance $dist instead of $distExpected expected"
+    }
+  } else {
+    puts "Error: non-parallel curves"
+  }
+}
diff --git a/tests/bugs/modalg_7/bug32874_2 b/tests/bugs/modalg_7/bug32874_2
new file mode 100644 (file)
index 0000000..0ee16c9
--- /dev/null
@@ -0,0 +1,29 @@
+puts "================================================="
+puts "0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0"
+puts "================================================="
+puts ""
+
+set distExpected 3.5
+circle c1 0 0 0 100
+circle c2 0 0 0 100+$distExpected
+
+set start {0.0 0.5*pi pi 1.5*pi 2.0*pi}
+set delta {pi/4.0 pi/3.0 pi/2.0 0.55*pi 0.99*pi pi 1.1*pi}
+
+foreach f $start {
+  foreach d $delta {
+    trim cc1 c1 $f $f+$d
+    trim cc2 c2 $f $f+$d
+
+    set extr [extrema cc1 cc2]
+    if {[regexp {Infinite number of extremas, distance = ([-0-9.+eE]+)} $extr full dist]} {
+      if {[expr abs($dist - $distExpected)] < 1.e-7} {
+        puts "OK"
+      } else {
+        puts "Error: wrong distance $dist instead of $distExpected expected"
+      }
+    } else {
+      puts "Error: non-parallel curves"
+    }
+  }
+}
diff --git a/tests/bugs/modalg_7/bug32874_3 b/tests/bugs/modalg_7/bug32874_3
new file mode 100644 (file)
index 0000000..8ff06ca
--- /dev/null
@@ -0,0 +1,30 @@
+puts "================================================="
+puts "0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0"
+puts "================================================="
+puts ""
+
+set radius 0.001
+set distExpected 0.00001
+circle c1 0 0 0 $radius
+circle c2 0 0 0 $radius+$distExpected
+
+set start {0.0 0.5*pi pi 1.5*pi 2.0*pi}
+set delta {pi/4.0 pi/3.0 pi/2.0 0.55*pi 0.99*pi pi 1.1*pi}
+
+foreach f $start {
+  foreach d $delta {
+    trim cc1 c1 $f $f+$d
+    trim cc2 c2 $f $f+$d
+
+    set extr [extrema cc1 cc2]
+    if {[regexp {Infinite number of extremas, distance = ([-0-9.+eE]+)} $extr full dist]} {
+      if {[expr abs($dist - $distExpected)] < 1.e-7} {
+        puts "OK"
+      } else {
+        puts "Error: wrong distance $dist instead of $distExpected expected"
+      }
+    } else {
+      puts "Error: non-parallel curves"
+    }
+  }
+}
diff --git a/tests/bugs/modalg_7/bug32874_4 b/tests/bugs/modalg_7/bug32874_4
new file mode 100644 (file)
index 0000000..9fc0988
--- /dev/null
@@ -0,0 +1,30 @@
+puts "================================================="
+puts "0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0"
+puts "================================================="
+puts ""
+
+set radius 0.001
+set distExpected 1000.0
+circle c1 0 0 0 $radius
+circle c2 0 0 0 $radius+$distExpected
+
+set start {0.0 0.5*pi pi 1.5*pi 2.0*pi}
+set delta {pi/4.0 pi/3.0 pi/2.0 0.55*pi 0.99*pi pi 1.1*pi}
+
+foreach f $start {
+  foreach d $delta {
+    trim cc1 c1 $f $f+$d
+    trim cc2 c2 $f $f+$d
+
+    set extr [extrema cc1 cc2]
+    if {[regexp {Infinite number of extremas, distance = ([-0-9.+eE]+)} $extr full dist]} {
+      if {[expr abs($dist - $distExpected)] < 1.e-7} {
+        puts "OK"
+      } else {
+        puts "Error: wrong distance $dist instead of $distExpected expected"
+      }
+    } else {
+      puts "Error: non-parallel curves"
+    }
+  }
+}
diff --git a/tests/bugs/modalg_7/bug32874_5 b/tests/bugs/modalg_7/bug32874_5
new file mode 100644 (file)
index 0000000..4cb2e68
--- /dev/null
@@ -0,0 +1,30 @@
+puts "================================================="
+puts "0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0"
+puts "================================================="
+puts ""
+
+set radius 1000.0
+set distExpected 1.e-5
+circle c1 0 0 0 $radius
+circle c2 0 0 0 $radius-$distExpected
+
+set start {0.0 0.5*pi pi 1.5*pi 2.0*pi}
+set delta {pi/4.0 pi/3.0 pi/2.0 0.55*pi 0.99*pi pi 1.1*pi}
+
+foreach f $start {
+  foreach d $delta {
+    trim cc1 c1 $f $f+$d
+    trim cc2 c2 $f $f+$d
+
+    set extr [extrema cc1 cc2]
+    if {[regexp {Infinite number of extremas, distance = ([-0-9.+eE]+)} $extr full dist]} {
+      if {[expr abs($dist - $distExpected)] < 1.e-7} {
+        puts "OK"
+      } else {
+        puts "Error: wrong distance $dist instead of $distExpected expected"
+      }
+    } else {
+      puts "Error: non-parallel curves"
+    }
+  }
+}