File: qwt3d_surfaceplot.sip

package info (click to toggle)
pyqwt3d 0.1.8-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 984 kB
  • sloc: python: 3,932; cpp: 328; makefile: 115; sh: 7
file content (264 lines) | stat: -rw-r--r-- 7,353 bytes parent folder | download | duplicates (2)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// The SIP interface definition for:
// - class SurfacePlot
//
// Copyright (C) 2004-2008 Gerard Vermeulen
//
// This file is part of PyQwt3D.
//
// PyQwt3D is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// PyQwt3D is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with PyQwt3D; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// In addition, as a special exception, Gerard Vermeulen gives permission
// to link PyQwt3D dynamically with non-free versions of Qt and PyQt,
// and to distribute PyQwt3D in this form, provided that equally powerful
// versions of Qt and PyQt have been released under the terms of the GNU
// General Public License.
//
// If PyQwt3D is dynamically linked with non-free versions of Qt and PyQt,
// PyQwt3D becomes a free plug-in for a non-free program.


class SurfacePlot: Plot3D
{

%TypeHeaderCode
#include <qwt3d_surfaceplot.h>
using namespace Qwt3D;

#ifdef PYQWT3D_DEBUG
#include <iostream>
using namespace std;
#endif

%End // %TypeHeaderCode 

public:
%If (HAS_QT3)
    SurfacePlot(QWidget * /TransferThis/ = 0, const char * = 0);
%End // (HAS_QT3)
%If (HAS_QT4)
    SurfacePlot(QWidget * /TransferThis/ = 0, const QGLWidget * = 0);
%End // (HAS_QT4)
%If (HAS_QT5)
    SurfacePlot(QWidget * /TransferThis/ = 0, const QGLWidget * = 0);
%End // (HAS_QT5)
    ~SurfacePlot();
    void updateNormals();
    int resolution() const;


    SIP_PYTUPLE /*std::pair<int,int>*/ facets() const;
%MethodCode
    std::pair<int, int> result = sipCpp -> SurfacePlot::facets();

    sipRes = sipBuildResult(&sipIsErr, "(ii)", result.first, result.second);
%End


    bool loadFromData(SIP_PYOBJECT /* Triple** */,
                      /* unsigned int, unsigned int, */
                      bool = false, bool = false);
%MethodCode
    double *array;
    unsigned int nx;
    unsigned int ny;
    unsigned int nz;
    PyObject *out;

    if (-1 == try_PyObject_to_PyArrayContiguousFloat3D(
            a0, &out, &array, &nx, &ny, &nz))
        return 0;

    if (nz != 3) {
        PyErr_SetString(
            PyExc_ValueError, "expected is the third dimension == 3");

        return 0;
    }

    // MSVC-6.0 does not like: new (foo)[bar];
    Triple **data = new Triple * [nx];
    for (unsigned int i=0; i<nx; i++)
        data[i] = reinterpret_cast<Triple *>(
            &array[i*ny*sizeof(Triple)/sizeof(double)]);
    
    sipRes = sipCpp -> SurfacePlot::loadFromData(data, nx, ny, a1, a2);
    
    delete [] data;
    Py_DECREF(out);
%End


    bool loadFromData(SIP_PYOBJECT /* double** */,
                      /* unsigned int, unsigned int, */
                      double, double, double, double);
%MethodCode
    double *array;
    unsigned int nx;
    unsigned int ny;
    PyObject *out;

#ifndef PYQWT3D_DEBUG
    if (-1 == try_PyObject_to_PyArrayContiguousFloat2D(
            a0, &out, &array, &nx, &ny))
        return 0;

    // MSVC-6.0 does not like: new (foo)[bar];
    double **data = new double * [nx];
    for (unsigned int i=0; i<nx; i++)
        data[i] = &array[i*ny];
#else
    nx = 3;
    ny = 5;
    // MSVC-6.0 does not like: new (foo)[bar];
    array = new double [nx*ny];
    // MSVC-6.0 does not like: new (foo)[bar];
    double **data = new double * [nx];
    for (unsigned int i=0; i<nx; i++)
        data[i] = &array[i*ny];

