QGIS API Documentation  3.6.0-Noosa (5873452)
qgstessellatedpolygongeometry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstessellatedpolygongeometry.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 QGSTESSELLATEDPOLYGONGEOMETRY_H
17 #define QGSTESSELLATEDPOLYGONGEOMETRY_H
18 
19 #include "qgsfeatureid.h"
20 #include "qgspolygon.h"
21 
22 #include <Qt3DRender/QGeometry>
23 
24 namespace Qt3DRender
25 {
26  class QBuffer;
27 }
28 
38 class QgsTessellatedPolygonGeometry : public Qt3DRender::QGeometry
39 {
40  Q_OBJECT
41  public:
43  QgsTessellatedPolygonGeometry( QNode *parent = nullptr );
44 
46  bool invertNormals() const { return mInvertNormals; }
48  void setInvertNormals( bool invert ) { mInvertNormals = invert; }
49 
54  bool addBackFaces() const { return mAddBackFaces; }
55 
60  void setAddBackFaces( bool add ) { mAddBackFaces = add; }
61 
63  void setPolygons( const QList<QgsPolygon *> &polygons, const QList<QgsFeatureId> &featureIds, const QgsPointXY &origin, float extrusionHeight, const QList<float> &extrusionHeightPerPolygon = QList<float>() );
64 
66  QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const;
67 
68  private:
69 
70  Qt3DRender::QAttribute *mPositionAttribute = nullptr;
71  Qt3DRender::QAttribute *mNormalAttribute = nullptr;
72  Qt3DRender::QBuffer *mVertexBuffer = nullptr;
73 
74  QVector<QgsFeatureId> mTriangleIndexFids;
75  QVector<uint> mTriangleIndexStartingIndices;
76 
77  bool mWithNormals = true;
78  bool mInvertNormals = false;
79  bool mAddBackFaces = false;
80 };
81 
82 #endif // QGSTESSELLATEDPOLYGONGEOMETRY_H
void setInvertNormals(bool invert)
Sets whether the normals of triangles will be inverted (useful for fixing clockwise / counter-clockwi...
A class to represent a 2D point.
Definition: qgspointxy.h:43
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
3 Class derived from Qt3DRender::QGeometry that represents polygons tessellated into 3D geometry...
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
bool invertNormals() const
Returns whether the normals of triangles will be inverted (useful for fixing clockwise / counter-cloc...