]> Creatis software - gdcm.git/commitdiff
Coding style + minor modif
authorjpr <jpr>
Wed, 24 Oct 2007 08:03:10 +0000 (08:03 +0000)
committerjpr <jpr>
Wed, 24 Oct 2007 08:03:10 +0000 (08:03 +0000)
Example/Dense2007ToDicom.cxx
Example/SplitIntoXCoherentDirectories.cxx
Example/ToInTag.cxx
Example/exXCoherentFileSet.cxx

index cb58bb01c4e70d453d8f82ae2aa5fcd83a52ba29..6cc49ff66e95fcae5e1d09b76941f8879972424d 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: Dense2007ToDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/15 13:55:35 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2007/10/24 08:03:10 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -603,14 +603,27 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
    std::cout << "Max X,Y,Z " << maxX << " " << maxY << " " << maxZ <<  std::endl;
    std::cout << "Size X,Y,Z " << maxX-minX << " " << maxY-minY << " " << maxZ-minZ <<  std::endl;      
 
-   uint16_t *img = new uint16_t[int(maxX)*int(maxY)];
+//   uint16_t *img = new uint16_t[int(maxX+0.5)*int(maxY+0.5)];
+   uint16_t *img = new uint16_t[int(maxX*4.)*int(maxY*4.)];
    
    // Set whole image to 0 
-   for(int i3=0;i3<int(maxX)*int(maxY);i3++)
+   for(int i3=0;i3<int(maxX*4.)*int(maxY*4.);i3++)
+//   for(int i3=0;i3<int(maxX+0.5)*int(maxY+0.5);i3++)
       img[i3] = 0; 
-     
+
    for(int i2=0; i2<NP; i2++) {
-      img[ int(maxX) -int(X[i2]-1) +  (int(maxY) -int(Y[i2]))* int(maxX) ] = int(tabVal[i2]*100);
+   
+      int ordX = int(X[i2]*4.-30);
+      int ordY = int(maxY*4.) - int(Y[i2]*4.)+30;      
+//   img[ /*int(maxX) -*/ int(X[i2]+0.5-1)   +  (int(maxY+0.5) - int(Y[i2]+0.5))   * int(maxX+0.5) ] = int(tabVal[i2]*100);
+   
+//   img[ /*int(maxX) -*/ int(X[i2]*4.-30)   +  (int(maxY*4.) - int(Y[i2]*4.)+30)   * int(maxX*4.) ] = int(tabVal[i2]*100);
+   img[ /*int(maxX) -*/ ordX   +  ordY   * int(maxX*4.) ] = int(tabVal[i2]*100);
+
+      // Try to round up, just to see.   
+       for(int iii=ordY-3; iii<ordY+4; iii++) for(int jjj=ordX-3; jjj<ordX+4; jjj++) 
+          img[  jjj  +  iii   * int(maxX*4.) ] = int(tabVal[i2]*100);         
+      std::cout << int(X[i2]*4.) << " " << int(Y[i2]*4.) << " = " << int(tabVal[i2]*100) << std::endl;      
    }       
   
  // GDCM_NAME_SPACE::Debug::DebugOn();
@@ -622,10 +635,10 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
               
   // Set the image size
    str.str(""); 
-   str << (int)(maxX);
+   str << (int)(maxX*4.);
    file->InsertEntryString(str.str(),0x0028,0x0011,"US"); // Columns
    str.str("");
-   str << (int)(maxY);
+   str << (int)(maxY*4.);
    file->InsertEntryString(str.str(),0x0028,0x0010,"US"); // Rows
    
   // Set the pixel type
@@ -657,7 +670,7 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
    fileH = GDCM_NAME_SPACE::FileHelper::New(file);
    // cast is just to avoid warnings (*no* conversion)
    //fileH->SetImageData((uint8_t *)img,int(maxX*maxY)*sizeof(uint16_t)); // troubles when maxX, mayY are *actually* float!
