ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkScalableAffineTransform.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkScalableAffineTransform_h
00019 #define __itkScalableAffineTransform_h
00020 
00021 #include "itkAffineTransform.h"
00022 
00023 namespace itk
00024 {
00033 template<
00034   class TScalarType = double,   // Data type for scalars (e.g. float or double)
00035   unsigned int NDimensions = 3 >
00036 // Number of dimensions in the input space
00037 class ITK_EXPORT ScalableAffineTransform:
00038   public AffineTransform< TScalarType, NDimensions >
00039 {
00040 public:
00042   typedef ScalableAffineTransform                     Self;
00043   typedef AffineTransform< TScalarType, NDimensions > Superclass;
00044   typedef SmartPointer< Self >                        Pointer;
00045   typedef SmartPointer< const Self >                  ConstPointer;
00046 
00048   itkTypeMacro(ScalableAffineTransform, AffineTransform);
00049 
00051   itkNewMacro(Self);
00052 
00054   itkStaticConstMacro(InputSpaceDimension, unsigned int, NDimensions);
00055   itkStaticConstMacro(OutputSpaceDimension, unsigned int, NDimensions);
00056   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00057   itkStaticConstMacro( ParametersDimension, unsigned int,
00058                        NDimensions * ( NDimensions + 1 ) );
00060 
00062   typedef typename Superclass::ParametersType            ParametersType;
00063   typedef typename Superclass::ParametersValueType       ParametersValueType;
00064   typedef typename Superclass::JacobianType              JacobianType;
00065   typedef typename Superclass::ScalarType                ScalarType;
00066   typedef typename Superclass::InputVectorType           InputVectorType;
00067   typedef typename Superclass::OutputVectorType          OutputVectorType;
00068   typedef typename Superclass::InputCovariantVectorType  InputCovariantVectorType;
00069   typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
00070   typedef typename Superclass::InputVnlVectorType        InputVnlVectorType;
00071   typedef typename Superclass::OutputVnlVectorType       OutputVnlVectorType;
00072   typedef typename Superclass::InputPointType            InputPointType;
00073   typedef typename Superclass::OutputPointType           OutputPointType;
00074   typedef typename Superclass::MatrixType                MatrixType;
00075   typedef typename Superclass::MatrixValueType           MatrixValueType;
00076   typedef typename Superclass::InverseMatrixType         InverseMatrixType;
00077   typedef typename Superclass::CenterType                CenterType;
00078   typedef typename Superclass::OffsetType                OffsetType;
00079   typedef typename Superclass::TranslationType           TranslationType;
00080 
00083   typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
00084   typedef typename InverseTransformBaseType::Pointer    InverseTransformBasePointer;
00085 
00089   void SetIdentity(void);
00090 
00092   virtual void SetScale(const InputVectorType & scale);
00093 
00094   virtual void SetScaleComponent(const InputVectorType & scale)
00095   { this->SetScale(scale); }
00096 
00098   virtual void SetScale(const double scale[NDimensions]);
00099 
00100   virtual void SetScaleComponent(const double scale[NDimensions])
00101   { this->SetScale(scale); }
00102 
00104   virtual const double * GetScale() const
00105   { return m_Scale; }
00106   virtual const double * GetScaleComponent() const
00107   { return m_Scale; }
00109 
00114   void SetMatrixComponent(const MatrixType & matrix)
00115   { this->SetMatrix(matrix); }
00116 
00120   const MatrixType & GetMatrixComponent() const
00121   { return this->GetMatrix(); }
00122 
00126   void SetOffsetComponent(const OffsetType & offset)
00127   { this->SetTranslation(offset); }
00128 
00132   const OffsetType & GetOffsetComponent(void) const
00133   { return this->GetTranslation(); }
00134 
00136   bool GetInverse(Self *inverse) const;
00137 
00139   virtual InverseTransformBasePointer GetInverseTransform() const;
00140 
00141 protected:
00149   ScalableAffineTransform(const MatrixType & matrix,
00150                           const OutputVectorType & offset);
00151   ScalableAffineTransform(unsigned int outputSpaceDimension,
00152                           unsigned int parametersDimension);
00153   ScalableAffineTransform(unsigned int parametersDimension);
00154   ScalableAffineTransform();
00156 
00157   void ComputeMatrix();
00158 
00160   virtual ~ScalableAffineTransform();
00161 
00163   void PrintSelf(std::ostream & s, Indent indent) const;
00164 
00165   void SetVarScale(const double *scale)
00166   { for ( int i = 0; i < InputSpaceDimension; i++ ) { m_Scale[i] = scale[i]; } }
00167 private:
00168 
00169   ScalableAffineTransform(const Self & other);
00170   const Self & operator=(const Self &);
00171 
00172   double          m_Scale[NDimensions];
00173   InputVectorType m_MatrixScale;
00174 }; //class ScalableAffineTransform
00175 }  // namespace itk
00176 
00177 // Define instantiation macro for this template.
00178 #define ITK_TEMPLATE_ScalableAffineTransform(_, EXPORT, TypeX, TypeY)     \
00179   namespace itk                                                           \
00180   {                                                                       \
00181   _( 2 ( class EXPORT ScalableAffineTransform< ITK_TEMPLATE_2 TypeX > ) ) \
00182   namespace Templates                                                     \
00183   {                                                                       \
00184   typedef ScalableAffineTransform< ITK_TEMPLATE_2 TypeX >                 \
00185   ScalableAffineTransform##TypeY;                                       \
00186   }                                                                       \
00187   }
00188 
00189 #if ITK_TEMPLATE_EXPLICIT
00190 #include "Templates/itkScalableAffineTransform+-.h"
00191 #endif
00192 
00193 #if ITK_TEMPLATE_TXX
00194 #include "itkScalableAffineTransform.hxx"
00195 #endif
00196 
00197 #endif /* __itkScalableAffineTransform_h */
00198