X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestReadWriteReadCompare.cxx;h=74030d58736348d44a30d959db001396a2d9bcdf;hb=d00078b5e19310b379c8339fa8fe38362e8ca392;hp=6d53cda116f23901ea1096871ae9f139e9d41e03;hpb=3afc179392ebebe610f7685bc8895b690c2a66aa;p=gdcm.git diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index 6d53cda1..74030d58 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -1,3 +1,20 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ + Language: C++ + Date: $Date: 2005/01/20 16:16:59 $ + Version: $Revision: 1.18 $ + + 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 "gdcmHeader.h" #include "gdcmFile.h" @@ -18,11 +35,11 @@ int CompareInternal(std::string const & filename, std::string const & output) delete header; return 1; } - std::cout << " step 1 ..."; + std::cout << " step 1..."; //////////////// Step 2: - gdcm::File* file = new gdcm::File( header ); + gdcm::FileHelper* file = new gdcm::FileHelper( header ); int dataSize = file->GetImageDataSize(); uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to @@ -47,15 +64,17 @@ int CompareInternal(std::string const & filename, std::string const & output) file->SetImageData(imageData, dataSize); + file->SetWriteModeToRGB(); file->WriteDcmExplVR( output ); std::cout << "2..."; //////////////// Step 3: - gdcm::File* reread = new gdcm::File( output ); + gdcm::FileHelper* reread = new gdcm::FileHelper( output ); if( !reread->GetHeader()->IsReadable() ) { - std::cerr << "Test::TestReadWriteReadCompare: Could not reread image " + std::cerr << "Failed" << std::endl + << "Test::TestReadWriteReadCompare: Could not reread image " << "written:" << filename << std::endl; delete header; delete file; @@ -68,10 +87,29 @@ int CompareInternal(std::string const & filename, std::string const & output) uint8_t* imageDataWritten = reread->GetImageData(); //////////////// Step 4: + // Test the image size + if (header->GetXSize() != reread->GetHeader()->GetXSize() || + header->GetYSize() != reread->GetHeader()->GetYSize() || + header->GetZSize() != reread->GetHeader()->GetZSize()) + { + std::cout << "Failed" << std::endl + << " X Size differs: " + << "X: " << header->GetXSize() << " # " + << reread->GetHeader()->GetXSize() << " | " + << "Y: " << header->GetYSize() << " # " + << reread->GetHeader()->GetYSize() << " | " + << "Z: " << header->GetZSize() << " # " + << reread->GetHeader()->GetZSize() << std::endl; + delete header; + delete file; + delete reread; + return 1; + } + // Test the data size if (dataSize != dataSizeWritten) { - std::cout << std::endl + std::cout << "Failed" << std::endl << " Pixel areas lengths differ: " << dataSize << " # " << dataSizeWritten << std::endl; delete header; @@ -80,10 +118,11 @@ int CompareInternal(std::string const & filename, std::string const & output) return 1; } + // Test the data's content if (int res = memcmp(imageData, imageDataWritten, dataSize) !=0) { (void)res; - std::cout << std::endl + std::cout << "Failed" << std::endl << " Pixel differ (as expanded in memory)." << std::endl; delete header; delete file;