blob: 28d874e4038244b390007aa87439b8049482a751 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include "qwt3d_surfaceplot.h"
#include "qwt3d_function.h"
using namespace Qwt3D;
Function::Function()
:GridMapping()
{
}
Function::Function(SurfacePlot& pw)
:GridMapping()
{
plotwidget_p = &pw;
}
Function::Function(SurfacePlot* pw)
:GridMapping()
{
plotwidget_p = pw;
}
void Function::assign(SurfacePlot& plotWidget)
{
if (&plotWidget != plotwidget_p)
plotwidget_p = &plotWidget;
}
void Function::assign(SurfacePlot* plotWidget)
{
if (plotWidget != plotwidget_p)
plotwidget_p = plotWidget;
}
void Function:: setMinZ(double val)
{
range_p.minVertex.z = val;
}
void Function:: setMaxZ(double val)
{
range_p.maxVertex.z = val;
}
bool Function::create()
{
if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p)
return false;
/* allocate some space for the mesh */
double** data = new double* [umesh_p] ;
unsigned i,j;
for ( i = 0; i < umesh_p; i++)
{
data[i] = new double [vmesh_p];
}
/* get the data */
double dx = (maxu_p - minu_p) / (umesh_p - 1);
double dy = (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*dx, minv_p + j*dy);
if (data[i][j] > range_p.maxVertex.z)
data[i][j] = range_p.maxVertex.z;
else if (data[i][j] < range_p.minVertex.z)
data[i][j] = range_p.minVertex.z;
}
}
Q_ASSERT(plotwidget_p);
if (!plotwidget_p)
{
fprintf(stderr,"Function: no valid Plot3D Widget assigned");
}
else
{
((SurfacePlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, minu_p, maxu_p, minv_p, maxv_p);
}
for ( i = 0; i < umesh_p; i++)
{
delete [] data[i];
}
delete [] data;
return true;
}
bool Function::create(SurfacePlot& pl)
{
assign(pl);
return create();
}
|