X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestReadWriteReadCompare.cxx;h=49658d12b49c0458298db806474c799149d56ca9;hb=bd34f4ad293e74dc0f6033ad3937056a404ae342;hp=f6a2a7eb272ebf17e97cdbd18de5cfc2054edd9d;hpb=bc69950a406d06c50f0fb75a96572784965cb534;p=gdcm.git diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index f6a2a7eb..49658d12 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -1,19 +1,19 @@ /*========================================================================= - + Program: gdcm Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.25 $ - + Date: $Date: 2007/07/25 16:14:33 $ + Version: $Revision: 1.31 $ + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. - + This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. - + =========================================================================*/ #include "gdcmFile.h" #include "gdcmFileHelper.h" @@ -21,14 +21,14 @@ //Generated file: #include "gdcmDataImages.h" - + int CompareInternal(std::string const &filename, std::string const &output) { std::cout << " Testing: " << filename << std::endl; //////////////// Step 1 (see above description): - gdcm::File *file = new gdcm::File( ); + GDCM_NAME_SPACE::File *file = GDCM_NAME_SPACE::File::New( ); file->SetFileName( filename ); file->Load (); if( !file->IsReadable() ) @@ -36,42 +36,43 @@ int CompareInternal(std::string const &filename, std::string const &output) std::cout << "Failed" << std::endl << "Test::TestReadWriteReadCompare: Image not gdcm compatible:" << filename << std::endl; - delete file; + file->Delete(); return 1; } std::cout << " step 1..."; //////////////// Step 2: - gdcm::FileHelper *filehelper = new gdcm::FileHelper( file ); + GDCM_NAME_SPACE::FileHelper *filehelper = GDCM_NAME_SPACE::FileHelper::New( file ); int dataSize = filehelper->GetImageDataSize(); uint8_t *imageData = filehelper->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to // GetImageData or if he wants to GetImageDataRaw - // (even if we do it by setting a flag, he will have to decide) + // (even if we do it by setting a flag, he will have to decide) //filehelper->SetImageData(imageData, dataSize); - + filehelper->SetWriteModeToRGB(); filehelper->WriteDcmExplVR( output ); std::cout << "2..."; - + //////////////// Step 3: - gdcm::File *fileout = new gdcm::File(); + GDCM_NAME_SPACE::File *fileout = GDCM_NAME_SPACE::File::New(); fileout->SetFileName( output ); fileout->Load(); // gdcm::FileHelper *reread = new gdcm::FileHelper( output ); // deprecated if( !fileout->IsReadable() ) { - std::cout << "Failed" << std::endl - << "Test::TestReadWriteReadCompare: Could not parse the newly " - << "written image:" << filename << std::endl; - delete file; - delete filehelper; - return 1; + std::cout << "Failed" << std::endl + << "Test::TestReadWriteReadCompare: Could not parse the newly " + << "written image:" << filename << std::endl; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + return 1; } - gdcm::FileHelper *reread = new gdcm::FileHelper( fileout ); + GDCM_NAME_SPACE::FileHelper *reread = GDCM_NAME_SPACE::FileHelper::New( fileout ); std::cout << "3..."; // For the next step: @@ -86,27 +87,33 @@ int CompareInternal(std::string const &filename, std::string const &output) { std::cout << "Failed" << std::endl << " X Size differs: " - << "X: " << file->GetXSize() << " # " + << "X: " << file->GetXSize() << " # " << reread->GetFile()->GetXSize() << " | " - << "Y: " << file->GetYSize() << " # " + << "Y: " << file->GetYSize() << " # " << reread->GetFile()->GetYSize() << " | " - << "Z: " << file->GetZSize() << " # " + << "Z: " << file->GetZSize() << " # " << reread->GetFile()->GetZSize() << std::endl; - delete file; - delete filehelper; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 1; } // Test the data size - if (dataSize != dataSizeWritten) + // beware of odd length Pixel Element! + int dataSizeFixed = dataSize + dataSize%2; + int dataSizeWrittenFixed = dataSizeWritten + dataSizeWritten%2; + + if (dataSizeFixed != dataSizeWrittenFixed) { std::cout << "Failed" << std::endl << " Pixel areas lengths differ: " << dataSize << " # " << dataSizeWritten << std::endl; - delete file; - delete filehelper; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 1; } @@ -115,17 +122,19 @@ int CompareInternal(std::string const &filename, std::string const &output) { std::cout << "Failed" << std::endl << " Pixel differ (as expanded in memory)." << std::endl; - delete file; - delete filehelper; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 1; } std::cout << "4...OK." << std::endl ; //////////////// Clean up: - delete file; - delete filehelper; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 0; } @@ -135,7 +144,7 @@ int TestReadWriteReadCompare(int argc, char *argv[]) int result = 0; if (argc == 4) - gdcm::Debug::DebugOn(); + GDCM_NAME_SPACE::Debug::DebugOn(); if (argc >= 3) {