]> OCCT Git - occt-copy.git/commitdiff
0026269: Modeling Data - Analytical extrema does not take into account trimmed input... CR26269
authorifv <igor.feoktistov@opencascade.com>
Fri, 6 Aug 2021 11:49:14 +0000 (14:49 +0300)
committerifv <igor.feoktistov@opencascade.com>
Mon, 16 Aug 2021 07:12:09 +0000 (10:12 +0300)
Treatment of trimmed data is added
Extrema/Extrema_ExtCC.cxx

Test cases added
tests/lowalgos/extcc/bug26269_1
tests/lowalgos/extcc/bug26269_2

Test cases are modified according to new behavior of algorithm

13 files changed:
src/Extrema/Extrema_ExtCC.cxx
tests/lowalgos/extcc/bug26269_1 [new file with mode: 0644]
tests/lowalgos/extcc/bug26269_2 [new file with mode: 0644]
tests/lowalgos/extcc/bug29712_13
tests/lowalgos/extcc/bug29712_21
tests/lowalgos/extcc/bug29712_22
tests/lowalgos/extcc/bug29712_24
tests/lowalgos/extcc/bug29712_25
tests/lowalgos/extcc/bug29712_29
tests/lowalgos/extcc/bug29712_3
tests/lowalgos/extcc/bug29712_32
tests/lowalgos/extcc/bug29712_37
tests/lowalgos/extcc/bug29712_5

index fa77b80c79a142341e1d71554066d365dd7d3a7e..e200956bbb0e58bc46d3ad68c83b0daf901015f4 100644 (file)
@@ -539,7 +539,54 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
         mypoints.Append(aP2);
         mySqDist.Append(theSqDist);
       }
-    }
+      else
+      {
+        //Case like this:
+
+        //  **************     aLin1
+        //                 o
+        //                  o
+        //                   ***********  aLin2
+        // 
+        //Take minimal trimmed distance
+        Standard_Real aDmin, aDists[4] = {mydist11, mydist12, mydist21, mydist22};
+        Extrema_POnCurv aP1, aP2;
+        aDmin = aDists[0];
+        Standard_Integer i, imin = 0;
+        for (i = 1; i < 4; ++i)
+        {
+          if (aDmin > aDists[i])
+          {
+            aDmin = aDists[i];
+            imin = i;
+          }
+        }
+        if (imin == 0)
+        {
+          aP1.SetValues(myInf[0], P1f);
+          aP2.SetValues(myInf[1], P2f);
+        }
+        else if (imin == 1)
+        {
+          aP1.SetValues(myInf[0], P1f);
+          aP2.SetValues(mySup[1], P2l);
+        }
+        else if (imin == 2)
+        {
+          aP1.SetValues(mySup[0], P1l);
+          aP2.SetValues(myInf[1], P2f);
+        }
+        else 
+        {
+          aP1.SetValues(mySup[0], P1l);
+          aP2.SetValues(mySup[1], P2l);
+        }
+        ClearSolutions();
+        mypoints.Append(aP1);
+        mypoints.Append(aP2);
+        mySqDist.Append(aDmin);
+      }
+    }   
   }
   else
   {
@@ -639,7 +686,7 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
           aMinSqD = Min(aMinSqD, ExtPCir.SquareDistance(anExtID));
         }
 
-        if (aMinSqD <= aMinSquareDist)
+        if (aMinSqD <= aMinSquareDist + 10.* Epsilon(1. + aMinSqD))
         {
           ClearSolutions();
           mySqDist.Append(aMinSqD);
@@ -717,7 +764,58 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11,
           }
         }
       }
