Blame view

src/InternLib/Resampling.hh 29.5 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Resampling.hh
 *
 *  Created on: 31 oct. 2012
 *      Author: AKKA IS
 */

#ifndef Resampling_HH_
#define Resampling_HH_

#include <list>
#include "ParamData.hh"
#include "DataTypeMath.hh"
#include "VisitorOfParamData.hh"
#include "Operation.hh"

#include "TimeInterval.hh"

namespace AMDA {
namespace Parameters {

namespace Resampling {

ca31a786   Benjamin Renard   Fix other side ef...
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
class MarkerAbstract {
public:
	MarkerAbstract() : _startTime(0.), _stopTime(0.), _samplingTime(0.), _markerMinTime(0.), _markerMaxTime(0.), _targetTime(0.) {
	}

	virtual bool init(double pStartTime, double pStopTime, int /*currentTimeIntervalIndex*/, double pSamplingTime) {
		_startTime = pStartTime;
		_stopTime = pStopTime;
		_samplingTime = pSamplingTime;
		return true;
	}

	virtual bool nextTarget() = 0;

	double getTargetTime() {
		return _targetTime;
	}

	double getMarkerMinTime() {
		return _markerMinTime;
	}

	double getMarkerMaxTime() {
		return _markerMaxTime;
	}

	virtual bool isFinished() = 0;

protected:
	bool setTargetTime(double pTargetTime) {
		_targetTime = pTargetTime;
		_markerMinTime = _targetTime - _samplingTime / 2.;
		if (_markerMinTime < _startTime) {
			_markerMinTime = _startTime;
		}
		_markerMaxTime = _targetTime + _samplingTime / 2.;
		return !isFinished();
	}

	double _startTime;
	double _stopTime;
	double _samplingTime;
	double _markerMinTime;
        double _markerMaxTime;
	double _targetTime;
};

class MarkerRefParam: public MarkerAbstract {
public:
	MarkerRefParam() : MarkerAbstract(), _refParamDataPtr(NULL), _crtRefIndex(-1) {
	}

	void setRefParamData(ParamData* refParamDataPtr) {
		_refParamDataPtr = refParamDataPtr;
	}

	bool init(double pStartTime, double pStopTime, int currentTimeIntervalIndex, double pSamplingTime) {
		MarkerAbstract::init(pStartTime, pStopTime, currentTimeIntervalIndex, pSamplingTime);
		if (_refParamDataPtr == NULL) {
			return false;
		}
		if (_refParamDataPtr->getIndexInfo()._endTimeIntIndexList.empty() || (currentTimeIntervalIndex == 0)) {
			_crtRefIndex = 0;
		}
		else {
			std::list<unsigned int>::iterator it = _refParamDataPtr->getIndexInfo()._endTimeIntIndexList.begin();
			std::advance(it, currentTimeIntervalIndex-1);
			_crtRefIndex = *it;
		}
deefda79   Benjamin Renard   Addapt resampling...
93
		while (pStartTime > _refTimes[_crtRefIndex]) {
ca31a786   Benjamin Renard   Fix other side ef...
94
95
96
97
98
99
			++_crtRefIndex;
			if (_crtRefIndex >= (int)_refParamDataPtr->getDataNumber()) {
				_crtRefIndex = -1;
				return false;
			}
		}
deefda79   Benjamin Renard   Addapt resampling...
100
		return setTargetTime(_refTimes[_crtRefIndex]);
ca31a786   Benjamin Renard   Fix other side ef...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
	}

	bool nextTarget() {
		if (_crtRefIndex < 0) {
			return false;
		}
		if (_refParamDataPtr == NULL) {
			_crtRefIndex = -1;
			return false;
		}
		++_crtRefIndex;
		if (_crtRefIndex >= (int)_refParamDataPtr->getDataNumber()) {
			_crtRefIndex = -1;
			return false;
		}
deefda79   Benjamin Renard   Addapt resampling...
116
		return setTargetTime(_refTimes[_crtRefIndex]);
ca31a786   Benjamin Renard   Fix other side ef...
117
118
119
120
121
122
	}

	bool isFinished() {
		return (_crtRefIndex == -1);
	}

deefda79   Benjamin Renard   Addapt resampling...
123
124
125
126
	void pushTime(double time) {
		_refTimes.push_back(time);
	}

ca31a786   Benjamin Renard   Fix other side ef...
127
128
129
130
private:
	ParamData* _refParamDataPtr;

	int _crtRefIndex;
deefda79   Benjamin Renard   Addapt resampling...
131
132

	std::vector<double> _refTimes;
ca31a786   Benjamin Renard   Fix other side ef...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
};

class MarkerSampling: public MarkerAbstract {
public:
	MarkerSampling() : MarkerAbstract() {
	}

