QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgstessellator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstessellator.h
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTESSELLATOR_H
17#define QGSTESSELLATOR_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsrectangle.h"
22
23class QgsPolygon;
24class QgsMultiPolygon;
25
26#include <QVector>
27#include <memory>
28
39class CORE_EXPORT QgsTessellator
40{
41 public:
43
48 Q_DECL_DEPRECATED QgsTessellator( double originX, double originY, bool addNormals, bool invertNormals = false, bool addBackFaces = false, bool noZ = false,
49 bool addTextureCoords = false, int facade = 3, float textureRotation = 0.0f ) SIP_DEPRECATED;
50
61 Q_DECL_DEPRECATED QgsTessellator( const QgsRectangle &bounds, bool addNormals, bool invertNormals = false, bool addBackFaces = false, bool noZ = false,
62 bool addTextureCoords = false, int facade = 3, float textureRotation = 0.0f ) SIP_DEPRECATED;
63
68 void setOrigin( const QgsVector3D &origin );
69
74 QgsVector3D origin() const { return mOrigin; }
75
80 void setBounds( const QgsRectangle &bounds );
81
87 void setInputZValueIgnored( bool ignore );
88
93 bool isZValueIgnored() const { return mInputZValueIgnored; }
94
99 void setExtrusionFaces( Qgis::ExtrusionFaces faces );
100
105 Qgis::ExtrusionFaces extrusionFaces() const { return mExtrusionFaces; }
106
111 void setTextureRotation( float rotation );
112
117 float textureRotation() const { return mTextureRotation; }
118
123 void setAddTextureUVs( bool addTextureUVs );
124
129 bool hasTextureUVs() const { return mAddTextureCoords; }
130
135 void setAddNormals( bool addNormals );
136
141 bool hasNormals() const { return mAddNormals; }
142
147 void setBackFacesEnabled( bool addBackFaces );
148
153 bool hasBackFacesEnabled() const { return mAddBackFaces; }
154
159 void setInvertNormals( bool invertNormals );
160
165 bool hasInvertedNormals() const { return mInvertNormals; }
166
173 void setOutputZUp( bool zUp ) { mOutputZUp = zUp; }
174
181 bool isOutputZUp() const { return mOutputZUp; }
182
184 void addPolygon( const QgsPolygon &polygon, float extrusionHeight );
185
191 QVector<float> data() const { return mData; }
192
194 int dataVerticesCount() const;
195
197 int stride() const { return mStride; }
198
202 std::unique_ptr< QgsMultiPolygon > asMultiPolygon() const SIP_SKIP;
203
208 float zMinimum() const { return mZMin; }
209
214 float zMaximum() const { return mZMax; }
215
221 QString error() const { return mError; }
222
223 private:
224 void updateStride();
225
226 void setExtrusionFacesLegacy( int facade );
227 void calculateBaseTransform( const QVector3D &pNormal, QMatrix4x4 *base ) const;
228 void addTriangleVertices( const std::array<QVector3D, 3> &points, QVector3D pNormal, float extrusionHeight, QMatrix4x4 *transformMatrix, const QgsPoint *originOffset, bool reverse );
229 std::vector<QVector3D> generateConstrainedDelaunayTriangles( const QgsPolygon *polygonNew );
230
231 QgsVector3D mOrigin = QgsVector3D( 0, 0, 0 );
232 bool mAddNormals = false;
233 bool mInvertNormals = false;
234 bool mAddBackFaces = false;
235 bool mAddTextureCoords = false;
236 bool mOutputZUp = false;
237 QVector<float> mData;
238 int mStride = 3 * sizeof( float );
239 bool mInputZValueIgnored = false;
241 float mTextureRotation = 0.0f;
242 float mScale = 1.0f;
243 QString mError;
244
245 float mZMin = std::numeric_limits<float>::max();
246 float mZMax = -std::numeric_limits<float>::max();
247};
248
249
250#endif // QGSTESSELLATOR_H
QFlags< ExtrusionFace > ExtrusionFaces
Tessellator extrusion face types.
Definition qgis.h:6168
Multi polygon geometry collection.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
Polygon geometry type.
Definition qgspolygon.h:33
A rectangle specified with double values.
float textureRotation() const
Returns the rotation of texture UV coordinates (in degrees).
bool hasTextureUVs() const
Returns whether texture UV coordinates are being added to the output data (true) or not (false).
void setOrigin(const QgsVector3D &origin)
Sets the origin point of the map.
QVector< float > data() const
Returns array of triangle vertex data.
bool isZValueIgnored() const
Returns whether Z values from the input geometries are ignored (true) or not (false).
int stride() const
Returns size of one vertex entry in bytes.
bool hasBackFacesEnabled() const
Returns whether back faces are being added to the output data (true) or not (false).
float zMinimum() const
Returns minimal Z value of the data (in world coordinates).
Qgis::ExtrusionFaces extrusionFaces() const
Returns which faces are generated during extrusion.
QgsVector3D origin() const
Returns the origin point of the map.
QString error() const
Returns a descriptive error string if the tessellation failed.
void setOutputZUp(bool zUp)
Sets whether the "up" direction should be the Z axis on output (true), otherwise the "up" direction w...
bool isOutputZUp() const
Returns whether the "up" direction should be the Z axis on output (true), otherwise the "up" directio...
bool hasNormals() const
Returns whether normals are being added to the output data (true) or not (false).
bool hasInvertedNormals() const
Returns whether normals are inverted (true) or not (false).
float zMaximum() const
Returns maximal Z value of the data (in world coordinates).
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:30
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_SKIP
Definition qgis_sip.h:134