]> Creatis software - gdcm.git/blobdiff - Example/exReadWriteFile.cxx
Synchronize (fix comments, misstyping, re ident, etc)
[gdcm.git] / Example / exReadWriteFile.cxx
index 3666c6eefed4d46d50ab290c85d1efc3eefa03b0..f0ff1209e56753685559bb99ab0c63f3ce588acb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exReadWriteFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2010/09/01 14:41:48 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -26,8 +26,6 @@
  
 int main(int argc, char *argv[])
 {
-
-
 std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
 std::cout << " "                                                    <<std::endl; 
 std::cout << " This source program is NOT intendend to be run as is"<<std::endl;
@@ -36,7 +34,7 @@ std::cout << " It just shows a set of possible uses."               <<std::endl;
 std::cout << "User MUST read it, "                                  <<std::endl;
 std::cout << "          comment out the useless parts "             <<std::endl;
 std::cout << "          invoke it with an ad hoc image(*) "         <<std::endl;
-std::cout << "           check the resulting image   "              <<std::endl; 
+std::cout << "          check the resulting image   "               <<std::endl;
 std::cout << "  "                                                   <<std::endl;
 std::cout << " (*) For samples, user can refer to gdcmData"         <<std::endl;
 std::cout << "         and read README.txt file "                   <<std::endl;
@@ -56,10 +54,10 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    std::string filename = argv[1];
    std::string output   = argv[2];
 
-   // First, let's create a gdcm::File
+   // First, let's create a GDCM_NAME_SPACE::File
    // that will contain all the Dicom fields but the Pixels Element
 
-   gdcm::File *f1= new gdcm::File( );
+   GDCM_NAME_SPACE::File *f1= GDCM_NAME_SPACE::File::New( );
    f1->SetFileName( filename );
    f1->Load();
 
@@ -79,18 +77,18 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
              << "--- Display only human readable values -----------------------"
              << std::endl;
 
-   gdcm::DataEntry *dataEntry;
+   GDCM_NAME_SPACE::DataEntry *dataEntry;
    std::string value;
-   std::string vr;   // value representation
+   GDCM_NAME_SPACE::VRKey vr;   // value representation
    std::string vm;   // value multiplicity
    std::string name; // held in the Dicom Dictionary
 
 
-   gdcm::DocEntry *d = f1->GetFirstEntry();
+   GDCM_NAME_SPACE::DocEntry *d = f1->GetFirstEntry();
    while( d )
    {
       // We skip SeqEntries, since user cannot do much with them
-      if ( !(dynamic_cast<gdcm::SeqEntry*>(d))
+      if ( !(dynamic_cast<GDCM_NAME_SPACE::SeqEntry*>(d))
       // We skip Shadow Groups, since nobody knows what they mean
            && !( d->GetGroup()%2 ) )
      {      
@@ -100,7 +98,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
 
          // If user wants to get info about the entry
          // (he is sure, here that DocEntry is a DataEntry)
-         dataEntry = dynamic_cast<gdcm::DataEntry *>(d);
+         dataEntry = dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(d);
          // Let's be carefull -maybe he commented out some previous line-
          if (!dataEntry)
             continue;
@@ -217,8 +215,8 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    
    // Hope now he knows enought about the image ;-)
 
-   // First, create a gdcm::FileHelper
-   gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+   // First, create a GDCM_NAME_SPACE::FileHelper
+   GDCM_NAME_SPACE::FileHelper *fh1 = GDCM_NAME_SPACE::FileHelper::New(f1);
 
    // Load the pixels, transforms LUT (if any) into RGB Pixels 
    uint8_t *imageData = fh1->GetImageData();
@@ -232,7 +230,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    // Get the image data size
    size_t dataRawSize    = fh1->GetImageDataRawSize();
 
-   // TODO : Newbee user would appreciate any comment !
+   /// \TODO : Newbee user would appreciate any comment !
  
    std::cout << "GetImageDataSize()"    
           << fh1->GetImageDataSize()    << std::endl;
@@ -253,7 +251,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
  
    // ------ User wants write a new image without shadow groups -------------
 
-   gdcm::FileHelper *copy = new gdcm::FileHelper( );
+   GDCM_NAME_SPACE::FileHelper *copy = GDCM_NAME_SPACE::FileHelper::New( );
    copy->SetFileName( output );
    copy->Load();
  
@@ -261,12 +259,12 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    while(d)
    {
       // We skip SeqEntries, since user cannot do much with them
-      if ( !(dynamic_cast<gdcm::SeqEntry*>(d))
+      if ( !(dynamic_cast<GDCM_NAME_SPACE::SeqEntry*>(d))
       // We skip Shadow Groups, since nobody knows what they mean
            && !( d->GetGroup()%2 ) )
       { 
 
-         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
+         if ( GDCM_NAME_SPACE::DataEntry *de = dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(d) )
          {              
             copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
                                                  de->GetGroup(),de->GetElement(),
@@ -274,7 +272,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
          }
          else
          {
-          // We skip gdcm::SeqEntries
+          // We skip GDCM_NAME_SPACE::SeqEntries
          }
       }
       d = f1->GetNextEntry();
@@ -323,9 +321,9 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    std::cout << std::endl
              << "------------------------------------------------------------"
              << std::endl;
-   delete f1;
-   delete fh1;
-   delete copy;
+   f1->Delete();
+   fh1->Delete();
+   copy->Delete();
 
    exit (0);
 }