+      else
+      {
+        //Case like this:
 
+        //  **************     Cir1
+        //                 o
+        //                  o
+        //                   ***********  Cir2
+        // 
+        //Take minimal trimmed distance
+        myIsPar = Standard_False;
+        Standard_Real aDmin, aDists[4] = { mydist11, mydist12, mydist21, mydist22 };
+        Extrema_POnCurv aP1, aP2;
+        aDmin = aDists[0];
+        Standard_Integer k, imin = 0;
+        for (k = 1; k < 4; ++k)
+        {
+          if (aDmin > aDists[k])
+          {
+            aDmin = aDists[k];
+            imin = k;
+          }
+        }
+        if (aDmin <= aMinSquareDist + 10.* Epsilon(1. + aDmin))
+        {
+          if (imin == 0)
+          {
+            aP1.SetValues(myInf[0], P1f);
+            aP2.SetValues(myInf[1], P2f);
+          }
+          else if (imin == 1)
+          {
+            aP1.SetValues(myInf[0], P1f);
+            aP2.SetValues(mySup[1], P2l);
+          }
+          else if (imin == 2)
+          {
+            aP1.SetValues(mySup[0], P1l);
+            aP2.SetValues(myInf[1], P2f);
+          }
+          else
+          {
+            aP1.SetValues(mySup[0], P1l);
+            aP2.SetValues(mySup[1], P2l);
+          }
+          ClearSolutions();
+          mypoints.Append(aP1);
+          mypoints.Append(aP2);
+          mySqDist.Append(aDmin);
+          aMinSquareDist = Min(aMinSquareDist, aDmin);
+        }
+      }
       aProjRng1.Shift(M_PI);
     }
   }
diff --git a/tests/lowalgos/extcc/bug26269_1 b/tests/lowalgos/extcc/bug26269_1
new file mode 100644 (file)
index 0000000..a07c5f6
--- /dev/null
@@ -0,0 +1,24 @@
+puts "========"
+puts "0026269: Modeling Data - Analytical extrema does not take into account trimmed input data"
+puts "========"
+puts ""
+
+#case 1
+line l1 0 0 0 1 0 0
+line l2 2 2 0 1 0 0
+trim l1 l1 0 1
+trim l2 l2 0 1
+
+set res_extrema [extrema l1 l2]
+
+if { [regexp "Infinite number of extremas" $res_extrema] == 0} {
+  if {[llength $res_extrema] != 1} {
+    puts "Error : expected 1 extrema, but found [llength $res_extrema]"
+  }
+} else {
+  puts "Error : Infinite number of extremas is found"
+}
+
+smallview  +X+Y
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file
diff --git a/tests/lowalgos/extcc/bug26269_2 b/tests/lowalgos/extcc/bug26269_2
new file mode 100644 (file)
index 0000000..0726fd2
--- /dev/null
@@ -0,0 +1,24 @@
+puts "========"
+puts "0026269: Modeling Data - Analytical extrema does not take into account trimmed input data"
+puts "========"
+puts ""
+
+#case 2
+circle c1 0 0 0 10
+circle c2 0 0 0 5
+trim c1 c1 0 1
+trim c2 c2 3 4
+
+set res_extrema [extrema c1 c2]
+
+if { [regexp "Infinite number of extremas" $res_extrema] == 0} {
+  if {[llength $res_extrema] != 1} {
+    puts "Error : expected 1 extrema, but found [llength $res_extrema]"
+  }
+} else {
+  puts "Error : Infinite number of extremas is found"
+}
+
+smallview  +X+Y
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
index 36dc300487f5e73864101019a6566ae68788726f..3e54f3fd6564e975a5fd1bd35c83ce10b7d8cc2a 100644 (file)
@@ -17,8 +17,19 @@ circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 3
 trim c2 c2 4 6
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index f2a1b419fee727f6697ca4bf0861265f087aef1d..569a0687c42f9de14f886bd42e11909d68c301b4 100644 (file)
@@ -17,8 +17,19 @@ circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 3
 trim c2 c2 -3.2 -1.2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
