-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathSkeleton.cpp
executable file
·105 lines (92 loc) · 2.1 KB
/
Skeleton.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "Skeleton.h"
//PointInfo
PointInfo::PointInfo() {
m_nLayer = 0;
m_nMaxLayer = -1;
m_nDepth = MAX_DEPTH / 2;
for(int i = 0; i < MAX_LAYERS; i++)
m_vecLayer[i] = Vector3D(1e30, 1e30, 1e30);
}
Vector3D PointInfo::MidPosition() {
if ( m_nLayer >= 1 && m_nLayer < m_nMaxLayer )
return ( m_vecLayer[m_nLayer] + m_vecLayer[m_nLayer - 1] ) / 2.0;
else
return Vector3D(1e30, 1e30, 1e30);
}
Vector3D PointInfo::DepthPosition() {
if ( m_nLayer >= 1 && m_nLayer < m_nMaxLayer )
return ( m_vecLayer[m_nLayer] - m_vecLayer[m_nLayer - 1] )
/ MAX_DEPTH * m_nDepth + m_vecLayer[m_nLayer - 1];
else
return Vector3D(1e30, 1e30, 1e30);
}
//LineSegment
LineSegment::LineSegment(Vector3D v1, Vector3D v2, int l) {
m_vPos[0] = v1;
m_vPos[1] = v2;
m_nLayer = l;
}
//LineInfo
LineInfo::LineInfo(int iStart, int iEnd) {
m_iPoint[0] = iStart;
m_iPoint[1] = iEnd;
}
//Skeleton
Skeleton::Skeleton() {
m_iPickPoint = -1;
}
void Skeleton::Show() {
for(int i = 0;i < m_vecPoint.size();i++)
{
cout << i << ":\t";
cout << m_vecPoint[i].m_vPosition.x << "\t"
<< m_vecPoint[i].m_vPosition.y << "\t"
<< m_vecPoint[i].m_vPosition.z << endl;
}
for(int i = 0;i < m_vecLine.size();i++)
{
cout << i << ":\t";
cout << m_vecLine[i].m_iPoint[0] << "\t"
<< m_vecLine[i].m_iPoint[1] << endl;
}
}
//.axs
bool Skeleton::LoadFrom(string strFile) {
ifstream fload(strFile.c_str());
char tmpChar;
string tmpStr;
int tmpInt;
while(fload >> tmpChar)
{
PointInfo ptInfo;
LineInfo lnInfo;
switch(tmpChar)
{
case '#':
fload >> tmpStr;
break;
case 'v':
fload >> ptInfo.m_vPosition.x;
fload >> ptInfo.m_vPosition.y;
fload >> ptInfo.m_vPosition.z;
m_vecPoint.push_back(ptInfo);
break;
case 'l':
fload >> lnInfo.m_iPoint[0];
lnInfo.m_iPoint[0]--;
fload >> lnInfo.m_iPoint[1];
lnInfo.m_iPoint[1]--;
m_vecLine.push_back(lnInfo);
break;
case 's':
fload >> tmpInt;
break;
case 'o':
return true;
default:
return false;
}
}
fload.close();
return true;
}