	bool init(double pStartTime, double pStopTime, int currentTimeIntervalIndex, double pSamplingTime) {
		MarkerAbstract::init(pStartTime, pStopTime, currentTimeIntervalIndex, pSamplingTime);
		return setTargetTime(pStartTime);
	}

	bool nextTarget() {
		return setTargetTime(getTargetTime() + _samplingTime);
	}

	bool isFinished() {
		return (_targetTime < _startTime || _targetTime > _stopTime);
	}
};


fbe3c2bb   Benjamin Renard   First commit
155
156
157
158
159
160
161
162
/**
 * Define type Resampling.
 */
class ResamplingAbstract: public Operation {
public:
	/**
	 * @brief constructor
	 */
ca31a786   Benjamin Renard   Fix other side ef...
163
164
	ResamplingAbstract(Process& pProcess, bool pUseNearestValue) :
			Operation(pProcess), _isNewInt(true), _useNearestValue(pUseNearestValue) {
fbe3c2bb   Benjamin Renard   First commit
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

	}
	/**
	 * @brief destructor.
	 */
	virtual ~ResamplingAbstract() {
	}
	/**
	 * @brief compute static data
	 */
	virtual void init() = 0;

	/**
	 * @overload Operation::reset(double pStartTime, double pTimeInt)
	 * @brief reset static data to process another TimeInterval
	 */
	virtual void reset() {
		Operation::reset();
a6490f4d   Benjamin Renard   Do not throw an e...
183
		resetResampling();
fbe3c2bb   Benjamin Renard   First commit
184
185
186
187
188
189
190
191
		_isNewInt = true;
	}

	/*
	 * @brief return sampling value
	 */
	virtual double getSampling() = 0;

a6490f4d   Benjamin Renard   Do not throw an e...
192
193
194
195
196
	/*
	 * @brief reset resampling
	 */
	virtual void resetResampling() = 0;

deefda79   Benjamin Renard   Addapt resampling...
197
198
	virtual void pushTime(double time) = 0;

01acda3f   Benjamin Renard   Fix a regression ...
199
200
201
202
	virtual bool isNewInt() {
		return _isNewInt;
	}

fbe3c2bb   Benjamin Renard   First commit
203
protected:
fbe3c2bb   Benjamin Renard   First commit
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
	/**
	 *@brief  tag to know if a new time interval is set
	 */
	bool _isNewInt;

	/*
	 * @brief  Define the resampling strategy
	 */
	bool _useNearestValue;
};

/**
 * Simple Resampling abstract class, depand of paramData type
 */
template<typename TParamData>
class ResamplingSimpleAbstract: public ResamplingAbstract {

public:
	/**
	 * @brief  Element type of paramData
	 */
	typedef typename TParamData::ElementType ElementType;

	/**
	 * @brief  Constructor
	 */
ca31a786   Benjamin Renard   Fix other side ef...
230
231
232
233
234
	ResamplingSimpleAbstract(Process& pProcess, MarkerAbstract* pMarkerPtr, TimeIntervalListSPtr pTimeIntervalList, double gapSize, TParamData &param, bool pUseNearestValue) :
			ResamplingAbstract(pProcess, pUseNearestValue),
					_markerPtr(pMarkerPtr),
					_timeIntervalList(pTimeIntervalList),
					_currentTimeInterval(_timeIntervalList->begin()), _currentTimeIntervalIndex(0), _samplingMode(INTERPOLATION), _nearestTime(NAN), _lastTime(0),
fbe3c2bb   Benjamin Renard   First commit
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
					_leftEffect(true), _paramOutput(new TParamData()), _paramInput(param),
					_gapSize(gapSize) {
		_paramDataOutput = _paramOutput;
	}

	/**
	 * @brief  Destructor
	 */
	virtual ~ResamplingSimpleAbstract() {
	}
	;

	/**
	 * @brief Type List of Element type of paramData
	 */
	typedef std::list<ElementType> ListValue;

	/**
	 * @overload ResamplingAbstract::ResamplingAbstract::write()
	 */
	void write(ParamDataIndexInfo &pParamDataIndexInfo) {
		if (_isNewInt)
		{
ca31a786   Benjamin Renard   Fix other side ef...
258
			_markerPtr->init((*_currentTimeInterval)._startTime, (*_currentTimeInterval)._stopTime, _currentTimeIntervalIndex, getSampling());
fbe3c2bb   Benjamin Renard   First commit
259
260
261
262
263
			_isNewInt = false;
		}

		if ((pParamDataIndexInfo._nbDataToProcess > 0)) {
			//init _val with the first data value (to init dimensions)
65aa1ad5   Benjamin Renard   Fix a bug in resa...
264
265
266
267
268
269
270
			if (pParamDataIndexInfo._startIndex == 0)
			{
				_val = _paramInput.get(pParamDataIndexInfo._startIndex);
				_nearestValue = _paramInput.get(pParamDataIndexInfo._startIndex);
				_val << NotANumber();
				_nearestValue << NotANumber();
			}
fbe3c2bb   Benjamin Renard   First commit
271
272
273
274
275

			switch (_samplingMode)
			{
			case AVERAGE :
				writeAverage(pParamDataIndexInfo);
fbe3c2bb   Benjamin Renard   First commit
276
277
278
279
280
281
282
283
				break;
			case NEARESTVALUE :
				writeNearestValue(pParamDataIndexInfo);
				break;
			case INTERPOLATION :
				writeInterpolation(pParamDataIndexInfo);
				break;
			}
ca31a786   Benjamin Renard   Fix other side ef...
284
		}
bb672c4c   Benjamin Renard   Fix side effect i...
285
		if (pParamDataIndexInfo._timeIntToProcessChanged || pParamDataIndexInfo._noMoreTimeInt) {
fbe3c2bb   Benjamin Renard   First commit
286
287
288
289
290
291
292
293
			terminated();
		}
	}

