aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03642.html
blob: 41ee329e2191f98d86f9d878e24dece0c81734a8 (plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NLMISC::CValueSmoother class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NLMISC::CValueSmoother Class Reference</h1><code>#include &lt;<a class="el" href="a06657.html">value_smoother.h</a>&gt;</code>
<p>
<p>Inheritance diagram for NLMISC::CValueSmoother:
<p><center><img src="a03642.png" usemap="#NLMISC::CValueSmoother_map" border="0" alt=""></center>
<map name="NLMISC::CValueSmoother_map">
<area href="a03643.html" alt="NLMISC::CValueSmootherTemplate< float >" shape="rect" coords="0,0,258,24">
</map>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03643.html#NLMISC_1_1CValueSmootherTemplatea0">addValue</a> (floatdt)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">add a new value to be smoothed.  <a href="#NLMISC_1_1CValueSmootherTemplatea0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03642.html#NLMISC_1_1CValueSmoothera1">CValueSmoother</a> (<a class="el" href="a04558.html#a15">uint</a> n=16)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor.  <a href="#NLMISC_1_1CValueSmoothera1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const std::vector&lt; float &gt; &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03643.html#NLMISC_1_1CValueSmootherTemplatea2">getLastFrames</a> () const</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03643.html#NLMISC_1_1CValueSmootherTemplatea3">getNumFrame</a> () const</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>float&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03643.html#NLMISC_1_1CValueSmootherTemplatea4">getSmoothValue</a> () const</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">get the smoothed value.  <a href="#NLMISC_1_1CValueSmootherTemplatea4"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03643.html#NLMISC_1_1CValueSmootherTemplatea5">init</a> (<a class="el" href="a04558.html#a15">uint</a> n)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">reset the ValueSmoother, and set the number of frame to smooth.  <a href="#NLMISC_1_1CValueSmootherTemplatea5"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03643.html#NLMISC_1_1CValueSmootherTemplatea6">reset</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">reset only the ValueSmoother  <a href="#NLMISC_1_1CValueSmootherTemplatea6"></a><br><br></td></tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="NLMISC_1_1CValueSmoothera1" doxytag="NLMISC::CValueSmoother::CValueSmoother" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NLMISC::CValueSmoother::CValueSmoother </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>n</em> = 16          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline, explicit]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Constructor. 
<p>

<p>
Definition at line <a class="el" href="a06657.html#l00201">201</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
References <a class="el" href="a05981.html#l00105">uint</a>.
<p>
<div class="fragment"><pre>00201                                            : CValueSmootherTemplate&lt;float&gt;(n)
00202         {
00203         }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLMISC_1_1CValueSmootherTemplatea0" doxytag="NLMISC::CValueSmoother::addValue" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void <a class="el" href="a03643.html">NLMISC::CValueSmootherTemplate</a>&lt; float  &gt;::addValue </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">float &nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>dt</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline, inherited]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
add a new value to be smoothed. 
<p>

