From b20ae1d3f5dad5f99a56b5b3efa4d548b2ddcf94 Mon Sep 17 00:00:00 2001 From: akaftasev Date: Mon, 6 Nov 2023 14:54:33 +0000 Subject: [PATCH] 0033515: Modeling Algorithm - BRepExtrema_DistShapeShape poduces wrong result Changed redundant square operation --- src/Extrema/Extrema_GenExtCC.gxx | 2 +- src/Extrema/Extrema_GlobOptFuncCC.cxx | 4 ++-- tests/bugs/modalg_8/bug33515 | 14 ++++++++++++++ tests/lowalgos/extcc/bug32882 | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/modalg_8/bug33515 diff --git a/src/Extrema/Extrema_GenExtCC.gxx b/src/Extrema/Extrema_GenExtCC.gxx index 33826fc5c8..8c48e74fe3 100644 --- a/src/Extrema/Extrema_GenExtCC.gxx +++ b/src/Extrema/Extrema_GenExtCC.gxx @@ -627,7 +627,7 @@ void Extrema_GenExtCC::Perform() { Standard_Real aDist1 = ProjPOnC(C1.Value(aT1[iT]), anExtPC2); Standard_Real aDist2 = ProjPOnC(C2.Value(aT2[iT]), anExtPC1); - isParallel = (Abs(Min(aDist1, aDist2) - aF) < Precision::Confusion()); + isParallel = (Abs(Min(aDist1, aDist2) - aF * aF) < Precision::Confusion()); } } diff --git a/src/Extrema/Extrema_GlobOptFuncCC.cxx b/src/Extrema/Extrema_GlobOptFuncCC.cxx index b0c5c67d83..ca7cc9ea95 100644 --- a/src/Extrema/Extrema_GlobOptFuncCC.cxx +++ b/src/Extrema/Extrema_GlobOptFuncCC.cxx @@ -45,7 +45,7 @@ static Standard_Boolean _Value(const Adaptor3d_Curve& C1, return Standard_False; } - F = C2.Value(v).SquareDistance(C1.Value(u)); + F = C2.Value(v).Distance(C1.Value(u)); return Standard_True; } @@ -66,7 +66,7 @@ static Standard_Boolean _Value(const Adaptor2d_Curve2d& C1, return Standard_False; } - F = C2.Value(v).SquareDistance(C1.Value(u)); + F = C2.Value(v).Distance(C1.Value(u)); return Standard_True; } diff --git a/tests/bugs/modalg_8/bug33515 b/tests/bugs/modalg_8/bug33515 new file mode 100644 index 0000000000..de54420d44 --- /dev/null +++ b/tests/bugs/modalg_8/bug33515 @@ -0,0 +1,14 @@ +puts "================================" +puts " 0033515: Modeling Algorithm - BRepExtrema_DistShapeShape poduces wrong result" +puts "================================" + +restore [locate_data_file bug33515_w1.brep] w1 +restore [locate_data_file bug33515_w2.brep] w2 + +distmini d w1 w2 +set dist [dval d_val] +if { $dist < 3.e-10 } { + puts "OK: Extrema is valid" +} else { + puts "Error: Extrema distance is too big" +} diff --git a/tests/lowalgos/extcc/bug32882 b/tests/lowalgos/extcc/bug32882 index 9e91bbedf6..5e5b1c1b36 100644 --- a/tests/lowalgos/extcc/bug32882 +++ b/tests/lowalgos/extcc/bug32882 @@ -24,7 +24,7 @@ if { [llength $info] != 3 } { # Check result checklength ext_1 -l 2.929642751e-14 -eps .01 checklength ext_2 -l 3.480934286e-14 -eps .01 -checklength ext_3 -l 3.177643716e-14 -eps .01 +checklength ext_3 -l 2.929642751054232-14 -eps .01 # Run extrema c3/c2 set info [extrema c3 c2]