ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkMatrixOffsetTransformBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkMatrixOffsetTransformBase_h
19 #define __itkMatrixOffsetTransformBase_h
20 
21 #include <iostream>
22 
23 #include "itkMatrix.h"
24 #include "itkTransform.h"
25 #include "itkMacro.h"
26 
27 namespace itk
28 {
70 template <
71  class TScalarType = double, // Data type for scalars
72  unsigned int NInputDimensions = 3, // Number of dimensions in the input space
73  unsigned int NOutputDimensions = 3>
74 // Number of dimensions in the output space
76  public Transform<TScalarType, NInputDimensions, NOutputDimensions>
77 {
78 public:
81  typedef Transform<TScalarType,
82  NInputDimensions,
83  NOutputDimensions> Superclass;
84 
87 
89  itkTypeMacro(MatrixOffsetTransformBase, Transform);
90 
92  itkNewMacro(Self);
93 
95  itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
96  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
97  itkStaticConstMacro( ParametersDimension, unsigned int,
98  NOutputDimensions * ( NInputDimensions + 1 ) );
100 
104 
107 
110 
113 
115  typedef Vector<TScalarType,
116  itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
117  typedef Vector<TScalarType,
118  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
121 
123  typedef CovariantVector<TScalarType,
124  itkGetStaticConstMacro(InputSpaceDimension)>
126  typedef CovariantVector<TScalarType,
127  itkGetStaticConstMacro(OutputSpaceDimension)>
130 
133 
139 
145 
148 
150  typedef vnl_vector_fixed<TScalarType,
151  itkGetStaticConstMacro(InputSpaceDimension)>
153  typedef vnl_vector_fixed<TScalarType,
154  itkGetStaticConstMacro(OutputSpaceDimension)>
157 
159  typedef Point<TScalarType,
160  itkGetStaticConstMacro(InputSpaceDimension)>
163  typedef Point<TScalarType,
164  itkGetStaticConstMacro(OutputSpaceDimension)>
168 
170  typedef Matrix<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension),
171  itkGetStaticConstMacro(InputSpaceDimension)>
175 
177  typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
178  itkGetStaticConstMacro(OutputSpaceDimension)>
180 
182 
185 
187 
189 
194 
198  virtual void SetIdentity(void);
199 
204  {
205  return Self::Linear;
206  }
207 
219  virtual void SetMatrix(const MatrixType & matrix)
220  {
221  m_Matrix = matrix; this->ComputeOffset();
222  this->ComputeMatrixParameters();
223  m_MatrixMTime.Modified(); this->Modified(); return;
224  }
226 
234  virtual const MatrixType & GetMatrix() const
235  {
236  return m_Matrix;
237  }
238 
247  void SetOffset(const OutputVectorType & offset)
248  {
249  m_Offset = offset; this->ComputeTranslation();
250  this->Modified(); return;
251  }
253 
259  const OutputVectorType & GetOffset(void) const
260  {
261  return m_Offset;
262  }
263 
286  void SetCenter(const InputPointType & center)
287  {
288  m_Center = center; this->ComputeOffset();
289  this->Modified(); return;
290  }
292 
299  const InputPointType & GetCenter() const
300  {
301  return m_Center;
302  }
303 
310  void SetTranslation(const OutputVectorType & translation)
311  {
312  m_Translation = translation; this->ComputeOffset();
313  this->Modified(); return;
314  }
316 
323  const OutputVectorType & GetTranslation(void) const
324  {
325  return m_Translation;
326  }
327 
332  void SetParameters(const ParametersType & parameters);
333 
335  const ParametersType & GetParameters(void) const;
336 
338  virtual void SetFixedParameters(const ParametersType &);
339 
341  virtual const ParametersType & GetFixedParameters(void) const;
342 
354  void Compose(const Self *other, bool pre = 0);
355 
364  OutputPointType TransformPoint(const InputPointType & point) const;
365 
367 
368  OutputVectorType TransformVector(const InputVectorType & vector) const;
369 
371 
373 
375 
377 
379 
381 
383 
385 
388 
390 
400  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & x, JacobianType & j) const;
401 
405  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & jac) const;
406 
410  virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType & x, JacobianType & jac) const;
411 
430  bool GetInverse(Self *inverse) const;
432 
435 
441  virtual bool IsLinear() const
442  {
443  return true;
444  }
445 
446 #if !defined(ITK_LEGACY_REMOVE)
447 
448 public:
449 #else
450 
451 protected:
452 #endif
453 
455  const InverseMatrixType & GetInverseMatrix(void) const;
456 
457 protected:
465  MatrixOffsetTransformBase(const MatrixType & matrix, const OutputVectorType & offset);
466  MatrixOffsetTransformBase(unsigned int paramDims);
469 
471  virtual ~MatrixOffsetTransformBase();
472 
474  void PrintSelf(std::ostream & s, Indent indent) const;
475 
477  {
478  return m_InverseMatrix;
479  }
480  void SetVarInverseMatrix(const InverseMatrixType & matrix) const
481  {
483  }
484  bool InverseMatrixIsOld(void) const
485  {
487  {
488  return true;
489  }
490  else
491  {
492  return false;
493  }
494  }
495 
496  virtual void ComputeMatrixParameters(void);
497 
498  virtual void ComputeMatrix(void);
499 
500  void SetVarMatrix(const MatrixType & matrix)
501  {
502  m_Matrix = matrix; m_MatrixMTime.Modified();
503  }
504 
505  virtual void ComputeTranslation(void);
506 
507  void SetVarTranslation(const OutputVectorType & translation)
508  {
509  m_Translation = translation;
510  }
511 
512  virtual void ComputeOffset(void);
513 
514  void SetVarOffset(const OutputVectorType & offset)
515  {
516  m_Offset = offset;
517  }
518 
519  void SetVarCenter(const InputPointType & center)
520  {
521  m_Center = center;
522  }
523 
524 private:
525 
526  MatrixOffsetTransformBase(const Self & other);
527  const Self & operator=(const Self &);
528 
529  MatrixType m_Matrix; // Matrix of the transformation
530  OutputVectorType m_Offset; // Offset of the transformation
531  mutable InverseMatrixType m_InverseMatrix; // Inverse of the matrix
532  mutable bool m_Singular; // Is m_Inverse singular?
533 
536 
540 }; // class MatrixOffsetTransformBase
541 } // namespace itk
542 
543 #ifndef ITK_MANUAL_INSTANTIATION
544 #include "itkMatrixOffsetTransformBase.hxx"
545 #endif
546 
547 #endif /* __itkMatrixOffsetTransformBase_h */
548