]> OCCT Git - occt-copy.git/commitdiff
Added tests for performance of bspline curve evaluation CR27074_ULC_4
authorabv <abv@opencascade.com>
Fri, 24 Feb 2017 14:33:11 +0000 (17:33 +0300)
committerabv <abv@opencascade.com>
Sat, 25 Feb 2017 07:04:58 +0000 (10:04 +0300)
src/QABugs/QABugs_20.cxx
tests/perf/bspline/curve_c1 [new file with mode: 0644]
tests/perf/bspline/curve_c2 [new file with mode: 0644]
tests/perf/bspline/curve_c3 [new file with mode: 0644]
tests/perf/bspline/curve_c4 [new file with mode: 0644]
tests/perf/bspline/curve_s1 [new file with mode: 0644]
tests/perf/bspline/curve_s2 [new file with mode: 0644]
tests/perf/bspline/curve_s3 [new file with mode: 0644]

index 5be38190b909792a46300d454fc0596f9c28a97d..28c3eaceb2788a49043f67284dd399c94a35c747 100644 (file)
 
 #include <HLRAppli_ReflectLines.hxx>
 
+#include <OSD_Timer.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
 //=======================================================================
 //function : SurfaceGenOCC26675_1 
 //purpose  : Generates a surface for intersect (in corresponding
@@ -2140,6 +2146,78 @@ static Standard_Integer OCC27875(Draw_Interpretor& theDI,
   return 0;
 }
 
+// calculate specified number of points on a curve
+template <class AdCurve>
+void evalCurve (const AdCurve& theCurve, int theNbP, bool isRandom, double theUMin, double theUMax)
+{
+  std::srand(1);
+  double aStep = (theUMax - theUMin) / (! isRandom && theNbP > 0 ? theNbP : 1);
+  for (int i = 0; i < theNbP; i++)
+  {
+    double aU = theUMin + aStep * (isRandom ? std::rand() / (double)RAND_MAX : (double)i);
+    theCurve.Value (aU);
+//    Standard_ASSERT_VOID(theCurve.Value (aU).SquareDistance (theCurve.BSpline()->Value(aU)) < 1e-20,
+//                         "Different points at the same parameter");
+  }
+}
+
+static Standard_Integer probspline (Draw_Interpretor& theDI,
+                                    Standard_Integer theNArg,
+                                    const char ** theArgVal)
+{
+  if (theNArg < 2)
+  {
+    std::cout << "Measures time of evaluating points on bspline" << std::endl;
+    std::cout << "Use: \n" << theArgVal[0] << " bspline nbpoints [-r{andom}] [ustart uend]" << std::endl;
+    return 1;
+  }
+
+  Handle(Geom2d_BSplineCurve) aCurve2d = DrawTrSurf::GetBSplineCurve2d (theArgVal[1]);
+  Handle(Geom_BSplineCurve) aCurve = DrawTrSurf::GetBSplineCurve (theArgVal[1]);
+  if (aCurve2d.IsNull() && aCurve.IsNull())
+  {
+    std::cout << "Error: " << theArgVal[1] << " is neither 2d nor 3d bspline" << std::endl;
+    return 1;
+  }
+
+  Standard_Integer aNbP = Draw::Atoi (theArgVal[2]);
+  Standard_Boolean isRandom = Standard_False;
+  Standard_Integer nbArg = 3;
+  if (theNArg > 3 && theArgVal[nbArg][0] == '-' && theArgVal[nbArg][1] == 'r')
+  {
+    isRandom = Standard_True;
+    nbArg++;
+  }
+  Standard_Real aUMin = (! aCurve2d.IsNull() ? aCurve2d->FirstParameter() : aCurve->FirstParameter());
+  Standard_Real aUMax = (! aCurve2d.IsNull() ? aCurve2d->LastParameter()  : aCurve->LastParameter());
+  if (nbArg + 1 < theNArg)
+  {
+    aUMin = Draw::Atof (theArgVal[nbArg++]);
+    aUMax = Draw::Atof (theArgVal[nbArg++]);
+  }
+
+  std::cout << "Evaluating " << aNbP << (isRandom ? " random" : "sequential") << " points on " 
+            << (! aCurve2d.IsNull() ? "2d" : "3d") << " bspline curve " << theArgVal[1]
+            << " in range [" << aUMin << ", " << aUMax << "]" << std::endl;
+  OSD_Timer aTimer;
+  aTimer.Start();
+  if (! aCurve2d.IsNull())
+  {
+    Geom2dAdaptor_Curve aC (aCurve2d);
+    evalCurve (aC, aNbP, isRandom, aUMin, aUMax);
+  }
+  else if (! aCurve.IsNull())
+  {
+    GeomAdaptor_Curve aC (aCurve);
+    evalCurve (aC, aNbP, isRandom, aUMin, aUMax);
+  }
+  Standard_Real aSec, aCPU;
+  Standard_Integer aMin, aHour;
+  aTimer.Show (aSec, aMin, aHour, aCPU);
+  theDI << "Elapsed " << (aSec + 60. * aMin + 3600. * aHour) << " sec, CPU = " << aCPU << " sec";
+
+  return 0;
+}
 
 #include <TDF_Tool.hxx>
 #include <XCAFDoc_View.hxx>