	/**
	 * @brief compute and write last value, right effect
	 */
	virtual void terminated() {
ca31a786   Benjamin Renard   Fix other side ef...
294
		if (_markerPtr->isFinished()) {
bb672c4c   Benjamin Renard   Fix side effect i...
295
296
			return;
		}
fbe3c2bb   Benjamin Renard   First commit
297
298
		switch (_samplingMode)
		{
fbe3c2bb   Benjamin Renard   First commit
299
		case AVERAGE :
a40aa278   Benjamin Renard   Fix resampling
300
301
302
303
304
305
306
			do {
				if (!_mem.empty()) {
					_val = average(_mem,_paramInput.getDim1(),_paramInput.getDim2());
				}
				else {
					_val << NotANumber();
				}
fbe3c2bb   Benjamin Renard   First commit
307
				_paramOutput->push(_val);
ca31a786   Benjamin Renard   Fix other side ef...
308
				_paramDataOutput->pushTime(_markerPtr->getTargetTime());
fbe3c2bb   Benjamin Renard   First commit
309
				_mem.clear();
a40aa278   Benjamin Renard   Fix resampling
310
			} while(_markerPtr->nextTarget());
fbe3c2bb   Benjamin Renard   First commit
311
			break;
2f932bad   Benjamin Renard   Fix interpolation...
312
		case INTERPOLATION :
fbe3c2bb   Benjamin Renard   First commit
313
		case NEARESTVALUE :
bb672c4c   Benjamin Renard   Fix side effect i...
314
			//Fix  side-off effects - Right boundary - CONSTANTS
ca31a786   Benjamin Renard   Fix other side ef...
315
316
317
318
319
320
321
322
323
			do {
				if ((_markerPtr->getTargetTime() - _lastTime) <= _gapSize)
					_val = _valMoins1;
				else
					_val << NotANumber();
				_paramOutput->pushTime(_markerPtr->getTargetTime());
				_paramOutput->push(_val);
			
			} while(_markerPtr->nextTarget());
bb672c4c   Benjamin Renard   Fix side effect i...
324
			break;
2f932bad   Benjamin Renard   Fix interpolation...
325
		}
fbe3c2bb   Benjamin Renard   First commit
326
327
328
329
330
331
332
333
334
335
336
337
338
	}

