From 64a44752853acc129e137c533eb5564446a79f9f Mon Sep 17 00:00:00 2001 From: msv Date: Fri, 21 Jun 2019 20:35:30 +0300 Subject: [PATCH] 0029679: Draw Harness - Command 2dapprox works wrong when giving points in command line 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/*. --- .../draw_test_harness/draw_test_harness.md | 2 +- .../GeomliteTest_API2dCommands.cxx | 42 +++++++++++++++++-- tests/lowalgos/2dapprox/bug29679_1 | 12 ++++++ tests/lowalgos/2dapprox/bug29679_2 | 12 ++++++ tests/lowalgos/2dinter/bug23587 | 2 +- tests/lowalgos/2dinter/bug24800 | 2 +- tests/lowalgos/2dinter/bug4426_1 | 7 ++-- tests/lowalgos/2dinter/bug4426_2 | 5 +-- tests/lowalgos/grids.list | 17 ++++---- 9 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 tests/lowalgos/2dapprox/bug29679_1 create mode 100644 tests/lowalgos/2dapprox/bug29679_2 diff --git a/dox/user_guides/draw_test_harness/draw_test_harness.md b/dox/user_guides/draw_test_harness/draw_test_harness.md index 8edd0eaa42..b5ae421a01 100644 --- a/dox/user_guides/draw_test_harness/draw_test_harness.md +++ b/dox/user_guides/draw_test_harness/draw_test_harness.md @@ -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 diff --git a/src/GeomliteTest/GeomliteTest_API2dCommands.cxx b/src/GeomliteTest/GeomliteTest_API2dCommands.cxx index 89e5f30bea..a7cf83934a 100644 --- a/src/GeomliteTest/GeomliteTest_API2dCommands.cxx +++ b/src/GeomliteTest/GeomliteTest_API2dCommands.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -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 index 0000000000..66b8a27138 --- /dev/null +++ b/tests/lowalgos/2dapprox/bug29679_1 @@ -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 index 0000000000..3b3415a719 --- /dev/null +++ b/tests/lowalgos/2dapprox/bug29679_2 @@ -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 diff --git a/tests/lowalgos/2dinter/bug23587 b/tests/lowalgos/2dinter/bug23587 index ee41d7906d..8da804346e 100644 --- a/tests/lowalgos/2dinter/bug23587 +++ b/tests/lowalgos/2dinter/bug23587 @@ -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 diff --git a/tests/lowalgos/2dinter/bug24800 b/tests/lowalgos/2dinter/bug24800 index 60b8cbcef2..35142aeeea 100644 --- a/tests/lowalgos/2dinter/bug24800 +++ b/tests/lowalgos/2dinter/bug24800 @@ -16,7 +16,7 @@ if { ${int1} == 0 } { puts "Error : Intersection is not found" } -av2d +smallview -2D- 2dfit xwd ${imagedir}/${test_image}.png diff --git a/tests/lowalgos/2dinter/bug4426_1 b/tests/lowalgos/2dinter/bug4426_1 index 0fc291e387..ac7c86bf3e 100644 --- a/tests/lowalgos/2dinter/bug4426_1 +++ b/tests/lowalgos/2dinter/bug4426_1 @@ -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 diff --git a/tests/lowalgos/2dinter/bug4426_2 b/tests/lowalgos/2dinter/bug4426_2 index 6e7e975533..fc5d873b53 100644 --- a/tests/lowalgos/2dinter/bug4426_2 +++ b/tests/lowalgos/2dinter/bug4426_2 @@ -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 diff --git a/tests/lowalgos/grids.list b/tests/lowalgos/grids.list index eabf01d895..7aa5c18d21 100644 --- a/tests/lowalgos/grids.list +++ b/tests/lowalgos/grids.list @@ -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 -- 2.20.1