X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestFileAccessors.cxx;h=b242ccbbfe279d13d1380d6b957ca4ba5494cf94;hb=e30f8921333d9d406a6e252c259b7891458c28b2;hp=5a55f1069e2ae9c58105ffa2254ee42f746074df;hpb=c74bc8cb4308864bd6e9c4f1bdf96d7af51c0ef2;p=gdcm.git diff --git a/Testing/TestFileAccessors.cxx b/Testing/TestFileAccessors.cxx index 5a55f106..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/02/03 09:51:53 $ - Version: $Revision: 1.1 $ + 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 @@ -25,110 +25,153 @@ #include "gdcmFileHelper.h" #include "gdcmUtil.h" #include "gdcmCommon.h" -#include "gdcmBinEntry.h" #include "gdcmDocEntry.h" #include "gdcmDocEntrySet.h" #include "gdcmDocument.h" #include "gdcmElementSet.h" #include "gdcmSeqEntry.h" #include "gdcmSQItem.h" -#include "gdcmValEntry.h" #include //Generated file: #include "gdcmDataImages.h" -int TestFileAccessors(int, char *[]) +#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 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 *e1= new gdcm::File( filename ); + GDCM_NAME_SPACE::File *f= GDCM_NAME_SPACE::File::New( ); + f->SetFileName( filename ); + f->Load( ); // We don't check the returned values // We just want to be sure no accessor seg faults on any image ... // And this will improve test coverage ;-) - std::cout << "GetSwapCode()" << e1->GetSwapCode() << std::endl; - std::cout << "GetImageNumber()" << e1->GetImageNumber() << std::endl; - std::cout << "GetModality()" << e1->GetModality() << std::endl; - std::cout << "GetXSize()" << e1->GetXSize() << std::endl; - std::cout << "GetYSize()" << e1->GetYSize() << std::endl; - std::cout << "GetZSize()" << e1->GetZSize() << std::endl; - std::cout << "GetXSpacing()" << e1->GetXSpacing() << std::endl; - std::cout << "GetYSpacing()" << e1->GetYSpacing() << std::endl; - std::cout << "GetZSpacing()" << e1->GetZSpacing() << std::endl; - std::cout << "GetXOrigin()" << e1->GetXOrigin() << std::endl; - std::cout << "GetYOrigin()" << e1->GetYOrigin() << std::endl; - std::cout << "GetZOrigin()" << e1->GetZOrigin() << std::endl; - std::cout << "GetBitsStored()" << e1->GetBitsStored() << std::endl; - std::cout << "GetBitsAllocated()" << e1->GetBitsAllocated() << std::endl; - std::cout << "GetHighBitPosition()" << e1->GetHighBitPosition() << std::endl; - std::cout << "GetSamplesPerPixel()" << e1->GetSamplesPerPixel() << std::endl; - std::cout << "GetPlanarConfiguration()" << e1->GetPlanarConfiguration() << std::endl; - std::cout << "GetPixelSize()" << e1->GetPixelSize() << std::endl; - std::cout << "GetPixelType()" << e1->GetPixelType() << std::endl; - std::cout << "GetLUTNbits()" << e1->GetLUTNbits() << std::endl; - std::cout << "GetRescaleIntercept()" << e1->GetRescaleIntercept() << std::endl; - std::cout << "GetRescaleSlope()" << e1->GetRescaleSlope() << std::endl; - std::cout << "GetGrPixel()" << std::hex << e1->GetGrPixel() << std::endl; - std::cout << "GetNumPixel()" << std::hex << e1->GetNumPixel() << std::endl; - std::cout << "GetPixelOffset()" << e1->GetPixelOffset() << std::endl; - - std::cout << "GetPixelAreaLength()" << e1->GetPixelAreaLength()<< std::endl; - std::cout << "GetNumberOfScalarComponents()" << e1->GetNumberOfScalarComponents()<< std::endl; - std::cout << "GetNumberOfScalarComponentsRaw()" << e1->GetNumberOfScalarComponentsRaw()<< std::endl; - std::cout << "IsSignedPixelData()" << e1->IsSignedPixelData()<< std::endl; - std::cout << "IsMonochrome()" << e1->IsMonochrome() << std::endl; - std::cout << "IsPaletteColor()" << e1->IsPaletteColor() << std::endl; - std::cout << "IsYBRFull()" << e1->IsYBRFull() << std::endl; - std::cout << "HasLut() " << e1->HasLUT() << std::endl; - std::cout << "GetTransferSyntax()" << e1->GetTransferSyntax() << std::endl; - std::cout << "GetTransferSyntaxName()" << e1->GetTransferSyntaxName() << std::endl; - std::cout << "GetFileType()" << e1->GetFileType() << std::endl; - std::cout << "GetFileName()" << e1->GetFileName() << std::endl; - - e1->GetImageOrientationPatient( iop ); + TestMethodMacro(std::dec,f,GetSwapCode) + TestMethodMacro(std::dec,f,GetImageNumber) + TestMethodMacro(std::dec,f,GetModality) + TestMethodMacro(std::dec,f,GetXSize) + TestMethodMacro(std::dec,f,GetYSize) + TestMethodMacro(std::dec,f,GetZSize) + TestMethodMacro(std::dec,f,GetXSpacing) + TestMethodMacro(std::dec,f,GetYSpacing) + TestMethodMacro(std::dec,f,GetZSpacing) + TestMethodMacro(std::dec,f,GetXOrigin) + TestMethodMacro(std::dec,f,GetYOrigin) + TestMethodMacro(std::dec,f,GetZOrigin) + TestMethodMacro(std::dec,f,GetBitsStored) + TestMethodMacro(std::dec,f,GetBitsAllocated) + TestMethodMacro(std::dec,f,GetHighBitPosition) + TestMethodMacro(std::dec,f,GetSamplesPerPixel) + TestMethodMacro(std::dec,f,GetPlanarConfiguration) + TestMethodMacro(std::dec,f,GetPixelSize) + TestMethodMacro(std::dec,f,GetPixelType) + TestMethodMacro(std::dec,f,GetLUTNbits) + TestMethodMacro(std::dec,f,GetRescaleIntercept) + TestMethodMacro(std::dec,f,GetRescaleSlope) + TestMethodMacro(std::hex,f,GetGrPixel) + TestMethodMacro(std::hex,f,GetNumPixel) + TestMethodMacro(std::dec,f,GetPixelOffset) + + TestMethodMacro(std::dec,f,GetPixelAreaLength) + TestMethodMacro(std::dec,f,GetNumberOfScalarComponents) + TestMethodMacro(std::dec,f,GetNumberOfScalarComponentsRaw) + TestMethodMacro(std::dec,f,IsSignedPixelData) + TestMethodMacro(std::dec,f,IsMonochrome) + TestMethodMacro(std::dec,f,IsPaletteColor) + TestMethodMacro(std::dec,f,IsYBRFull) + TestMethodMacro(std::dec,f,HasLUT) + TestMethodMacro(std::dec,f,GetTransferSyntax) + TestMethodMacro(std::dec,f,GetTransferSyntaxName) + TestMethodMacro(std::dec,f,GetFileType) + TestMethodMacro(std::dec,f,GetFileName) + + f->GetImageOrientationPatient( iop ); + std::cout << " Orientation:" << std::endl; for (int j=0; j<6; j++) - std::cout << "iop[" << j << "] = " << iop[j] << std::endl; + 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( e1->IsReadable() ) + if( f->IsReadable() ) { - std::cout <GetImageDataSize() << std::endl; - std::cout << "GetImageDataRawSize()" << fh1->GetImageDataRawSize() << std::endl; - // User Data - std::cout << "GetRGBDataSize()" << fh1->GetRGBDataSize() << std::endl; - std::cout << "GetRawDataSize()" << fh1->GetRawDataSize() << std::endl; - std::cout << "GetUserDataSize()" << fh1->GetUserDataSize() << std::endl; - - std::cout << "GetWriteType()" << fh1->GetWriteType() << std::endl; - - delete fh1; + fh->Delete(); } else { std::cout << filename << " is NOT Readable" << std::endl << std::endl; - delete e1; + f->Delete(); return 1; } + f->Delete(); + + if (argc ==2) + break; // user asked to check a single file. - delete e1; i++; } return 0;