Deformetrica

AbstractDeformations.h
1 /***************************************************************************************
2 * *
3 * Deformetrica *
4 * *
5 * Copyright Inria and the University of Utah. All rights reserved. This file is *
6 * distributed under the terms of the Inria Non-Commercial License Agreement. *
7 * *
8 * *
9 ****************************************************************************************/
10 
11 #ifndef _AbstractDeformations_h
12 #define _AbstractDeformations_h
13 
14 #include "vnl/vnl_matrix.h"
15 
16 #include <vector>
17 
18 
27 template <class TScalar, unsigned int Dimension>
29 {
30 public:
31 
33  // typedef :
35 
37  typedef enum
38  {
39  null,
42 
44  typedef vnl_vector<TScalar> VNLVectorType;
46  typedef vnl_matrix<TScalar> VNLMatrixType;
48  typedef std::vector<VNLMatrixType> VNLMatrixList;
49 
50 
51 
53  // Constructor(s) / Destructor :
55 
59 
61  virtual AbstractDeformations* Clone() = 0;
62 
63  virtual ~AbstractDeformations();
64 
65 
66 
68  // Encapsulation method(s) :
70 
72  inline bool isADiffeo() const { return (m_Type == Diffeos); }
74  inline void SetDiffeosType() { m_Type = Diffeos; }
75 
77  inline unsigned int GetNumberOfTimePoints() const { return m_NumberOfTimePoints; }
79  inline void SetNumberOfTimePoints(unsigned int n) { m_NumberOfTimePoints = n; m_Modified = true;}
80 
82  inline TScalar GetKernelWidth() const { return m_KernelWidth; }
84  inline void SetKernelWidth(TScalar kernelWidth) { m_KernelWidth = kernelWidth; m_Modified = true; }
85 
87  inline void SetStartPositions(const VNLMatrixType& X) { m_StartPositions = X; m_Modified = true; }
88 
90  inline void SetStartMomentas(const VNLMatrixType& A) { m_StartMomentas = A; m_Modified = true; }
91 
94 
96  inline VNLMatrixList GetTrajectoryMomentas() const { return m_MomentasT; }
97 
99  inline bool ImprovedEuler() const { return m_UseImprovedEuler; }
101  void UseStandardEuler() { m_UseImprovedEuler = false; m_Modified = true; }
103  void UseImprovedEuler() { m_UseImprovedEuler = true; m_Modified = true; }
104 
106  inline VNLMatrixType GetDataDomain() const { return m_DataDomain; }
108  inline void SetDataDomain(VNLMatrixType& domain) { m_DataDomain = domain; }
109 
111  inline bool OutOfBox() const { return m_OutOfBox; }
112 
114  inline TScalar GetPaddingFactor() const { return m_PaddingFactor; }
116  inline void SetPaddingFactor(TScalar paddingFactor) { m_PaddingFactor = paddingFactor; }
117 
119  inline bool IsModified() const { return m_Modified; }
121  inline void SetModified() { m_Modified = true; }
123  inline void UnsetModified() { m_Modified = false; }
124 
125 
126 
128  // Other method(s) :
130 
140  bool CheckBoundingBox(VNLMatrixList& X, int t);
141 
148  virtual void Update();
149 
152  virtual void ReverseFlow() = 0;
153 
154 
155 
156 protected:
157 
159  // Method(s) :
161 
168  virtual void Shoot() = 0;
169 
176  void InitBoundingBox();
177 
178 
179 
181  // Attribute(s)
183 
186 
188  unsigned int m_NumberOfTimePoints;
189 
192 
195 
198 
200  TScalar m_KernelWidth;
201 
204 
207 
210 
213 
216 
219 
222 
223 
224 
225 }; /* class AbstractDeformations */
226 
227 
228 #ifndef MU_MANUAL_INSTANTIATION
229 #include "AbstractDeformations.txx"
230 #endif
231 
232 
233 #endif /* _AbstractDeformations_h */
VNLMatrixList GetTrajectoryPositions() const
Returns the list of the different positions between and .
Definition: AbstractDeformations.h:93
void SetModified()
Sets m_Modified to true (i.e. trajectory not computed or parameters changed).
Definition: AbstractDeformations.h:121
void UseStandardEuler()
Sets standard Euler's method.
Definition: AbstractDeformations.h:101
bool isADiffeo() const
Returns true if it is of Diffeos type, false otherwise.
Definition: AbstractDeformations.h:72
unsigned int m_NumberOfTimePoints
Number of time points between and .
Definition: AbstractDeformations.h:188
unsigned int GetNumberOfTimePoints() const
Returns the number of time points between and .
Definition: AbstractDeformations.h:77
Abstract deformations.
Definition: AbstractDeformations.h:28
std::vector< VNLMatrixType > VNLMatrixList
List of matrices type.
Definition: AbstractDeformations.h:48
VNLMatrixType m_StartMomentas
Matrix containing initial momentas (Size : N x Dimension).
Definition: AbstractDeformations.h:194
VNLMatrixType GetDataDomain() const
Returns the data domain.
Definition: AbstractDeformations.h:106
Standard diffeomorphisms.
Definition: Diffeos.h:27
VNLMatrixType m_BoundingBox
Box where any trajectory must not exit (Size : 2 x Dimension with the min (resp. the max) at first (r...
Definition: AbstractDeformations.h:221
void SetNumberOfTimePoints(unsigned int n)
Sets the number of time points between and .
Definition: AbstractDeformations.h:79
virtual void Update()
Updates the trajectory.
VNLMatrixList m_MomentasT
List of m_NumberOfTimePoints matrices containing momentas.
Definition: AbstractDeformations.h:206
bool m_Modified
Boolean which avoids computing the trajectory (via Update()) if no parameter has changed.
Definition: AbstractDeformations.h:212
void UnsetModified()
Sets m_Modified to false (i.e. trajectory computed and parameters not changed).
Definition: AbstractDeformations.h:123
void UseImprovedEuler()
Sets improved Euler's method.
Definition: AbstractDeformations.h:103
TScalar GetKernelWidth() const
Returns the size of the kernel.
Definition: AbstractDeformations.h:82
Definition: AbstractDeformations.h:40
TScalar m_KernelWidth
Size of the kernel.
Definition: AbstractDeformations.h:200
Definition: AbstractDeformations.h:39
bool ImprovedEuler() const
Returns true if use improved Euler's method, false otherwise.
Definition: AbstractDeformations.h:99
virtual void ReverseFlow()=0
Reverse the direction of the flow.
VNLMatrixList m_PositionsT
List of m_NumberOfTimePoints matrices containing positions.
Definition: AbstractDeformations.h:203
void InitBoundingBox()
Initializes the bounding box.
vnl_matrix< TScalar > VNLMatrixType
Matrix type.
Definition: AbstractDeformations.h:46
bool CheckBoundingBox(VNLMatrixList &X, int t)
Checks if a set of points is out of box or not.
void SetPaddingFactor(TScalar paddingFactor)
Sets the padding factor to paddingFactor.
Definition: AbstractDeformations.h:116
VNLMatrixType m_DataDomain
Matrix containing the min (resp. the max) of the initial positions at first (resp. second) line.
Definition: AbstractDeformations.h:197
vnl_vector< TScalar > VNLVectorType
Vector type.
Definition: AbstractDeformations.h:44
TScalar m_PaddingFactor
Multiplier coefficient for the creation of the bounding box ("boundingBox = dataDomain +/- paddingFac...
Definition: AbstractDeformations.h:218
bool OutOfBox() const
Returns true if any point is out of the bounding box, false otherwise.
Definition: AbstractDeformations.h:111
void SetKernelWidth(TScalar kernelWidth)
Sets the size of the kernel to kernelWidth.
Definition: AbstractDeformations.h:84
void SetStartMomentas(const VNLMatrixType &A)
Sets the initial momentas to A.
Definition: AbstractDeformations.h:90
void SetDiffeosType()
Sets type of the deformation to Diffeos.
Definition: AbstractDeformations.h:74
virtual void Shoot()=0
Computes the trajectory.
void SetStartPositions(const VNLMatrixType &X)
Sets the initial positions to X.
Definition: AbstractDeformations.h:87
VNLMatrixType m_StartPositions
Matrix containing initial positions (Size : N x Dimension).
Definition: AbstractDeformations.h:191
bool m_OutOfBox
Boolean which prevents computations if any point (e.g. the coordinates of trajectory) is outside the ...
Definition: AbstractDeformations.h:215
bool m_UseImprovedEuler
Boolean which indicates if we use improved Euler's method or not.
Definition: AbstractDeformations.h:209
DeformationsType
Possible type of deformations.
Definition: AbstractDeformations.h:37
virtual AbstractDeformations * Clone()=0
Makes a copy of the object.
TScalar GetPaddingFactor() const
Returns the padding factor.
Definition: AbstractDeformations.h:114
VNLMatrixList GetTrajectoryMomentas() const
Returns the list of the different momentas between and .
Definition: AbstractDeformations.h:96
DeformationsType m_Type
Type of the deformation.
Definition: AbstractDeformations.h:185
void SetDataDomain(VNLMatrixType &domain)
Sets the data domain to domain.
Definition: AbstractDeformations.h:108
bool IsModified() const
Returns true if one of the parameters of the deformation has changed, false otherwise.
Definition: AbstractDeformations.h:119