X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=Testing%2FTestFileAccessors.cxx;h=c48a69cf4e9185fb64b8cf9f56cc9a2103dd4776;hb=4e0fff9935d03469ce6d7484e5f43dddb06e251b;hp=8be0e831db225953eabe9a396c9a61faa9d9a781;hpb=99527f7d2edc2714942c0837cb56ff333b9fbb92;p=gdcm.git diff --git a/Testing/TestFileAccessors.cxx b/Testing/TestFileAccessors.cxx index 8be0e831..c48a69cf 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: 2005/11/25 15:56:31 $ + Version: $Revision: 1.6 $ 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,51 @@ #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" +#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; \ + f->Delete(); \ + return 1; \ + } + + int TestFileAccessors(int, char *[]) { int i = 0; - float iop[6]; + double iop[6]; while( gdcmDataImages[i] != 0 ) { + + if (gdcmDataImages[i] == "00191113.dcm" ) + gdcm::Debug::DebugOn(); + else + gdcm::Debug::DebugOff(); + std::string filename = GDCM_DATA_ROOT; filename += "/"; //doh! filename += gdcmDataImages[i]; - gdcm::File *f= new gdcm::File( ); + std::cout << "Begin with " << filename << std::endl; + gdcm::File *f= gdcm::File::New( ); f->SetFileName( filename ); f->Load( ); @@ -59,78 +77,75 @@ 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; 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; } - delete f; + f->Delete(); + std::cout << "End with " << filename << std::endl; i++; } return 0;