-   fileH->SetImageData((uint8_t *)img,int(maxX)*int(maxY)*sizeof(uint16_t));
+   fileH->SetImageData((uint8_t *)img,int(maxX*4.)*int(maxY*4.)*sizeof(uint16_t));
    fileH->SetWriteModeToRaw(); 
    fileH->SetWriteTypeToDcmExplVR();
         
index 4fc1d51557ab2464d1c085fb63f4574bc9a64646..47de2ea03fa7e77b73203fe0550ed098d4021f45 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: SplitIntoXCoherentDirectories.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/19 11:53:42 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2007/10/24 08:03:10 $
+  Version:   $Revision: 1.3 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -34,14 +34,14 @@ int main(int argc, char *argv[])
    "usage: exXCoherentFileSet {dirin=inputDirectoryName}                      ",
    "                           dirout=outputDirectoryName                     ",
    "                       { tag=group-elem | pos | ori } [sort]              ",
-   "                       [{ write | copy }] [studyUID = ]                   ", 
+   "                       [{ write | copy }] [studyUID = ]                   ",
    "                       [ { [noshadowseq] | [noshadow][noseq] } ] [debug]  ",
    "                                                                          ",
    "       dirin : user wants to analyze *all* the files                      ",
    "                            within the directory                          ",
    "       copy  : user wants to copy the files into a directories tree       ",
    "       write : user wants to rewrite the files into a directories tree    ",
-   "               each directory with the same 'Series Instance UID'         ", 
+   "               each directory with the same 'Series Instance UID'         ",
    "       dirout : will be created if doesn't exist                          ",
    "       pos  : user wants to split each Single SerieUID Fileset on the     ",
    "                         'Image Position '                                ",
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
    bool ori  =    ( 0 != am->ArgMgrDefined("ori") );   
    bool sort =    ( 0 != am->ArgMgrDefined("sort") );
    bool copy =    ( 0 != am->ArgMgrDefined("copy") );
-   bool write =   ( 0 != am->ArgMgrDefined("write") );   
+   bool write =   ( 0 != am->ArgMgrDefined("write") );
    bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
    bool tag     = ( 0 != am->ArgMgrDefined("tag") );
    
@@ -143,8 +143,7 @@ int main(int argc, char *argv[])
  
    delete am;  // ------ we don't need Arguments Manager any longer ------
 
-
-      
+   
    GDCM_NAME_SPACE::SerieHelper *s;  
    s = GDCM_NAME_SPACE::SerieHelper::New();
    
@@ -161,26 +160,26 @@ int main(int argc, char *argv[])
    {
       if (verbose)
          std::cout << *it << std::endl;
+
       if (write) {
          loadMode = GDCM_NAME_SPACE::LD_ALL; // load any DataElement
           maxSize  = 0x7fff;                  // load any length
       } else {
          loadMode = GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW ; 
-         maxSize  = 0x0100;      
+         maxSize  = 0x0100;
       }
 
       f = GDCM_NAME_SPACE::File::New();
       f->SetLoadMode(loadMode);
-      f->SetMaxSizeLoadEntry(maxSize); 
+      f->SetMaxSizeLoadEntry(maxSize);
       f->SetFileName( *it );
       f->Load();
-      l->push_back(f);     
+      l->push_back(f);
    }
 
    std::string systemCommand;
    std::string filenameout;
-   if (write || copy) { 
+   if (write || copy) {
       if (verbose)
          std::cout << "Check for output directory :[" << dirNameout << "]."
                    <<std::endl;
@@ -210,7 +209,7 @@ int main(int argc, char *argv[])
                       << "] already exists; Used as is."
                       << std::endl;
       }
-   } 
+   }
       // --> End of checking supposed-to-be-directory names
 
    int nbFiles;
@@ -225,12 +224,12 @@ int main(int argc, char *argv[])
    std::string serieUID;
    std::string currentSerieWriteDir = "";
    std::string xCoherentWriteDir = "";
-   std::string xCoherentName = ""; 
+   std::string xCoherentName = "";
    std::string serieDirectory;
    std::string lastFilename;
    std::string rep("_");
    int controlCount = 0;
