Project

General

Profile

BitmapToolkit Scol plugin
Smoothers.h
Go to the documentation of this file.
1#ifndef SMOOTHERS_H
2#define SMOOTHERS_H
3
4#include "Prerequisites.h"
5#include <vector>
6
7#define SMOOTHER_TYPE_UNDEFINED 0
8#define SMOOTHER_TYPE_FLOAT 1
9#define SMOOTHER_TYPE_VEC2 2
10#define SMOOTHER_TYPE_VEC3 3
11
12#define SMOOTHER_METHOD_UNDEFINED 0
13#define SMOOTHER_METHOD_LINEAR 1
14#define SMOOTHER_METHOD_DOUBLEEXP 2
15
20{
21public:
22 virtual ~ISmoother() {}
23
24 // Get type of derived smoother
25 virtual int getSmootherType() = 0;
26
27 // Get method use to smooth (liear, double exponential, ...)
28 virtual int getSmootherMethod() = 0;
29
30 // Clear internal values
31 virtual void clearValues() = 0;
32};
33
34template <typename T>
35class TSmoother : public ISmoother
36{
37public:
38 virtual ~TSmoother() {}
39
40 virtual void pushValue(T val) = 0;
41 virtual T getExtrapolatedValue() = 0;
42 virtual T getSmoothedValue() = 0;
43
44 int getSmootherType();
45 virtual int getSmootherMethod() = 0;
46 virtual void clearValues() = 0;
47};
48
52template <typename T>
53class LinearSmoother : public TSmoother < T >
54{
55protected:
56 float mFactor;
59
60public:
61 // Construct LinearExponentialSmoother from a smoothing factor (between 0 and 1)
62 LinearSmoother(float factor = 0.5f);
63 void setSmoothingFactor(float factor);
64
65 virtual void pushValue(T val);
66 virtual T getExtrapolatedValue();
67 virtual T getSmoothedValue();
68 virtual int getSmootherMethod();
69 virtual void clearValues();
70};
71
75template <typename T>
77{
78protected:
79 float mAlpha;
80 float mBeta;
83 bool init;
84
85public:
86 // Construct from alpha & beta, smoothing factors (between 0 and 1 exclusive)
87 DoubleExponentialSmoother(float alpha = 0.5f, float beta = 0.5f);
88 void setSmoothingFactor(float alpha, float beta);
89
90 virtual void pushValue(T val);
91 virtual T getExtrapolatedValue();
92 virtual T getSmoothedValue();
93 virtual int getSmootherMethod();
94 virtual void clearValues();
95};
96
97#endif // !SMOOTHERS_H
Double Exponential smoother.
Definition Smoothers.h:77
virtual void clearValues()
virtual void pushValue(T val)
virtual int getSmootherMethod()
void setSmoothingFactor(float alpha, float beta)
Definition Smoothers.cpp:89
virtual T getExtrapolatedValue()
Definition Smoothers.cpp:97
Smoother interface.
Definition Smoothers.h:20
virtual void clearValues()=0
virtual ~ISmoother()
Definition Smoothers.h:22
virtual int getSmootherMethod()=0
virtual int getSmootherType()=0
Linear smoother.
Definition Smoothers.h:54
virtual void clearValues()
Definition Smoothers.cpp:69
virtual T getSmoothedValue()
Definition Smoothers.cpp:41
virtual void pushValue(T val)
Definition Smoothers.cpp:48
virtual int getSmootherMethod()
Definition Smoothers.cpp:63
void setSmoothingFactor(float factor)
Definition Smoothers.cpp:27
virtual T getExtrapolatedValue()
Definition Smoothers.cpp:34
virtual void pushValue(T val)=0
virtual void clearValues()=0
virtual T getExtrapolatedValue()=0
virtual T getSmoothedValue()=0
int getSmootherType()
Definition Smoothers.cpp:4
virtual int getSmootherMethod()=0
virtual ~TSmoother()
Definition Smoothers.h:38