	/**
	 * @brief compute and write new value in average mode
	 */
	void writeNearestValue(ParamDataIndexInfo &pParamDataIndexInfo)
	{
		for (unsigned int index = pParamDataIndexInfo._startIndex;
				index < pParamDataIndexInfo._startIndex
					+ pParamDataIndexInfo._nbDataToProcess; index++)
		{
			double timeCurrent = _paramInput.getTime(index);

ca31a786   Benjamin Renard   Fix other side ef...
339
			if (timeCurrent < _markerPtr->getMarkerMaxTime())
fbe3c2bb   Benjamin Renard   First commit
340
			{
ca31a786   Benjamin Renard   Fix other side ef...
341
342
343
				if (timeCurrent < _markerPtr->getMarkerMinTime()) {
					continue;
				}
fbe3c2bb   Benjamin Renard   First commit
344
345
346
347
348
				if (isNAN(_nearestTime))
				{
					_nearestValue = _paramInput.get(index);
					_nearestTime = timeCurrent;
				}
ca31a786   Benjamin Renard   Fix other side ef...
349
				else if (abs(_nearestTime-_markerPtr->getTargetTime()) > abs(timeCurrent-_markerPtr->getTargetTime()))
fbe3c2bb   Benjamin Renard   First commit
350
351
352
353
354
355
				{
					_nearestValue = _paramInput.get(index);
					_nearestTime = timeCurrent;
				}
			} else {
				_paramOutput->push(_nearestValue);
ca31a786   Benjamin Renard   Fix other side ef...
356
357
				_paramDataOutput->pushTime(_markerPtr->getTargetTime());
				if(!_markerPtr->nextTarget())
fbe3c2bb   Benjamin Renard   First commit
358
					break;
ca31a786   Benjamin Renard   Fix other side ef...
359
				while (_markerPtr->getMarkerMaxTime() < timeCurrent)
fbe3c2bb   Benjamin Renard   First commit
360
				{
2f932bad   Benjamin Renard   Fix interpolation...
361
					if (timeCurrent - _lastTime < _gapSize) {
80265e6a   Benjamin Renard   Compute interpola...
362
						//Interpolation
ca31a786   Benjamin Renard   Fix other side ef...
363
						double coefT = (float) (_markerPtr->getTargetTime() - _lastTime) / (timeCurrent - _lastTime);
2f932bad   Benjamin Renard   Fix interpolation...
364
						_val = interpolation(_valMoins1, _paramInput.get(index), coefT, _paramInput.getDim1(),_paramInput.getDim2());
80265e6a   Benjamin Renard   Compute interpola...
365
					}
2f932bad   Benjamin Renard   Fix interpolation...
366
					else {
80265e6a   Benjamin Renard   Compute interpola...
367
						_val << NotANumber();
2f932bad   Benjamin Renard   Fix interpolation...
368
					}
fbe3c2bb   Benjamin Renard   First commit
369
					_paramOutput->push(_val);
ca31a786   Benjamin Renard   Fix other side ef...
370
					_paramDataOutput->pushTime(_markerPtr->getTargetTime());
fbe3c2bb   Benjamin Renard   First commit
371
					_nearestTime << NotANumber();
ca31a786   Benjamin Renard   Fix other side ef...
372
					if(!_markerPtr->nextTarget())
fbe3c2bb   Benjamin Renard   First commit
373
						break;
fbe3c2bb   Benjamin Renard   First commit
374
				}
fbe3c2bb   Benjamin Renard   First commit
375
376
377
				_nearestValue = _paramInput.get(index);
				_nearestTime = timeCurrent;
			}
80265e6a   Benjamin Renard   Compute interpola...
378
379
380

			_lastTime = _paramInput.getTime(index);
			_valMoins1 = _paramInput.get(index);
fbe3c2bb   Benjamin Renard   First commit
381
382
383
384
385
386
387
		}
	}

	/**
	 * @brief compute and write new value in average mode
	 */
	void writeAverage(ParamDataIndexInfo &pParamDataIndexInfo) {
fbe3c2bb   Benjamin Renard   First commit
388
389
390
391
392
393
394
395
		for (unsigned int index = pParamDataIndexInfo._startIndex;
				index
						< pParamDataIndexInfo._startIndex
								+ pParamDataIndexInfo._nbDataToProcess;
				index++) {

			double timeCurrent = _paramInput.getTime(index);

ca31a786   Benjamin Renard   Fix other side ef...
396
397
398
399
			if (timeCurrent < _markerPtr->getMarkerMaxTime()) {
				if (timeCurrent >= _markerPtr->getMarkerMinTime()) { 
					_mem.push_back(_paramInput.get(index));
				}
fbe3c2bb   Benjamin Renard   First commit
400
			} else {
ca31a786   Benjamin Renard   Fix other side ef...
401
				if (!_mem.empty()) {
c6877b6f   Benjamin Renard   Fix average for v...
402
					_val = average(_mem,_paramInput.getDim1(),_paramInput.getDim2());
ca31a786   Benjamin Renard   Fix other side ef...
403
				}
2f932bad   Benjamin Renard   Fix interpolation...
404
				else if (timeCurrent - _lastTime < _gapSize) {
80265e6a   Benjamin Renard   Compute interpola...
405
					//Interpolation
ca31a786   Benjamin Renard   Fix other side ef...
406
					double coefT = (float) (_markerPtr->getTargetTime() - _lastTime) / (timeCurrent - _lastTime);
2f932bad   Benjamin Renard   Fix interpolation...
407
					_val = interpolation(_valMoins1, _paramInput.get(index), coefT, _paramInput.getDim1(),_paramInput.getDim2());
80265e6a   Benjamin Renard   Compute interpola...
408
				}
ca31a786   Benjamin Renard   Fix other side ef...
409
				else {
fbe3c2bb   Benjamin Renard   First commit
410
					_val << NotANumber();
ca31a786   Benjamin Renard   Fix other side ef...
411
				}
fbe3c2bb   Benjamin Renard   First commit
412
				_paramOutput->push(_val);
ca31a786   Benjamin Renard   Fix other side ef...
413
414
				_paramDataOutput->pushTime(_markerPtr->getTargetTime());
				_mem.clear();
fbe3c2bb   Benjamin Renard   First commit
415

ca31a786   Benjamin Renard   Fix other side ef...
416
				if(!_markerPtr->nextTarget())
fbe3c2bb   Benjamin Renard   First commit
417
					break;
fbe3c2bb   Benjamin Renard   First commit
418

ca31a786   Benjamin Renard   Fix other side ef...
419
				while (_markerPtr->getMarkerMaxTime() < timeCurrent)
fbe3c2bb   Benjamin Renard   First commit
420
				{
2f932bad   Benjamin Renard   Fix interpolation...
421
					if (timeCurrent - _lastTime < _gapSize) {
80265e6a   Benjamin Renard   Compute interpola...
422
						//Interpolation
ca31a786   Benjamin Renard   Fix other side ef...
423
						double coefT = (float) (_markerPtr->getTargetTime() - _lastTime) / (timeCurrent - _lastTime);
2f932bad   Benjamin Renard   Fix interpolation...
424
						_val = interpolation(_valMoins1, _paramInput.get(index), coefT, _paramInput.getDim1(),_paramInput.getDim2());
80265e6a   Benjamin Renard   Compute interpola...
425
426
427
					}
					else
						_val << NotANumber();
fbe3c2bb   Benjamin Renard   First commit
428
					_paramOutput->push(_val);
ca31a786   Benjamin Renard   Fix other side ef...
429
430
					_paramDataOutput->pushTime(_markerPtr->getTargetTime());
					if(!_markerPtr->nextTarget())
fbe3c2bb   Benjamin Renard   First commit
431
						break;
fbe3c2bb   Benjamin Renard   First commit
432
				}
ca31a786   Benjamin Renard   Fix other side ef...
433
434
435
				if ((timeCurrent >= _markerPtr->getMarkerMinTime()) && (timeCurrent < _markerPtr->getMarkerMaxTime())) {
					_mem.push_back(_paramInput.get(index));
				}
fbe3c2bb   Benjamin Renard   First commit
436
			}
80265e6a   Benjamin Renard   Compute interpola...
437
438
			_lastTime = _paramInput.getTime(index);
			_valMoins1 = _paramInput.get(index);
fbe3c2bb   Benjamin Renard   First commit
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
		}
	}