-   
+  
    // 'Study Instance UID'
    // The user is allowed to create his own Study, 
    //          keeping the same 'Study Instance UID' for various images
@@ -293,9 +292,9 @@ GDCM_NAME_SPACE::Debug::DebugOn();
  
             xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] );
          }
+
          GDCM_NAME_SPACE::FileHelper *fh;
+
          for (GDCM_NAME_SPACE::XCoherentFileSetmap::iterator i = xcm.begin(); 
                                                   i != xcm.end();
                                                 ++i)
@@ -334,7 +333,7 @@ GDCM_NAME_SPACE::Debug::DebugOn();
            // OrderFileList() causes trouble, since some files
            // (eg:MIP views) don't have 'Position', now considered as mandatory
            // --> Activated on user demand.
-           
+
             if (sort) {
               s->OrderFileList((*i).second);  // sort the XCoherent Fileset
               std::cout << "ZSpacing for the file set " << s->GetZSpacing()
@@ -353,10 +352,10 @@ GDCM_NAME_SPACE::Debug::DebugOn();
     
                // --- for write
                lastFilename =  GDCM_NAME_SPACE::Util::GetName( fileName );
-               filenameout = xCoherentWriteDir  + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;   
+               filenameout = xCoherentWriteDir  + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
                if (write)
                {  
-                  fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) );  
+                  fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) );
                   fh->SetKeepOverlays( true );       
                   fh->InsertEntryString(strSerieUID,0x0020,0x000e,"UI");
                   unsigned int dataSize  = fh->GetImageDataRawSize();
@@ -371,16 +370,15 @@ GDCM_NAME_SPACE::Debug::DebugOn();
                                << std::endl;
                   }
                   fh->Delete();
-               } 
+               }
                else if (copy)
                {
                    systemCommand   = "cp " + fileName + " " + filenameout;
                    system( systemCommand.c_str());
-               } 
+               }
                if (verbose)
                      std::cout << "3 " << systemCommand << std::endl;
-            } 
-
+            }
             std::cout << std::endl;   
          }
       }
@@ -388,7 +386,7 @@ GDCM_NAME_SPACE::Debug::DebugOn();
     
    if ( controlCount == 0 )
       std::cout << "No suitable file was found!" << std::endl;
+
    s->Delete();
    return 0;
 }
index 8d2ae3ea8f9015838554d1ea8ec97feb14115832..1b4f292df6bf354f84f12b8b05b76001fddf2703 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: ToInTag.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/09/28 14:09:20 $
-  Version:   $Revision: 1.19 $
+  Date:      $Date: 2007/10/24 08:03:10 $
+  Version:   $Revision: 1.20 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -599,7 +599,7 @@ int main(int argc, char *argv[])
                              + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
                              + currentPhaseEncodingDirection;
              systemCommand   = "mkdir " + currentPhaseEncodingDirectionWriteDir;     
-             system (systemCommand.c_str()); 
+             system (systemCommand.c_str());
          }
 
          previousPhaseEncodingDirection = currentPhaseEncodingDirection;
index f4949fea13962f5af285f3574903a94d98936d4d..3604db0720227f0f0f7971dfb26327cea4f95367 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exXCoherentFileSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/19 15:15:16 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2007/10/24 08:03:10 $
+  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
 #include <iostream>
 #include "gdcmDirList.h"
 #include "gdcmUtil.h"
-
 #include "gdcmArgMgr.h"
-
-     
 int main(int argc, char *argv[])
