]> Creatis software - gdcm.git/blobdiff - Testing/TestImageSet.cxx
BUG: backport from gdcm 1.2. Should not crash when jpeg was not instanciated
[gdcm.git] / Testing / TestImageSet.cxx
index 4caf0ade80e4a8ddea67ff4e32ec4a0a7af58385..24168671cce4468302b5e43852b6a5b20e7dbedd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestImageSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:52:31 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2007/05/23 14:18:06 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <sstream>
 #include <list>
 
-typedef std::list<gdcm::File *> FileList;
+typedef std::list<GDCM_NAME_SPACE::File *> FileList;
 
 // If there is sameSerie, sameStudy is set to true
 int CompareImages(FileList &list, bool sameSerie, bool sameStudy)
 {
-   gdcm::Debug::DebugOn();
+   GDCM_NAME_SPACE::Debug::DebugOn();
 
    if( sameSerie )
       sameStudy = true;
 
-   gdcm::DataEntry *entry;
+   GDCM_NAME_SPACE::DataEntry *entry;
    std::map<std::string, int> instUID;
    std::map<std::string, int> mediaUID;
    std::map<std::string, int> serieUID;
@@ -146,25 +146,25 @@ void ClearList(FileList &list)
    list.clear();
 }
 
-gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName)
+GDCM_NAME_SPACE::File *WriteImage(GDCM_NAME_SPACE::File *file, const std::string &fileName)
 {
    // Create a 256x256x1 image 8 bits, unsigned 
    std::ostringstream str;
 
    // Set the image size
-   file->InsertEntryString("256",0x0028,0x0011); // Columns
-   file->InsertEntryString("256",0x0028,0x0010); // Rows
+   file->InsertEntryString("256",0x0028,0x0011,"US"); // Columns
+   file->InsertEntryString("256",0x0028,0x0010,"US"); // Rows
 
    // Set the pixel type
-   file->InsertEntryString("8",0x0028,0x0100); // Bits Allocated
-   file->InsertEntryString("8",0x0028,0x0101); // Bits Stored
-   file->InsertEntryString("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->InsertEntryString("0",0x0028,0x0103); // Pixel Representation
+   file->InsertEntryString("0",0x0028,0x0103,"US"); // Pixel Representation
 
    // Set the samples per pixel
-   file->InsertEntryString("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 = gdcm::FileHelper::New(file);
+   GDCM_NAME_SPACE::FileHelper *hlp = GDCM_NAME_SPACE::FileHelper::New(file);
    hlp->SetImageData(imageData,size);
    hlp->SetWriteTypeToDcmExplVR();
    if( !hlp->Write(fileName) )
@@ -198,7 +198,7 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName)
    hlp->Delete();
 
 // Read the written image
-   gdcm::File *reread = gdcm::File::New(  );
+   GDCM_NAME_SPACE::File *reread = GDCM_NAME_SPACE::File::New(  );
    reread->SetFileName( fileName );
    reread->Load();
    if( !reread->IsReadable() )
@@ -233,8 +233,8 @@ int TestImageSet(int argc, char *argv[])
              << "           to different Series within the same Study" << std::endl;
    std::cout << std::endl << std::endl;
 
-   gdcm::File *file;
-   gdcm::File *newFile;
+   GDCM_NAME_SPACE::File *file;
+   GDCM_NAME_SPACE::File *newFile;
    FileList fileList;
    int i;
 
@@ -248,14 +248,14 @@ int TestImageSet(int argc, char *argv[])
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
-      file = gdcm::File::New();
+      file = GDCM_NAME_SPACE::File::New();
       // It's up to the user to initialize Serie UID and Study UID
       // Study Instance UID
-      studyUID = gdcm::Util::CreateUniqueUID();
-      file->InsertEntryString(studyUID, 0x0020, 0x000d);
+      studyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+      file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI");
       // Series Instance UID
-      serieUID = gdcm::Util::CreateUniqueUID();
-      file->InsertEntryString(serieUID, 0x0020, 0x000e);
+      serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+      file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI");
 
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
@@ -280,15 +280,15 @@ int TestImageSet(int argc, char *argv[])
 
    // Step 2 : Same Serie & Study
    fileList.clear();
-   studyUID = gdcm::Util::CreateUniqueUID();
-   serieUID = gdcm::Util::CreateUniqueUID();
+   studyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+   serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
    for(i = 0;i < 4;i++)
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
-      file = gdcm::File::New();
-      file->InsertEntryString(studyUID, 0x0020, 0x000d);
-      file->InsertEntryString(serieUID, 0x0020, 0x000e);
+      file = GDCM_NAME_SPACE::File::New();
+      file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI");
+      file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI");
 
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
@@ -313,15 +313,15 @@ int TestImageSet(int argc, char *argv[])
 
    // Step 3 : Same Study
    fileList.clear();
-   serieUID = gdcm::Util::CreateUniqueUID();
+   serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
    for(i = 0;i < 4;i++)
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
-      file = gdcm::File::New();
-      file->InsertEntryString(studyUID, 0x0020, 0x000d);
-      serieUID = gdcm::Util::CreateUniqueUID();
-      file->InsertEntryString(serieUID, 0x0020, 0x000e);
+      file = GDCM_NAME_SPACE::File::New();
+      file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI");
+      serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+      file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI");
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
       {