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