From: nbv Date: Thu, 11 May 2017 12:17:43 +0000 (+0300) Subject: 0028725: Degradation in performance of BRepExtrema_DistShapeShape X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=b8e5ce678e4223e3b359256067e235cbe053ad5c;p=occt-copy.git 0028725: Degradation in performance of BRepExtrema_DistShapeShape If Curve-Curve-Extrema algorithm returned small number of extremas then unification of every extrema will been made as it was made before the patch #27665 (without Cell-filter). --- diff --git a/src/Extrema/Extrema_GExtCC.gxx b/src/Extrema/Extrema_GExtCC.gxx index 8d41a32880..88064e4cfa 100644 --- a/src/Extrema/Extrema_GExtCC.gxx +++ b/src/Extrema/Extrema_GExtCC.gxx @@ -267,6 +267,13 @@ void Extrema_GExtCC::Perform() U21 = myInf[1]; U22 = mySup[1]; + { + const Standard_Real aF = 1.0e6;// static_cast(INT_MAX - 1); + //Standard_Real aCS[2] = { Max((U12 - U11) / aF, 1.0e-5), Max((U22 - U21) / aF, 1.0e-5) }; + Standard_Real aCS[2] = { (U12 - U11) / aF, (U22 - U21) / aF }; + myFilter.Reset(aCS); + } + if (!Precision::IsInfinite(U11)) P1f = Tool1::Value(*((Curve1*)myC[0]), U11); if (!Precision::IsInfinite(U12)) P1l = Tool1::Value(*((Curve1*)myC[0]), U12); if (!Precision::IsInfinite(U21)) P2f = Tool2::Value(*((Curve2*)myC[1]), U21); @@ -513,7 +520,10 @@ void Extrema_GExtCC::Perform() { const Handle(Extrema_CCache)& aCache1 = Handle(Extrema_CCache)::DownCast (anIt1.Value()); ComputeIntervExtrema aSel(aCache1, myECC, this, aFInd == 0, U11, U12, U21, U22); - myFilter.Reset(myTol); + + // No reset + //myFilter.Reset(myTol); + aDeflTree.Select(aSel); } } @@ -940,9 +950,9 @@ void Extrema_GExtCC::Results(const Extrema_ECC& AlgExt, const Standard_Real Ut21, const Standard_Real Ut22) { - Standard_Integer i, NbExt; + Standard_Integer NbExt; Standard_Real Val, U, U2; - Extrema_POnCurv P1, P2; + Extrema_POnCurv P1, P2, P1j, P2j; myDone = AlgExt.IsDone(); if (myDone) { @@ -950,27 +960,55 @@ void Extrema_GExtCC::Results(const Extrema_ECC& AlgExt, Extrema_CCPointsInspector anInspector(myTol); - for (i = 1; i <= NbExt; i++) + const Standard_Boolean isToUseCFilter = (NbExt >= 15); + + for (Standard_Integer i = 1; i <= NbExt; i++) { AlgExt.Points(i, P1, P2); U = P1.Parameter(); U2 = P2.Parameter(); - gp_XY aPnt2d(U, U2); - gp_XY aXYmin(U - myTol[0], U2 - myTol[1]); - gp_XY aXYmax(U + myTol[0], U2 + myTol[1]); - - anInspector.ClearFind(); - anInspector.SetCurrent(aPnt2d); - myFilter.Inspect(aXYmin, aXYmax, anInspector); + Standard_Boolean IsExtrema = Standard_True; + if (!isToUseCFilter) + { + for (Standard_Integer j = 1; j <= mynbext; j++) + { + P1j = mypoints.Value(2 * j - 1); + P2j = mypoints.Value(2 * j); + Standard_Real Uj = P1j.Parameter(); + Standard_Real U2j = P2j.Parameter(); + if ((Abs(Uj - U) <= myTol[0]) && (Abs(U2j - U2) <= myTol[1])) + { + IsExtrema = Standard_False; + break; + } + } + } + else + { + gp_XY aPnt2d(U, U2); + gp_XY aXYmin(U - myTol[0], U2 - myTol[1]); + gp_XY aXYmax(U + myTol[0], U2 + myTol[1]); + + anInspector.ClearFind(); + anInspector.SetCurrent(aPnt2d); + myFilter.Inspect(aXYmin, aXYmax, anInspector); + if (!anInspector.isFind()) + { + IsExtrema = Standard_True; + myFilter.Add(aPnt2d, aPnt2d); + } + else + { + IsExtrema = Standard_False; + } + } - if (anInspector.isFind()) + if (!IsExtrema) { continue; } - myFilter.Add(aPnt2d, aPnt2d); - // Verification de la validite des parametres if (Tool1::IsPeriodic(*((Curve1*)myC[0]))) { U = ElCLib::InPeriod(U, Ut11, Ut11+Tool1::Period(*((Curve1*)myC[0]))); diff --git a/tests/bugs/modalg_2/bug5805_17 b/tests/bugs/modalg_2/bug5805_17 index a64f73a1b6..ebe2413346 100755 --- a/tests/bugs/modalg_2/bug5805_17 +++ b/tests/bugs/modalg_2/bug5805_17 @@ -3,6 +3,8 @@ puts "TODO ?OCC11111 ALL: Error : The square of result shape is" puts "TODO ?OCC11111 ALL: Faulty shapes in variables faulty_1 to faulty_" puts "TODO ?OCC11111 ALL: Faulty OCC5805 : result is not Closed shape" puts "TODO ?OCC11111 ALL: Error : The command is not valid." +puts "TODO ?OCC11111 ALL: Tcl Exception: result is not a topological shape!!!" + puts "============" puts "OCC5805" puts "============" diff --git a/tests/bugs/modalg_5/bug23706_11 b/tests/bugs/modalg_5/bug23706_11 index 01fdf1e1a2..207023b2a8 100755 --- a/tests/bugs/modalg_5/bug23706_11 +++ b/tests/bugs/modalg_5/bug23706_11 @@ -10,7 +10,7 @@ bsplinecurve r1 2 5 1 3 2 1 3 1 4 1 5 3 2 5 3 1 3 7 3 1 4 8 3 1 4 8 3 1 5 9 3 1 bsplinecurve r2 2 5 2 3 2.5 1 3 1 3.5 1 4 3 -1 2 3 1 1 11 3 1 3 9 3 1 3 9 3 1 3 9 3 1 5 7 3 1 7 4 3 1 set info [extrema r1 r2] -if { [llength $info] != 9 } { +if { [llength $info] != 3 } { puts "Error : Extrema is wrong" } else { puts "OK: Extrema is valid" diff --git a/tests/bugs/modalg_5/bug23706_12 b/tests/bugs/modalg_5/bug23706_12 index 05763a1fec..9345faae0a 100755 --- a/tests/bugs/modalg_5/bug23706_12 +++ b/tests/bugs/modalg_5/bug23706_12 @@ -11,7 +11,7 @@ bsplinecurve r10 2 6 2 3 2.5 1 3 1 3.5 1 4 1 4.5 3 5 20 3 1 8 15 3 1 12 18 3 1 1 set info [extrema r9 r10] -if { [llength $info] != 18 } { +if { [llength $info] != 7 } { puts "Error : Extrema is wrong" } else { puts "OK: Extrema is valid" diff --git a/tests/bugs/modalg_6/bug28725 b/tests/bugs/modalg_6/bug28725 new file mode 100644 index 0000000000..59bea90824 --- /dev/null +++ b/tests/bugs/modalg_6/bug28725 @@ -0,0 +1,26 @@ +puts "========" +puts "OCC28725" +puts "========" +puts "" +################################################# +# Degradation in performance of BRepExtrema_DistShapeShape +################################################# + +cpulimit 120 + +restore [locate_data_file bug28725_holes1.brep] h1 +restore [locate_data_file bug28725_holes2.brep] h2 + +dchrono cr reset +dchrono cr start +distmini dd h1 h2 +dchrono cr stop + +puts [ dchrono cr show ] + +set dist [dval dd_val] + +set expected_dist 1.7021376848002463 +set tol_abs_dist 1.0e-07 +set tol_rel_dist 0.0 +checkreal "Dump of dd_val" ${dist} ${expected_dist} ${tol_abs_dist} ${tol_rel_dist} \ No newline at end of file