    for (unsigned i=0; i<nx; i++)
        for (unsigned int j=0; j<ny; j++)
            data[i][j] = (-1.0+i*2.0/(nx-1))*(-1.0+j*2.0/(ny-1));

    cout << "Fake data (Numeric or numarray have been by-passed):" << endl;
    for (unsigned i=0; i<nx; i++) {
        cout << array[i*ny];
        for (unsigned int j=1; j<ny; j++)
            cout << ", " << array[i*ny+j];
        cout << endl;
    }
#endif

    sipRes = sipCpp -> SurfacePlot::loadFromData(data, nx, ny, a1, a2, a3, a4);

#ifndef PYQWT3D_DEBUG
    delete [] data;
    Py_DECREF(out);
#else
    delete [] data;
    delete [] array;
    cout << "Returning from Python wrapper code." << endl;
    cout << "When will we see the floating point exception?" << endl;
#endif
%End


    bool loadFromData(const TripleField &, const CellField &);
/*  -- deprecated --
    bool createDataRepresentation(Triple**, unsigned int, unsigned int,
                                  bool = false, bool = false);
    bool createDataRepresentation(double** data, unsigned int, unsigned int,
                                  double, double, double, double);
    bool createDataRepresentation(const TripleField &, const CellField &);
*/

    FLOORSTYLE floorStyle() const;
    void  setFloorStyle(FLOORSTYLE);
    void showNormals(bool);
    bool normals() const;
    void setNormalLength(double);
    double normalLength() const;
    void setNormalQuality(int);
    int normalQuality() const;

signals:
    void resolutionChanged(int);

public slots:
    void setResolution(int);

protected:
    //bool datanormals_p;
    //double normalLength_p;
    //int normalQuality_p;
    //int resolution_p;

    virtual void calculateHull();
    virtual void createData();
    virtual void createEnrichment(Enrichment &);
    virtual void createFloorData();
    // FIXME: void createNormals(); missing C++ code?
    void createPoints();

    
    void readIn(GridData &, SIP_PYOBJECT)
        [void (GridData &, Triple **, unsigned int, unsigned int)];
%MethodCode
    double *array;
    unsigned int nx;
    unsigned int ny;
    unsigned int nz;
    PyObject *out;

    if (-1 == try_PyObject_to_PyArrayContiguousFloat3D(
            a1, &out, &array, &nx, &ny, &nz))
        return 0;

    if (nz != 3) {
        PyErr_SetString(
            PyExc_ValueError, "expected is the third dimension == 3");

        return 0;
    }

    // MSVC-6.0 does not like: new (foo)[bar];
    Triple **data = new Triple * [nx];
    for (unsigned int i=0; i<nx; i++)
        data[i] = reinterpret_cast<Triple *>(
            &array[i*ny*sizeof(Triple)/sizeof(double)]);

    sipCpp -> sipProtect_readIn(*a0, data, nx, ny);

    delete [] data;
    Py_DECREF(out);
%End


void readIn(GridData &, SIP_PYOBJECT, double, double, double, double)
    [void (GridData &, double **, unsigned int, unsigned int,
           double, double, double, double)];
%MethodCode
    double *array;
    unsigned int nx;
    unsigned int ny;
    PyObject *out;

    if (-1 == try_PyObject_to_PyArrayContiguousFloat2D(
            a1, &out, &array, &nx, &ny))
        return 0;

    // MSVC-6.0 does not like: new (foo)[bar];
    double **data = new double * [nx];
    for (unsigned int i=0; i<nx; i++)
        data[i] = &array[i*ny];

    sipCpp -> sipProtect_readIn(*a0, data, nx, ny, a2, a3, a4, a5);

    delete [] data;
    Py_DECREF(out);
%End


    void calcNormals(GridData &);
    void sewPeriodic(GridData &);

}; // class SurfacePlot


// Local Variables:
// mode: C++
// c-file-style: "stroustrup"
// indent-tabs-mode: nil
// End: