X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestFileAccessors.cxx;h=b242ccbbfe279d13d1380d6b957ca4ba5494cf94;hb=5071bc6d73c22304b8b139d040a02eb3e1f33407;hp=8be0e831db225953eabe9a396c9a61faa9d9a781;hpb=99527f7d2edc2714942c0837cb56ff333b9fbb92;p=gdcm.git diff --git a/Testing/TestFileAccessors.cxx b/Testing/TestFileAccessors.cxx index 8be0e831..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/07/08 13:39:57 $ - Version: $Revision: 1.2 $ + 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,33 +25,70 @@ #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]; + } - 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( ); @@ -59,78 +96,82 @@ int TestFileAccessors(int, char *[]) // We just want to be sure no accessor seg faults on any image ... // And this will improve test coverage ;-) - std::cout << "GetSwapCode()" << f->GetSwapCode() << std::endl; - std::cout << "GetImageNumber()" << f->GetImageNumber() << std::endl; - std::cout << "GetModality()" << f->GetModality() << std::endl; - std::cout << "GetXSize()" << f->GetXSize() << std::endl; - std::cout << "GetYSize()" << f->GetYSize() << std::endl; - std::cout << "GetZSize()" << f->GetZSize() << std::endl; - std::cout << "GetXSpacing()" << f->GetXSpacing() << std::endl; - std::cout << "GetYSpacing()" << f->GetYSpacing() << std::endl; - std::cout << "GetZSpacing()" << f->GetZSpacing() << std::endl; - std::cout << "GetXOrigin()" << f->GetXOrigin() << std::endl; - std::cout << "GetYOrigin()" << f->GetYOrigin() << std::endl; - std::cout << "GetZOrigin()" << f->GetZOrigin() << std::endl; - std::cout << "GetBitsStored()" << f->GetBitsStored() << std::endl; - std::cout << "GetBitsAllocated()" << f->GetBitsAllocated() << std::endl; - std::cout << "GetHighBitPosition()" << f->GetHighBitPosition() << std::endl; - std::cout << "GetSamplesPerPixel()" << f->GetSamplesPerPixel() << std::endl; - std::cout << "GetPlanarConfiguration()" << f->GetPlanarConfiguration() << std::endl; - std::cout << "GetPixelSize()" << f->GetPixelSize() << std::endl; - std::cout << "GetPixelType()" << f->GetPixelType() << std::endl; - std::cout << "GetLUTNbits()" << f->GetLUTNbits() << std::endl; - std::cout << "GetRescaleIntercept()" << f->GetRescaleIntercept() << std::endl; - std::cout << "GetRescaleSlope()" << f->GetRescaleSlope() << std::endl; - std::cout << "GetGrPixel()" << std::hex << f->GetGrPixel() << std::endl; - std::cout << "GetNumPixel()" << std::hex << f->GetNumPixel() << std::endl; - std::cout << "GetPixelOffset()" << f->GetPixelOffset() << std::endl; - - std::cout << "GetPixelAreaLength()" << f->GetPixelAreaLength()<< std::endl; - std::cout << "GetNumberOfScalarComponents()" << f->GetNumberOfScalarComponents()<< std::endl; - std::cout << "GetNumberOfScalarComponentsRaw()" << f->GetNumberOfScalarComponentsRaw()<< std::endl; - std::cout << "IsSignedPixelData()" << f->IsSignedPixelData()<< std::endl; - std::cout << "IsMonochrome()" << f->IsMonochrome() << std::endl; - std::cout << "IsPaletteColor()" << f->IsPaletteColor() << std::endl; - std::cout << "IsYBRFull()" << f->IsYBRFull() << std::endl; - std::cout << "HasLut() " << f->HasLUT() << std::endl; - std::cout << "GetTransferSyntax()" << f->GetTransferSyntax() << std::endl; - std::cout << "GetTransferSyntaxName()" << f->GetTransferSyntaxName() << std::endl; - std::cout << "GetFileType()" << f->GetFileType() << std::endl; - std::cout << "GetFileName()" << f->GetFileName() << std::endl; + 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( f->IsReadable() ) { - std::cout <GetImageDataSize() << std::endl; - std::cout << "GetImageDataRawSize()" << fh->GetImageDataRawSize() << std::endl; - // User Data - std::cout << "GetRGBDataSize()" << fh->GetRGBDataSize() << std::endl; - std::cout << "GetRawDataSize()" << fh->GetRawDataSize() << std::endl; - std::cout << "GetUserDataSize()" << fh->GetUserDataSize() << std::endl; - - std::cout << "GetWriteType()" << fh->GetWriteType() << std::endl; + TestMethodMacro(std::dec,fh,GetImageDataSize) + TestMethodMacro(std::dec,fh,GetImageDataRawSize) + TestMethodMacro(std::dec,fh,GetRGBDataSize) + TestMethodMacro(std::dec,fh,GetRawDataSize) + 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; i++; } return 0;