1
#if defined(_MSC_VER) /* MSVC Compiler */
2
#pragma warning ( disable : 4786 )
5
#ifndef __DATATYPES_H__
6
#define __DATATYPES_H__
14
#include "qwt3d_global.h"
21
#define WHEEL_DELTA 120
24
#include "qwt3d_portability.h"
25
#include "qwt3d_helper.h"
26
#include "qwt3d_openglhelper.h"
28
//! Common namespace for all QwtPlot3D classes
32
const double PI = 3.14159265358979323846264338328;
37
NOPLOT , //!< No visible data
38
WIREFRAME , //!< Wireframe style
39
HIDDENLINE , //!< Hidden Line style
40
FILLED , //!< Color filled polygons w/o edges
41
FILLEDMESH , //!< Color filled polygons w/ separately colored edges
42
POINTS , //!< User defined style (used by Enrichments)
43
USER //!< User defined style (used by Enrichments)
49
FLAT, //!< Flat shading (OpenGL)
50
GOURAUD //!< Gouraud Shading (OpenGL)
53
//! Style of Coordinate system
56
NOCOORD, //!< Coordinate system is not visible
58
FRAME //!< Frame - 3 visible axes
61
//! Different types of axis scales
64
LINEARSCALE,//!< Linear scaling
65
LOG10SCALE, //!< Logarithmic scaling (base 10)
66
USERSCALE //!< User-defined (for extensions)
69
//! Plotting style for floor data (projections)
72
NOFLOOR, //!< Empty floor
73
FLOORISO, //!< Isoline projections visible
74
FLOORDATA //!< Projected polygons visible
80
GRID, //!< Rectangular grid
81
POLYGON //!< Convex polygon
90
X1 = 0, //!< 1st x-axis
91
X2 = 3, //!< 2nd x-axis
92
X3 = 4, //!< 3th x-axis
93
X4 = 5, //!< 4th x-axis
94
Y1 = 1, //!< 1st y-axis
95
Y2 = 8, //!< 2nd y-axis
96
Y3 = 7, //!< 3th y-axis
97
Y4 = 6, //!< 4th y-axis
98
Z1 = 2, //!< 1st z-axis
99
Z2 = 9, //!< 2nd z-axis
100
Z3 = 11, //!< 3th z-axis
101
Z4 = 10 //!< 4th z-axis
116
//! Possible anchor points for drawing operations
131
//! Tuple <tt>[x,y]</tt>
132
struct QWT3D_EXPORT Tuple
134
Tuple() : x(0), y(0) {} //!< Calls Tuple(0,0)
135
Tuple(double X, double Y) : x(X), y(Y) {} //!< Initialize Tuple with x and y
136
//! Tuple coordinates
140
//! Triple <tt>[x,y,z]</tt>
142
Consider Triples also as vectors in R^3
144
struct QWT3D_EXPORT Triple
146
//! Initialize Triple with x,y and z
147
explicit Triple(double xv = 0,double yv = 0,double zv = 0)
148
: x(xv), y(yv), z(zv)
152
#ifndef QWT3D_NOT_FOR_DOXYGEN
154
Triple(const Triple& val)
162
const Triple& operator=(const Triple& val)
172
#endif // QWT3D_NOT_FOR_DOXYGEN
174
//! Triple coordinates
177
Triple& operator+=(Triple t)
186
Triple& operator-=(Triple t)
194
Triple& operator*=(double d)
202
Triple& operator/=(double d)
210
Triple& operator*=(Triple t) // scale
219
bool operator!=(Triple t) const
221
return !isPracticallyZero(x,t.x) || !isPracticallyZero(y,t.y) || !isPracticallyZero(z,t.z);
224
bool operator==(Triple t) const
226
return !operator!=(t);
229
double length() const
231
double l2 = x*x + y*y + z*z;
232
return (isPracticallyZero(l2)) ? 0 :sqrt(l2);
243
inline const Triple operator+(const Triple& t, const Triple& t2)
245
return Triple(t) += t2;
247
inline const Triple operator-(const Triple& t, const Triple& t2)
249
return Triple(t) -= t2;
251
inline const Triple operator*(double d, const Triple& t)
253
return Triple(t) *= d;
255
inline const Triple operator*(const Triple& t, double d)
257
return Triple(t) *= d;
259
inline const Triple operator/(double d, const Triple& t)
261
return Triple(t) /= d;
263
inline const Triple operator/(const Triple& t, double d)
265
return Triple(t) /= d;
267
inline const Triple operator*(const Triple& t, const Triple& t2)
269
return Triple(t) *= t2;
272
//! Parallelepiped spanned by 2 Triples
274
Please use \em normalized Parallelepipeds:\n\n
275
minVertex.x <= maxVertex.x\n
276
minVertex.y <= maxVertex.y\n
277
minVertex.z <= maxVertex.z\n
279
struct QWT3D_EXPORT ParallelEpiped
281
//! Construct non-initialized Parallelepiped
286
//! Construct initialized Parallelepiped
291
ParallelEpiped(Triple minv, Triple maxv)
292
: minVertex(minv), maxVertex(maxv)
302
FreeVectors represent objects like normal vectors and other vector fields inside R^3
304
struct QWT3D_EXPORT FreeVector
310
//! Construct initialized vector
315
FreeVector(Triple b, Triple t)
324
//! A free vector field in R^3
325
typedef std::vector<FreeVector> FreeVectorField;
327
//! A point field in R^3
328
typedef std::vector<Triple> TripleField;
329
//! Holds indices in a TripleField interpreted as counterclockwise node numbering for a convex polygon
330
typedef std::vector<unsigned> Cell;
331
//! Vector of convex polygons. You need a TripleField as base for the node data
332
typedef std::vector<Cell> CellField;
333
//! Returns the sum over the sizes of the single cells
334
unsigned tesselationSize(Qwt3D::CellField const& t);
336
//! Red-Green-Blue-Alpha value
337
struct QWT3D_EXPORT RGBA
340
: r(0), g(0), b(0), a(1)
342
RGBA(double rr, double gg, double bb, double aa = 1)
343
: r(rr), g(gg), b(bb), a(aa)
349
typedef std::vector<RGBA> ColorVector;
351
#ifndef QWT3D_NOT_FOR_DOXYGEN
353
QWT3D_EXPORT QColor GL2Qt(GLdouble r, GLdouble g, GLdouble b); //!< RGB -> QColor
354
QWT3D_EXPORT Qwt3D::RGBA Qt2GL(QColor col); //!< QColor -> RGBA
356
typedef double *Vertex;
357
typedef std::vector<Vertex> DataRow;
358
typedef std::vector<DataRow> DataMatrix;
364
Qwt3D::DATATYPE datatype;
365
Data() {datatype= Qwt3D::POLYGON;}
367
virtual void clear() = 0; //!< destroy content
368
virtual bool empty() const = 0; //!< no data
369
void setHull(Qwt3D::ParallelEpiped const& h) {hull_p = h;}
370
Qwt3D::ParallelEpiped const& hull() const {return hull_p;}
373
Qwt3D::ParallelEpiped hull_p;
377
//! Implements a matrix of z-Values with limit access functions
378
class GridData : public Data
382
GridData(unsigned int columns, unsigned int rows);//!< see setSize()
383
~GridData() { clear();}
388
void clear(); //!< destroy content
389
bool empty() const { return vertices.empty();}
390
void setSize(unsigned int columns, unsigned int rows); //!< destroys content and set new size, elements are uninitialized
392
DataMatrix vertices; //!< mesh vertices
393
DataMatrix normals; //!< mesh normals
394
void setPeriodic(bool u, bool v) {uperiodic_ = u; vperiodic_ = v;}
395
bool uperiodic() const {return uperiodic_;}
396
bool vperiodic() const {return vperiodic_;}
399
bool uperiodic_, vperiodic_;
403
//! Implements a graph-like cell structure with limit access functions
404
class CellData : public Data
407
CellData() {datatype=Qwt3D::POLYGON;}
408
~CellData() { clear();}
410
void clear(); //!< destroy content
411
bool empty() const { return cells.empty();}
413
Triple const& operator()(unsigned cellnumber, unsigned vertexnumber);
415
CellField cells; //!< polygon/cell mesh
417
TripleField normals; //!< mesh normals
420
inline Triple normalizedcross(Triple const& u, Triple const& v)
424
/* compute the cross product (u x v for right-handed [ccw]) */
425
n.x = u.y * v.z - u.z * v.y;
426
n.y = u.z * v.x - u.x * v.z;
427
n.z = u.x * v.y - u.y * v.x;
430
double l = n.length();
443
inline double dotProduct(Triple const& u, Triple const& v)
445
return u.x*v.x + u.y*v.y + u.z*v.z;
448
void convexhull2d( std::vector<unsigned>& idx, const std::vector<Qwt3D::Tuple>& src );
451
#endif // QWT3D_NOT_FOR_DOXYGEN