]> OCCT Git - occt.git/commitdiff
0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7...
authorazv <azv@opencascade.com>
Fri, 18 Mar 2022 20:46:44 +0000 (23:46 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 21 Mar 2022 16:11:50 +0000 (19:11 +0300)
Improve tolerance criteria to check values of extremas for equality: use multiplier, which depends on the value, instead of magic number

src/Extrema/Extrema_ExtCC.cxx
tests/bugs/modalg_7/bug32874 [new file with mode: 0644]

index 389e2a0dde39620ffe655bf785b3e23813ec022f..d6eb92a41c845c2debef0b4165dcd04e9582e2ac 100644 (file)
@@ -678,7 +678,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
           aMinSqD = Min(aMinSqD, ExtPCir.SquareDistance(anExtID));
         }
 
-        if (aMinSqD <= aMinSquareDist + 10.* Epsilon(1. + aMinSqD))
+        if (aMinSqD <= aMinSquareDist + (1. + aMinSqD) * Epsilon(1. + aMinSqD))
         {
           ClearSolutions();
           mySqDist.Append(aMinSqD);
@@ -778,7 +778,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
             imin = k;
           }
         }
-        if (aDmin <= aMinSquareDist + 10.* Epsilon(1. + aDmin))
+        if (aDmin <= aMinSquareDist + (1. + aDmin) * Epsilon(1. + aDmin))
         {
           if (imin == 0)
           {
diff --git a/tests/bugs/modalg_7/bug32874 b/tests/bugs/modalg_7/bug32874
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"
+  }
+}