knowL: Knowledge Libraries
Loading...
Searching...
No Matches
PointCloudGeometry.h
1#pragma once
2
3#include <Qt3DRender/QGeometry>
4#include <knowCore/Forward.h>
5
6namespace knowVis
7{
8 struct PointCloud
9 {
10 QByteArray data;
11 bool hasColor = false;
12 int points = 0;
13 void resize(int _points)
14 {
15 points = _points;
16 data.resize(_points * stride());
17 }
18 int stride() const {
19 return sizeof(float) * (hasColor ? 7 : 3);
20 }
21 void setValue(int _index, float _x, float _y, float _z, float _r = 0.0, float _g = 0.0, float _b = 0.0, float _a = 1.0)
22 {
23 float* pt = reinterpret_cast<float*>(data.data() + _index * stride());
24 pt[0] = _x;
25 pt[1] = _y;
26 pt[2] = _z;
27 if(hasColor)
28 {
29 pt[3] = _r;
30 pt[4] = _g;
31 pt[5] = _b;
32 pt[6] = _a;
33 }
34 }
35 };
36 class PointCloudGeometry : public Qt3DRender::QGeometry
37 {
38 Q_OBJECT
39
40 public:
41 explicit PointCloudGeometry(QNode *parent = NULL);
43 void updateVertices();
44
45 void setPointCloud(const PointCloud& _pc);
46 PointCloud pointCloud() const;
47
48 private:
49 void updateAttributes();
50
51 private:
52 struct Private;
53 Private* const d;
54 };
55}
Definition PointCloudGeometry.h:37
Definition PointCloudGeometry.cpp:13
Definition PointCloudGeometry.h:9