]> OCCT Git - occt-copy.git/commitdiff
0028725: Degradation in performance of BRepExtrema_DistShapeShape
authornbv <nbv@opencascade.com>
Thu, 11 May 2017 12:17:43 +0000 (15:17 +0300)
committernbv <nbv@opencascade.com>
Mon, 15 May 2017 07:54:24 +0000 (10:54 +0300)
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).

src/Extrema/Extrema_GExtCC.gxx
tests/bugs/modalg_2/bug5805_17
tests/bugs/modalg_5/bug23706_11
tests/bugs/modalg_5/bug23706_12
tests/bugs/modalg_6/bug28725 [new file with mode: 0644]

index 8d41a328807580678560389af022e9582497cc53..88064e4cfa9982a6cbf340636a6b20bac72d2c45 100644 (file)
@@ -267,6 +267,13 @@ void Extrema_GExtCC::Perform()
   U21 = myInf[1];
   U22 = mySup[1];
 
+  {
+    const Standard_Real aF = 1.0e6;// static_cast<Standard_Real>(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])));
index a64f73a1b65f045ffdbbf14df328e8a436f41570..ebe241334643b9777c4ee3523e5a4c3ea69882f0 100755 (executable)
@@ -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 "============"
index 01fdf1e1a20ee3bfca6cacc7e15b7e8365a46eda..207023b2a806ee8092c750d7abd4038033b7cba7 100755 (executable)
@@ -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"
index 05763a1fec3ac94f5ea549df3a8df4a5df39e9f9..9345faae0a363152d38f3f48b83989bbefd3fc54 100755 (executable)
@@ -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 (file)
index 0000000..59bea90
--- /dev/null
@@ -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