QGIS API Documentation 3.99.0-Master (a5475b57e34)
Loading...
Searching...
No Matches
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
21#include <Qt3DCore/QGeometry>
22
23#define SIP_NO_FILE
24
26class QgsPolygon;
27class QgsPointXY;
28
29namespace Qt3DCore
30{
31 class QBuffer;
32}
33
34
45class QgsTessellatedPolygonGeometry : public Qt3DCore::QGeometry
46{
47 Q_OBJECT
48 public:
50 QgsTessellatedPolygonGeometry( bool _withNormals = true, bool invertNormals = false, bool addBackFaces = false, bool addTextureCoords = false, QNode *parent = nullptr );
51
53 bool invertNormals() const { return mInvertNormals; }
55 void setInvertNormals( bool invert ) { mInvertNormals = invert; }
56
61 bool addBackFaces() const { return mAddBackFaces; }
62
67 void setAddBackFaces( bool add ) { mAddBackFaces = add; }
68
73 void setAddTextureCoords( bool add ) { mAddTextureCoords = add; }
74
80 void setVertexBufferData( const QByteArray &vertexBufferData, int vertexCount, const QVector<QgsFeatureId> &triangleIndexFids, const QVector<uint> &triangleIndexStartingIndices );
81
86 void setIndexBufferData( const QByteArray &indexBufferData, size_t indexCount );
87
92 QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const;
93
95 QVector<QgsFeatureId> featureIds() const { return mTriangleIndexFids; }
96
98 QVector<uint> triangleIndexStartingIndices() const { return mTriangleIndexStartingIndices; }
99
100 friend class Qgs3DSceneExporter;
101
102 private:
103 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
104 Qt3DCore::QAttribute *mNormalAttribute = nullptr;
105 Qt3DCore::QAttribute *mTextureCoordsAttribute = nullptr;
106 Qt3DCore::QBuffer *mVertexBuffer = nullptr;
107 Qt3DCore::QBuffer *mIndexBuffer = nullptr;
108 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
109
110 QVector<QgsFeatureId> mTriangleIndexFids;
111 QVector<uint> mTriangleIndexStartingIndices;
112
113 bool mWithNormals = true;
114 bool mInvertNormals = false;
115 bool mAddBackFaces = false;
116 bool mAddTextureCoords = false;
117};
118
119#endif // QGSTESSELLATEDPOLYGONGEOMETRY_H
Entity that handles the exporting of 3D scenes.
Represents a 2D point.
Definition qgspointxy.h:62
Polygon geometry type.
Definition qgspolygon.h:37
QVector< QgsFeatureId > featureIds() const
Returns included feature ids.
void setVertexBufferData(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 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 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...
QVector< uint > triangleIndexStartingIndices() const
Returns triangle index for features. For a feature featureIds()[i], matching triangles start at trian...
void setIndexBufferData(const QByteArray &indexBufferData, size_t indexCount)
Sets index buffer data.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features