QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
29 #define SIP_NO_FILE
30 
42 class QgsTessellatedPolygonGeometry : public Qt3DRender::QGeometry
43 {
44  Q_OBJECT
45  public:
47  QgsTessellatedPolygonGeometry( QNode *parent = nullptr );
48 
50  bool invertNormals() const { return mInvertNormals; }
52  void setInvertNormals( bool invert ) { mInvertNormals = invert; }
53 
58  bool addBackFaces() const { return mAddBackFaces; }
59 
64  void setAddBackFaces( bool add ) { mAddBackFaces = add; }
65 
67  void setPolygons( const QList<QgsPolygon *> &polygons, const QList<QgsFeatureId> &featureIds, const QgsPointXY &origin, float extrusionHeight, const QList<float> &extrusionHeightPerPolygon = QList<float>() );
68 
74  void setData( const QByteArray &vertexBufferData, int vertexCount, const QVector<QgsFeatureId> &triangleIndexFids, const QVector<uint> &triangleIndexStartingIndices );
75 
80  QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const;
81 
82  private:
83 
84  Qt3DRender::QAttribute *mPositionAttribute = nullptr;
85  Qt3DRender::QAttribute *mNormalAttribute = nullptr;
86  Qt3DRender::QBuffer *mVertexBuffer = nullptr;
87 
88  QVector<QgsFeatureId> mTriangleIndexFids;
89  QVector<uint> mTriangleIndexStartingIndices;
90 
91  bool mWithNormals = true;
92  bool mInvertNormals = false;
93  bool mAddBackFaces = false;
94 };
95 
96 #endif // QGSTESSELLATEDPOLYGONGEOMETRY_H
qgspolygon.h
QgsTessellatedPolygonGeometry::QgsTessellatedPolygonGeometry
QgsTessellatedPolygonGeometry(QNode *parent=nullptr)
Constructor.
Definition: qgstessellatedpolygongeometry.cpp:28
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:52
QgsTessellatedPolygonGeometry::triangleIndexToFeatureId
QgsFeatureId triangleIndexToFeatureId(uint triangleIndex) const
Returns ID of the feature to which given triangle index belongs (used for picking).
Definition: qgstessellatedpolygongeometry.cpp:132
QgsTessellatedPolygonGeometry::invertNormals
bool invertNormals() const
Returns whether the normals of triangles will be inverted (useful for fixing clockwise / counter-cloc...
Definition: qgstessellatedpolygongeometry.h:50
QgsTessellatedPolygonGeometry::addBackFaces
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
Definition: qgstessellatedpolygongeometry.h:58
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:93
Qt3DRender
Definition: qgs3dmapscene.h:25
QgsPointXY
Definition: qgspointxy.h:43
QgsTessellatedPolygonGeometry::setAddBackFaces
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
Definition: qgstessellatedpolygongeometry.h:64
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:63
QgsTessellatedPolygonGeometry
Definition: qgstessellatedpolygongeometry.h:42
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25