From: azv Date: Thu, 7 Apr 2022 11:28:03 +0000 (+0300) Subject: 0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7... X-Git-Tag: V7_7_0_beta~134 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=ee6581adbea1b030be8c10ea3763341efdc94a69;p=occt.git 0032874: IsParallel() method of Extrema_ExtCC does not give same results in OCC 7.6.0 vs OCC 7.5.0 Use precision depending on radii of participating circles. --- diff --git a/src/Extrema/Extrema_ExtCC.cxx b/src/Extrema/Extrema_ExtCC.cxx index d6eb92a41c..def27cbe5e 100644 --- a/src/Extrema/Extrema_ExtCC.cxx +++ b/src/Extrema/Extrema_ExtCC.cxx @@ -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 index e1085f1c37..0000000000 --- a/tests/bugs/modalg_7/bug32874 +++ /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 index 0000000000..e1085f1c37 --- /dev/null +++ b/tests/bugs/modalg_7/bug32874_1 @@ -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 index 0000000000..0ee16c9efa --- /dev/null +++ b/tests/bugs/modalg_7/bug32874_2 @@ -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 index 0000000000..8ff06ca948 --- /dev/null +++ b/tests/bugs/modalg_7/bug32874_3 @@ -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 index 0000000000..9fc0988886 --- /dev/null +++ b/tests/bugs/modalg_7/bug32874_4 @@ -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 index 0000000000..4cb2e68340 --- /dev/null +++ b/tests/bugs/modalg_7/bug32874_5 @@ -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" + } + } +}