X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllReadCompareDicom.cxx;h=d2fb988f5087435919ae0942aed0b78e8483141d;hb=7232238105e44d9569d21452e1600e00d8a44961;hp=d31b1f40cd04fb68f23589a2de8533f90fbff107;hpb=faf9f777a09c115e44b29d40a0c6ea2d122fc1e7;p=gdcm.git diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index d31b1f40..d2fb988f 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllReadCompareDicom.cxx,v $ Language: C++ - Date: $Date: 2004/12/03 20:43:36 $ - Version: $Revision: 1.22 $ + Date: $Date: 2005/02/03 10:00:06 $ + Version: $Revision: 1.30 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -15,8 +15,9 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include "gdcmHeader.h" +#include "gdcmDirList.h" #include "gdcmFile.h" +#include "gdcmFileHelper.h" #include #include @@ -24,15 +25,15 @@ //Generated file: #include "gdcmDataImages.h" -int InternalTest(std::string const & filename, - std::string const & referenceFileName ) +int InternalTest(std::string const &filename, + std::string const &referenceFileName ) { std::cout << " Testing: " << filename << std::endl; ////// Step 1: std::cout << " 1..."; - gdcm::File* tested = new gdcm::File( filename ); - if( !tested->GetHeader()->IsReadable() ) + gdcm::FileHelper *tested = new gdcm::FileHelper( filename ); + if( !tested->GetFile()->IsReadable() ) { std::cout << " Failed" << std::endl << " Image not gdcm compatible:" @@ -45,28 +46,23 @@ int InternalTest(std::string const & filename, ////// Check for existence of reference baseline dicom file: std::cout << "2..."; - //FILE* testFILE = fopen( referenceFileName.c_str(), "r" ); std::ifstream testFILE( referenceFileName.c_str() ); if (! testFILE ) { - uint8_t* testedImageData = tested->GetImageData(); // Kludge + uint8_t *testedImageData = tested->GetImageData(); // Kludge (void)testedImageData; tested->SetWriteModeToRGB(); tested->WriteDcmExplVR( referenceFileName ); } - else - { - //fclose( testFILE ); - } testFILE.close(); ////// Step 3a: ////// When reference file is not gdcm readable test is failed: std::cout << "3a..."; - gdcm::File* reference = new gdcm::File( referenceFileName ); - if( !reference->GetHeader()->IsReadable() ) + gdcm::FileHelper *reference = new gdcm::FileHelper( referenceFileName ); + if( !reference->GetFile()->IsReadable() ) { std::cout << " Failed" << std::endl << " reference image " @@ -77,27 +73,29 @@ int InternalTest(std::string const & filename, return 1; } + std::string PixelType = reference->GetFile()->GetPixelType(); + ////// Step 3b: std::cout << "3b..."; int testedDataSize = tested->GetImageDataSize(); - uint8_t* testedImageData = tested->GetImageData(); + uint8_t *testedImageData = tested->GetImageData(); int referenceDataSize = reference->GetImageDataSize(); - uint8_t* referenceImageData = reference->GetImageData(); + uint8_t *referenceImageData = reference->GetImageData(); // Test the image size - if (tested->GetHeader()->GetXSize() != reference->GetHeader()->GetXSize() || - tested->GetHeader()->GetYSize() != reference->GetHeader()->GetYSize() || - tested->GetHeader()->GetZSize() != reference->GetHeader()->GetZSize()) + if (tested->GetFile()->GetXSize() != reference->GetFile()->GetXSize() || + tested->GetFile()->GetYSize() != reference->GetFile()->GetYSize() || + tested->GetFile()->GetZSize() != reference->GetFile()->GetZSize()) { std::cout << "Failed" << std::endl << " Size differs: " - << "X: " << tested->GetHeader()->GetXSize() << " # " - << reference->GetHeader()->GetXSize() << " | " - << "Y: " << tested->GetHeader()->GetYSize() << " # " - << reference->GetHeader()->GetYSize() << " | " - << "Z: " << tested->GetHeader()->GetZSize() << " # " - << reference->GetHeader()->GetZSize() << std::endl; + << "X: " << tested->GetFile()->GetXSize() << " # " + << reference->GetFile()->GetXSize() << " | " + << "Y: " << tested->GetFile()->GetYSize() << " # " + << reference->GetFile()->GetYSize() << " | " + << "Z: " << tested->GetFile()->GetZSize() << " # " + << reference->GetFile()->GetZSize() << std::endl; delete reference; delete tested; return 1; @@ -107,7 +105,9 @@ int InternalTest(std::string const & filename, if (testedDataSize != referenceDataSize) { std::cout << " Failed" << std::endl - << " pixel areas lengths differ: " + << " pixel (" + << PixelType + <<") areas lengths differ: " << testedDataSize << " # " << referenceDataSize << std::endl; delete tested; @@ -121,7 +121,9 @@ int InternalTest(std::string const & filename, { (void)res; std::cout << " Failed" << std::endl - << " pixel differ (as expanded in memory)." + << " pixel (" + << PixelType + << ") differ (as expanded in memory)." << std::endl; delete tested; delete reference; @@ -137,7 +139,7 @@ int InternalTest(std::string const & filename, return 0; } -int TestAllReadCompareDicom(int argc, char* argv[]) +int TestAllReadCompareDicom(int argc, char *argv[]) { if ( argc == 3 ) { @@ -164,7 +166,7 @@ int TestAllReadCompareDicom(int argc, char* argv[]) << std::endl; std::cout << " apply the following to each filename.xxx: " << std::endl; - std::cout << " step 1: parse the image (as gdcmHeader) and call" + std::cout << " step 1: parse the image (as gdcmFile) and call" << " IsReadable(). " << std::endl; std::cout << " step 2: find in GDCM_DATA_ROOT/BaselineDicom/filename.dcm" @@ -195,8 +197,7 @@ int TestAllReadCompareDicom(int argc, char* argv[]) std::string baseLineDir = GDCM_DATA_ROOT; baseLineDir += "/BaselineDicom/"; - std::ifstream* testDIR = new std::ifstream(baseLineDir.c_str(), std::ios::in | std::ios::binary); - if (!testDIR ) + if( !gdcm::DirList::IsDirectory(baseLineDir) ) { std::cerr << " The reference baseline directory " << std::endl << " " @@ -205,10 +206,6 @@ int TestAllReadCompareDicom(int argc, char* argv[]) << std::endl; return 1; } - else - { - testDIR->close(); - } ////// Step 1 (see above description): std::string filename = GDCM_DATA_ROOT; @@ -217,7 +214,7 @@ int TestAllReadCompareDicom(int argc, char* argv[]) std::string referenceFileName = baseLineDir + gdcmDataImages[i++]; std::string::size_type slash_pos = referenceFileName.rfind( "." ); - if ( slash_pos != std::string::npos ) + if( slash_pos != std::string::npos ) { referenceFileName.replace( slash_pos + 1, 3, "dcm" ); }