]> Creatis software - gdcm.git/blobdiff - Example/TestCopyDicom.cxx
* src/gdcmFile.[h|cxx] : add the Print method
[gdcm.git] / Example / TestCopyDicom.cxx
index f0f7c23388d3618ccecbdc3f9ba77658297a5df5..b13d002e31c7e4ee7879e9ecccd314b187fb6909 100644 (file)
@@ -1,3 +1,20 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: TestCopyDicom.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/11/19 08:37:55 $
+  Version:   $Revision: 1.14 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
 #include "gdcmHeader.h"
 #include "gdcmFile.h"
 #include "gdcmDocument.h"
@@ -6,6 +23,8 @@
 
 #ifndef _WIN32
 #include <unistd.h> //for access, unlink
+#else
+#include <io.h> //for _access
 #endif
 
 // return true if the file exists
@@ -47,6 +66,8 @@ int main(int argc, char* argv[])
       return 1;
    }
 
+// don't modify identation in order to let this source xdiffable with ../Test
+
       std::string filename = argv[1];
       std::string output = argv[2];
 
@@ -59,17 +80,19 @@ int main(int argc, char* argv[])
             return 1;
          }
       }
-      gdcmFile *original = new gdcmFile( filename );
+      gdcm::File *original = new gdcm::File( filename );
    
       std::cout << "--- Original ----------------------" << std::endl;
       //original->GetHeader()->Print();
    
-      gdcmFile *copy = new gdcmFile( output );
+      gdcm::File *copy = new gdcm::File( output );
 
-      TagDocEntryHT & Ht = original->GetHeader()->GetEntry();
+      const gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetTagHT();
 
       size_t dataSize = original->GetImageDataSize();
-      void *imageData = original->GetImageData();
+      uint8_t* imageData = original->GetImageData();
+      (void)imageData;
+      (void)dataSize;
   
       //First of all copy the header field by field
   
@@ -78,22 +101,22 @@ int main(int argc, char* argv[])
       // (the user does NOT have to know the way we implemented the Header !)
       // Waiting for a 'clean' solution, I keep the method ...JPRx
 
-      gdcmDocEntry* d;
+      gdcm::DocEntry* d;
 
-      for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
+      for (gdcm::TagDocEntryHT::const_iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
       {
          d = tag->second;
          d->Print(); std::cout << std::endl;
-         if ( gdcmBinEntry* b = dynamic_cast<gdcmBinEntry*>(d) )
+         if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
          {              
             copy->GetHeader()->ReplaceOrCreateByNumber( 
-                                 b->GetVoidArea(),
+                                 b->GetBinArea(),
                                  b->GetLength(),
                                  b->GetGroup(), 
                                  b->GetElement(),
                                  b->GetVR() );
          }
-         else if ( gdcmValEntry* v = dynamic_cast<gdcmValEntry*>(d) )
+         else if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
          {   
             copy->GetHeader()->ReplaceOrCreateByNumber( 
                                  v->GetValue(),
@@ -116,7 +139,7 @@ int main(int argc, char* argv[])
 
 
       //copy->GetImageData();
-      copy->SetImageData(imageData, dataSize);
+      //copy->SetImageData(imageData, dataSize);
 
       std::cout << "--- Copy ----------------------" << std::endl;
       std::cout <<std::endl << "DO NOT care about Offset"  <<std::endl<<std::endl;;