1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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 copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
19 #ifndef __clitkGenericAffineTransform_txx
20 #define __clitkGenericAffineTransform_txx
22 #include "clitkTransformUtilities.h"
27 //=========================================================================================================================
29 template<class args_info_type, class TCoordRep, unsigned int Dimension>
30 GenericAffineTransform<args_info_type, TCoordRep, Dimension>::GenericAffineTransform()
36 //=========================================================================================================================
38 template<class args_info_type, class TCoordRep, unsigned int Dimension>
39 typename GenericAffineTransform<args_info_type, TCoordRep, Dimension>::TransformPointer
40 GenericAffineTransform<args_info_type, TCoordRep, Dimension>::GetTransform()
42 //============================================================================
43 // We retrieve the type of transform from the command line
44 //============================================================================
45 typedef itk::MatrixOffsetTransformBase<TCoordRep, Dimension, Dimension> MatrixXType;
46 typename MatrixXType::Pointer tMatrix;
47 typedef itk::TranslationTransform< TCoordRep, Dimension> TranslationXType;
48 typename TranslationXType::Pointer tTranslation;
50 switch ( m_ArgsInfo.transform_arg ) {
52 m_Transform= itk::IdentityTransform< TCoordRep, Dimension>::New();
53 if (m_Verbose) std::cout<<"Using identity transform..."<<std::endl;
56 tTranslation = TranslationXType::New();
57 if (m_Verbose) std::cout<<"Using translation transform..."<<std::endl;
60 tMatrix = GetNewEulerTransform();
61 if (m_Verbose) std::cout<<"Using euler transform..."<<std::endl;
64 tMatrix = itk::AffineTransform< TCoordRep, Dimension >::New();
65 if (m_Verbose) std::cout<<"Using affine transform..."<<std::endl;
70 typename MatrixXType::OutputVectorType offset;
71 if(m_ArgsInfo.transform_arg>0) {
72 //Initialize translations
73 offset[0] = m_ArgsInfo.transX_arg;
74 offset[1] = m_ArgsInfo.transY_arg;
75 if(Dimension>2) offset[2] = m_ArgsInfo.transZ_arg;
76 if(m_ArgsInfo.initMatrix_given) {
77 itk::Matrix<double, Dimension+1 , Dimension+1> matHom = ReadMatrix<Dimension>(m_ArgsInfo.initMatrix_arg);
78 offset = GetTranslationPartMatrix(matHom);
81 switch(m_ArgsInfo.transform_arg) {
83 tTranslation->SetOffset(offset);
84 m_Transform=tTranslation;
88 //Init rigid and affine transform center
89 itk::Point<TCoordRep, Dimension> center;
90 for (unsigned int i=0; i<Dimension; i++)
92 tMatrix->SetCenter(center);
94 //Initialize transform
95 if(m_ArgsInfo.initMatrix_given) {
96 itk::Matrix<double, Dimension+1 , Dimension+1> matHom = ReadMatrix<Dimension>(m_ArgsInfo.initMatrix_arg);
97 typename MatrixXType::MatrixType matrix = GetRotationalPartMatrix(matHom);
98 tMatrix->SetOffset(offset);
99 tMatrix->SetMatrix(matrix);