Deformetrica

KernelFactory.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 MIT License. This file is also distributed *
7 * under the terms of the Inria Non-Commercial License Agreement. *
8 * *
9 * *
10 ****************************************************************************************/
11 
12 #ifndef _KernelFactory_h
13 #define _KernelFactory_h
14 
15 #include "itkSimpleFastMutexLock.h"
16 
17 #include "ExactKernel.h"
18 #include "FGTKernel.h"
19 
20 
31 template <class TScalar, unsigned int PointDim>
33 {
34 public:
35 
37  // typedef :
39 
41  typedef enum
42  {
44 #ifdef USE_CUDA
45  CUDAExact,
46 #endif
47  FGT,
48  P3M
50 
53 
58 
59 
60 
62  // Encapsulation method(s) :
64 
68  void UseExactKernel() { m_Mutex.Lock(); m_WhichKernel = Exact; m_Mutex.Unlock();}
69 #ifdef USE_CUDA
70  void UseCUDAExactKernel() { m_Mutex.Lock(); m_WhichKernel = CUDAExact; m_Mutex.Unlock();}
72 #endif
73  void UseFGTKernel() { m_Mutex.Lock(); m_WhichKernel = FGT; m_Mutex.Unlock();}
76  void UseP3MKernel() { m_Mutex.Lock(); m_WhichKernel = P3M; m_Mutex.Unlock();}
77 
82 
84  TScalar GetWorkingSpacingRatio() const { return m_WorkingSpacingRatio; }
86  void SetWorkingSpacingRatio(TScalar d) { m_Mutex.Lock(); m_WorkingSpacingRatio = d; m_Mutex.Unlock(); }
87 
89  TScalar GetPaddingFactor() const { return m_PaddingFactor; }
91  void SetPaddingFactor(TScalar d) { m_Mutex.Lock(); m_PaddingFactor = d; m_Mutex.Unlock(); }
92 
93 
94 
96  // Other method(s) :
98 
101 
104 
107  const VNLMatrixType& X,
108  const VNLMatrixType& W,
109  TScalar h);
110 
111 // NOTE: make sure to assign the target image when using P3M
112 // void SetWorkingImage(ImageType* img);
113 // ImagePointer GetWorkingImage() const { return m_WorkingImage; }
114 
115 
116 
117 protected:
118 
120  // Constructor(s) / Destructor :
122 
123  KernelFactory();
124 
125  ~KernelFactory();
126 
128  // Attribute(s)
130 
133 
134  // Information of image domain for heuristically determining parameters
135  // ImagePointer m_WorkingImage;
136 
139 
142 
145 
146 
147 
148 private:
149 
151  // Attribute(s)
153 
155  static itk::SimpleFastMutexLock m_Mutex;
156 
158  static bool m_IsInstantiated;
159 
161  static KernelFactory* m_SingletonInstance;
162 
163 
164 }; /* class KernelFactory */
165 
166 
167 #ifndef MU_MANUAL_INSTANTIATION
168 #include "KernelFactory.txx"
169 #endif
170 
171 
172 #endif /* _KernelFactory_h */
Superclass::VNLMatrixType VNLMatrixType
Matrix type.
Definition: ExactKernel.h:44
void UseFGTKernel()
Sets the type of the kernel to FGTKernel.
Definition: KernelFactory.h:74
TScalar GetPaddingFactor() const
Returns the padding factor.
Definition: KernelFactory.h:89
TScalar m_PaddingFactor
See P3MKernel::m_PaddingFactor for details.
Definition: KernelFactory.h:144
KernelEnumType GetKernelCode() const
Returns the type of the kernel.
Definition: KernelFactory.h:66
TScalar GetWorkingSpacingRatio() const
Get the spacing of the lattice for grid optimization (p3m).
Definition: KernelFactory.h:84
Definition: KernelFactory.h:43
VNLMatrixType GetDataDomain() const
Returns the data domain.
Definition: KernelFactory.h:79
KernelEnumType
Possible type of kernels.
Definition: KernelFactory.h:41
Definition: KernelFactory.h:47
KernelBaseType::VNLVectorType VNLVectorType
Vector type.
Definition: KernelFactory.h:55
KernelBaseType::VNLMatrixType VNLMatrixType
Matrix type.
Definition: KernelFactory.h:57
Exact kernels.
Definition: ExactKernel.h:30
KernelEnumType m_WhichKernel
Type of the kernel.
Definition: KernelFactory.h:132
void UseExactKernel()
Sets the type of the kernel to ExactKernel.
Definition: KernelFactory.h:68
ExactKernel< TScalar, PointDim > KernelBaseType
Exact kernel type.
Definition: KernelFactory.h:52
TScalar m_WorkingSpacingRatio
See P3MKernel::m_WorkingSpacingRatio for details.
Definition: KernelFactory.h:141
A kernel factory.
Definition: KernelFactory.h:32
void SetWorkingSpacingRatio(TScalar d)
Set the spacing of the lattice for grid optimization (p3m).
Definition: KernelFactory.h:86
Definition: KernelFactory.h:48
Superclass::VNLVectorType VNLVectorType
Vector type.
Definition: ExactKernel.h:42
void SetPaddingFactor(TScalar d)
Sets the padding factor to d.
Definition: KernelFactory.h:91
VNLMatrixType m_DataDomain
See AbstractDeformations::m_DataDomain for details.
Definition: KernelFactory.h:138
KernelBaseType * CreateKernelObject()
Returns the instance of the object, NULL in case of error.
void UseP3MKernel()
Sets the type of the kernel to P3MKernel.
Definition: KernelFactory.h:76
static KernelFactory< TScalar, PointDim > * Instantiate()
Instantiates an object of KernelFactory type with the Singleton strategy.
void SetDataDomain(VNLMatrixType DD)
Sets the data domain to DD.