]> Creatis software - gdcm.git/blobdiff - Example/ToInTag.cxx
Add uint64_t related checks
[gdcm.git] / Example / ToInTag.cxx
index 5939b558be059019785fe0a24bfd24921473ffbc..80005ed185f3c2fac8f4aac9aae5268464d358a4 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: ToInTag.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/06/02 05:46:44 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2006/06/08 13:41:28 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -101,6 +101,8 @@ int main(int argc, char *argv[])
    " debug    : *developer*  wants to run the program in 'debug mode'         ",
    FINISH_USAGE
 
+   std::cout << "inside ToInTag" << std::endl;
+   
    // ----- Initialize Arguments Manager ------
       
    gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv);
@@ -267,7 +269,8 @@ int main(int argc, char *argv[])
    s->AddSeriesDetail(0x0018, 0x1060, true);  // Trigger Time (true: convert to keep numerical order)
    s->AddSeriesDetail(0x0018, 0x1312, false); // In-plane Phase Encoding Direction 
 
-   uint8_t *imageData;
+   //uint8_t *imageData; // Useless : pixels will not be loaded 
+                         //          (images are overwritten)
          
    for (gdcm::DirListType::iterator it = fileNames.begin();  
                                     it != fileNames.end();
@@ -365,6 +368,8 @@ int main(int argc, char *argv[])
    std::string previousImagePosition, currentImagePosition;
    std::string previousPhaseEncodingDirection, currentPhaseEncodingDirection;
    std::string previousTriggerTime, currentTriggerTime;
+   
+   std::string currentStudyUID;   
       
    std::string writeDir, currentWriteDir;
    std::string currentPatientWriteDir, currentSerieWriteDir, 
@@ -387,6 +392,9 @@ int main(int argc, char *argv[])
    int flag       = 0;
        
    gdcm::File *currentFile;
+
+   std::string defaultStudyUID =  gdcm::Util::CreateUniqueUID();
+   std::string defaultSerieUID; 
      
    for (it2 = sf.begin() ; it2 != sf.end(); ++it2)
    {  
@@ -411,7 +419,15 @@ int main(int argc, char *argv[])
           currentImagePosition[0] = 'P'; 
       
       if (previousPatientName != currentPatientName)
-      {
+      {      
+         if ( currentFile->GetEntryString(0x0020,0x000d) == gdcm::GDCM_UNFOUND)
+         {
+            if (verbose)   
+               std::cout << "--- new  Study UID created" << std::endl;
+            defaultStudyUID =  gdcm::Util::CreateUniqueUID();
+            currentFile->InsertEntryString(defaultStudyUID, 0x0020, 0x000d, "UI" );
+         }
+  
          previousPatientName = currentPatientName;
          if (verbose)   
             std::cout << "==== new Patient  [" << currentPatientName  << "]" << std::endl;
@@ -437,6 +453,15 @@ int main(int argc, char *argv[])
          if (verbose)   
             std::cout << "==== === new Serie [" << currentSerieInstanceUID << "]"
                       << std::endl;
+      
+         if ( currentFile->GetEntryString(0x0020,0x000e) == gdcm::GDCM_UNFOUND)
+         {
+            if (verbose)   
+               std::cout << "--- --- new  Serie UID created" << std::endl;
+            defaultSerieUID =  gdcm::Util::CreateUniqueUID();
+            currentFile->InsertEntryString(defaultSerieUID, 0x0020, 0x000e, "UI" );
+         }       
+      
          if (split)
          {
              currentSerieWriteDir  = currentPatientWriteDir + gdcm::GDCM_FILESEPARATOR