	/**
	 * @brief compute and write new value in interpolation mode
	 */
	void writeInterpolation(ParamDataIndexInfo &pParamDataIndexInfo) {
		for (unsigned int index = pParamDataIndexInfo._startIndex;
				index
						< pParamDataIndexInfo._startIndex
								+ pParamDataIndexInfo._nbDataToProcess;
				index++) {

			double timeCurrent = _paramInput.getTime(index);

fbe3c2bb   Benjamin Renard   First commit
454
455
			//Fix  side-off effects - Left boundary - CONSTANTS
			if (_leftEffect) {
ca31a786   Benjamin Renard   Fix other side ef...
456
457
				while (_markerPtr->getTargetTime() <= timeCurrent) {
					if (abs(timeCurrent - _markerPtr->getTargetTime()) <= _gapSize) {
fbe3c2bb   Benjamin Renard   First commit
458
459
460
461
						_val = _paramInput.get(index);
					} else {
						_val << NotANumber();
					}
ca31a786   Benjamin Renard   Fix other side ef...
462
					_paramDataOutput->pushTime(_markerPtr->getTargetTime());
fbe3c2bb   Benjamin Renard   First commit
463
					_paramOutput->push(_val);
ca31a786   Benjamin Renard   Fix other side ef...
464
					if (!_markerPtr->nextTarget())
fbe3c2bb   Benjamin Renard   First commit
465
466
467
468
						break;
				}
				_leftEffect = false;
			} else {
ca31a786   Benjamin Renard   Fix other side ef...
469
470
				if (_markerPtr->getTargetTime() <= timeCurrent) {
					while (_markerPtr->getTargetTime() <= timeCurrent) {
fbe3c2bb   Benjamin Renard   First commit
471
472
						double deltaT = (float) (timeCurrent - _lastTime);
						if (deltaT <= _gapSize) {
ca31a786   Benjamin Renard   Fix other side ef...
473
							double coefT = (float) (_markerPtr->getTargetTime() - _lastTime) / deltaT;
2f932bad   Benjamin Renard   Fix interpolation...
474
							_val = interpolation(_valMoins1, _paramInput.get(index), coefT, _paramInput.getDim1(),_paramInput.getDim2());
fbe3c2bb   Benjamin Renard   First commit
475
476
477
						} else {
							_val << NotANumber();
						}
ca31a786   Benjamin Renard   Fix other side ef...
478
						_paramDataOutput->pushTime(_markerPtr->getTargetTime());
fbe3c2bb   Benjamin Renard   First commit
479
						_paramOutput->push(_val);
ca31a786   Benjamin Renard   Fix other side ef...
480
						if (!_markerPtr->nextTarget())
fbe3c2bb   Benjamin Renard   First commit
481
482
483
484
							break;
					}
				}
			}
fbe3c2bb   Benjamin Renard   First commit
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
			_lastTime = _paramInput.getTime(index);
			_valMoins1 = _paramInput.get(index);
		}
	}

