]> OCCT Git - occt-copy.git/commitdiff
0029679: Draw Harness - Command 2dapprox works wrong when giving points in command...
authormsv <msv@opencascade.com>
Fri, 21 Jun 2019 17:35:30 +0000 (20:35 +0300)
committerapn <apn@opencascade.com>
Mon, 24 Jun 2019 16:22:47 +0000 (19:22 +0300)
Correct the behavior of the command 2dapprox for the case of points input in the command line.
Restore the work of the command 2dinterpole (implemented in the same method as 2dapprox).
Add test cases.
Correct generation of snapshots for the tests lowalgos/2dinter/*.

dox/user_guides/draw_test_harness/draw_test_harness.md
src/GeomliteTest/GeomliteTest_API2dCommands.cxx
tests/lowalgos/2dapprox/bug29679_1 [new file with mode: 0644]
tests/lowalgos/2dapprox/bug29679_2 [new file with mode: 0644]
tests/lowalgos/2dinter/bug23587
tests/lowalgos/2dinter/bug24800
tests/lowalgos/2dinter/bug4426_1
tests/lowalgos/2dinter/bug4426_2
tests/lowalgos/grids.list

index 8edd0eaa422040dd4e75c04408c9d472157470e0..b5ae421a0167316e3a7bb340945dfac5dca61d9b 100644 (file)
@@ -5595,7 +5595,7 @@ Draw provides command to create curves and surfaces by approximation.
 * **appro** fits a curve through 3d points;
 * **surfapp** and **grilapp** fit a surface through 3d points by approximation;
 * **surfint** fit a surface through 3d points by interpolation;
-* **2dinterpolate** interpolates a curve. 
+* **2dinterpole** interpolates a curve. 
 
 @subsubsection occt_draw_6_8_1   appro, dapprox
 
index 89e5f30bea80cb19e53a95b2089990a649a461bc..a7cf83934ab3277469b06269f2c55e9f0c4a8bc6 100644 (file)
@@ -26,6 +26,7 @@
 #include <DrawTrSurf_Curve2d.hxx>
 #include <Geom2dAPI_ProjectPointOnCurve.hxx>
 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
+#include <Geom2dAPI_Interpolate.hxx>
 #include <Geom2dAPI_PointsToBSpline.hxx>
 #include <Geom2dAPI_InterCurveCurve.hxx>
 #include <Geom2d_Line.hxx>
@@ -178,7 +179,6 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
 
     else {
       // test points ou ordonnees
-      hasPoints = Standard_False;
       Standard_Integer nc = n - 3;
       if (nc == 2 * Nb) {
        // points
@@ -190,6 +190,7 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
       }
       else if (nc - 2 == Nb) {
        // YValues
+        hasPoints = Standard_False;
        nc = 5;
        X0 = Draw::Atof(a[3]);
        DX = Draw::Atof(a[4]);
@@ -214,9 +215,44 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
   
   Handle(Geom2d_BSplineCurve) TheCurve;
   if (hasPoints)
-    TheCurve = Geom2dAPI_PointsToBSpline(Points,Dmin,Dmax,GeomAbs_C2,Tol2d);
+  {
+    if (!strcmp (a[0], "2dinterpole"))
+    {
+      Geom2dAPI_Interpolate anInterpol (new TColgp_HArray1OfPnt2d(Points), Standard_False, Tol2d);
+      anInterpol.Perform();
+      if (!anInterpol.IsDone())
+      {
+        di << "not done";
+        return 1;
+      }
+      TheCurve = anInterpol.Curve();
+    }
+    else
+    {
+      Geom2dAPI_PointsToBSpline anApprox (Points, Dmin, Dmax, GeomAbs_C2, Tol2d);
+      if (!anApprox.IsDone())
+      {
+        di << "not done";
+        return 1;
+      }
+      TheCurve = anApprox.Curve();
+    }
+  }
   else
-    TheCurve = Geom2dAPI_PointsToBSpline(YValues,X0,DX,Dmin,Dmax,GeomAbs_C2,Tol2d);
+  {
+    if (!strcmp (a[0], "2dinterpole"))
+    {
+      di << "incorrect usage";
+      return 1;
+    }
+    Geom2dAPI_PointsToBSpline anApprox (YValues, X0, DX, Dmin, Dmax, GeomAbs_C2, Tol2d);
+    if (!anApprox.IsDone())
+    {
+      di << "not done";
+      return 1;
+    }
+    TheCurve = anApprox.Curve();
+  }
   
   DrawTrSurf::Set(a[1], TheCurve);
   di << a[1];
diff --git a/tests/lowalgos/2dapprox/bug29679_1 b/tests/lowalgos/2dapprox/bug29679_1
new file mode 100644 (file)
index 0000000..66b8a27
--- /dev/null
@@ -0,0 +1,12 @@
+puts "================"
+puts "0029679: Command 2dapprox works wrong when giving points in command line"
+puts "================"
+puts ""
+
+2dapprox c 5 0 0 3 4 -1 4 -4 0 -4 -3
+
+checklength c -l 18.723980878126035
+
+smallview -2D-
+2dfit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/lowalgos/2dapprox/bug29679_2 b/tests/lowalgos/2dapprox/bug29679_2
new file mode 100644 (file)
index 0000000..3b3415a
--- /dev/null
@@ -0,0 +1,12 @@
+puts "================"
+puts "0029679: Command 2dapprox works wrong when giving points in command line"
+puts "================"
+puts ""
+
+2dinterpole c 5 0 0 3 4 -1 4 -4 0 -4 -3
+
+checklength c -l 18.236785351873756
+
+smallview -2D-
+2dfit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
index ee41d7906db4f27da7316530121d26aaab616bfc..8da804346e91ab1dd72f2e708227062c5ef4da5c 100644 (file)
@@ -30,7 +30,7 @@ if { $int1 == 0 || $int2 == 0 || $int3 == 0 || $int4 ==0 } {
     puts "Error : Intersection is not found"
 } 
 
-av2d
+smallview -2D-
 2dfit
 
 xwd ${imagedir}/${test_image}.png
index 60b8cbcef27fd1dfc3064bf4bba7b85d807294fa..35142aeeeaa7ab4d3b7f5f6203bcff35ffd32d0c 100644 (file)
@@ -16,7 +16,7 @@ if { ${int1} == 0 } {
     puts "Error : Intersection is not found"
 } 
 
-av2d
+smallview -2D-
 2dfit
 
 xwd ${imagedir}/${test_image}.png
index 0fc291e38751ee8a4d1e19ab9287cb308aab052f..ac7c86bf3e0d878c0fe7d835e1642387ab09b144 100644 (file)
@@ -6,17 +6,16 @@ puts ""
 # Incorrect result of intersection in 2D between circle and line
 #######################################################################################
 
-v2d2
+smallview -2D-
+don
 circle c1 2 2 1
 2dfit
 2dzoom 120
 line l1 3 0 0 1
 2dintersect l1 c1
 erase l1 c1
-2dfit
 
 puts "ATTENTION! Check following:"
 puts "There is only one intersection point (green X)"
 
-checkview -display result -2d -path ${imagedir}/${test_image}.png
-
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
index 6e7e975533a1eab90860b9503a6ef9466e696af3..fc5d873b531d0ff79911222288385c5156032515 100644 (file)
@@ -6,7 +6,7 @@ puts ""
 # Incorrect result of intersection in 2D between circle and line
 #######################################################################################
 
-v2d2
+smallview -2D-
 line ll1 0 0 0.3 0.7
 line ll2 0 0 0.37 0.63
 trim tll1 ll1 -0.00001 0.00001
@@ -18,5 +18,4 @@ donly tll1 tll2
 puts "ATTENTION! Check following:"
 puts "There is the intersection point (green X) on center of grid axis"
 
-checkview -display result -2d -path ${imagedir}/${test_image}.png
-
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
index eabf01d895d4915635ae16faef4106c5d540bac9..7aa5c18d2158fd964b1021c0d4d786c1cc58d8ea 100644 (file)
@@ -1,8 +1,9 @@
-001 2dinter
-002 bnd
-003 extcs
-004 extcc
-005 2dgcc
-006 intss
-007 classifier
-008 bvh
+001 2dapprox
+002 2dinter
+003 bnd
+004 extcs
+005 extcc
+006 2dgcc
+007 intss
+008 classifier
+009 bvh