\ No newline at end of file
index 9287c1f237517cf8cf98abf71efb6eed21432eab..b9e5d0733332ff777fb5d1a510dc6deb31359d30 100644 (file)
@@ -10,15 +10,24 @@ puts ""
 # However, they are bounded (trimmed) curves
 # and are shifted relatively to each other.
 
-set ExpDist 150.0
-
 circle c1 0 0 0 0 0 1 100
 circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 3
 trim c2 c2 -3.1 -1.1
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index 280f73a4edf0d524c3e779800c1eba603c4cace3..7c0e22d63f9286d210f6f8820ec0007a72b2744f 100644 (file)
@@ -10,15 +10,25 @@ puts ""
 # However, they are bounded (trimmed) curves
 # and are shifted relatively to each other.
 
-set ExpDist 150.0
 
 circle c1 0 0 0 0 0 1 100
 circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 3
 trim c2 c2 -9.5 -7.5
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index c8bd0973ba01aa3aa120d4d31d46d93ca5282e7e..1503119687c535ad4a56f854b78d145bbc3247a9 100644 (file)
@@ -17,8 +17,19 @@ circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 3
 trim c2 c2 -8.3 -6.3
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index 0339082b9bbb309b65cecd40164f4dfe6e22b50a..eeb9d4efa3d27cb160cb030ca4fb94bedf446f13 100644 (file)
@@ -10,15 +10,25 @@ puts ""
 # However, they are bounded (trimmed) curves
 # and are shifted relatively to each other.
 
-set ExpDist 150.0
 
 circle c1 0 0 0 0 0 1 100
 circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 3
 trim c2 c2 3.1 5.1
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index e5424faea652f8cf8aaae60cebc7ae4f04c42faa..e9963706459dd2c523ca522410336ad1dbd8fb2c 100644 (file)
@@ -17,9 +17,19 @@ line c2 3 4 0 1 0 0
 trim c1 c1 0 1
 trim c2 c2 0 1
 
-if { ![regexp {No solutions!} [extrema c1 c2] ] } {
+extrema c1 c2
+
+if { ![isdraw ext_1 ] } {
   puts "Error in Extrema-algorithm"
 } else {
   puts "Extrema-algorithm works properly"
 }
 
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index bd554f50357231a558fc6d1397c92ad66b1ead6d..53a41faeb9748ed0746e2f2e054b6ba5f5c6b7df 100644 (file)
@@ -17,8 +17,19 @@ circle c2 0 0 0 0 0 1 50
 trim c1 c1 0 pi
 trim c2 c2 -9.4 -7.4
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
index ab063504aa14d6eb7f407d13fe46f7d230332ff4..f9efb649811ce76545284e84c4a574d5b9567c36 100644 (file)
@@ -18,8 +18,20 @@ circle c2 0 0 0 0 0 1 50
 trim c1 c1 3 6.5 
 trim c2 c2 4 6 
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
-checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+extrema c1 c2
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
+
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
+  puts "Error in Extrema-algorithm"
+} else {
+  puts "Extrema-algorithm works properly"
+}
 
-regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
-checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
index b5794fadc32f966a355d52daa4b0637b9690dfc3..c43d75dd96b4cf7c55f783873fe6458d44f0a75d 100644 (file)
@@ -16,14 +16,19 @@ line c2 5 0 0 0 0 1
 trim c1 c1 -1.0e100 5
 trim c2 c2 10 20
 
-if { ![regexp {No solutions!} [extrema c1 c2] ] } {
+extrema c1 c2
+
+if { ![isdraw ext_1 ] } {
   puts "Error in Extrema-algorithm"
 } else {
   puts "Extrema-algorithm works properly"
 }
 
-if { ![regexp {No solutions!} [extrema c2 c1] ] } {
+renamevar ext_1 e1
+extrema c2 c1
+
+if { ![isdraw ext_1 ] } {
   puts "Error in Extrema-algorithm"
 } else {
   puts "Extrema-algorithm works properly"
-}
+}
\ No newline at end of file