]> Creatis software - clitk.git/blob - tools/clitkTrajectory2D.h
- ok Joel, you are righet, I forgot the file ...
[clitk.git] / tools / clitkTrajectory2D.h
1 /*=========================================================================
2                                                                                 
3   Program:   clitk
4   Module:    $RCSfile: clitkTrajectory2D.h,v $
5   Language:  C++
6   Date:      $Date: 2010/03/03 12:41:27 $
7   Version:   $Revision: 1.1 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                              
17 =========================================================================*/
18
19 #ifndef CLITKTRAJECTORY2D_H
20 #define CLITKTRAJECTORY2D_H
21
22 #include "clitkCommon.h"
23 #include "clitkSignal.h"
24 #include "itkVector.h"
25 #include <vnl/algo/vnl_generalized_eigensystem.h>
26 #include <vnl/algo/vnl_symmetric_eigensystem.h>
27 #include <vnl/algo/vnl_real_eigensystem.h>
28
29 namespace clitk {
30
31   //---------------------------------------------------------------------
32   class Trajectory2D {
33   public:
34     typedef itk::Vector<double,2> Vector2d;
35
36     void ResampleWithTimeWarpTo(int begin, int end, Trajectory2D & output) const;
37     void ResampleWithTimeWarpTo(Trajectory2D & output) const; 
38     void Shift(double s);
39     
40     bool Read(std::string filename);
41
42     void GetPoint(const int index, Vector2d & p);
43     void GetMean(Vector2d & m);
44     double GetU(const int index) const { return mU[index]; }
45     double GetV(const int index) const { return mV[index]; }
46     clitk::Signal & GetU() { return mU; }
47     clitk::Signal & GetV() { return mV; }
48     
49     int size() const { return mU.size(); }
50     void resize(int n) { mU.resize(n); mV.resize(n); }
51
52     void SetPoint(const int i, Vector2d & p) { mU[i] = p[0]; mV[i] = p[1]; }
53     void SetPoint(const int i, double u, double v) { mU[i] = u; mV[i] = v; }
54     void GetValueAtLin(double t, Vector2d & p) const;
55
56     double GetSamplingPeriod() const { return mU.GetSamplingPeriod(); }
57     void SetSamplingPeriod(double sp){ mU.SetSamplingPeriod(sp); mV.SetSamplingPeriod(sp); }
58     double DistanceTo(int delta, const clitk::Trajectory2D & B) const;
59
60     Trajectory2D & operator+(Trajectory2D & d);
61     Trajectory2D & operator-(Trajectory2D & d);
62     
63     void Print(const std::string & name) const;
64     void Print(const std::string & name, int begin, int end) const;
65
66     void push_back(double u, double v) { mU.push_back(u); mV.push_back(v); }
67     void Substract(const Vector2d & m);
68     double GetTotalTimeDuration() const { return mU.GetTotalTimeDuration(); }
69
70   protected:
71     clitk::Signal mU;
72     clitk::Signal mV;
73     
74   };
75   //---------------------------------------------------------------------
76
77
78 } // end namespace
79
80 #endif