	/**
	 * @overload ResamplingAbstract::ResamplingAbstract::init()
	 */
	virtual void init() {
		//Compute Sampling mode
		if (_useNearestValue)
		{
			_samplingMode = NEARESTVALUE;
			_nearestValue = ElementType();
			_nearestTime << NotANumber();
		}
		else
		{
			float minSampling = _paramInput.getMinSampling();

			if ((minSampling * 2) < getSampling()) {
				_samplingMode = AVERAGE;
			}
		}

		_isNewInt = true;
	}

	/**
	 * @overload ResamplingAbstract::reset(double pStartTime, double pTimeInt)
	 */
a6490f4d   Benjamin Renard   Do not throw an e...
516
	virtual void resetResampling() {
fbe3c2bb   Benjamin Renard   First commit
517
518
519
		if (_currentTimeInterval == _timeIntervalList->end())
			return;

fbe3c2bb   Benjamin Renard   First commit
520
521
		// Get next TimeInteval;
		++_currentTimeInterval;
ca31a786   Benjamin Renard   Fix other side ef...
522
		++_currentTimeIntervalIndex;
fbe3c2bb   Benjamin Renard   First commit
523
524
525
		_samplingMode = INTERPOLATION;
		_lastTime = 0;
		_leftEffect = true;
599e1446   Benjamin Renard   Fix new interval ...
526
527
		_valMoins1 << NotANumber();
		_val<< NotANumber();
fbe3c2bb   Benjamin Renard   First commit
528
529
530
531
532
		_mem.clear();

		init();
	}

ca31a786   Benjamin Renard   Fix other side ef...
533
	virtual double getSampling() = 0;
fbe3c2bb   Benjamin Renard   First commit
534

deefda79   Benjamin Renard   Addapt resampling...
535

fbe3c2bb   Benjamin Renard   First commit
536
537
538
539
540
541
542
	/**
	 * @brief sampling mode
	 */
	enum SamplingMode {
		INTERPOLATION, AVERAGE, NEARESTVALUE
	};

fbe3c2bb   Benjamin Renard   First commit
543
544
545
546
547
548
549
private:

	/**
	 * @brief stored val to compute average in average mode
	 */
	ListValue _mem;

ca31a786   Benjamin Renard   Fix other side ef...
550
551
	MarkerAbstract* _markerPtr;
	
fbe3c2bb   Benjamin Renard   First commit
552
553
554
555
	TimeIntervalListSPtr _timeIntervalList;

	TimeIntervalList::iterator _currentTimeInterval;

ca31a786   Benjamin Renard   Fix other side ef...
556
	int _currentTimeIntervalIndex;
fbe3c2bb   Benjamin Renard   First commit
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605

	/**<
	 * @brief current sampling mode
	 */
	SamplingMode _samplingMode;

	/**<
	 * @brief last computed value
	 */
	ElementType _val;

	/**
	 * @brief nearest time
	 */
	double _nearestTime;

	/**
	 * @brief nearest value
	 */
	ElementType _nearestValue;

	/**<
	 * @brief last input value
	 */
	ElementType _valMoins1;
	/**<
	 * @brief time of  last input value
	 */
	double _lastTime;

	/**
	 * @brief left effect indicator in interpolation mode
	 */
	bool _leftEffect;

	/**
	 * @brief real ParamData Output
	 */
	TParamData *_paramOutput;

	/**
	 * @brief real ParamData Input
	 */
	TParamData& _paramInput;

	/**
	 * @brief gap size for input data
	 */
	double _gapSize;
fbe3c2bb   Benjamin Renard   First commit
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
}
;

/**
 * Resampling implementation with a given sampling time , depand of paramData type
 */
template<typename TParamData>
class ResamplingWithSamplingTime : public ResamplingSimpleAbstract<TParamData> {

public:
	/**
	 * @brief  Constructor
	 */
	ResamplingWithSamplingTime(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList,
			double sampling, double gapSize, TParamData &param, bool  pUseNearestValue) :
ca31a786   Benjamin Renard   Fix other side ef...
621
622
			ResamplingSimpleAbstract<TParamData>(pProcess, &_marker, pTimeIntervalList,
						gapSize, param, pUseNearestValue), _samplingTime(sampling) {
fbe3c2bb   Benjamin Renard   First commit
623
624
625
626
627
628
629
630
	}

	/**
	 * @brief  Destructor
	 */
	virtual ~ResamplingWithSamplingTime() {
	}

ca31a786   Benjamin Renard   Fix other side ef...
631
632
	double getSampling() {
		return _samplingTime;
fbe3c2bb   Benjamin Renard   First commit
633
634
	}

deefda79   Benjamin Renard   Addapt resampling...
635
636
637
638
	void pushTime(double /*time*/) {
		//Not used
	}

fbe3c2bb   Benjamin Renard   First commit
639
private:
ca31a786   Benjamin Renard   Fix other side ef...
640
641
642
643
	MarkerSampling _marker;

