~ubuntu-branches/ubuntu/saucy/pyqwt3d/saucy-proposed

« back to all changes in this revision

Viewing changes to qwtplot3d-0.2.7/src/qwt3d_parametricsurface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gudjon I. Gudjonsson
  • Date: 2009-11-07 12:54:42 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20091107125442-92kgp0l7lessmiwo
Tags: 0.1.7~cvs20090625-2
* Change sip4 dependencies to >=4.9
* Add binary dependency on python-sip4 >=4.9
* Bump standards version to 3.8.3, no changes needed
* Add README.source file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "qwt3d_parametricsurface.h"
2
 
#include "qwt3d_surfaceplot.h"
3
 
 
4
 
using namespace Qwt3D;
5
 
 
6
 
ParametricSurface::ParametricSurface()
7
 
:GridMapping()
8
 
{
9
 
}
10
 
 
11
 
ParametricSurface::ParametricSurface(SurfacePlot& pw)
12
 
:GridMapping()
13
 
{
14
 
  plotwidget_p = &pw;
15
 
  uperiodic_ = false;
16
 
  vperiodic_ = false;
17
 
}
18
 
 
19
 
ParametricSurface::ParametricSurface(SurfacePlot* pw)
20
 
:GridMapping()
21
 
{
22
 
  plotwidget_p = pw;
23
 
  uperiodic_ = false;
24
 
  vperiodic_ = false;
25
 
}
26
 
 
27
 
void ParametricSurface::setPeriodic(bool u, bool v)
28
 
{
29
 
  uperiodic_ = u;
30
 
  vperiodic_ = v;
31
 
}
32
 
 
33
 
void ParametricSurface::assign(SurfacePlot& plotWidget)
34
 
{
35
 
  if (&plotWidget != plotwidget_p)
36
 
    plotwidget_p = &plotWidget;
37
 
}
38
 
 
39
 
void ParametricSurface::assign(SurfacePlot* plotWidget)
40
 
{
41
 
  if (plotWidget != plotwidget_p)
42
 
    plotwidget_p = plotWidget;
43
 
}
44
 
 
45
 
/**
46
 
For plotWidget != 0 the function permanently assigns her argument (In fact, assign(plotWidget) is called)
47
 
*/
48
 
bool ParametricSurface::create()
49
 
{
50
 
  if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p)
51
 
    return false;
52
 
  
53
 
  /* allocate some space for the mesh */
54
 
  Triple** data         = new Triple* [umesh_p] ;
55
 
 
56
 
  unsigned i,j;
57
 
  for ( i = 0; i < umesh_p; i++) 
58
 
  {
59
 
    data[i]         = new Triple [vmesh_p];
60
 
  }
61
 
  
62
 
  /* get the data */
63
 
 
64
 
  double du = (maxu_p - minu_p) / (umesh_p - 1);
65
 
  double dv = (maxv_p - minv_p) / (vmesh_p - 1);
66
 
  
67
 
  for (i = 0; i < umesh_p; ++i) 
68
 
  {
69
 
    for (j = 0; j < vmesh_p; ++j) 
70
 
    {
71
 
      data[i][j] = operator()(minu_p + i*du, minv_p + j*dv);
72
 
      
73
 
      if (data[i][j].x > range_p.maxVertex.x)
74
 
        data[i][j].x = range_p.maxVertex.x;
75
 
      else if (data[i][j].y > range_p.maxVertex.y)
76
 
        data[i][j].y = range_p.maxVertex.y;
77
 
      else if (data[i][j].z > range_p.maxVertex.z)
78
 
        data[i][j].z = range_p.maxVertex.z;
79
 
      else if (data[i][j].x < range_p.minVertex.x)
80
 
        data[i][j].x = range_p.minVertex.x;
81
 
      else if (data[i][j].y < range_p.minVertex.y)
82
 
        data[i][j].y = range_p.minVertex.y;
83
 
      else if (data[i][j].z < range_p.minVertex.z)
84
 
        data[i][j].z = range_p.minVertex.z;
85
 
    }
86
 
  }
87
 
 
88
 
  ((SurfacePlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, uperiodic_, vperiodic_);
89
 
 
90
 
  for ( i = 0; i < umesh_p; i++) 
91
 
  {
92
 
    delete [] data[i];
93
 
  }
94
 
 
95
 
  delete [] data;
96
 
 
97
 
  return true;
98
 
}
99
 
 
100
 
bool ParametricSurface::create(SurfacePlot& pl)
101
 
{
102
 
  assign(pl);
103
 
  return create();
104
 
}