QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
22#include <Qt3DRender/QGeometry>
23#else
24#include <Qt3DCore/QGeometry>
25#endif
26
28class QgsPolygon;
29class QgsPointXY;
30
32{
33 class Ray3D;
34}
35
36#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
37namespace Qt3DRender
38{
39 class QBuffer;
40}
41#else
42namespace Qt3DCore
43{
44 class QBuffer;
45}
46#endif
47
48#define SIP_NO_FILE
49
60#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
61class QgsTessellatedPolygonGeometry : public Qt3DRender::QGeometry
62#else
63class QgsTessellatedPolygonGeometry : public Qt3DCore::QGeometry
64#endif
65{
66 Q_OBJECT
67 public:
69 QgsTessellatedPolygonGeometry( bool _withNormals = true, bool invertNormals = false, bool addBackFaces = false, bool addTextureCoords = false, QNode *parent = nullptr );
70
72 bool invertNormals() const { return mInvertNormals; }
74 void setInvertNormals( bool invert ) { mInvertNormals = invert; }
75
80 bool addBackFaces() const { return mAddBackFaces; }
81
86 void setAddBackFaces( bool add ) { mAddBackFaces = add; }
87
92 void setAddTextureCoords( bool add ) { mAddTextureCoords = add; }
93
95 void setPolygons( const QList<QgsPolygon *> &polygons, const QList<QgsFeatureId> &featureIds, const QgsPointXY &origin, float extrusionHeight, const QList<float> &extrusionHeightPerPolygon = QList<float>() );
96
102 void setData( const QByteArray &vertexBufferData, int vertexCount, const QVector<QgsFeatureId> &triangleIndexFids, const QVector<uint> &triangleIndexStartingIndices );
103
108 QgsFeatureId triangleIndexToFeatureId( uint triangleIndex ) const;
109
111 QVector<QgsFeatureId> featureIds() const { return mTriangleIndexFids; }
112
114 QVector<uint> triangleIndexStartingIndices() const { return mTriangleIndexStartingIndices; }
115
116 friend class Qgs3DSceneExporter;
117 private:
118
119#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
120 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
121 Qt3DRender::QAttribute *mNormalAttribute = nullptr;
122 Qt3DRender::QAttribute *mTextureCoordsAttribute = nullptr;
123 Qt3DRender::QBuffer *mVertexBuffer = nullptr;
124#else
125 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
126 Qt3DCore::QAttribute *mNormalAttribute = nullptr;
127 Qt3DCore::QAttribute *mTextureCoordsAttribute = nullptr;
128 Qt3DCore::QBuffer *mVertexBuffer = nullptr;
129#endif
130
131 QVector<QgsFeatureId> mTriangleIndexFids;
132 QVector<uint> mTriangleIndexStartingIndices;
133
134 bool mWithNormals = true;
135 bool mInvertNormals = false;
136 bool mAddBackFaces = false;
137 bool mAddTextureCoords = false;
138};
139
140#endif // QGSTESSELLATEDPOLYGONGEOMETRY_H
Entity that handles the exporting of 3D scene.
A class to represent a 2D point.
Definition: qgspointxy.h:60
Polygon geometry type.
Definition: qgspolygon.h:33
QVector< QgsFeatureId > featureIds() const
Returns included feature ids.
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...
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
Definition: qgsfeatureid.h:28