	double _samplingTime;
};
fbe3c2bb   Benjamin Renard   First commit
644
645
646
647
648
649
650
651
652
653
654
655
656
657


/**
 * Resampling implementation with a given reference parameter for time definition , depand of paramData type
 */
template<typename TParamData>
class ResamplingWithRefParam: public ResamplingSimpleAbstract<TParamData> {

public:
	/**
	 * @brief  Constructor
	 */
	ResamplingWithRefParam(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList,
			TParamData &param, ParamData &refParamData, double gapSize, bool  pUseNearestValue) :
ca31a786   Benjamin Renard   Fix other side ef...
658
659
660
			ResamplingSimpleAbstract<TParamData>(pProcess, &_marker, pTimeIntervalList,
					gapSize, param, pUseNearestValue), _refParamData(refParamData) {
		_marker.setRefParamData(&refParamData);
fbe3c2bb   Benjamin Renard   First commit
661
662
663
664
665
666
667
668
	}

	/**
	 * @brief  Destructor
	 */
	virtual ~ResamplingWithRefParam() {
	}

ca31a786   Benjamin Renard   Fix other side ef...
669
	double getSampling() {
fbe3c2bb   Benjamin Renard   First commit
670
		return _refParamData.getMinSampling();
ca31a786   Benjamin Renard   Fix other side ef...
671
        }
fbe3c2bb   Benjamin Renard   First commit
672

deefda79   Benjamin Renard   Addapt resampling...
673
674
675
676
	void pushTime(double time) {
		_marker.pushTime(time);
	}

fbe3c2bb   Benjamin Renard   First commit
677
private:
ca31a786   Benjamin Renard   Fix other side ef...
678
	MarkerRefParam _marker;
fbe3c2bb   Benjamin Renard   First commit
679

fbe3c2bb   Benjamin Renard   First commit
680
	ParamData& _refParamData;
ca31a786   Benjamin Renard   Fix other side ef...
681
};
fbe3c2bb   Benjamin Renard   First commit
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825

/**
 * create the real Resampling implementation with visitor design pattern
 */
class CreateResampling: public VisitorOfParamData {
public:
	enum ResamplingType {
		RT_WITHSAMPLINGTIME,
		RT_WITHREFTIMELIST
	};

	/**
	 * @brief constructor
	 */
	CreateResampling(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList,
			double sampling, double gapSize, ParamData &paramData, bool useNearestValue) :
			_type(ResamplingType::RT_WITHSAMPLINGTIME),
			_process(pProcess), _paramData(paramData), _resampling(NULL), _timeIntervalList(
					pTimeIntervalList), _sampling(sampling), _gapSize(
					gapSize), _refParamData(paramData), _useNearestValue(useNearestValue) {
		_paramData.accept(*this);
	}