-{  
+{
 
    START_USAGE(usage)
    "\n exXCoherentFileSet :\n                                                 ",
@@ -53,7 +50,7 @@ int main(int argc, char *argv[])
    "       noshadowseq: user doesn't want to load Private Sequences           ",
    "       noshadow   : user doesn't want to load Private groups (odd number) ",
    "       noseq      : user doesn't want to load Sequences                   ",
-   "       verbose    : user wants to run the program in 'verbose mode'       ",   
+   "       verbose    : user wants to run the program in 'verbose mode'       ",
    "       debug      : developper wants to run the program in 'debug mode'   ",
    FINISH_USAGE
    
@@ -74,7 +71,7 @@ int main(int argc, char *argv[])
    int loadMode = GDCM_NAME_SPACE::LD_ALL;
    if ( am->ArgMgrDefined("noshadowseq") )
       loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
-   else 
+   else
    {
       if ( am->ArgMgrDefined("noshadow") )
          loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW;
@@ -144,17 +141,17 @@ int main(int argc, char *argv[])
    s = GDCM_NAME_SPACE::SerieHelper::New();
    s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL);     // Load everything for each File
    
-   //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);   
+   //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);
    //s->AddRestriction(t, "340", GDCM_NAME_SPACE::GDCM_LESS); // Keep only files where
                                                               // restriction is true
-     
+   
    s->SetDirectory(dirName, true); // true : recursive exploration
 
    // The Dicom file set is splitted into several 'Single SerieUID Files Sets'
    // (a 'Single SerieUID Files Set' per SerieUID)
    // In some cases, it's not enough, since, in some cases
    // we can find scout view with the same SerieUID
-   
+
 /*
    std::cout << " ---------------------------------------- "
              << "'Single UID' Filesets found in :["
@@ -166,8 +163,8 @@ int main(int argc, char *argv[])
 */
 
    std::string systemCommand;
-   std::string filenameout;   
-   if (write) { 
+   std::string filenameout;
+   if (write) {
       if (verbose)
          std::cout << "Check for output directory :[" << dirNameout << "]."
                    <<std::endl;
@@ -193,29 +190,27 @@ int main(int argc, char *argv[])
       else
       {
          if (verbose)
-            std::cout << "Output Directory [" << dirNameout 
+            std::cout << "Output Directory [" << dirNameout
                       << "] already exists; Used as is."
                       << std::endl;
-      }      
+      }
    }
-   
       // --> End of checking supposed-to-be-directory names
-      
+
    int nbFiles;
    std::string fileName;
-   
+
    // For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
    GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();
-   
    GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
-   
+
    std::string serieUID;
    std::string currentSerieWriteDir = "";
-   std::string xCoherentWriteDir = ""; 
-   std::string xCoherentName = "";     
+   std::string xCoherentWriteDir = "";
+   std::string xCoherentName = "";
    std::string serieDirectory;
    std::string lastFilename;
-   std::string rep("_");   
+   std::string rep("_");
    int controlCount = 0;
   
    while (l) // for each 'Single SerieUID FileSet'
@@ -265,7 +260,7 @@ int main(int argc, char *argv[])
                                                   i != xcm.end();
                                                 ++i)
          {
-             xCoherentName = (*i).first;
+            xCoherentName = (*i).first;
             if (verbose)
                std::cout << "xCoherentName = " << xCoherentName << std::endl;
             GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
@@ -299,7 +294,7 @@ int main(int argc, char *argv[])
            // OrderFileList() causes trouble, since some files
            // (eg:MIP views) don't have 'Position', now considered as mandatory
            // Commented out for the moment.
-           
+
            if (sort) {
               s->OrderFileList((*i).second);  // sort the XCoherent Fileset
               std::cout << "ZSpacing for the file set " << s->GetZSpacing()
@@ -318,14 +313,14 @@ int main(int argc, char *argv[])
                if (write)
                {  
                   lastFilename =  GDCM_NAME_SPACE::Util::GetName( fileName );
-                  filenameout = xCoherentWriteDir  + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename; 
+                  filenameout = xCoherentWriteDir  + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename;
                   systemCommand   = "cp " + fileName + " " + filenameout;
                   system( systemCommand.c_str());
                   if (verbose)
                      std::cout << "3 " << systemCommand << std::endl;
-                } 
+                }
                // --- end for write       
-            } 
+            }
             std::cout << std::endl;   
          }
       }
@@ -334,7 +329,7 @@ int main(int argc, char *argv[])
     
    if ( controlCount == 0 )
       std::cout << "No suitable file was found!" << std::endl;
+
    s->Delete();
 
    return 0;