X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestImageSet.cxx;h=7bf62230b57f299a90b28d90f1f760fbd2293bdc;hb=7a6f4850521b56e6b907cb8c7938471898613fa4;hp=ee307ae2931d78172fb833712db73fbc360521a8;hpb=be4f9f96c4f78c43f8f1e476ce1c0cb76245eda8;p=gdcm.git diff --git a/Testing/TestImageSet.cxx b/Testing/TestImageSet.cxx index ee307ae2..7bf62230 100644 --- a/Testing/TestImageSet.cxx +++ b/Testing/TestImageSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestImageSet.cxx,v $ Language: C++ - Date: $Date: 2005/03/02 17:38:35 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/07/08 13:39:57 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,6 +37,8 @@ typedef std::list FileList; // If there is sameSerie, sameStudy is set to true int CompareImages(FileList &list, bool sameSerie, bool sameStudy) { + gdcm::Debug::DebugOn(); + if( sameSerie ) sameStudy = true; @@ -144,7 +146,7 @@ void ClearList(FileList &list) list.clear(); } -gdcm::File *WriteImage(gdcm::File *file,const std::string &fileName) +gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName) { // Create a 256x256x1 image 8 bits, unsigned std::ostringstream str; @@ -164,12 +166,16 @@ gdcm::File *WriteImage(gdcm::File *file,const std::string &fileName) // Set the samples per pixel file->InsertValEntry("1",0x0028,0x0002); // Samples per Pixel - if( !file->IsReadable() ) - { - std::cout << "Failed\n" - << " Prepared image isn't readable\n"; - return NULL; - } + // The so called 'prepared image', built ex nihilo just before, + // has NO Pixel Element yet. + // therefore, it's NEVER 'file readable' ... + + //if( !file->IsReadable() ) + // { + // std::cout << "Failed\n" + // << " Prepared image isn't readable\n"; + // return NULL; + //} size_t size = 256 * 256 * 1; unsigned char *imageData = new unsigned char[size]; @@ -192,7 +198,9 @@ gdcm::File *WriteImage(gdcm::File *file,const std::string &fileName) delete hlp; // Read the written image - gdcm::File *reread = new gdcm::File( fileName ); + gdcm::File *reread = new gdcm::File( ); + reread->SetFileName( fileName ); + reread->Load(); if( !reread->IsReadable() ) { std::cerr << "Failed" << std::endl @@ -249,7 +257,7 @@ int TestImageSet(int argc, char *argv[]) serieUID = gdcm::Util::CreateUniqueUID(); file->InsertValEntry(serieUID, 0x0020, 0x000e); - newFile = WriteImage(file,fileName.str()); + newFile = WriteImage(file, fileName.str()); if( !newFile ) { delete file; @@ -261,7 +269,7 @@ int TestImageSet(int argc, char *argv[]) delete file; } - if( CompareImages(fileList,false,false) ) + if( CompareImages(fileList, false, false) ) { ClearList(fileList); return 1; @@ -279,10 +287,10 @@ int TestImageSet(int argc, char *argv[]) std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; file = new gdcm::File(); - file->InsertValEntry(studyUID,0x0020,0x000d); - file->InsertValEntry(serieUID,0x0020,0x000e); + file->InsertValEntry(studyUID, 0x0020, 0x000d); + file->InsertValEntry(serieUID, 0x0020, 0x000e); - newFile = WriteImage(file,fileName.str()); + newFile = WriteImage(file, fileName.str()); if( !newFile ) { delete file; @@ -294,7 +302,7 @@ int TestImageSet(int argc, char *argv[]) delete file; } - if( CompareImages(fileList,true,true) ) + if( CompareImages(fileList, true, true) ) { ClearList(fileList); return 1; @@ -311,10 +319,10 @@ int TestImageSet(int argc, char *argv[]) std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; file = new gdcm::File(); - file->InsertValEntry(studyUID,0x0020,0x000d); + file->InsertValEntry(studyUID, 0x0020, 0x000d); serieUID = gdcm::Util::CreateUniqueUID(); - file->InsertValEntry(serieUID,0x0020,0x000e); - newFile = WriteImage(file,fileName.str()); + file->InsertValEntry(serieUID, 0x0020, 0x000e); + newFile = WriteImage(file, fileName.str()); if( !newFile ) { delete file; @@ -326,7 +334,7 @@ int TestImageSet(int argc, char *argv[]) delete file; } - if( CompareImages(fileList,false,true) ) + if( CompareImages(fileList, false, true) ) { ClearList(fileList); return 1;