@@ -2274,5 +2352,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC27875", "OCC27875 curve", __FILE__, OCC27875, group);
   theCommands.Add("OCC28389", "OCC28389", __FILE__, OCC28389, group);
 
+  theCommands.Add("probspline", "probspline curve nbpoints [-random] [umin umax]", __FILE__, probspline, group);
+
   return;
 }
diff --git a/tests/perf/bspline/curve_c1 b/tests/perf/bspline/curve_c1
new file mode 100644 (file)
index 0000000..c813a72
--- /dev/null
@@ -0,0 +1,20 @@
+puts "Evaluation of complex curve, random, in range"
+
+pload QAcommands
+bsplinecurve  c 3 37 \
+0 4 1 1 2 1 3 1 5 1 6 1 7 1 8 1 9 1 10 1 \
+11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 \
+21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 \
+31 1 32 1 33 1 34 1 35 1 36 1 37 4 \
+0 0 0 1  0 0 1 1  1 0 1 1  1 0 0 1 \
+0 1 0 1  0 1 1 1  1 1 1 1  1 1 0 1 \
+0 2 0 1  0 2 1 1  1 2 1 1  1 2 0 1 \
+0 3 0 1  0 3 1 1  1 3 1 1  1 3 0 1 \
+0 4 0 1  0 4 1 1  1 4 1 1  1 4 0 1 \
+0 5 0 1  0 5 1 1  1 5 1 1  1 5 0 1 \
+0 6 0 1  0 6 1 1  1 6 1 1  1 6 0 1 \
+0 7 0 1  0 7 1 1  1 7 1 1  1 7 0 1 \
+0 8 0 1  0 8 1 1  1 8 1 1  1 8 0 1 \
+0 9 0 1  0 9 1 1  1 9 1 1  1 9 0 1
+
+probspline c 10000000 -r
diff --git a/tests/perf/bspline/curve_c2 b/tests/perf/bspline/curve_c2
new file mode 100644 (file)
index 0000000..8efbd06
--- /dev/null
@@ -0,0 +1,20 @@
+puts "Evaluation of complex curve, sequential, in range"
+
+pload QAcommands
+bsplinecurve  c 3 37 \
+0 4 1 1 2 1 3 1 5 1 6 1 7 1 8 1 9 1 10 1 \
+11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 \
+21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 \
+31 1 32 1 33 1 34 1 35 1 36 1 37 4 \
+0 0 0 1  0 0 1 1  1 0 1 1  1 0 0 1 \
+0 1 0 1  0 1 1 1  1 1 1 1  1 1 0 1 \
+0 2 0 1  0 2 1 1  1 2 1 1  1 2 0 1 \
+0 3 0 1  0 3 1 1  1 3 1 1  1 3 0 1 \
+0 4 0 1  0 4 1 1  1 4 1 1  1 4 0 1 \
+0 5 0 1  0 5 1 1  1 5 1 1  1 5 0 1 \
+0 6 0 1  0 6 1 1  1 6 1 1  1 6 0 1 \
+0 7 0 1  0 7 1 1  1 7 1 1  1 7 0 1 \
+0 8 0 1  0 8 1 1  1 8 1 1  1 8 0 1 \
+0 9 0 1  0 9 1 1  1 9 1 1  1 9 0 1
+
+probspline c 10000000
diff --git a/tests/perf/bspline/curve_c3 b/tests/perf/bspline/curve_c3
new file mode 100644 (file)
index 0000000..be253fa
--- /dev/null
@@ -0,0 +1,20 @@
+puts "Evaluation of complex curve, random, out of range"
+
+pload QAcommands
+bsplinecurve  c 3 37 \
+0 4 1 1 2 1 3 1 5 1 6 1 7 1 8 1 9 1 10 1 \
+11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 \
+21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 \
+31 1 32 1 33 1 34 1 35 1 36 1 37 4 \
+0 0 0 1  0 0 1 1  1 0 1 1  1 0 0 1 \
+0 1 0 1  0 1 1 1  1 1 1 1  1 1 0 1 \
+0 2 0 1  0 2 1 1  1 2 1 1  1 2 0 1 \
+0 3 0 1  0 3 1 1  1 3 1 1  1 3 0 1 \
+0 4 0 1  0 4 1 1  1 4 1 1  1 4 0 1 \
+0 5 0 1  0 5 1 1  1 5 1 1  1 5 0 1 \
+0 6 0 1  0 6 1 1  1 6 1 1  1 6 0 1 \
+0 7 0 1  0 7 1 1  1 7 1 1  1 7 0 1 \
+0 8 0 1  0 8 1 1  1 8 1 1  1 8 0 1 \
+0 9 0 1  0 9 1 1  1 9 1 1  1 9 0 1
+
+probspline c 10000000 -r -100. 0.
diff --git a/tests/perf/bspline/curve_c4 b/tests/perf/bspline/curve_c4
new file mode 100644 (file)
index 0000000..cc1e5e6
--- /dev/null
@@ -0,0 +1,20 @@
+puts "Evaluation of complex curve, random, narrow range"
+
+pload QAcommands
+bsplinecurve  c 3 37 \
+0 4 1 1 2 1 3 1 5 1 6 1 7 1 8 1 9 1 10 1 \
+11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 \
+21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 \
+31 1 32 1 33 1 34 1 35 1 36 1 37 4 \
+0 0 0 1  0 0 1 1  1 0 1 1  1 0 0 1 \
+0 1 0 1  0 1 1 1  1 1 1 1  1 1 0 1 \
+0 2 0 1  0 2 1 1  1 2 1 1  1 2 0 1 \
+0 3 0 1  0 3 1 1  1 3 1 1  1 3 0 1 \
+0 4 0 1  0 4 1 1  1 4 1 1  1 4 0 1 \
+0 5 0 1  0 5 1 1  1 5 1 1  1 5 0 1 \
+0 6 0 1  0 6 1 1  1 6 1 1  1 6 0 1 \
+0 7 0 1  0 7 1 1  1 7 1 1  1 7 0 1 \
+0 8 0 1  0 8 1 1  1 8 1 1  1 8 0 1 \
+0 9 0 1  0 9 1 1  1 9 1 1  1 9 0 1
+
+probspline c 10000000 -r 10. 11.
diff --git a/tests/perf/bspline/curve_s1 b/tests/perf/bspline/curve_s1
new file mode 100644 (file)
index 0000000..ccbbe0e
--- /dev/null
@@ -0,0 +1,5 @@
+puts "Evaluation of simple curve, random, in range"
+
+pload QAcommands
+bsplinecurve  c 3 2 0 4 1 4 0 0 0 1 0 0 1 1  1 0 1 1  1 0 0 1
+probspline c 100000000 -r
diff --git a/tests/perf/bspline/curve_s2 b/tests/perf/bspline/curve_s2
new file mode 100644 (file)
index 0000000..65df9cd
--- /dev/null
@@ -0,0 +1,5 @@
+puts "Evaluation of simple curve, sequential, in range"
+
+pload QAcommands
+bsplinecurve  c 3 2 0 4 1 4 0 0 0 1 0 0 1 1  1 0 1 1  1 0 0 1
+probspline c 10000000
diff --git a/tests/perf/bspline/curve_s3 b/tests/perf/bspline/curve_s3
new file mode 100644 (file)
index 0000000..c0d5980
--- /dev/null
@@ -0,0 +1,5 @@
+puts "Evaluation of simple curve, random, out of range"
+
+pload QAcommands
+bsplinecurve  c 3 2 0 4 1 4 0 0 0 1 0 0 1 1  1 0 1 1  1 0 0 1
+probspline c 10000000 -r -100. 100.