X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkTransformUtilities.h;h=562ed63a67e11facfdcc07ff960fd5456394613a;hb=d55f025b18f68066a52b8f33c2dc6481e82c2580;hp=778fc973e18b82cfba176746abba3a2c90f3a77a;hpb=c2969de5a9d788ad06178e4d79947603ac40cbac;p=clitk.git diff --git a/common/clitkTransformUtilities.h b/common/clitkTransformUtilities.h index 778fc97..562ed63 100644 --- a/common/clitkTransformUtilities.h +++ b/common/clitkTransformUtilities.h @@ -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,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #ifndef CLITKTRANSFORMUTILITIES_H #define CLITKTRANSFORMUTILITIES_H @@ -23,7 +23,9 @@ #include "itkPoint.h" #include "clitkImageCommon.h" #include "clitkCommon.h" - +#define VTK_EXCLUDE_STRSTREAM_HEADERS +#include +#include namespace clitk { @@ -32,12 +34,15 @@ namespace clitk //============================================================================ itk::Matrix GetForwardAffineMatrix2D(itk::Array transformParameters); itk::Matrix GetForwardAffineMatrix3D(itk::Array transformParameters); + template itk::Matrix GetForwardAffineMatrix(itk::Array transformParameters); itk::Matrix GetBackwardAffineMatrix2D(itk::Array transformParameters); itk::Matrix GetBackwardAffineMatrix3D(itk::Array transformParameters); template itk::Matrix GetBackwardAffineMatrix(itk::Array transformParameters); itk::Matrix GetRotationMatrix3D(itk::Array rotationParameters); + itk::Matrix GetRotationMatrix2D(itk::Array rotationParameters); + template itk::Matrix GetRotationMatrix(itk::Array rotationParameters); itk::Point GetRotatedPoint3D(itk::Array rotationParameters, itk::Point input); itk::Matrix GetCenteredRotationMatrix3D(itk::Array rotationParameters,itk::Point centerOfRotation); // itk::Matrix GetComposedMatrix3D(itk::Matrix firstTransform, itk::Matrix secondTransform); @@ -166,9 +171,17 @@ namespace clitk matrix[2][2]= cos(rotationParameters[0])*cos(rotationParameters[1]); return matrix; } - - - + + inline itk::Matrix GetRotationMatrix2D(itk::Array rotationParameters) + { + itk::Matrix matrix; + matrix[0][0] = cos(rotationParameters[0]); + matrix[1][0] = sin(rotationParameters[0]); + matrix[0][1] = -matrix[1][0]; + matrix[1][1] = matrix[0][0]; + return matrix; + } + //======================================================================================== inline itk::Point GetRotatedPoint3D(itk::Array rotationParameters, itk::Point input) { @@ -243,8 +256,9 @@ namespace clitk return matrix; } - inline itk::Matrix ReadMatrix3D(std::string fileName) - { + itk::Matrix ReadMatrix3D(std::string fileName); + + inline vtkMatrix4x4* ReadVTKMatrix3D(std::string fileName) { // read input matrix std::ifstream is; openFileForReading(is, fileName); @@ -255,18 +269,18 @@ namespace clitk while (!is.eof()) { nb.push_back(x); skipComment(is); - is >> x; + is >> x; } - - //copy it to the matrix - itk::Matrix matrix; + + vtkSmartPointer matrix = vtkSmartPointer::New(); 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; + matrix->SetElement(i,j, nb[index++]); + + return matrix; } - + inline itk::Matrix ReadMatrix2D(std::string fileName) { // read input matrix