]> Creatis software - gdcm.git/commitdiff
Change meaningless name 'TestSequence' (that does NOT tests Sequences) to
authorjpr <jpr>
Wed, 2 Mar 2005 16:39:28 +0000 (16:39 +0000)
committerjpr <jpr>
Wed, 2 Mar 2005 16:39:28 +0000 (16:39 +0000)
TestImageSet
Improve TestWriteSimple
Improve TestMakeIcon

Testing/CMakeLists.txt
Testing/TestImageSet.cxx [moved from Testing/TestSequence.cxx with 82% similarity]
Testing/TestMakeIcon.cxx
Testing/TestWriteSimple.cxx

index 200a31f611411197de54ca88efbf4c9341275840..02bc063b759b3067acf4af167762c603edab7113 100644 (file)
@@ -15,7 +15,7 @@ SET(TEST_SOURCES
   TestVR.cxx
   TestDict.cxx
   TestWriteSimple.cxx
-  TestSequence.cxx
+  TestImageSet.cxx
   TestDicomDirElement.cxx
   TestDicomString.cxx
 )
similarity index 82%
rename from Testing/TestSequence.cxx
rename to Testing/TestImageSet.cxx
index 253819989325ce6ad0091bfa44e2929dc4512b87..9e7366f075e75537751c16b61df32a0add2bdb28 100644 (file)
@@ -1,10 +1,10 @@
 /*=========================================================================
                                                                                 
   Program:   gdcm
-  Module:    $RCSfile: TestSequence.cxx,v $
+  Module:    $RCSfile: TestImageSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/10 14:23:18 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/03/02 16:39:28 $
+  Version:   $Revision: 1.1 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -35,7 +35,7 @@
 typedef std::list<gdcm::File *> FileList;
 
 // If there is sameSerie, sameStudy is set to true
-int CompareImages(FileList &list,bool sameSerie,bool sameStudy)
+int CompareImages(FileList &list, bool sameSerie, bool sameStudy)
 {
    if( sameSerie )
       sameStudy = true;
@@ -50,7 +50,7 @@ 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)->GetValEntry(0x0008, 0x0018);
       if( entry )
          if( instUID.find(entry->GetValue())!=instUID.end() )
             instUID[entry->GetValue()]++;
@@ -196,7 +196,7 @@ gdcm::File *WriteImage(gdcm::File *file,const std::string &fileName)
    if( !reread->IsReadable() )
    {
      std::cerr << "Failed" << std::endl
-               << "        Could not reread image written:" << fileName << std::endl;
+               << "        Could not reread written image :" << fileName << std::endl;
      delete reread;
      return NULL;
    }
@@ -215,14 +215,14 @@ int TestSequence(int argc, char *argv[])
    }
 
    std::cout << "   Description (Test::TestSequence): " << std::endl;
-   std::cout << "   Will test the creation of sequences of 4 images" << std::endl;
+   std::cout << "   Tests the creation of a 4 images Set" << std::endl;
    std::cout << "   with the following steps : "<< std::endl;
-   std::cout << "   step 1: create separed images without correspondance" << std::endl
-             << "           in UID for study and serie" << std::endl;
-   std::cout << "   step 2: create serie of image." << std::endl
-             << "           So the Serie and Study UID must be equal" << std::endl;
-   std::cout << "   step 3: create separed serie of image with same study" << std::endl
-             << "           So the Study UID must be equal" << std::endl;
+   std::cout << "   step 1: create images belonging" << std::endl
+             << "           to different Study and Terie" << std::endl;
+   std::cout << "   step 2: create images belonging" << std::endl
+             << "           to the same Serie (therefore to the same Study)" << std::endl;
+   std::cout << "   step 3: create images belonging" << std::endl
+             << "           to different Series within the same Study" << std::endl;
    std::cout << std::endl << std::endl;
 
    gdcm::File *file;
@@ -231,8 +231,8 @@ int TestSequence(int argc, char *argv[])
    int i;
 
    std::cout<<"     step...";
-   std::string studyUID = gdcm::Util::CreateUniqueUID();
-   std::string serieUID = gdcm::Util::CreateUniqueUID();
+   std::string studyUID;
+   std::string serieUID;
 
    // Step 1 : All files have different UID 
    fileList.clear();
@@ -241,6 +241,13 @@ int TestSequence(int argc, char *argv[])
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
       file = new gdcm::File();
+      // 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);
+      // Series Instance UID
+      serieUID = gdcm::Util::CreateUniqueUID();
+      file->InsertValEntry(serieUID, 0x0020, 0x000e);
 
       newFile = WriteImage(file,fileName.str());
       if( !newFile )
@@ -265,13 +272,15 @@ int TestSequence(int argc, char *argv[])
 
    // Step 2 : Same Serie & Study
    fileList.clear();
+   studyUID = gdcm::Util::CreateUniqueUID();
+   serieUID = gdcm::Util::CreateUniqueUID();
    for(i = 0;i < 4;i++)
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
       file = new gdcm::File();
-      file->SetValEntry(studyUID,0x0020,0x000d);
-      file->SetValEntry(serieUID,0x0020,0x000e);
+      file->InsertValEntry(studyUID,0x0020,0x000d);
+      file->InsertValEntry(serieUID,0x0020,0x000e);
 
       newFile = WriteImage(file,fileName.str());
       if( !newFile )
@@ -296,13 +305,15 @@ int TestSequence(int argc, char *argv[])
 
    // Step 3 : Same Study
    fileList.clear();
+   serieUID = gdcm::Util::CreateUniqueUID();
    for(i = 0;i < 4;i++)
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
       file = new gdcm::File();
-      file->SetValEntry(studyUID,0x0020,0x000d);
-
+      file->InsertValEntry(studyUID,0x0020,0x000d);
+      serieUID = gdcm::Util::CreateUniqueUID();
+      file->InsertValEntry(serieUID,0x0020,0x000e);
       newFile = WriteImage(file,fileName.str());
       if( !newFile )
       {
index 0e31543f10d3a8dc57d66810d48b329423c03349..758016bd2996f28786246566d443d68d73dbf61d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeIcon.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 13:12:05 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/03/02 16:39:28 $
+  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
@@ -33,6 +33,8 @@ int TestMakeIcon (int argc, char *argv[])
    std::string input = "LIBIDO-8-ACR_NEMA-Lena_128_128.acr";
    std::string output = "test.dcm";
 
+   gdcm::Debug::DebugOn();
+
    if ( argc == 3 )
    {
       input  = argv[1];
@@ -62,6 +64,7 @@ int TestMakeIcon (int argc, char *argv[])
    // icone is just define like the image
    // The purpose is NOT to imagine an icon, 
    // just check the stuff works
+
    uint16_t binVal[3]={0x52f7,0xf358,0xad9b};
  
    sqi->InsertValEntry( "MONOCHROME2", 0x0028,0x0004);
@@ -81,19 +84,32 @@ int TestMakeIcon (int argc, char *argv[])
 
    f1 = new gdcm::File(output);
    f1->Print();
+   std::cout << "End of Print" << std::endl;
 
    icon = f1->GetSeqEntry(0x0088, 0x0200);
+   if (!icon)
+   {
+      std::cout << "Sequence 0088|0200 not found" << std::endl
+                << "   ... Failed" << std::endl;
+      delete fh1;
+      delete f1;
+      return 1;
+   }
+   std::cout << "Sequence 0088|0200 found" << std::endl;
+   
    sqi = icon->GetFirstSQItem();
 
    if ( !sqi )
    {
-      std::cout << "Sequence 0088|0200 not found" << std::endl
+      std::cout << "Sequence 0088|0200 has no SQItem" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh1;
       delete f1;
       return 1;
    }
 
+   std::cout << "First Item found" << std::endl;
+
    // Test for entry 0028|0010
    if ( !sqi->GetValEntry(0x0028,0x0010) )
    {
@@ -103,6 +119,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->ValEntry 0028|0010 found" << std::endl;
    if ( sqi->GetValEntry(0x0028,0x0010)->GetValue() != "128" )
    {
       std::cout << "Value 0028|0010 don't match" << std::endl
@@ -123,6 +140,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->ValEntry 0028|0011 found" << std::endl;
    if ( sqi->GetValEntry(0x0028,0x0011)->GetValue() != "128" )
    {
       std::cout << "Value 0028|0011 don't match" << std::endl
@@ -143,6 +161,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->ValEntry 0028|0100 found" << std::endl;
    if ( sqi->GetValEntry(0x0028,0x0100)->GetValue() != "8" )
    {
       std::cout << "Value 0028|0100 don't match" << std::endl
@@ -163,6 +182,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->ValEntry 0028|0101 found" << std::endl;
    if ( sqi->GetValEntry(0x0028,0x0101)->GetValue() != "8" )
    {
       std::cout << "Value 0028|0101 don't match" << std::endl
@@ -183,6 +203,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->ValEntry 0028|0102 found" << std::endl;
    if ( sqi->GetValEntry(0x0028,0x0102)->GetValue() != "7" )
    {
       std::cout << "Value 0028|0102 don't match" << std::endl
@@ -203,6 +224,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->ValEntry 0028|0103 found" << std::endl;
    if ( sqi->GetValEntry(0x0028,0x0103)->GetValue() != "0" )
    {
       std::cout << "Value 0028|0103 don't match" << std::endl
@@ -215,7 +237,7 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0005|0010
-   if ( !sqi->GetValEntry(0x0028,0x0010) )
+   if ( !sqi->GetBinEntry(0x0005,0x0010) )
    {
       std::cout << "BinEntry 0005|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
@@ -223,6 +245,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "First Item ->BinEntry 0005|0010 found" << std::endl;
    if( sqi->GetBinEntry(0x0005,0x0010)->GetLength() != 6 )
    {
       std::cout << "BinEntry size 0005|0010 don't match" << std::endl
@@ -234,6 +257,8 @@ int TestMakeIcon (int argc, char *argv[])
       return 1;
    }
 
+   std::cout << "Length BinEntry 0005|0010 OK" << std::endl;
+
    if( memcmp(sqi->GetBinEntry(0x0005,0x0010)->GetBinArea(),binVal,6)!=0 )
    {
       std::cout << "Value 0005|0010 don't match (BinEntry)" << std::endl
@@ -242,6 +267,7 @@ int TestMakeIcon (int argc, char *argv[])
       delete f1;
       return 1;
    }
+   std::cout << "Value BinEntry 0005|0010 OK" << std::endl;
 
    delete fh1;
    delete f1;
index 19b216bc1e901c5a116bcfcd7584bb821cda2da5..d0364ea10f116f38f38c33a2acf685090cd19710 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/10 14:23:18 $
-  Version:   $Revision: 1.25 $
+  Date:      $Date: 2005/03/02 16:39:28 $
+  Version:   $Revision: 1.26 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -237,7 +237,7 @@ int WriteSimple(Image &img)
    if( !reread->GetFile()->IsReadable() )
    {
       std::cerr << "Failed" << std::endl
-                << "Could not reread image written: " << fileName << std::endl;
+                << "Could not read written image : " << fileName << std::endl;
       delete fileToBuild;
       delete file;
       delete reread;
@@ -318,10 +318,13 @@ int TestWriteSimple(int argc, char *argv[])
       return 1;
    }
 
+  // gdcm::Debug::DebugOn();    
    int ret=0;
    int i=0;
    while( Images[i].sizeX>0 && Images[i].sizeY>0 )
    {
+      std::cout << std::endl << "Test n :" << i << std::endl;
       ret += WriteSimple(Images[i]);
       i++;
    }