]> Creatis software - gdcm.git/blobdiff - Example/TestFromScratch.cxx
methods ReplaceOrCreate renamed as Insert
[gdcm.git] / Example / TestFromScratch.cxx
index f7293996266db4a8de47fe44fd322591a0dccbcd..29099d77772e0f072eaa176283fad74cf8dc314f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestFromScratch.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/07 16:26:11 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/01/24 16:44:53 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -15,8 +15,8 @@
      PURPOSE.  See the above copyright notices for more information.
                                                                                 
 =========================================================================*/
-#include "gdcmHeader.h"
 #include "gdcmFile.h"
+#include "gdcmFileHelper.h"
 #include "gdcmDictEntry.h"
 #include "gdcmDocEntry.h"
 #include "gdcmBinEntry.h"
@@ -36,14 +36,14 @@ int main(int argc, char *argv[])
    }
 
    // Doesn't seems to do anything:
-   gdcm::Debug::SetDebugLevel(-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();
+   gdcm::FileHelper *f1 = new gdcm::FileHelper( filename );
+   gdcm::File *h1 = f1->GetFile();
 
    int dataSize = f1->GetImageDataSize();
    std::cout << "DataSize:      " << dataSize << std::endl;
@@ -51,12 +51,10 @@ int main(int argc, char *argv[])
    uint8_t* imageData = f1->GetImageData();
  
    // Hopefully default to something
-   gdcm::Header *h2 = new gdcm::Header();
-
-   h1->Initialize();
-   gdcm::DocEntry* d = h1->GetNextEntry();
+   gdcm::File *h2 = new gdcm::File();
 
    // Copy of the header content
+   gdcm::DocEntry* d = h1->GetFirstEntry();
    while(d)
    {
       if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
@@ -64,11 +62,10 @@ int main(int argc, char *argv[])
          // Do not bother with field from private dict
          if( v->GetName() != "gdcm::Unknown" )
          {  
-            h2->ReplaceOrCreateByNumber( 
-                              v->GetValue(),
-                              v->GetGroup(), 
-                              v->GetElement(),
-                              v->GetVR() ); 
+            h2->Insert( v->GetValue(),
+                        v->GetGroup(), 
+                        v->GetElement(),
+                        v->GetVR() ); 
          }
       }
       //else
@@ -79,7 +76,7 @@ int main(int argc, char *argv[])
    }
    h2->Print( std::cout );
 
-   gdcm::File *f2 = new gdcm::File( h2 );
+   gdcm::FileHelper *f2 = new gdcm::FileHelper( h2 );
    f2->SetImageData(imageData, dataSize);
 
    f2->SetWriteTypeToDcmExplVR();