]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Extensions/Algorithms/KalmanFilter.h
Kalman completely ported
[cpPlugins.git] / lib / cpPlugins / Extensions / Algorithms / KalmanFilter.h
index ac5d9e261bc2f7a836dc9f0c8b904b02ca613821..74b0f3ad1009594bde4a677e426c673793a37630 100644 (file)
@@ -5,23 +5,15 @@
 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__KALMANFILTER__H__
 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__KALMANFILTER__H__
 
+#include <itkObject.h>
+#include <itkObjectFactory.h>
 #include <vnl/vnl_matrix.h>
 #include <vnl/vnl_vector.h>
 
 // -------------------------------------------------------------------------
-#define kalmanGetMacro( type, name )            \
-  virtual type Get##name( ) const               \
-  { return( this->m_##name ); }
-
-// -------------------------------------------------------------------------
-#define kalmanSetMacro( type, name )            \
-  virtual void Set##name( const type& m )       \
-  { this->m_##name = m; }
-
-// -------------------------------------------------------------------------
-#define kalmanGetSetMacro( type, name )         \
-  kalmanGetMacro( type, name );                 \
-  kalmanSetMacro( type, name );
+#define kalmanGetSetMacro( type, name )    \
+  itkGetConstMacro( name, type );          \
+  itkSetMacro( name, type );
 
 // -------------------------------------------------------------------------
 #define kalmanGetMatrixMacro( var, name )       \
@@ -31,7 +23,7 @@
 // -------------------------------------------------------------------------
 #define kalmanSetMatrixMacro( var, name )       \
   virtual void Set##name( const TMatrix& m )    \
-  { this->m_##var = m; }
+  { this->Set##var( m ); }
 
 // -------------------------------------------------------------------------
 #define kalmanGetSetMatrixMacro( var, name )    \
@@ -46,7 +38,7 @@
 // -------------------------------------------------------------------------
 #define kalmanSetVectorMacro( var, name )       \
   virtual void Set##name( const TVector& v )    \
-  { this->m_##var = v; }
+  { this->Set##var( v ); }
 
 // -------------------------------------------------------------------------
 #define kalmanGetSetVectorMacro( var, name )    \
@@ -66,9 +58,13 @@ namespace cpPlugins
        */
       template< typename T >
       class KalmanFilter
+        : public itk::Object
       {
       public:
-        typedef KalmanFilter Self;
+        typedef KalmanFilter                    Self;
+        typedef itk::Object                     Superclass;
+        typedef itk::SmartPointer< Self >       Pointer;
+        typedef itk::SmartPointer< const Self > ConstPointer;
 
         // Template parameters types
         typedef T TScalar;
@@ -86,10 +82,13 @@ namespace cpPlugins
         };
 
       public:
+        itkNewMacro( Self );
+        itkTypeMacro( KalmanFilter, itkObject );
+
         // Values
-        kalmanGetMacro( unsigned int, StateSize );
-        kalmanGetMacro( unsigned int, InputSize );
-        kalmanGetMacro( unsigned int, MeasureSize );
+        itkGetConstMacro( StateSize, unsigned int );
+        itkGetConstMacro( InputSize, unsigned int );
+        itkGetConstMacro( MeasureSize, unsigned int );
 
         // Matrices
         kalmanGetSetMacro( TMatrix, A );
@@ -128,10 +127,6 @@ namespace cpPlugins
         kalmanGetSetVectorMacro( xp, APosterioriState );
 
       public:
-        KalmanFilter(
-          unsigned int s = 1, unsigned int i = 1, unsigned int m = 1
-          );
-        virtual ~KalmanFilter( );
 
         void Configure( unsigned int s, unsigned int i, unsigned int m );
 
@@ -156,6 +151,10 @@ namespace cpPlugins
         unsigned char CurrentStep( ) const
           { return( this->m_Step ); }
 
+      protected:
+        KalmanFilter( );
+        virtual ~KalmanFilter( );
+
       private:
         // Purposely not implemented
         KalmanFilter( const Self& );