QGIS API Documentation 3.99.0-Master (e9821da5c6b)
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
24class QgsPolygon;
25class QgsPointXY;
26
27namespace Qt3DCore
28{
29 class QBuffer;
30}
31
32#define SIP_NO_FILE
33
44class QgsTessellatedPolygonGeometry : public Qt3DCore::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
79 void setData( const QByteArray &vertexBufferData, int vertexCount, const QVector<QgsFeatureId> &triangleIndexFids, const QVector<uint> &triangleIndexStartingIndices );
80
85 QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const;
86
88 QVector<QgsFeatureId> featureIds() const { return mTriangleIndexFids; }
89
91 QVector<uint> triangleIndexStartingIndices() const { return mTriangleIndexStartingIndices; }
92
93 friend class Qgs3DSceneExporter;
94
95 private:
96 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
97 Qt3DCore::QAttribute *mNormalAttribute = nullptr;
98 Qt3DCore::QAttribute *mTextureCoordsAttribute = nullptr;
99 Qt3DCore::QBuffer *mVertexBuffer = nullptr;
100
101 QVector<QgsFeatureId> mTriangleIndexFids;
102 QVector<uint> mTriangleIndexStartingIndices;
103
104 bool mWithNormals = true;
105 bool mInvertNormals = false;
106 bool mAddBackFaces = false;
107 bool mAddTextureCoords = false;
108};
109
110#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 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...
QVector< uint > triangleIndexStartingIndices() const
Returns triangle index for features. For a feature featureIds()[i], matching triangles start at trian...
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features