Qt 4.8
qtriangulator_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtOpenGL module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QTRIANGULATOR_P_H
43 #define QTRIANGULATOR_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qvector.h>
57 #include <QtGui/private/qvectorpath_p.h>
58 
60 
62 {
63 public:
64  enum Type {
67  };
68 
69  inline Type type() const { return t; }
70 
71  inline void setDataUint(const QVector<quint32> &data)
72  {
73  t = UnsignedInt;
74  indices32 = data;
75  }
76 
77  inline void setDataUshort(const QVector<quint16> &data)
78  {
79  t = UnsignedShort;
80  indices16 = data;
81  }
82 
83  inline const void* data() const
84  {
85  if (t == UnsignedInt)
86  return indices32.data();
87  return indices16.data();
88  }
89 
90  inline int size() const
91  {
92  if (t == UnsignedInt)
93  return indices32.size();
94  return indices16.size();
95  }
96 
98  {
99  if (t == UnsignedInt)
100  indices32 = other.indices32;
101  else
102  indices16 = other.indices16;
103 
104  return *this;
105  }
106 
107 private:
108 
112 };
113 
115 {
116  inline QTriangleSet() { }
117  inline QTriangleSet(const QTriangleSet &other) : vertices(other.vertices), indices(other.indices) { }
118  QTriangleSet &operator = (const QTriangleSet &other) {vertices = other.vertices; indices = other.indices; return *this;}
119 
120  // The vertices of a triangle are given by: (x[i[n]], y[i[n]]), (x[j[n]], y[j[n]]), (x[k[n]], y[k[n]]), n = 0, 1, ...
121  QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
122  QVertexIndexVector indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...]
123 };
124 
126 {
127  inline QPolylineSet() { }
128  inline QPolylineSet(const QPolylineSet &other) : vertices(other.vertices), indices(other.indices) { }
129  QPolylineSet &operator = (const QPolylineSet &other) {vertices = other.vertices; indices = other.indices; return *this;}
130 
131  QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
133 };
134 
135 // The vertex coordinates of the returned triangle set will be rounded to a grid with a mesh size
136 // of 1/32. The polygon is first transformed, then scaled by 32, the coordinates are rounded to
137 // integers, the polygon is triangulated, and then scaled back by 1/32.
138 // 'hint' should be a combination of QVectorPath::Hints.
139 // 'lod' is the level of detail. Default is 1. Curves are split into more lines when 'lod' is higher.
140 QTriangleSet qTriangulate(const qreal *polygon, int count, uint hint = QVectorPath::PolygonHint | QVectorPath::OddEvenFill, const QTransform &matrix = QTransform());
141 QTriangleSet qTriangulate(const QVectorPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
142 QTriangleSet qTriangulate(const QPainterPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
143 QPolylineSet qPolyline(const QVectorPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
144 QPolylineSet qPolyline(const QPainterPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
145 
147 
148 #endif
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QVertexIndexVector indices
void setDataUint(const QVector< quint32 > &data)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QVertexIndexVector & operator=(const QVertexIndexVector &other)
QTriangleSet(const QTriangleSet &other)
QVertexIndexVector indices
QTriangleSet qTriangulate(const qreal *polygon, int count, uint hint=QVectorPath::PolygonHint|QVectorPath::OddEvenFill, const QTransform &matrix=QTransform())
QVector< quint32 > indices32
void setDataUshort(const QVector< quint16 > &data)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QPolylineSet qPolyline(const QVectorPath &path, const QTransform &matrix=QTransform(), qreal lod=1)
QVector< qreal > vertices
const void * data() const
unsigned int uint
Definition: qglobal.h:996
QVector< qreal > vertices
QVector< quint16 > indices16
QPolylineSet(const QPolylineSet &other)
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65