QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgspointcloud3dsymbol_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloud3dsymbol_p.h
3 ------------------------------
4 Date : December 2020
5 Copyright : (C) 2020 by Nedjima Belgacem
6 Email : belgacem dot nedjima 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 QGSPOINTCLOUD3DSYMBOL_P_H
17#define QGSPOINTCLOUD3DSYMBOL_P_H
18
20
22
23#include <QFutureWatcher>
24
25#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
26#include <Qt3DRender/QGeometry>
27#include <Qt3DRender/QBuffer>
28#else
29#include <Qt3DCore/QGeometry>
30#include <Qt3DCore/QBuffer>
31#endif
32#include <QVector3D>
33
34#define SIP_NO_FILE
35
37class QgsAABB;
38
39class QgsPointCloud3DSymbolHandler
40{
41 public:
42 QgsPointCloud3DSymbolHandler();
43
44 virtual ~QgsPointCloud3DSymbolHandler() = default;
45
46 struct PointData;
47
48 virtual bool prepare( const QgsPointCloud3DRenderContext &context ) = 0; // override;
49 virtual void processNode( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, PointData *output = nullptr ) = 0; // override;
50 virtual void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) = 0; // override;
51
52 void triangulate( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, const QgsBox3D &box3D );
53
54 float zMinimum() const { return mZMin; }
55 float zMaximum() const { return mZMax; }
56
58 struct PointData
59 {
60 QgsVector3D positionsOrigin; // All "positions" are relative to this point, defined in map coordinates (with double precision)
61 QVector<QVector3D> positions; // Contains triplets of float x,y,z for each point. These are in map coordinates, relative to "positionsOrigin"
62 QVector<float> parameter;
63 QVector<float> pointSizes; // Contains point sizes, in case they are overridden for classification renderer
64 QVector<QVector3D> colors;
65 QByteArray triangles; // In case of points triangulation, contains index of point in the array positions
66 QByteArray normals; // In case of points triangulation, contains the normals of the solid surface on each vertex
67 };
68
69 protected:
70 float mZMin = std::numeric_limits<float>::max();
71 float mZMax = std::numeric_limits<float>::lowest();
72
73 void makeEntity( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context, const PointData &out, bool selected );
74
75#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
76 virtual Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) = 0;
77#else
78 virtual Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) = 0;
79#endif
80 std::unique_ptr<QgsPointCloudBlock> pointCloudBlock( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request, const QgsPointCloud3DRenderContext &context );
81
82 // outputs
83 PointData outNormal;
84
85 private:
87 std::vector<double> getVertices( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, const QgsBox3D &box3D );
88
90 void calculateNormals( const std::vector<size_t> &triangles );
91
100 void filterTriangles( const std::vector<size_t> &triangleIndexes, const QgsPointCloud3DRenderContext &context, const QgsBox3D &box3D );
101};
102
103class QgsSingleColorPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
104{
105 public:
106 QgsSingleColorPointCloud3DSymbolHandler();
107
108 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
109 void processNode( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, PointData *output = nullptr ) override;
110 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
111
112 private:
113#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
114 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
115#else
116 Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
117#endif
118};
119
120class QgsColorRampPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
121{
122 public:
123 QgsColorRampPointCloud3DSymbolHandler();
124
125 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
126 void processNode( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, PointData *output = nullptr ) override;
127 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
128
129 private:
130#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
131 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
132#else
133 Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
134#endif
135};
136
137class QgsRGBPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
138{
139 public:
140 QgsRGBPointCloud3DSymbolHandler();
141
142 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
143 void processNode( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, PointData *output = nullptr ) override;
144 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
145
146 private:
147#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
148 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
149#else
150 Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
151#endif
152};
153
154class QgsClassificationPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
155{
156 public:
157 QgsClassificationPointCloud3DSymbolHandler();
158
159 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
160 void processNode( QgsPointCloudIndex &pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, PointData *output = nullptr ) override;
161 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
162
163 private:
164#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
165 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
166#else
167 Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
168#endif
169};
170
171#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
172class QgsPointCloud3DGeometry : public Qt3DRender::QGeometry
173#else
174class QgsPointCloud3DGeometry : public Qt3DCore::QGeometry
175#endif
176{
177 Q_OBJECT
178
179 public:
180 QgsPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
181
182 protected:
183 virtual void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) = 0;
184
185#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
186 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
187 Qt3DRender::QAttribute *mParameterAttribute = nullptr;
188 Qt3DRender::QAttribute *mPointSizeAttribute = nullptr;
189 Qt3DRender::QAttribute *mColorAttribute = nullptr;
190 Qt3DRender::QAttribute *mTriangleIndexAttribute = nullptr;
191 Qt3DRender::QAttribute *mNormalsAttribute = nullptr;
192 Qt3DRender::QBuffer *mVertexBuffer = nullptr;
193 Qt3DRender::QBuffer *mTriangleBuffer = nullptr;
194 Qt3DRender::QBuffer *mNormalsBuffer = nullptr;
195#else
196 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
197 Qt3DCore::QAttribute *mParameterAttribute = nullptr;
198 Qt3DCore::QAttribute *mPointSizeAttribute = nullptr;
199 Qt3DCore::QAttribute *mColorAttribute = nullptr;
200 Qt3DCore::QAttribute *mTriangleIndexAttribute = nullptr;
201 Qt3DCore::QAttribute *mNormalsAttribute = nullptr;
202 Qt3DCore::QBuffer *mVertexBuffer = nullptr;
203 Qt3DCore::QBuffer *mTriangleBuffer = nullptr;
204 Qt3DCore::QBuffer *mNormalsBuffer = nullptr;
205#endif
206 int mVertexCount = 0;
207
208 unsigned int mByteStride = 16;
209};
210
211class QgsSingleColorPointCloud3DGeometry : public QgsPointCloud3DGeometry
212{
213 Q_OBJECT
214
215 public:
216 QgsSingleColorPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
217
218 private:
219 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
220};
221
222class QgsColorRampPointCloud3DGeometry : public QgsPointCloud3DGeometry
223{
224 Q_OBJECT
225
226 public:
227 QgsColorRampPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
228
229 private:
230 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
231};
232
233class QgsRGBPointCloud3DGeometry : public QgsPointCloud3DGeometry
234{
235 Q_OBJECT
236
237 public:
238 QgsRGBPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
239
240 private:
241 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
242};
243
244class QgsClassificationPointCloud3DGeometry : public QgsPointCloud3DGeometry
245{
246 Q_OBJECT
247
248 public:
249 QgsClassificationPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
250
251 private:
252 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
253};
255
256#endif // QGSPOINTCLOUD3DSYMBOL_P_H
Axis-aligned bounding box - in world coords.
Definition qgsaabb.h:35
Represents an indexed point cloud node's position in octree.