X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkTransformUtilities.cxx;h=832d5983eed109898fe427337ec9b4f6dd0a8483;hb=08f7de414957e92b25ca5b299007e941b610d3a8;hp=b5512489bd6b7db790359f24752d544fa0de1734;hpb=58074f0d36fda9b8a06d046438cefa36086c891b;p=clitk.git diff --git a/common/clitkTransformUtilities.cxx b/common/clitkTransformUtilities.cxx index b551248..832d598 100644 --- a/common/clitkTransformUtilities.cxx +++ b/common/clitkTransformUtilities.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,13 +14,29 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #include "clitkTransformUtilities.h" namespace clitk { +//-------------------------------------------------------------------- +template < > +itk::Matrix +GetForwardAffineMatrix<2>(itk::Array transformParameters) +{ + return GetForwardAffineMatrix2D(transformParameters); +} + +//-------------------------------------------------------------------- +template < > +itk::Matrix +GetForwardAffineMatrix<3>(itk::Array transformParameters) +{ + return GetForwardAffineMatrix3D(transformParameters); +} + //-------------------------------------------------------------------- template < > itk::Matrix @@ -37,4 +53,46 @@ GetBackwardAffineMatrix<3>(itk::Array transformParameters) return GetBackwardAffineMatrix3D(transformParameters); } +//-------------------------------------------------------------------- +template <> +itk::Matrix GetRotationMatrix<2>(itk::Array rotationParameters) +{ + return GetRotationMatrix2D(rotationParameters); +} + +//-------------------------------------------------------------------- +template <> +itk::Matrix GetRotationMatrix<3>(itk::Array rotationParameters) +{ + return GetRotationMatrix3D(rotationParameters); +} + +//-------------------------------------------------------------------- +itk::Matrix ReadMatrix3D(std::string fileName) +{ + // read input matrix + std::ifstream is; + openFileForReading(is, fileName); + std::vector nb; + double x; + skipComment(is); + is >> x; + while (is && !is.eof()) { + nb.push_back(x); + skipComment(is); + is >> x; + } + + if(nb.size() != 16) + itkGenericExceptionMacro(<< "Could not read 4x4 matrix in " << fileName); + + //copy it to the matrix + itk::Matrix matrix; + unsigned int index=0; + for (unsigned int i=0;i<4;i++) + for (unsigned int j=0;j<4;j++) + matrix[i][j]=nb[index++]; + return matrix; +} + }