X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllReadCompareDicom.cxx;h=23563114b754b500921f210be3d6f65b8bc96472;hb=223e9fe80278019fef96c2b926c4df6fcacd4d3b;hp=19c473391b7e7062c3a43ad1dd062cd0a0b92cb3;hpb=b9696a96680588a28191dacbeb955c8622c13321;p=gdcm.git diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index 19c47339..23563114 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllReadCompareDicom.cxx,v $ Language: C++ - Date: $Date: 2005/04/15 21:41:43 $ - Version: $Revision: 1.35 $ + Date: $Date: 2005/05/02 17:56:44 $ + Version: $Revision: 1.42 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -18,9 +18,10 @@ #include "gdcmDirList.h" #include "gdcmFile.h" #include "gdcmFileHelper.h" +#include "gdcmGlobal.h" +#include "gdcmTS.h" #include -#include //Generated file: #include "gdcmDataImages.h" @@ -76,19 +77,19 @@ private: bool WriteFileData(std::ofstream *fp); uint8_t ReadInt8 (std::ifstream *fp) -#if !(__GNUC__==2 && __GNUC_MINOR__==96) - throw( std::ofstream::failure ); +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) + throw( std::ios::failure ); #else ; #endif uint16_t ReadInt16(std::ifstream *fp) -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) throw( std::ios::failure ); #else ; #endif uint32_t ReadInt32(std::ifstream *fp) -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) throw( std::ios::failure ); #else ; @@ -103,17 +104,18 @@ private: int sizeX; int sizeY; int sizeZ; - int scalarSize; - int components; + uint16_t scalarSize; + uint16_t components; uint8_t *data; int swapCode; static const unsigned int HEADER_SIZE; }; +const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10; const unsigned int TestFile::HEADER_SIZE = 20; -TestFile::TestFile(void) +TestFile::TestFile() { fileName = ""; readable=false; @@ -248,7 +250,7 @@ bool TestFile::ReadFileHeader(std::ifstream *fp) sizeY = ReadInt32(fp); // Size Y sizeZ = ReadInt32(fp); // Size Z scalarSize = ReadInt16(fp)/8; // bits per scalar - components = ReadInt16(fp); // Number of components + components = ReadInt16(fp); // Number of components return(true); } @@ -294,7 +296,7 @@ bool TestFile::WriteFileHeader(std::ofstream *fp) WriteInt32(fp,sizeY); // Size Y WriteInt32(fp,sizeZ); // Size Z WriteInt16(fp,scalarSize*8); // bits per scalar - WriteInt16(fp,components); // number of components + WriteInt16(fp,components); // number of components return(true); } @@ -307,13 +309,13 @@ bool TestFile::WriteFileData(std::ofstream *fp) } uint8_t TestFile::ReadInt8 (std::ifstream *fp) -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) throw( std::ios::failure ) #endif { uint8_t g; fp->read ((char*)&g, (size_t)1); -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) if ( fp->fail() ) throw std::ios::failure( "TestFile::ReadInt8() - file error." ); if( fp->eof() ) @@ -323,13 +325,13 @@ uint8_t TestFile::ReadInt8 (std::ifstream *fp) } uint16_t TestFile::ReadInt16(std::ifstream *fp) -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) throw( std::ios::failure ) #endif { uint16_t g; fp->read ((char*)&g, (size_t)2); -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) if ( fp->fail() ) throw std::ios::failure( "TestFile::ReadInt16() - file error." ); if( fp->eof() ) @@ -343,13 +345,13 @@ uint16_t TestFile::ReadInt16(std::ifstream *fp) } uint32_t TestFile::ReadInt32(std::ifstream *fp) -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) throw( std::ios::failure ) #endif { uint32_t g; fp->read ((char*)&g, (size_t)4); -#if !(__GNUC__==2 && __GNUC_MINOR__==96) +#if !(__GNUC__==2 && __GNUC_MINOR__<=96) if ( fp->fail() ) throw std::ios::failure( "TestFile::ReadInt32() - file error." ); if( fp->eof() ) @@ -503,11 +505,34 @@ int InternalTest(std::string const &filename, testedDataSize) != 0 ) { (void)res; + std::string ts = tested->GetFile()->GetTransferSyntax(); + std::cout << " Failed" << std::endl << " pixel (" << PixelType << ") differ (as expanded in memory)." + << std::endl + << " compression : " + << gdcm::Global::GetTS()->GetValue(ts) << std::endl; + + std::cout << " list of the first " << MAX_NUMBER_OF_DIFFERENCE + << " pixels differing (pos : test - ref) :" << std::endl; + int i; + unsigned int j; + for(i=0, j=0;i