]> Creatis software - gdcm.git/blobdiff - Testing/TestDicomDir.cxx
use GDCM_NAME_SPACE:: instead of gdcm::, even in Examples ...
[gdcm.git] / Testing / TestDicomDir.cxx
index 9d99963730695ba518b87656f2e5b80af9da201e..b2dad187df6046de3137692e082cf2f47bef288d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/05/31 16:51:41 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2008/09/15 15:49:21 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 #include <stdlib.h>
 
-// check *all* the dicom elements (gdcm::DocEntry)
-// of this gdcm::DicomDirObject
-int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 )
+// check *all* the dicom elements (GDCM_NAME_SPACE::DocEntry)
+// of this GDCM_NAME_SPACE::DicomDirObject
+int CompareSQItem(GDCM_NAME_SPACE::SQItem *pa1, GDCM_NAME_SPACE::SQItem *pa2 )
 {
-   gdcm::DocEntry *e1;
-   gdcm::DocEntry *e2;
+   GDCM_NAME_SPACE::DocEntry *e1;
+   GDCM_NAME_SPACE::DocEntry *e2;
 
    e2 = pa2->GetFirstEntry();
    while (!e2)
@@ -50,31 +50,34 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 )
        return 1; 
       }
       // skip SeqEntries (I don't want to deal with 'recursion pbs' here)
-      if ( !dynamic_cast<gdcm::DataEntry *>(e1) ||
-           !dynamic_cast<gdcm::DataEntry *>(e2) )
+      if ( !dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(e1) ||
+           !dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(e2) )
          continue;
 
       // a value is read as GDCM_UNFOUND 
-      if ( ((gdcm::DataEntry *)e1)->GetString() == gdcm::GDCM_UNFOUND )
+      if ( ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() == GDCM_NAME_SPACE::GDCM_UNFOUND )
       {
          std::cout << "for gdcm source DicomDir : element (" << std::hex 
                    << e1->GetGroup() << "," <<e1->GetElement() 
-                   << ") has values [" << gdcm::GDCM_UNFOUND << "]"
+                   << ") has values [" << GDCM_NAME_SPACE::GDCM_UNFOUND << "]"
                    << std::endl;
          return 1;
       }
 
       // values differ in source file and destination file
-      if ( ((gdcm::DataEntry *)e1)->GetString() != 
-           ((gdcm::DataEntry *)e2)->GetString() )
+      if ( ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() != 
+           ((GDCM_NAME_SPACE::DataEntry *)e2)->GetString() )
       {
  
+ /// \todo : check the value *written on disc*, not the value converted as a std::string
+ ///         (this comparison doesn't make the difference between Ox(ff) and "255" ...)
          // serious trouble : values differ in source and destination file
          std::cout << "for gdcm DicomDir element (" << std::hex 
                    << e2->GetGroup() << "," <<e2->GetElement() 
                    << ") values differ [" 
-                   << ((gdcm::DataEntry *)e1)->GetString() << "] != [" 
-                   << ((gdcm::DataEntry *)e2)->GetString() << "]"
+                   << ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() << "] != [" 
+                   << ((GDCM_NAME_SPACE::DataEntry *)e2)->GetString() << "]"
                    << std::endl;
           return 1;
       }
@@ -84,14 +87,14 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 )
  
 int TestDicomDir(int argc, char *argv[])
 {  
-   gdcm::DicomDir *dicomdir;
+   GDCM_NAME_SPACE::DicomDir *dicomdir;
    
-   gdcm::DicomDirPatient *pa1;
-   gdcm::DicomDirStudy   *st1;
-   gdcm::DicomDirSerie   *se1;
-   gdcm::DicomDirImage   *im1;
+   GDCM_NAME_SPACE::DicomDirPatient *pa1;
+   GDCM_NAME_SPACE::DicomDirStudy   *st1;
+   GDCM_NAME_SPACE::DicomDirSerie   *se1;
+   GDCM_NAME_SPACE::DicomDirImage   *im1;
 
-   gdcm::TSKey v;
+   GDCM_NAME_SPACE::TSKey v;
     
    std::string file; 
    if (argc > 1) 
@@ -102,7 +105,10 @@ int TestDicomDir(int argc, char *argv[])
       file += "/DICOMDIR";
    }
 
