From: Simon Rit Date: Tue, 25 Nov 2014 06:51:24 +0000 (+0100) Subject: Improved robustness of ImagX xml file reader X-Git-Tag: v1.4.0~105 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=05ce426737d3b387d2d787e71ed3ffead2b1ae13;p=clitk.git Improved robustness of ImagX xml file reader --- diff --git a/common/rtkImagXImageIO.cxx b/common/rtkImagXImageIO.cxx index d197ed7..09cb910 100644 --- a/common/rtkImagXImageIO.cxx +++ b/common/rtkImagXImageIO.cxx @@ -57,7 +57,7 @@ void rtk::ImagXImageIO::ReadImageInformation() if(pixelType=="Type_float") SetComponentType(itk::ImageIOBase::FLOAT); - if(dic["dimensions"].GetPointer()==NULL) + if( dic["dimensions"].GetPointer() == NULL ) SetNumberOfDimensions(3); else SetNumberOfDimensions( ( dynamic_cast(dic["dimensions"].GetPointer() )->GetMetaDataObjectValue() ) ); @@ -73,15 +73,22 @@ void rtk::ImagXImageIO::ReadImageInformation() { SetDimensions(2, dynamic_cast(dic["z"].GetPointer() )->GetMetaDataObjectValue() ); SetSpacing(2, dynamic_cast(dic["spacing_z"].GetPointer() )->GetMetaDataObjectValue() ); + if(GetSpacing(2) == 0) + SetSpacing(2, 1); } - std::istringstream iss( - dynamic_cast(dic["matrixTransform"].GetPointer() )->GetMetaDataObjectValue() ); itk::Matrix matrix; - for(unsigned int j=0; j<4; j++) - for(unsigned int i=0; i<4; i++) - iss >> matrix[j][i]; - matrix /= matrix[3][3]; + if(dic["matrixTransform"].GetPointer() == NULL) + matrix.SetIdentity(); + else + { + std::istringstream iss( + dynamic_cast(dic["matrixTransform"].GetPointer() )->GetMetaDataObjectValue() ); + for(unsigned int j=0; j<4; j++) + for(unsigned int i=0; i<4; i++) + iss >> matrix[j][i]; + matrix /= matrix[3][3]; + } std::vector direction; for(unsigned int i=0; i