QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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
qgspolygon.h
qgsfeatureid.h
QgsTessellatedPolygonGeometry::setInvertNormals
void setInvertNormals(bool invert)
Sets whether the normals of triangles will be inverted (useful for fixing clockwise / counter-clockwi...
Definition: qgstessellatedpolygongeometry.h:54
QgsTessellatedPolygonGeometry::triangleIndexToFeatureId
QgsFeatureId triangleIndexToFeatureId(uint triangleIndex) const
Returns ID of the feature to which given triangle index belongs (used for picking).
Definition: qgstessellatedpolygongeometry.cpp:149
QgsTessellatedPolygonGeometry::invertNormals
bool invertNormals() const
Returns whether the normals of triangles will be inverted (useful for fixing clockwise / counter-cloc...
Definition: qgstessellatedpolygongeometry.h:52
QgsTessellatedPolygonGeometry::addBackFaces
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
Definition: qgstessellatedpolygongeometry.h:60
Qgs3DSceneExporter
Entity that handles the exporting of 3D scene.
Definition: qgs3dsceneexporter.h:55
QgsTessellatedPolygonGeometry::setData
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.
Definition: qgstessellatedpolygongeometry.cpp:108
Qt3DRender
Definition: qgs3dmapscene.h:28
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsTessellatedPolygonGeometry::setAddTextureCoords
void setAddTextureCoords(bool add)
Sets whether the texture coordinates will be generated.
Definition: qgstessellatedpolygongeometry.h:72
QgsTessellatedPolygonGeometry::setAddBackFaces
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
Definition: qgstessellatedpolygongeometry.h:66
QgsTessellatedPolygonGeometry::QgsTessellatedPolygonGeometry
QgsTessellatedPolygonGeometry(bool _withNormals=true, bool invertNormals=false, bool addBackFaces=false, bool addTextureCoords=false, QNode *parent=nullptr)
Constructor.
Definition: qgstessellatedpolygongeometry.cpp:28
QgsTessellatedPolygonGeometry::setPolygons
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.
Definition: qgstessellatedpolygongeometry.cpp:76
QgsTessellatedPolygonGeometry
Class derived from Qt3DRender::QGeometry that represents polygons tessellated into 3D geometry.
Definition: qgstessellatedpolygongeometry.h:44
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28