go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedMatrixOffsetTransformBase.h
Go to the documentation of this file.
1 /*======================================================================
2 
3 This file is part of the elastix software.
4 
5 Copyright (c) University Medical Center Utrecht. All rights reserved.
6 See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7 details.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 /*
16 
17  Program: Insight Segmentation & Registration Toolkit
18  Module: $RCSfile: itkAdvancedMatrixOffsetTransformBase.h,v $
19  Language: C++
20  Date: $Date: 2008-06-29 12:58:58 $
21  Version: $Revision: 1.20 $
22 
23  Copyright (c) Insight Software Consortium. All rights reserved.
24  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
25 
26  This software is distributed WITHOUT ANY WARRANTY; without even
27  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
28  PURPOSE. See the above copyright notices for more information.
29 
30 =========================================================================*/
31 
32 #ifndef __itkAdvancedMatrixOffsetTransformBase_h
33 #define __itkAdvancedMatrixOffsetTransformBase_h
34 
35 #include <iostream>
36 
37 #include "itkMatrix.h"
38 #include "itkAdvancedTransform.h"
39 #include "itkExceptionObject.h"
40 #include "itkMacro.h"
41 
42 namespace itk
43 {
44 
45 
90 template <
91  class TScalarType=double, // Data type for scalars
92  unsigned int NInputDimensions=3, // Number of dimensions in the input space
93  unsigned int NOutputDimensions=3> // Number of dimensions in the output space
95  : public AdvancedTransform< TScalarType, NInputDimensions, NOutputDimensions >
96 {
97 public:
100  typedef AdvancedTransform< TScalarType,
101  NInputDimensions, NOutputDimensions > Superclass;
102  typedef SmartPointer<Self> Pointer;
103  typedef SmartPointer<const Self> ConstPointer;
104 
107 
109  itkNewMacro( Self );
110 
112  itkStaticConstMacro( InputSpaceDimension, unsigned int, NInputDimensions );
113  itkStaticConstMacro( OutputSpaceDimension, unsigned int, NOutputDimensions );
114  itkStaticConstMacro( ParametersDimension, unsigned int,
115  NOutputDimensions * ( NInputDimensions + 1 ) );
116 
123  typedef typename Superclass
125  typedef typename Superclass
131 
132  typedef typename Superclass
135  typedef typename Superclass
138  typedef typename Superclass
141 
143  typedef Matrix< TScalarType,
144  itkGetStaticConstMacro( OutputSpaceDimension ),
145  itkGetStaticConstMacro( InputSpaceDimension )> MatrixType;
146 
148  typedef Matrix< TScalarType,
149  itkGetStaticConstMacro( InputSpaceDimension ),
150  itkGetStaticConstMacro( OutputSpaceDimension )> InverseMatrixType;
151 
156 
160  virtual void SetIdentity( void );
161 
174  virtual void SetMatrix( const MatrixType & matrix )
175  {
176  this->m_Matrix = matrix;
177  this->ComputeOffset();
178  this->ComputeMatrixParameters();
179  this->m_MatrixMTime.Modified();
180  this->Modified();
181  }
182 
190  const MatrixType & GetMatrix( void ) const
191  {
192  return this->m_Matrix;
193  }
194 
204  void SetOffset( const OutputVectorType &offset )
205  {
206  this->m_Offset = offset;
207  this->ComputeTranslation();
208  this->Modified();
209  }
210 
217  const OutputVectorType & GetOffset( void ) const
218  {
219  return this->m_Offset;
220  }
221 
245  void SetCenter( const InputPointType & center )
246  {
247  this->m_Center = center;
248  this->ComputeOffset();
249  this->Modified();
250  }
251 
259  const InputPointType & GetCenter( void ) const
260  {
261  return this->m_Center;
262  }
263 
271  void SetTranslation( const OutputVectorType & translation )
272  {
273  this->m_Translation = translation;
274  this->ComputeOffset();
275  this->Modified();
276  }
277 
285  const OutputVectorType & GetTranslation( void ) const
286  {
287  return this->m_Translation;
288  }
289 
295  void SetParameters( const ParametersType & parameters );
296 
298  const ParametersType & GetParameters( void ) const;
299 
301  virtual void SetFixedParameters( const ParametersType & );
302 
304  virtual const ParametersType & GetFixedParameters( void ) const;
305 
318  void Compose( const Self * other, bool pre = 0 );
319 
328  OutputPointType TransformPoint( const InputPointType & point ) const;
329  OutputVectorType TransformVector( const InputVectorType & vector ) const;
332  const InputCovariantVectorType & vector ) const;
333 
351  bool GetInverse( Self * inverse ) const;
352 
356  const InverseMatrixType & GetInverseMatrix( void ) const;
357 
363  virtual bool IsLinear( void ) const
364  {
365  return true;
366  }
367 
369  const JacobianType & GetJacobian( const InputPointType & point ) const;
370 
372  virtual void GetJacobian(
373  const InputPointType &,
374  JacobianType &,
375  NonZeroJacobianIndicesType & ) const;
376 
378  virtual void GetSpatialJacobian(
379  const InputPointType &,
380  SpatialJacobianType & ) const;
381 
383  virtual void GetSpatialHessian(
384  const InputPointType &,
385  SpatialHessianType & ) const;
386 
388  virtual void GetJacobianOfSpatialJacobian(
389  const InputPointType &,
391  NonZeroJacobianIndicesType & ) const;
392 
394  virtual void GetJacobianOfSpatialJacobian(
395  const InputPointType &,
398  NonZeroJacobianIndicesType & ) const;
399 
401  virtual void GetJacobianOfSpatialHessian(
402  const InputPointType &,
404  NonZeroJacobianIndicesType & ) const;
405 
408  virtual void GetJacobianOfSpatialHessian(
409  const InputPointType & ipp,
410  SpatialHessianType & sh,
412  NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
413 
414 protected:
424  const OutputVectorType & offset );
425  AdvancedMatrixOffsetTransformBase( unsigned int outputDims,
426  unsigned int paramDims );
428 
430  virtual void PrecomputeJacobians(unsigned int outputDims, unsigned int paramDims);
431 
434 
436  void PrintSelf( std::ostream &s, Indent indent ) const;
437 
439  {
440  return this->m_InverseMatrix;
441  };
442 
443  void SetVarInverseMatrix( const InverseMatrixType & matrix ) const
444  {
445  this->m_InverseMatrix = matrix;
446  this->m_InverseMatrixMTime.Modified();
447  };
448 
449  bool InverseMatrixIsOld( void ) const
450  {
451  if ( this->m_MatrixMTime != this->m_InverseMatrixMTime )
452  {
453  return true;
454  }
455  else
456  {
457  return false;
458  }
459  };
460 
461  virtual void ComputeMatrixParameters( void );
462 
463  virtual void ComputeMatrix( void );
464 
465  void SetVarMatrix( const MatrixType & matrix )
466  {
467  this->m_Matrix = matrix;
468  this->m_MatrixMTime.Modified();
469  };
470 
471  virtual void ComputeTranslation( void );
472 
473  void SetVarTranslation( const OutputVectorType & translation )
474  {
475  this->m_Translation = translation;
476  };
477 
478  virtual void ComputeOffset( void );
479 
480  void SetVarOffset( const OutputVectorType & offset )
481  {
482  this->m_Offset = offset;
483  };
484 
485  void SetVarCenter( const InputPointType & center )
486  {
487  this->m_Center = center;
488  };
489 
497 
498 private:
499 
501  const Self & operator=( const Self & );
502 
504  MatrixType m_Matrix; // Matrix of the transformation
505  OutputVectorType m_Offset; // Offset of the transformation
506  mutable InverseMatrixType m_InverseMatrix; // Inverse of the matrix
507  mutable bool m_Singular; // Is m_Inverse singular?
508 
511 
515 
519 
520 }; //class AdvancedMatrixOffsetTransformBase
521 
522 } // namespace itk
523 
524 // Define instantiation macro for this template.
525 #define ITK_TEMPLATE_AdvancedMatrixOffsetTransformBase(_, EXPORT, x, y) namespace itk { \
526  _(3(class EXPORT AdvancedMatrixOffsetTransformBase< ITK_TEMPLATE_3 x >)) \
527  namespace Templates { typedef AdvancedMatrixOffsetTransformBase< ITK_TEMPLATE_3 x > AdvancedMatrixOffsetTransformBase##y; } \
528  }
529 
530 #if ITK_TEMPLATE_EXPLICIT
531 # include "Templates/itkAdvancedMatrixOffsetTransformBase+-.h"
532 #endif
533 
534 #if ITK_TEMPLATE_TXX
535 # include "itkAdvancedMatrixOffsetTransformBase.txx"
536 #endif
537 
538 #endif /* __itkAdvancedMatrixOffsetTransformBase_h */
539 


Generated on 21-03-2014 for elastix by doxygen 1.8.1.2 elastix logo