X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestFileAccessors.cxx;h=b242ccbbfe279d13d1380d6b957ca4ba5494cf94;hb=d9f8b4b69e332d38e9c883ba60f40dc858883de9;hp=ff1ea02b56c25caff1782a85139d8b313976e619;hpb=eacd2efd90ffb9015d6358f135cb17a838a29abb;p=gdcm.git diff --git a/Testing/TestFileAccessors.cxx b/Testing/TestFileAccessors.cxx index ff1ea02b..b242ccbb 100644 --- a/Testing/TestFileAccessors.cxx +++ b/Testing/TestFileAccessors.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestFileAccessors.cxx,v $ Language: C++ - Date: $Date: 2005/10/20 08:58:15 $ - Version: $Revision: 1.4 $ + Date: $Date: 2007/06/21 14:59:06 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,33 +37,58 @@ //Generated file: #include "gdcmDataImages.h" -#define TestMethodMacro(mode,obj,name) \ - try \ - { \ - std::cout << " " << #name << "() : " << mode << obj->name() << std::endl; \ - } \ - catch(...) \ - { \ - std::cout << " --> Can't access to the '" << #name << "' method !" << std::endl; \ - delete f; \ - return 1; \ +#define TestMethodMacro(mode,obj,name) \ + try \ + { \ + std::cout <<" "<< #name << "() : " \ + << std::endl; \ + std::cout << " " \ + << mode << obj->name() << std::endl; \ + } \ + catch(...) \ + { \ + std::cout << " --> Can't access to the '" \ + << #name << "' method !" << std::endl;\ + f->Delete(); \ + return 1; \ } - -int TestFileAccessors(int, char *[]) +int TestFileAccessors(int argc, char *argv[]) { int i = 0; float iop[6]; + float ipp[3]; + // gdcm::Debug::DebugOn(); + while( gdcmDataImages[i] != 0 ) { - std::string filename = GDCM_DATA_ROOT; - filename += "/"; //doh! - filename += gdcmDataImages[i]; + + // Keep the comment to be able to track a bug on a given image + // for all the OS. + + // if (gdcmDataImages[i] == "00191113.dcm" ) + // gdcm::Debug::DebugOn(); + // else + // gdcm::Debug::DebugOff(); + + std::string filename; + if (argc ==2) + { + filename = argv[1]; + } + else + { + filename = GDCM_DATA_ROOT; + filename += "/"; //doh! + filename += gdcmDataImages[i]; + } - std::cout << "Begin with " << filename << std::endl; - gdcm::File *f= new gdcm::File( ); + std::cout << " ----------------------------------------------" + << "Begin with " << filename << std::endl; + + GDCM_NAME_SPACE::File *f= GDCM_NAME_SPACE::File::New( ); f->SetFileName( filename ); f->Load( ); @@ -114,12 +139,17 @@ int TestFileAccessors(int, char *[]) std::cout << " Orientation:" << std::endl; for (int j=0; j<6; j++) std::cout << " iop[" << j << "] = " << iop[j] << std::endl; + + f->GetImagePositionPatient( ipp ); + std::cout << " Position:" << std::endl; + for (int j2=0; j2<3; j2++) + std::cout << " ipp[" << j2 << "] = " << ipp[j2] << std::endl; if( f->IsReadable() ) { std::cout << " " << filename << " is Readable" << std::endl; - gdcm::FileHelper *fh= new gdcm::FileHelper( f ); + GDCM_NAME_SPACE::FileHelper *fh= GDCM_NAME_SPACE::FileHelper::New( f ); TestMethodMacro(std::dec,fh,GetImageDataSize) TestMethodMacro(std::dec,fh,GetImageDataRawSize) @@ -128,18 +158,20 @@ int TestFileAccessors(int, char *[]) TestMethodMacro(std::dec,fh,GetUserDataSize) TestMethodMacro(std::dec,fh,GetWriteType) - delete fh; + fh->Delete(); } else { std::cout << filename << " is NOT Readable" << std::endl << std::endl; - delete f; + f->Delete(); return 1; } + f->Delete(); + + if (argc ==2) + break; // user asked to check a single file. - delete f; - std::cout << "End with " << filename << std::endl; i++; } return 0;