QGIS API Documentation 3.27.0-Master (9c08adf5ef)
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 "qgschunkloader_p.h"
25#include "qgschunkedentity_p.h"
26
28
29#include <QFutureWatcher>
30#include <Qt3DRender/QGeometry>
31#include <Qt3DRender/QBuffer>
32#include <Qt3DRender/QMaterial>
33#include <QVector3D>
34
35#define SIP_NO_FILE
36
38
39class QgsPointCloud3DSymbolHandler // : public QgsFeature3DHandler
40{
41 public:
42 QgsPointCloud3DSymbolHandler();
43
44 virtual ~QgsPointCloud3DSymbolHandler() = default;
45
46 virtual bool prepare( const QgsPointCloud3DRenderContext &context ) = 0;// override;
47 virtual void processNode( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context ) = 0; // override;
48 virtual void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) = 0;// override;
49
50 void triangulate( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context, const QgsAABB &bbox );
51
52 float zMinimum() const { return mZMin; }
53 float zMaximum() const { return mZMax; }
54
56 struct PointData
57 {
58 QVector<QVector3D> positions; // contains triplets of float x,y,z for each point
59 QVector<float> parameter;
60 QVector<QVector3D> colors;
61 QByteArray triangles; // in case of points triangulation, contains index of point in the array positions
62 QByteArray normals; // in case of points triangulation, contains the normals of the solid surface on each vertex
63 };
64
65 protected:
66 float mZMin = std::numeric_limits<float>::max();
67 float mZMax = std::numeric_limits<float>::lowest();
68
69 void makeEntity( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context, const PointData &out, bool selected );
70 virtual Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) = 0;
71 QgsPointCloudBlock *pointCloudBlock( QgsPointCloudIndex *pc, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request, const QgsPointCloud3DRenderContext &context );
72
73 // outputs
74 PointData outNormal;
75
76 private:
78 std::vector<double> getVertices( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context, const QgsAABB &bbox );
79
81 void calculateNormals( const std::vector<size_t> &triangles );
82
91 void filterTriangles( const std::vector<size_t> &triangleIndexes, const QgsPointCloud3DRenderContext &context, const QgsAABB &bbox );
92};
93
94class QgsSingleColorPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
95{
96 public:
97 QgsSingleColorPointCloud3DSymbolHandler();
98
99 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
100 void processNode( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context ) override;
101 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
102
103 private:
104 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
105};
106
107class QgsColorRampPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
108{
109 public:
110 QgsColorRampPointCloud3DSymbolHandler();
111
112 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
113 void processNode( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context ) override;
114 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
115
116 private:
117 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
118};
119
120class QgsRGBPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
121{
122 public:
123 QgsRGBPointCloud3DSymbolHandler();
124
125 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
126 void processNode( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context ) override;
127 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
128
129 private:
130 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
131};
132
133class QgsClassificationPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler
134{
135 public:
136 QgsClassificationPointCloud3DSymbolHandler();
137
138 bool prepare( const QgsPointCloud3DRenderContext &context ) override;
139 void processNode( QgsPointCloudIndex *pc, const IndexedPointCloudNode &n, const QgsPointCloud3DRenderContext &context ) override;
140 void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override;
141
142 private:
143 Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override;
144};
145
146
147class QgsPointCloud3DGeometry: public Qt3DRender::QGeometry
148{
149 Q_OBJECT
150
151 public:
152 QgsPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
153
154 protected:
155 virtual void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) = 0;
156
157 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
158 Qt3DRender::QAttribute *mParameterAttribute = nullptr;
159 Qt3DRender::QAttribute *mColorAttribute = nullptr;
160 Qt3DRender::QAttribute *mTriangleIndexAttribute = nullptr;
161 Qt3DRender::QAttribute *mNormalsAttribute = nullptr;
162 Qt3DRender::QBuffer *mVertexBuffer = nullptr;
163 Qt3DRender::QBuffer *mTriangleBuffer = nullptr;
164 Qt3DRender::QBuffer *mNormalsBuffer = nullptr;
165 int mVertexCount = 0;
166
167 unsigned int mByteStride = 16;
168};
169
170class QgsSingleColorPointCloud3DGeometry : public QgsPointCloud3DGeometry
171{
172 Q_OBJECT
173
174 public:
175 QgsSingleColorPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
176
177 private:
178 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
179};
180
181class QgsColorRampPointCloud3DGeometry : public QgsPointCloud3DGeometry
182{
183 Q_OBJECT
184
185 public:
186 QgsColorRampPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
187
188 private:
189 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
190};
191
192class QgsRGBPointCloud3DGeometry : public QgsPointCloud3DGeometry
193{
194 Q_OBJECT
195
196 public:
197 QgsRGBPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride );
198 private:
199 void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override;
200};
201
202
204
205#endif // QGSPOINTCLOUD3DSYMBOL_P_H
Represents a indexed point cloud node in octree.
3
Definition: qgsaabb.h:34
Encapsulates the render context for a 3D point cloud rendering operation.
Base class for storing raw data from point cloud nodes.
Represents a indexed point clouds data in octree.
Point cloud data request.