	/**
	 * @brief constructor
	 */
	CreateResampling(Process& pProcess, TimeIntervalListSPtr pTimeIntervalList,
			ParamData &paramData, ParamData& refParamData, double gapSize, bool useNearestValue) :
			_type(ResamplingType::RT_WITHREFTIMELIST),
			_process(pProcess), _paramData(paramData), _resampling(NULL), _timeIntervalList(
					pTimeIntervalList), _sampling(0.), _gapSize(
					gapSize),_refParamData(refParamData), _useNearestValue(useNearestValue) {
		_paramData.accept(*this);
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataScalaireShort *)
	 */
	virtual void visit(ParamDataScalaireShort *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataScalaireShort>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataScalaireShort &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataScalaireShort>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataScalaireShort &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *)
	 */
	virtual void visit(ParamDataScalaireFloat *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataScalaireFloat>(_process,
							_timeIntervalList, _sampling, _gapSize,
							dynamic_cast<ParamDataScalaireFloat &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataScalaireFloat>(_process,
							_timeIntervalList,
							dynamic_cast<ParamDataScalaireFloat &>(_paramData),
							_refParamData,
							_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *)
	 */
	virtual void visit(ParamDataScalaireDouble *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataScalaireDouble>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataScalaireDouble &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataScalaireDouble>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataScalaireDouble &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *)
	 */
	virtual void visit(ParamDataScalaireLongDouble *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataScalaireLongDouble>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataScalaireLongDouble &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataScalaireLongDouble>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataScalaireLongDouble &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataScalaireInt *)
	 */
	virtual void visit(ParamDataScalaireInt *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataScalaireInt>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataScalaireInt &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataScalaireInt>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataScalaireInt &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataLogicalData *)
	 */
	virtual void visit(ParamDataLogicalData *) {
7578a549   Benjamin Renard   Add boolean suppo...
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			// !! Force the use of the nearest value
			_resampling = new ResamplingWithSamplingTime<ParamDataLogicalData>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataLogicalData &>(_paramData), true);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			// !! Force the use of the nearest value
			_resampling = new ResamplingWithRefParam<ParamDataLogicalData>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataLogicalData &>(_paramData),
				_refParamData,
				_gapSize, true);
			break;
		}
fbe3c2bb   Benjamin Renard   First commit
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab1DShort *)
	 */
	virtual void visit(ParamDataTab1DShort *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab1DShort>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataTab1DShort &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab1DShort>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab1DShort &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *)
	 */
	virtual void visit(ParamDataTab1DFloat *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab1DFloat>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataTab1DFloat &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab1DFloat>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab1DFloat &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *)
	 */
	virtual void visit(ParamDataTab1DDouble *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab1DDouble>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataTab1DDouble &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab1DDouble>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab1DDouble &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *)
	 */
	virtual void visit(ParamDataTab1DLongDouble *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab1DLongDouble>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataTab1DLongDouble &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab1DLongDouble>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab1DLongDouble &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab1DInt *)
	 */
	virtual void visit(ParamDataTab1DInt *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab1DInt>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataTab1DInt &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab1DInt>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab1DInt &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *)
	 */
	virtual void visit(ParamDataTab1DLogicalData *) {
7578a549   Benjamin Renard   Add boolean suppo...
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			// !! Force the use of the nearest value
			_resampling = new ResamplingWithSamplingTime<ParamDataTab1DLogicalData>(_process,
				_timeIntervalList, _sampling, _gapSize,
				dynamic_cast<ParamDataTab1DLogicalData &>(_paramData), true);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			// !! Force the use of the nearest value
			_resampling = new ResamplingWithRefParam<ParamDataTab1DLogicalData>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab1DLogicalData &>(_paramData),
				_refParamData,
				_gapSize, true);
			break;
		}
fbe3c2bb   Benjamin Renard   First commit
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab2DShort *)
	 */
	virtual void visit(ParamDataTab2DShort *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab2DShort>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataTab2DShort &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab2DShort>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab2DShort &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *)
	 */
	virtual void visit(ParamDataTab2DFloat *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab2DFloat>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataTab2DFloat &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab2DFloat>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab2DFloat &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *)
	 */
	virtual void visit(ParamDataTab2DDouble *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab2DDouble>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataTab2DDouble &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab2DDouble>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab2DDouble &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *)
	 */
	virtual void visit(ParamDataTab2DLongDouble *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab2DLongDouble>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataTab2DLongDouble &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab2DLongDouble>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab2DLongDouble &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab2DInt *)
	 */
	virtual void visit(ParamDataTab2DInt *) {
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			_resampling = new ResamplingWithSamplingTime<ParamDataTab2DInt>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataTab2DInt &>(_paramData), _useNearestValue);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			_resampling = new ResamplingWithRefParam<ParamDataTab2DInt>(_process,
				_timeIntervalList,
				dynamic_cast<ParamDataTab2DInt &>(_paramData),
				_refParamData,
				_gapSize, _useNearestValue);
			break;
		}
	}

	/**
	 * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *)
	 */
	virtual void visit(ParamDataTab2DLogicalData *) {
7578a549   Benjamin Renard   Add boolean suppo...
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
		switch (_type)
		{
		case ResamplingType::RT_WITHSAMPLINGTIME :
			// !! Force the use of the nearest value
			_resampling = new ResamplingWithSamplingTime<ParamDataTab2DLogicalData>(_process,
					_timeIntervalList, _sampling, _gapSize,
					dynamic_cast<ParamDataTab2DLogicalData &>(_paramData), true);
			break;
		case ResamplingType::RT_WITHREFTIMELIST :
			// !! Force the use of the nearest value
			_resampling = new ResamplingWithRefParam<ParamDataTab2DLogicalData>(_process,
					_timeIntervalList,
					dynamic_cast<ParamDataTab2DLogicalData &>(_paramData),
					_refParamData,
					_gapSize, true);
                        break;
                }
fbe3c2bb   Benjamin Renard   First commit
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
	}

	/**
	 * @brief Good resampling getter
	 */
	ResamplingAbstract* getResampling() const {
		return _resampling;
	}
private:
	ResamplingType _type;
	Process &_process;
	ParamData &_paramData;
	ResamplingAbstract *_resampling;
	TimeIntervalListSPtr _timeIntervalList;
	double _sampling;
	double _gapSize;
	ParamData& _refParamData;
	bool _useNearestValue;
};

} /* Resampling */
} /* AMDA */
} /* Parameters */

#endif /* Resampling_HH_ */