QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 class Qgs3DSceneExporter;
25 
26 namespace Qt3DRender
27 {
28  class QBuffer;
29 }
30 
31 #define SIP_NO_FILE
32 
44 class QgsTessellatedPolygonGeometry : public Qt3DRender::QGeometry
45 {
46  Q_OBJECT
47  public:
49  QgsTessellatedPolygonGeometry( bool _withNormals = true, bool invertNormals = false, bool addBackFaces = false, bool addTextureCoords = false, QNode *parent = nullptr );
50 
52  bool invertNormals() const { return mInvertNormals; }
54  void setInvertNormals( bool invert ) { mInvertNormals = invert; }
55 
60  bool addBackFaces() const { return mAddBackFaces; }
61 
66  void setAddBackFaces( bool add ) { mAddBackFaces = add; }
67 
72  void setAddTextureCoords( bool add ) { mAddTextureCoords = add; }
73 
75  void setPolygons( const QList<QgsPolygon *> &polygons, const QList<QgsFeatureId> &featureIds, const QgsPointXY &origin, float extrusionHeight, const QList<float> &extrusionHeightPerPolygon = QList<float>() );
76 
82  void setData( const QByteArray &vertexBufferData, int vertexCount, const QVector<QgsFeatureId> &triangleIndexFids, const QVector<uint> &triangleIndexStartingIndices );
83 
88  QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const;
89 
90  friend class Qgs3DSceneExporter;
91  private:
92 
93  Qt3DRender::QAttribute *mPositionAttribute = nullptr;
94  Qt3DRender::QAttribute *mNormalAttribute = nullptr;
95  Qt3DRender::QAttribute *mTextureCoordsAttribute = nullptr;
96  Qt3DRender::QBuffer *mVertexBuffer = nullptr;
97 
98  QVector<QgsFeatureId> mTriangleIndexFids;
99  QVector<uint> mTriangleIndexStartingIndices;
100 
101  bool mWithNormals = true;
102  bool mInvertNormals = false;
103  bool mAddBackFaces = false;
104  bool mAddTextureCoords = false;
105 };
106 
107 #endif // QGSTESSELLATEDPOLYGONGEOMETRY_H
Entity that handles the exporting of 3D scene.
A class to represent a 2D point.
Definition: qgspointxy.h:59
void setPolygons(const QList< QgsPolygon * > &polygons, const QList< QgsFeatureId > &featureIds, const QgsPointXY &origin, float extrusionHeight, const QList< float > &extrusionHeightPerPolygon=QList< float >())
Initializes vertex buffer from given polygons. Takes ownership of passed polygon geometries.
void setInvertNormals(bool invert)
Sets whether the normals of triangles will be inverted (useful for fixing clockwise / counter-clockwi...
QgsFeatureId triangleIndexToFeatureId(uint triangleIndex) const
Returns ID of the feature to which given triangle index belongs (used for picking).
QgsTessellatedPolygonGeometry(bool _withNormals=true, bool invertNormals=false, bool addBackFaces=false, bool addTextureCoords=false, QNode *parent=nullptr)
Constructor.
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
void setData(const QByteArray &vertexBufferData, int vertexCount, const QVector< QgsFeatureId > &triangleIndexFids, const QVector< uint > &triangleIndexStartingIndices)
Initializes vertex buffer (and other members) from data that were already tessellated.
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
void setAddTextureCoords(bool add)
Sets whether the texture coordinates will be generated.
bool invertNormals() const
Returns whether the normals of triangles will be inverted (useful for fixing clockwise / counter-cloc...
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28