-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointCloudViewer.cpp
More file actions
99 lines (86 loc) · 3.03 KB
/
PointCloudViewer.cpp
File metadata and controls
99 lines (86 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
******************************************************************************
* @file PointCloudViewer.cpp
* @author Junxin Zheng
* @version V1.0.0
* @date 17-January-2019
* @brief ...
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "PointCloudViewer.h"
#include <math.h>
#include <stdlib.h>
/* Macro Definition ----------------------------------------------------------*/
#define PI 3.1415927
using namespace qglviewer;
using namespace std;
/* Variables -----------------------------------------------------------------*/
/* Function ------------------------------------------------------------------*/
/*******************************************************************************
* @brief Viewer initialization.
* @param None.
* @retval None.
*****************************************************************************/
void Viewer::init() {
glDisable(GL_LIGHTING);
glPointSize(1.0);
setGridIsDrawn();
setAxisIsDrawn();
setSceneRadius(5000);
setFPSIsDisplayed(true);
camera()->setUpVector(Vec(0.0, 0.0, 1.0));
camera()->setViewDirection(Vec(-1.0, -1.0, -0.5));
showEntireScene();
startAnimation();
}
/*******************************************************************************
* @brief Function of viewer drawing.
* @param None.
* @retval None.
*****************************************************************************/
void Viewer::draw()
{
glBegin(GL_POINTS);
int i = 0, j = 0; double z = 0;
for(i = 0; i < pointList.count(); i++)
{
if(j < layerPointCount) {j++;}
else {j = 0; z += layerHeight;}
glVertex3d(z, pointList.at(i).at(1), pointList.at(i).at(0));
}
glEnd();
}
/*******************************************************************************
* @brief Setting the series of points.
* @param const QList<QList<double>> &list
* qint32 cnt
* double height
* @retval None.
*****************************************************************************/
void Viewer::setPointList(const QList<QList<double>> &list, qint32 cnt, double height)
{
pointList.clear();
for(int i = 0; i < list.count(); i++)
{
// Calculate the radian and distance.
double rad = ((list.at(i).at(0) - 45.0)/180.0) * PI;
double distance = list.at(i).at(1);
// And Single Point.
QList<double> point;
point << distance*sin(rad) + 1500 << distance*cos(rad);
pointList.append(point);
}
layerPointCount = cnt;
layerHeight = height;
}
/*******************************************************************************
* @brief Setting the height of layer.
* @param double height.
* @retval None.
*****************************************************************************/
void Viewer::setLayerHeight(double height)
{
layerHeight = height;
}
/**************** (C) COPYRIGHT 2019 Junxin Zheng ******** END OF FILE ********/