]> Creatis software - gdcm.git/blobdiff - Example/TestFromScratch.cxx
COMP: Fix compilation on Mingw
[gdcm.git] / Example / TestFromScratch.cxx
index 66771cca61659cce4fee4504dfe57b3acc6f945d..6b1ebaa0bfc899cd8df0fc66e55cbe3f481fad7c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestFromScratch.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/12/10 16:48:37 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/01/18 07:55:16 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,12 +36,12 @@ int main(int argc, char *argv[])
    }
 
    // Doesn't seems to do anything:
-   dbg.SetDebug(-1);
+   gdcm::Debug::SetDebugOn();
+
    // Doesn't link properly:
    //gdcm::Debug::GetReference().SetDebug(1);
 
    std::string filename = argv[1];
-   //gdcm::File *f1 = new gdcm::File( "/home/malaterre/Creatis/gdcmData/012345.002.050.dcm" );
    gdcm::File *f1 = new gdcm::File( filename );
    gdcm::Header *h1 = f1->GetHeader();
 
@@ -53,32 +53,29 @@ int main(int argc, char *argv[])
    // Hopefully default to something
    gdcm::Header *h2 = new gdcm::Header();
 
-   h1->Initialize();
-   gdcm::DocEntry* d = h1->GetNextEntry();
-
    // Copy of the header content
+   gdcm::DocEntry* d = h1->GetFirstEntry();
    while(d)
    {
-      if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
-      {
-         // We skip bin entries
-      }
-      else if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
+      if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
       {   
-          h2->ReplaceOrCreateByNumber( 
+         // Do not bother with field from private dict
+         if( v->GetName() != "gdcm::Unknown" )
+         {  
+            h2->ReplaceOrCreate( 
                               v->GetValue(),
                               v->GetGroup(), 
                               v->GetElement(),
                               v->GetVR() ); 
+         }
       }
-      else
-      {
-       // We skip pb of SQ recursive exploration
-      }
+      //else
+         // We skip pb of SQ recursive exploration
+         // We skip bin entries
 
       d = h1->GetNextEntry();
    }
-   //h2->Print( std::cout );
+   h2->Print( std::cout );
 
    gdcm::File *f2 = new gdcm::File( h2 );
    f2->SetImageData(imageData, dataSize);