]> Creatis software - gdcm.git/blobdiff - Testing/TestDicomDir.cxx
Add some more info in News
[gdcm.git] / Testing / TestDicomDir.cxx
index 7c4ccb3b27e5f544641d8e6577f1a4c462cd4b17..64bc7d754973270cb1b99777ae3936327e1d8b42 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/17 13:24:15 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/01/26 16:43:10 $
+  Version:   $Revision: 1.33 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,7 +28,7 @@
 
 int TestDicomDir(int argc, char* argv[])
 {  
-   gdcm::DicomDir *e1;
+   gdcm::DicomDir *dicomdir;
    
    gdcm::DicomDirPatient *pa;
    gdcm::DicomDirStudy *st;
@@ -46,22 +46,21 @@ int TestDicomDir(int argc, char* argv[])
       file += "/DICOMDIR";
    }
 
-std::cout << "----------------- " << file << "-----" <<std::endl;
-   e1 = new gdcm::DicomDir(file);
+   dicomdir = new gdcm::DicomDir(file);
    if (argc > 2) 
    {
       int level = atoi(argv[2]);   
-      e1->SetPrintLevel(level);
+      dicomdir->SetPrintLevel(level);
    }
 
    // Test if the DicomDir is readable
-   if( !e1->IsReadable() )
+   if( !dicomdir->IsReadable() )
    {
       std::cout<<"          DicomDir '"<<file
                <<"' is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete e1;
+      delete dicomdir;
       return 1;
    }
    else
@@ -70,61 +69,59 @@ std::cout << "----------------- " << file << "-----" <<std::endl;
                <<"' is readable"<<std::endl;
    }
 
-   e1->InitTraversal();
    // Test if the DicomDir contains any Patient
-   if( !e1->GetNextEntry() )
+   if( !dicomdir->GetFirstPatient() )
    {
       std::cout<<"          DicomDir '"<<file
                <<" has no patient"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete e1;
+      delete dicomdir;
       return 1;
    }
 
-
-  // step by step structure full exploitation
-  
+   // step by step structure full exploitation
    std::cout << std::endl << std::endl  
              << " = PATIENT/STUDY/SERIE/IMAGE List ============================" 
              << std::endl<< std::endl;
   
-   e1->InitTraversal();
-   pa = e1->GetNextEntry(); 
-   while ( pa ) {  // on degouline la liste de PATIENT
-      std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
-      pa->InitTraversal();
-      st = pa->GetNextEntry();
-      while ( st ) { // on degouline les STUDY de ce patient
-         std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl;    // Study Description
-         std::cout << " Stud.ID:["          << st->GetEntry(0x0020, 0x0010); // Study ID
-         st->InitTraversal();
-         se = st->GetNextEntry();
-         while ( se ) { // on degouline les SERIES de cette study
-            std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl;      // Serie Description
-            std::cout << " Ser.nb:["         <<  se->GetEntry(0x0020, 0x0011);        // Series number
-            std::cout << "] Mod.:["          <<  se->GetEntry(0x0008, 0x0060) << "]"; // Modality
-            se->InitTraversal();
-            im = se->GetNextEntry();
-            while ( im ) { // on degouline les Images de cette serie
-               std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name
-               im = se->GetNextEntry();   
+   pa = dicomdir->GetFirstPatient(); 
+   while ( pa ) 
+   {  // we process all the PATIENT of this DICOMDIR 
+      std::cout << pa->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
+
+      st = pa->GetFirstStudy();
+      while ( st ) 
+      { // we process all the STUDY of this patient
+         std::cout << "--- "<< st->GetEntryValue(0x0008, 0x1030) << std::endl;    // Study Description
+         std::cout << " Stud.ID:["          << st->GetEntryValue(0x0020, 0x0010); // Study ID
+
+         se = st->GetFirstSerie();
+         while ( se ) 
+         { // we process all the SERIES of this study
+            std::cout << "--- --- "<< se->GetEntryValue(0x0008, 0x103e) << std::endl;      // Serie Description
+            std::cout << " Ser.nb:["         <<  se->GetEntryValue(0x0020, 0x0011);        // Series number
+            std::cout << "] Mod.:["          <<  se->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+
+            im = se->GetFirstImage();
+            while ( im ) { // we process all the IMAGE of this serie
+               std::cout << "--- --- --- "<< im->GetEntryValue(0x0004, 0x1500) << std::endl; // File name
+               im = se->GetNextImage();   
             }
-            se = st->GetNextEntry();   
+            se = st->GetNextSerie();   
          }
-         st = pa->GetNextEntry();
-     }  
-     pa = e1->GetNextEntry();
-  }  
-      
-    
+         st = pa->GetNextStudy();
+      }  
+      pa = dicomdir->GetNextPatient();
+   }  
+
    std::cout << std::endl << std::endl  
              << " = DICOMDIR full content ====================================" 
              << std::endl<< std::endl;
-   e1->Print();
+   dicomdir->Print();
    
    std::cout<<std::flush;
-   delete e1;
+   delete dicomdir;
 
    return 0;
 }