<p>
Definition at line <a class="el" href="a06657.html#l00080">80</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
References <a class="el" href="a05484.html#l00038">min</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a05559.html#l00424">NL3D::CCloudScape::anim()</a>, <a class="el" href="a05923.html#l00067">NL3D::CLoadBalancingGroup::computeRatioAndSmooth()</a>, and <a class="el" href="a05559.html#l00269">NL3D::CCloudScape::init()</a>.
<p>
<div class="fragment"><pre>00081         {
00082                 <span class="keywordflow">if</span> (_LastFrames.empty())
00083                         <span class="keywordflow">return</span>;
00084 
00085                 <span class="comment">// update the frame sum. NB: see init(), at start, array is full of 0. so it works even for un-inited values.</span>
00086                 _FrameSum-= _LastFrames[_CurFrame];
00087                 _FrameSum+= dt;
00088                 
00089                 <span class="comment">// backup this value in the array.</span>
00090                 _LastFrames[_CurFrame]= dt;
00091                 
00092                 <span class="comment">// next frame.</span>
00093                 _CurFrame++;
00094 <span class="comment">//              _CurFrame%=_LastFrames.size();</span>
00095                 <span class="keywordflow">if</span> (_CurFrame &gt;= _LastFrames.size())
00096                         _CurFrame -= _LastFrames.size();
00097                 
00098                 <span class="comment">// update the number of frames added.</span>
00099                 _NumFrame++;
00100                 _NumFrame= <a class="code" href="a04061.html#a0">std::min</a>(_NumFrame, (<a class="code" href="a04558.html#a15">uint</a>)_LastFrames.size());
00101         }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CValueSmootherTemplatea2" doxytag="NLMISC::CValueSmoother::getLastFrames" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> const std::vector&lt;float &gt;&amp; <a class="el" href="a03643.html">NLMISC::CValueSmootherTemplate</a>&lt; float  &gt;::getLastFrames </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline, inherited]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06657.html#l00117">117</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
<div class="fragment"><pre>00118         {
00119                 <span class="keywordflow">return</span> _LastFrames;
00120         }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CValueSmootherTemplatea3" doxytag="NLMISC::CValueSmoother::getNumFrame" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a03643.html">NLMISC::CValueSmootherTemplate</a>&lt; float  &gt;::getNumFrame </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline, inherited]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06657.html#l00112">112</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
References <a class="el" href="a05981.html#l00105">uint</a>.
<p>
<div class="fragment"><pre>00113         {
00114                 <span class="keywordflow">return</span> _NumFrame;
00115         }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CValueSmootherTemplatea4" doxytag="NLMISC::CValueSmoother::getSmoothValue" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> float  <a class="el" href="a03643.html">NLMISC::CValueSmootherTemplate</a>&lt; float  &gt;::getSmoothValue </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline, inherited]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
get the smoothed value. 
<p>

<p>
Definition at line <a class="el" href="a06657.html#l00104">104</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
Referenced by <a class="el" href="a05923.html#l00067">NL3D::CLoadBalancingGroup::computeRatioAndSmooth()</a>.
<p>
<div class="fragment"><pre>00105         {
00106                 <span class="keywordflow">if</span>(_NumFrame&gt;0)
00107                         <span class="keywordflow">return</span> T(_FrameSum / _NumFrame);
00108                 <span class="keywordflow">else</span>
00109                         <span class="keywordflow">return</span> T(0);
00110         }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CValueSmootherTemplatea5" doxytag="NLMISC::CValueSmoother::init" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void <a class="el" href="a03643.html">NLMISC::CValueSmootherTemplate</a>&lt; float  &gt;::init </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>n</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline, inherited]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
reset the ValueSmoother, and set the number of frame to smooth. 
<p>

<p>
Definition at line <a class="el" href="a06657.html#l00056">56</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
References <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a05923.html#l00054">NL3D::CLoadBalancingGroup::CLoadBalancingGroup()</a>, <a class="el" href="a05923.html#l00067">NL3D::CLoadBalancingGroup::computeRatioAndSmooth()</a>, and <a class="el" href="a05559.html#l00269">NL3D::CCloudScape::init()</a>.
<p>
<div class="fragment"><pre>00057         {
00058                 <span class="comment">// reset all the array to 0.</span>
00059                 _LastFrames.clear();
00060 
00061                 <span class="keywordflow">if</span> (n &gt; 0)
00062                         _LastFrames.resize(n, 0);
00063                 
00064                 _CurFrame = 0;
00065                 _NumFrame = 0;
00066                 _FrameSum = 0;
00067         }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CValueSmootherTemplatea6" doxytag="NLMISC::CValueSmoother::reset" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void <a class="el" href="a03643.html">NLMISC::CValueSmootherTemplate</a>&lt; float  &gt;::reset </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline, inherited]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
reset only the ValueSmoother 
<p>

<p>
Definition at line <a class="el" href="a06657.html#l00070">70</a> of file <a class="el" href="a06657.html">value_smoother.h</a>.
<p>
Referenced by <a class="el" href="a05923.html#l00067">NL3D::CLoadBalancingGroup::computeRatioAndSmooth()</a>.
<p>
<div class="fragment"><pre>00071         {
00072                 std::fill(_LastFrames.begin(), _LastFrames.end(), T(0));
00073                 
00074                 _CurFrame = 0;
00075                 _NumFrame = 0;
00076                 _FrameSum = 0;
00077         }
</pre></div>    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="a06657.html">value_smoother.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:40:03 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>