-
Notifications
You must be signed in to change notification settings - Fork 2
/
Bullet.cpp
126 lines (110 loc) · 3.21 KB
/
Bullet.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/******************************************
* Define Bullet Class member function *
******************************************/
#include "stdafx.h"
#include "Bullet.h"
#include <iterator>
Bullet::Bullet():
m_vfValues(VluK_Total, 0.0), isEmptyObj(TRUE),
m_LastModifyTime(CTime::GetCurrentTime())
{}
Bullet::Bullet(const Bullet& xp):
m_vfValues(xp.m_vfValues), isEmptyObj(xp.isEmptyObj),
m_LastModifyTime(xp.m_LastModifyTime)
{}
Bullet::~Bullet()
{
m_vfValues.clear();
}
void Bullet::i(const ValueKind& _VK, const float& _F)
{
// ASSERT( _F>=0 && _F<=0.8 );
//不是只會輸入色度,所以不需要檢查定義域
if (_F != 0.0 )
{
m_vfValues[_VK] = _F;
m_LastModifyTime = CTime::GetCurrentTime();
isEmptyObj = FALSE;
}
}
void Bullet::i(const ValueKind& _VK, const CString& _S)
{
// ASSERT( str2flt(_S)>=0 && str2flt(_S)<=0.8 );
if ( str2flt(_S) != 0.0 )
{
m_vfValues[_VK] = str2flt(_S);
m_LastModifyTime = CTime::GetCurrentTime();
isEmptyObj = FALSE;
}
}
const float Bullet::oFlt(const ValueKind& _VK) const
{
return m_vfValues[_VK];
}
const CString Bullet::oStr(const ValueKind& _VK) const
{
return flt2str(m_vfValues[_VK]);
}
//////////////////////////////////////////////////////////////////////////
const float Bullet::str2flt(CString _Str) const
{
return atof(_Str.GetBuffer(0));
}
const CString Bullet::flt2str(const float& _F) const
{
CString str;
str.Format("%f", _F);
return str;
}
//////////////////////////////////////////////////////////////////////////
void Bullet::operator= (const Bullet& xp)
{
m_vfValues = xp.m_vfValues;
m_LastModifyTime = xp.m_LastModifyTime;
isEmptyObj = xp.isEmptyObj;
}
const BOOL Bullet::IsEmpty() const
{
#ifdef _DEBUG
BOOL B(TRUE);
for (std::vector<float>::const_iterator vitor = m_vfValues.begin(); vitor != m_vfValues.end(); ++vitor)
{
if ( *vitor != 0.0 )
B = FALSE;
}
ASSERT(B == isEmptyObj);
#endif
return isEmptyObj;
}
const CString Bullet::GetLastTime() const
{
CString str;
str.Format("%d/%d/%d, %d:%d:%d",
m_LastModifyTime.GetYear(), m_LastModifyTime.GetMonth(), m_LastModifyTime.GetDay(),
m_LastModifyTime.GetHour(), m_LastModifyTime.GetMinute(), m_LastModifyTime.GetSecond());
return str;
}
const CString Bullet::ShowDataReport() const
{
return " Lv =" + flt2str(m_vfValues[VluK_Lv]) + "\n"
+ " x =" + flt2str(m_vfValues[VluK_Sx]) + "\n"
+ " y =" + flt2str(m_vfValues[VluK_Sy]) + "\n"
+ " T =" + flt2str(m_vfValues[VluK_T]) + "\n"
+ "Δuv=" + flt2str(m_vfValues[VluK_Duv]) + "\n"
+ " u' =" + flt2str(m_vfValues[VluK_Du]) + "\n"
+ " v' =" + flt2str(m_vfValues[VluK_Dv]) + "\n"
+ " X =" + flt2str(m_vfValues[VluK_X]) + "\n"
+ " Y =" + flt2str(m_vfValues[VluK_Y]) + "\n"
+ " Z =" + flt2str(m_vfValues[VluK_Z]);
}
const CString Bullet::ShowData() const
{
CString accumulation, everyTemp;
for (std::vector<float>::const_iterator itor = m_vfValues.begin(); itor != m_vfValues.end(); ++itor)
{
everyTemp.Format("%f\t", *itor);
accumulation += everyTemp;
}
accumulation.TrimRight();
return accumulation;
}