00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkThreadSafeTransform_h
00018 #define __itkThreadSafeTransform_h
00019
00020 #include "itkTransformBase.h"
00021 #include "itkPoint.h"
00022 #include "itkVector.h"
00023 #include "itkCovariantVector.h"
00024 #include "vnl/vnl_vector_fixed.h"
00025 #include "itkArray.h"
00026 #include "itkArray2D.h"
00027
00028 #include "itkObjectFactory.h"
00029
00030
00031 namespace itk
00032 {
00033
00063 template <class TScalarType,
00064 unsigned int NInputDimensions=3,
00065 unsigned int NOutputDimensions=3>
00066 class ITK_EXPORT Transform : public TransformBase
00067 {
00068 public:
00070 typedef Transform Self;
00071 typedef TransformBase Superclass;
00072 typedef SmartPointer< Self > Pointer;
00073 typedef SmartPointer< const Self > ConstPointer;
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00086 itkTypeMacro( Transform, TransformBase );
00087
00089 itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
00090 itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
00092
00094 unsigned int GetInputSpaceDimension(void) const {return NInputDimensions;}
00095
00097 unsigned int GetOutputSpaceDimension(void) const {return NOutputDimensions;}
00098
00100 typedef TScalarType ScalarType;
00101
00103 typedef typename Superclass::ParametersType ParametersType;
00104
00106 typedef Array2D< double > JacobianType;
00107
00109 typedef Vector<TScalarType, NInputDimensions> InputVectorType;
00110 typedef Vector<TScalarType, NOutputDimensions> OutputVectorType;
00111
00113 typedef CovariantVector<TScalarType, NInputDimensions> InputCovariantVectorType;
00114 typedef CovariantVector<TScalarType, NOutputDimensions> OutputCovariantVectorType;
00115
00117 typedef vnl_vector_fixed<TScalarType, NInputDimensions> InputVnlVectorType;
00118 typedef vnl_vector_fixed<TScalarType, NOutputDimensions> OutputVnlVectorType;
00119
00121 typedef Point<TScalarType, NInputDimensions> InputPointType;
00122 typedef Point<TScalarType, NOutputDimensions> OutputPointType;
00123
00125 virtual OutputPointType TransformPoint( const InputPointType & inputPoint,
00126 unsigned int itkNotUsed( threadId ) ) const
00127 { return this->TransformPoint( inputPoint ); }
00128 virtual OutputPointType TransformPoint(const InputPointType & inputPoint ) const
00129 { return this->TransformPoint( inputPoint, 0 ); }
00131
00133 virtual OutputVectorType TransformVector( const InputVectorType & inputVector,
00134 unsigned int itkNotUsed( threadId ) ) const
00135 { return this->TransformVector( inputVector ); }
00136 virtual OutputVectorType TransformVector(const InputVectorType & inputVector ) const
00137 { return this->TransformVector( inputVector, 0 ); }
00139
00141 virtual OutputVnlVectorType TransformVector( const InputVnlVectorType & inputVnlVector,
00142 unsigned int itkNotUsed( threadId ) ) const
00143 { return this->TransformVector( inputVnlVector ); }
00144 virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & inputVnlVector ) const
00145 { return TransformVector( inputVnlVector, 0 ); }
00147
00149 virtual OutputCovariantVectorType TransformCovariantVector(
00150 const InputCovariantVectorType &inputCovariantVector,
00151 unsigned int itkNotUsed( threadId ) ) const
00152 { return this->TransformCovariantVector( inputCovariantVector ); }
00153 virtual OutputCovariantVectorType TransformCovariantVector(
00154 const InputCovariantVectorType & inputCovariantVector ) const
00155 { return TransformCovariantVector( inputCovariantVector, 0 ); }
00157
00165 virtual void SetParameters( const ParametersType & )
00166 { itkExceptionMacro( << "Subclasses should override this method" ) }
00167
00175 virtual void SetParametersByValue ( const ParametersType & p )
00176 { this->SetParameters ( p ); };
00177
00179 virtual const ParametersType& GetParameters(void) const
00180 { itkExceptionMacro( << "Subclasses should override this method" );
00181 return m_Parameters; }
00183
00185 virtual void SetFixedParameters( const ParametersType & )
00186 { itkExceptionMacro( << "Subclasses should override this method" ) };
00187
00189 virtual const ParametersType& GetFixedParameters(void) const
00190 { itkExceptionMacro( << "Subclasses should override this method" );
00191 return m_Parameters; };
00193
00221 virtual const JacobianType & GetJacobian( const InputPointType & inputPoint,
00222 unsigned int itkNotUsed( threadId ) ) const
00223 { return this->GetJacobian( inputPoint ); }
00224 virtual const JacobianType & GetJacobian(const InputPointType & inputPoint ) const
00225 { return this->GetJacobian( inputPoint, 0 ); }
00227
00228
00230 virtual unsigned int GetNumberOfParameters(void) const
00231 { return m_Parameters.Size(); }
00232
00235 bool GetInverse(Self*) const {return false;}
00236
00238 virtual std::string GetTransformTypeAsString() const;
00239
00253 virtual bool IsLinear() const { return false; }
00254
00257 virtual void SetNumberOfThreads( unsigned int numberOfThreads ) const;
00258 itkGetConstReferenceMacro( NumberOfThreads, unsigned int );
00260
00261 protected:
00262 Transform();
00263 Transform(unsigned int Dimension, unsigned int NumberOfParameters);
00264 virtual ~Transform() {};
00265 void PrintSelf(std::ostream& os, Indent indent) const;
00266
00267
00268 mutable ParametersType m_Parameters;
00269 mutable ParametersType m_FixedParameters;
00270 mutable JacobianType m_Jacobian;
00271 mutable JacobianType * m_ThreaderJacobian;
00272
00273 virtual JacobianType * GetJacobianVariableForThread( unsigned int threadId=0 ) const;
00274
00275 private:
00276 Transform(const Self&);
00277 void operator=(const Self&);
00278
00279 mutable unsigned int m_NumberOfThreads;
00280
00281 unsigned int m_JacobianDimensions;
00282 unsigned int m_JacobianNumberOfParameters;
00283
00284 };
00285
00286 }
00287
00288
00289 #define ITK_TEMPLATE_Transform(_, EXPORT, x, y) namespace itk { \
00290 _(3(class EXPORT Transform< ITK_TEMPLATE_3 x >)) \
00291 namespace Templates { typedef Transform< ITK_TEMPLATE_3 x > Transform##y; } \
00292 }
00293
00294 #if ITK_TEMPLATE_EXPLICIT
00295 # include "Templates/itkTransform+-.h"
00296 #endif
00297
00298 #if ITK_TEMPLATE_TXX
00299 # include "itkThreadSafeTransform.txx"
00300 #endif
00301
00302 #endif
00303