-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeometry.cpp
83 lines (66 loc) · 1.63 KB
/
geometry.cpp
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
#include "geometry.h"
Crit3DGeometry::Crit3DGeometry()
{
this->clear();
}
void Crit3DGeometry::clear()
{
m_xCenter = 0;
m_yCenter = 0;
m_zCenter = 0;
m_dx = 0;
m_dy = 0;
m_magnify = 1;
m_artifactSlope = 60;
m_vertices.clear();
m_colors.clear();
}
void Crit3DGeometry::setCenter(float x, float y, float z)
{
m_xCenter = x;
m_yCenter = y;
m_zCenter = z;
}
void Crit3DGeometry::setDimension(float dx, float dy)
{
m_dx = dx;
m_dy = dy;
}
void Crit3DGeometry::addTriangle(const gis::Crit3DPoint &p1, const gis::Crit3DPoint &p2, const gis::Crit3DPoint &p3,
const Crit3DColor &c1, const Crit3DColor &c2, const Crit3DColor &c3)
{
addVertex(p1);
addVertexColor(c1);
addVertex(p2);
addVertexColor(c2);
addVertex(p3);
addVertexColor(c3);
}
void Crit3DGeometry::addVertex(const gis::Crit3DPoint &v)
{
m_vertices.push_back(v.utm.x - m_xCenter);
m_vertices.push_back(v.utm.y - m_yCenter);
m_vertices.push_back((v.z - m_zCenter) * m_magnify);
}
void Crit3DGeometry::addVertexColor(const Crit3DColor &color)
{
m_colors.push_back(color.red);
m_colors.push_back(color.green);
m_colors.push_back(color.blue);
}
void Crit3DGeometry::setVertexColor(int i, const Crit3DColor &color)
{
if (i > vertexCount()) return;
m_colors[i*3] = color.red;
m_colors[i*3+1] = color.green;
m_colors[i*3+2] = color.blue;
}
void Crit3DGeometry::setMagnify(float magnify)
{
float ratio = magnify / m_magnify;
for (int i = 0; i < vertexCount(); i++)
{
m_vertices[i*3+2] *= ratio;
}
m_magnify = magnify;
}