-   dicomdir = gdcm::DicomDir::New();
+   std::cout << "DicomDir we're going to deal with : ["<< file << "]" 
+             << std::endl;
+
+   dicomdir = GDCM_NAME_SPACE::DicomDir::New();
    dicomdir->SetFileName(file);
    dicomdir->Load();
    if (argc > 2) 
@@ -111,7 +117,7 @@ int TestDicomDir(int argc, char *argv[])
       dicomdir->SetPrintLevel(level);
    }
 
-   // Test if the DicomDir is readable
+   // Test if the DICOMDIR file is readable
    if( !dicomdir->IsReadable() )
    {
       std::cout<<"          DicomDir '"<<file
@@ -127,7 +133,7 @@ int TestDicomDir(int argc, char *argv[])
                <<"' is readable"<<std::endl;
    }
 
-   // Test if the DicomDir contains any patient
+   // Test if the GDCM_NAME_SPACE::DicomDir contains any patient
    if( !dicomdir->GetFirstPatient() )
    {
       std::cout<<"          DicomDir '"<<file
@@ -145,7 +151,7 @@ int TestDicomDir(int argc, char *argv[])
 
    pa1 = dicomdir->GetFirstPatient(); 
    while ( pa1 ) 
-   {  // we process all the PATIENT of this DICOMDIR 
+   {  // we process all the PATIENT of this GDCM_NAME_SPACE::DicomDir 
       std::cout << pa1->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name
 
       st1 = pa1->GetFirstStudy();
@@ -175,12 +181,22 @@ int TestDicomDir(int argc, char *argv[])
       pa1 = dicomdir->GetNextPatient();
    }  
 
+/*
+// this one is *really* too much verbose!
+
    std::cout << std::endl << std::endl  
              << " = DICOMDIR full content ====================================" 
              << std::endl<< std::endl;
-  // dicomdir->Print();
-
+   dicomdir->Print();
+   std::cout << std::endl << std::endl  
+             << " = end of DICOMDIR full content ====================================" 
+             << std::endl<< std::endl;
+*/
    // ------------------------- second stage ---------------------------
+ GDCM_NAME_SPACE::Debug::DebugOn();
     
    // Write on disc what we read
    dicomdir->Write("NewDICOMDIR");
@@ -189,7 +205,7 @@ int TestDicomDir(int argc, char *argv[])
              << "NewDICOMDIR written on disc =================================" 
              << std::endl<< std::endl;
   // Read what we wrote  
-   gdcm::DicomDir *d2 = gdcm::DicomDir::New();
+   GDCM_NAME_SPACE::DicomDir *d2 = GDCM_NAME_SPACE::DicomDir::New();
    d2->SetFileName("NewDICOMDIR");
    d2->Load();
    if (!d2->IsReadable())
@@ -203,10 +219,10 @@ int TestDicomDir(int argc, char *argv[])
              << "NewDICOMDIR successfully read from disc =================================" 
              << std::endl<< std::endl;
   
-   gdcm::DicomDirPatient *pa2;
-   gdcm::DicomDirStudy   *st2;
-   gdcm::DicomDirSerie   *se2;
-   gdcm::DicomDirImage   *im2;
+   GDCM_NAME_SPACE::DicomDirPatient *pa2;
+   GDCM_NAME_SPACE::DicomDirStudy   *st2;
+   GDCM_NAME_SPACE::DicomDirSerie   *se2;
+   GDCM_NAME_SPACE::DicomDirImage   *im2;
 
    pa1 = dicomdir->GetFirstPatient(); 
    pa2 = d2->GetFirstPatient();