Choreonoid
1.1
メインページ
関連ページ
ネームスペース
クラス
ファイル
ファイル一覧
ファイルメンバ
src
Util
Seq.h
説明を見る。
1
6
#ifndef CNOID_UTIL_SEQ_H_INCLUDED
7
#define CNOID_UTIL_SEQ_H_INCLUDED
8
9
#include "
SeqBase.h
"
10
#include <vector>
11
#include "
exportdecl.h
"
12
13
namespace
cnoid {
14
15
template
<
typename
ElementType>
class
Seq
:
public
SeqBase
16
{
17
public
:
18
typedef
boost::shared_ptr< Seq<ElementType> >
Ptr
;
19
20
Seq
(
const
char
*
seqType
,
int
nFrames = 0.0,
double
frameRate
= 100.0)
21
:
SeqBase
(seqType),
22
container
(nFrames) {
23
frameRate_
=
frameRate
;
24
}
25
26
Seq
(
const
Seq<ElementType>
& org)
27
:
SeqBase
(org),
28
container
(org.
container
) {
29
frameRate_
= org.
frameRate_
;
30
}
31
32
virtual
~Seq
() { }
33
34
virtual
double
getFrameRate
()
const
{
35
return
frameRate_
;
36
}
37
38
inline
double
frameRate
()
const
{
39
return
frameRate_
;
40
}
41
42
virtual
void
setFrameRate
(
double
frameRate
) {
43
frameRate_
=
frameRate
;
44
}
45
46
virtual
int
getNumFrames
()
const
{
47
return
container
.size();
48
}
49
50
inline
int
numFrames
()
const
{
51
return
container
.size();
52
}
53
54
virtual
void
setNumFrames
(
int
n,
bool
clearNewElements =
false
) {
55
if
(clearNewElements){
56
container
.resize(n,
defaultValue
());
57
}
else
{
58
container
.resize(n);
59
}
60
}
61
62
inline
bool
empty
()
const
{
63
return
container
.empty();
64
}
65
66
inline
int
frameOfTime
(
double
time)
const
{
67
return
(
int
)(time *
frameRate_
);
68
}
69
70
inline
double
timeOfFrame
(
int
frame)
const
{
71
return
(frame /
frameRate_
);
72
}
73
74
inline
ElementType&
operator[]
(
int
frameIndex) {
75
return
container
[frameIndex];
76
}
77
78
inline
const
ElementType&
operator[]
(
int
frameIndex)
const
{
79
return
container
[frameIndex];
80
}
81
82
inline
ElementType&
at
(
int
frameIndex) {
83
return
container
[frameIndex];
84
}
85
86
inline
const
ElementType&
at
(
int
frameIndex)
const
{
87
return
container
[frameIndex];
88
}
89
90
virtual
bool
read
(
const
YamlMapping
& archive) {
return
SeqBase::read
(archive); }
91
virtual
bool
write
(
YamlWriter
& writer) {
return
SeqBase::write
(writer); }
92
93
protected
:
94
95
std::vector<ElementType>
container
;
96
double
frameRate_
;
97
98
virtual
ElementType
defaultValue
()
const
{
return
ElementType(); }
99
};
100
}
101
102
#endif
Choreonoidに対してWed May 8 2013 17:51:03に生成されました。
1.8.1.2