summaryrefslogtreecommitdiffstats
path: root/lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-11 14:15:27 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-11 14:15:27 -0500
commitb85a292ce06475d560bfa1195b63a8bfe211f22d (patch)
tree463d71be55ff807513139f1de106aef6bdd7b4db /lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp
parentce039289815e2802fdeca8d384126c807ca9cb58 (diff)
downloadulab-b85a292ce06475d560bfa1195b63a8bfe211f22d.tar.gz
ulab-b85a292ce06475d560bfa1195b63a8bfe211f22d.zip
Add 0.2.7 release of qwtplot3d for future TQt3 conversion and use
Diffstat (limited to 'lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp')
-rw-r--r--lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp b/lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp
new file mode 100644
index 0000000..c3103c9
--- /dev/null
+++ b/lib/tqwtplot3d/src/qwt3d_parametricsurface.cpp
@@ -0,0 +1,104 @@
+#include "qwt3d_parametricsurface.h"
+#include "qwt3d_surfaceplot.h"
+
+using namespace Qwt3D;
+
+ParametricSurface::ParametricSurface()
+:GridMapping()
+{
+}
+
+ParametricSurface::ParametricSurface(SurfacePlot& pw)
+:GridMapping()
+{
+ plotwidget_p = &pw;
+ uperiodic_ = false;
+ vperiodic_ = false;
+}
+
+ParametricSurface::ParametricSurface(SurfacePlot* pw)
+:GridMapping()
+{
+ plotwidget_p = pw;
+ uperiodic_ = false;
+ vperiodic_ = false;
+}
+
+void ParametricSurface::setPeriodic(bool u, bool v)
+{
+ uperiodic_ = u;
+ vperiodic_ = v;
+}
+
+void ParametricSurface::assign(SurfacePlot& plotWidget)
+{
+ if (&plotWidget != plotwidget_p)
+ plotwidget_p = &plotWidget;
+}
+
+void ParametricSurface::assign(SurfacePlot* plotWidget)
+{
+ if (plotWidget != plotwidget_p)
+ plotwidget_p = plotWidget;
+}
+
+/**
+For plotWidget != 0 the function permanently assigns her argument (In fact, assign(plotWidget) is called)
+*/
+bool ParametricSurface::create()
+{
+ if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p)
+ return false;
+
+ /* allocate some space for the mesh */
+ Triple** data = new Triple* [umesh_p] ;
+
+ unsigned i,j;
+ for ( i = 0; i < umesh_p; i++)
+ {
+ data[i] = new Triple [vmesh_p];
+ }
+
+ /* get the data */
+
+ double du = (maxu_p - minu_p) / (umesh_p - 1);
+ double dv = (maxv_p - minv_p) / (vmesh_p - 1);
+
+ for (i = 0; i < umesh_p; ++i)
+ {
+ for (j = 0; j < vmesh_p; ++j)
+ {
+ data[i][j] = operator()(minu_p + i*du, minv_p + j*dv);
+
+ if (data[i][j].x > range_p.maxVertex.x)
+ data[i][j].x = range_p.maxVertex.x;
+ else if (data[i][j].y > range_p.maxVertex.y)
+ data[i][j].y = range_p.maxVertex.y;
+ else if (data[i][j].z > range_p.maxVertex.z)
+ data[i][j].z = range_p.maxVertex.z;
+ else if (data[i][j].x < range_p.minVertex.x)
+ data[i][j].x = range_p.minVertex.x;
+ else if (data[i][j].y < range_p.minVertex.y)
+ data[i][j].y = range_p.minVertex.y;
+ else if (data[i][j].z < range_p.minVertex.z)
+ data[i][j].z = range_p.minVertex.z;
+ }
+ }
+
+ ((SurfacePlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, uperiodic_, vperiodic_);
+
+ for ( i = 0; i < umesh_p; i++)
+ {
+ delete [] data[i];
+ }
+
+ delete [] data;
+
+ return true;
+}
+
+bool ParametricSurface::create(SurfacePlot& pl)
+{
+ assign(pl);
+ return create();
+}