X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestImageSet.cxx;h=789a43b20d1a70c711e0adb814dafbc1dbe4c439;hb=544e9b239eea5ec46a1e637a58e9cbe86afdc08a;hp=56ce95f036baba0bc859df108628ee772f945774;hpb=1a9bdd7942ea28a2894eb57baa60abec0871a639;p=gdcm.git diff --git a/Testing/TestImageSet.cxx b/Testing/TestImageSet.cxx index 56ce95f0..789a43b2 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/06/03 09:55:18 $ - Version: $Revision: 1.3 $ + Date: $Date: 2006/04/11 16:05:03 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,7 +24,7 @@ */ #include "gdcmFile.h" #include "gdcmFileHelper.h" -#include "gdcmValEntry.h" +#include "gdcmDataEntry.h" #include "gdcmUtil.h" #include "gdcmDebug.h" @@ -42,7 +42,7 @@ int CompareImages(FileList &list, bool sameSerie, bool sameStudy) if( sameSerie ) sameStudy = true; - gdcm::ValEntry *entry; + gdcm::DataEntry *entry; std::map instUID; std::map mediaUID; std::map serieUID; @@ -52,33 +52,33 @@ int CompareImages(FileList &list, bool sameSerie, bool sameStudy) for(it=list.begin();it!=list.end();++it) { // SOP Instance UID - entry=(*it)->GetValEntry(0x0008, 0x0018); + entry=(*it)->GetDataEntry(0x0008, 0x0018); if( entry ) - if( instUID.find(entry->GetValue())!=instUID.end() ) - instUID[entry->GetValue()]++; + if( instUID.find(entry->GetString())!=instUID.end() ) + instUID[entry->GetString()]++; else - instUID[entry->GetValue()]=1; + instUID[entry->GetString()]=1; // Media Storage SOP Instance UID - entry=(*it)->GetValEntry(0x0002,0x0003); + entry=(*it)->GetDataEntry(0x0002,0x0003); if( entry ) - if( mediaUID.find(entry->GetValue())!=mediaUID.end() ) - mediaUID[entry->GetValue()]++; + if( mediaUID.find(entry->GetString())!=mediaUID.end() ) + mediaUID[entry->GetString()]++; else - mediaUID[entry->GetValue()]=1; + mediaUID[entry->GetString()]=1; // Series Instance UID - entry=(*it)->GetValEntry(0x0020,0x000e); + entry=(*it)->GetDataEntry(0x0020,0x000e); if( entry ) - if( serieUID.find(entry->GetValue())!=serieUID.end() ) - serieUID[entry->GetValue()]++; + if( serieUID.find(entry->GetString())!=serieUID.end() ) + serieUID[entry->GetString()]++; else - serieUID[entry->GetValue()]=1; + serieUID[entry->GetString()]=1; // Study Instance UID - entry=(*it)->GetValEntry(0x0020,0x000d); + entry=(*it)->GetDataEntry(0x0020,0x000d); if( entry ) - if( studyUID.find(entry->GetValue())!=studyUID.end() ) - studyUID[entry->GetValue()]++; + if( studyUID.find(entry->GetString())!=studyUID.end() ) + studyUID[entry->GetString()]++; else - studyUID[entry->GetValue()]=1; + studyUID[entry->GetString()]=1; } if( sameSerie ) @@ -141,7 +141,7 @@ void ClearList(FileList &list) FileList::iterator it; for(it=list.begin();it!=list.end();++it) { - delete (*it); + (*it)->Delete(); } list.clear(); } @@ -152,19 +152,19 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName) std::ostringstream str; // Set the image size - file->InsertValEntry("256",0x0028,0x0011); // Columns - file->InsertValEntry("256",0x0028,0x0010); // Rows + file->InsertEntryString("256",0x0028,0x0011,"US"); // Columns + file->InsertEntryString("256",0x0028,0x0010,"US"); // Rows // Set the pixel type - file->InsertValEntry("8",0x0028,0x0100); // Bits Allocated - file->InsertValEntry("8",0x0028,0x0101); // Bits Stored - file->InsertValEntry("7",0x0028,0x0102); // High Bit + file->InsertEntryString("8",0x0028,0x0100,"US"); // Bits Allocated + file->InsertEntryString("8",0x0028,0x0101,"US"); // Bits Stored + file->InsertEntryString("7",0x0028,0x0102,"US"); // High Bit // Set the pixel representation - file->InsertValEntry("0",0x0028,0x0103); // Pixel Representation + file->InsertEntryString("0",0x0028,0x0103,"US"); // Pixel Representation // Set the samples per pixel - file->InsertValEntry("1",0x0028,0x0002); // Samples per Pixel + file->InsertEntryString("1",0x0028,0x0002,"US"); // Samples per Pixel // The so called 'prepared image', built ex nihilo just before, // has NO Pixel Element yet. @@ -182,7 +182,7 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName) memset(imageData,0,size); // Write the image - gdcm::FileHelper *hlp = new gdcm::FileHelper(file); + gdcm::FileHelper *hlp = gdcm::FileHelper::New(file); hlp->SetImageData(imageData,size); hlp->SetWriteTypeToDcmExplVR(); if( !hlp->Write(fileName) ) @@ -190,20 +190,22 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName) std::cout << "Failed\n" << " File in unwrittable\n"; - delete hlp; + hlp->Delete(); delete[] imageData; return NULL; } delete[] imageData; - delete hlp; + hlp->Delete(); // Read the written image - gdcm::File *reread = new gdcm::File( fileName ); + gdcm::File *reread = gdcm::File::New( ); + reread->SetFileName( fileName ); + reread->Load(); if( !reread->IsReadable() ) { std::cerr << "Failed" << std::endl << " Could not reread written image :" << fileName << std::endl; - delete reread; + reread->Delete(); return NULL; } @@ -246,25 +248,25 @@ int TestImageSet(int argc, char *argv[]) { std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; - file = new gdcm::File(); + file = gdcm::File::New(); // It's up to the user to initialize Serie UID and Study UID // Study Instance UID studyUID = gdcm::Util::CreateUniqueUID(); - file->InsertValEntry(studyUID, 0x0020, 0x000d); + file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI"); // Series Instance UID serieUID = gdcm::Util::CreateUniqueUID(); - file->InsertValEntry(serieUID, 0x0020, 0x000e); + file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI"); newFile = WriteImage(file, fileName.str()); if( !newFile ) { - delete file; + file->Delete(); return 1; } else fileList.push_back(newFile); - delete file; + file->Delete(); } if( CompareImages(fileList, false, false) ) @@ -284,20 +286,20 @@ 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 = gdcm::File::New(); + file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI"); + file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI"); newFile = WriteImage(file, fileName.str()); if( !newFile ) { - delete file; + file->Delete(); return(1); } else fileList.push_back(newFile); - delete file; + file->Delete(); } if( CompareImages(fileList, true, true) ) @@ -316,20 +318,20 @@ int TestImageSet(int argc, char *argv[]) { std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; - file = new gdcm::File(); - file->InsertValEntry(studyUID, 0x0020, 0x000d); + file = gdcm::File::New(); + file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI"); serieUID = gdcm::Util::CreateUniqueUID(); - file->InsertValEntry(serieUID, 0x0020, 0x000e); + file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI"); newFile = WriteImage(file, fileName.str()); if( !newFile ) { - delete file; + file->Delete(); return(1); } else fileList.push_back(newFile); - delete file; + file->Delete(); } if( CompareImages(fileList, false, true) )