]> Creatis software - gdcm.git/commitdiff
minor improvements
authorjpr <jpr>
Thu, 28 May 2009 15:44:34 +0000 (15:44 +0000)
committerjpr <jpr>
Thu, 28 May 2009 15:44:34 +0000 (15:44 +0000)
Example/CMakeLists.txt
Example/PrintFile.cxx
Example/SplitIntoDirectories.cxx
Example/SplitIntoXCoherentDirectories.cxx
Example/SplitIntoXCoherentDirectoriesIgnoreSerieUID.cxx
Example/exExtractOverlaysDCM.cxx
Example/exPresentationState.cxx
Example/exSerieHelper.cxx
Example/exXCoherentFileSet.cxx

index df209e4c3f7009cb3e1b89f1b749177c69b9096a..d98b401df0a18c6c009b7126aa5bb7d46d5f0321 100644 (file)
@@ -9,6 +9,7 @@ SET(EXAMPLE_SOURCES
   #Txt2Mat  
   #exDicomRTStructSetFile  
   #exExtractCSA
+ exPresentationState
  
   exReadPapyrus  
   exReadWriteFile  
index a89c6260a9f8ec2e7880ffea56b3b98faf0e5350..23f648359c4b9ceff43a4c82de5324deaf281cb3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/03/04 08:57:40 $
-  Version:   $Revision: 1.92 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  Version:   $Revision: 1.93 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -347,13 +347,18 @@ if (!noex)
       std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
       std::cout << " ------" << std::endl;
 
+
       std::cout << "\n\n" << std::endl; 
       std::cout << "X spacing " << f->GetXSpacing() << std::endl;
       std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
       std::cout << "Z spacing " << f->GetZSpacing() << std::endl;
-    
+   
 //------------------------------
 
+
+
+
+
       // Let's get and print some usefull fields about 'Orientation'
       // ------------------------------------------------------------
 
@@ -407,9 +412,11 @@ if (!noex)
                    << strImagePositionPatientRET << "]" << std::endl;
   
      float iop[6];
-     /*bool riop = */f->GetImageOrientationPatient(iop);  
+     //bool riop = 
+        f->GetImageOrientationPatient(iop);  
      float ipp[3];
-     /*bool ripp = */f->GetImagePositionPatient(ipp);
+     //bool ripp = 
+        f->GetImagePositionPatient(ipp);
 
      std::cout << "Image Position (0x0020,0x0032|0x0030) : "
                << ipp[0] << " , " << ipp[1] << " , "<< ipp[2]
index 07e7b58e713593e16ee7f9737ba900f551e96689..abcfbe75c18877f16da89cde16d99ce83750d474 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: SplitIntoDirectories.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/30 11:37:16 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  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
 #include <iostream>
 
 /**
-  * \brief   
+  * \brief
   *          - explores recursively the given directory
   *          - keeps the requested series
   *          - orders the gdcm-readable found Files
   *            according to their Patient/Study/Serie/Image characteristics
-  */  
+  */
 
 typedef std::map<std::string, GDCM_NAME_SPACE::File*> SortedFiles;
 
-int main(int argc, char *argv[]) 
+int main(int argc, char *argv[])
 {
    START_USAGE(usage)
    " \n SplitIntoDirectories :\n                                              ",
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
    " - keeps the requested series / drops the unrequested series              ",
    " - orders the gdcm-readable found Files according to their                ",
    "           (0x0010, 0x0010) Patient's Name                                ",
-   "           (0x0020, 0x000d) Study Instance UID                            ",   
+   "           (0x0020, 0x000d) Study Instance UID                            ",
    "           (0x0020, 0x000e) Series Instance UID                           ",
    " - fills a tree-like structure of directories as :                        ",
    "        - Patient                                                         ",
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
    std::cout << "... inside " << argv[0] << std::endl;
    
    // ----- Initialize Arguments Manager ------
-      
+
    GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
   
    if (argc == 1 || am->ArgMgrDefined("usage")) 
@@ -108,16 +108,16 @@ int main(int argc, char *argv[])
       return 0;
    }
 
-   const char *dirNamein;   
-   dirNamein  = am->ArgMgrGetString("dirin","."); 
+   const char *dirNamein;
+   dirNamein  = am->ArgMgrGetString("dirin",".");
 
    const char *dirNameout;   
-   dirNameout  = am->ArgMgrGetString("dirout",".");  
+   dirNameout  = am->ArgMgrGetString("dirout",".");
    
    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;
@@ -131,30 +131,30 @@ int main(int argc, char *argv[])
    bool verbose    = ( 0 != am->ArgMgrDefined("verbose") );
    bool listonly   = ( 0 != am->ArgMgrDefined("listonly") );
    bool seriedescr = ( 0 != am->ArgMgrDefined("seriedescr") );
-            
+
    int nbSeriesToKeep;
    int *seriesToKeep = am->ArgMgrGetListOfInt("keep", &nbSeriesToKeep);
    int nbSeriesToDrop;
    int *seriesToDrop = am->ArgMgrGetListOfInt("drop", &nbSeriesToDrop);
+
    if ( nbSeriesToKeep!=0 && nbSeriesToDrop!=0)
    {
       std::cout << "KEEP and DROP are mutually exclusive !" << std::endl;
       delete am;
-      return 0;         
+      return 0;
    }
 
-   bool hasSkel = ( 0 != am->ArgMgrDefined("hasSkel") );    
+   bool hasSkel = ( 0 != am->ArgMgrDefined("hasSkel") );
    const char *skel;
    if (hasSkel)
-      skel = am->ArgMgrGetString("skel");   
-      
-      
+      skel = am->ArgMgrGetString("skel");
+
+
    const char *input   = am->ArgMgrGetString("input","DCM");
    
    // if unused Param we give up
    if ( am->ArgMgrPrintUnusedLabels() )
-   { 
+   {
       am->ArgMgrUsage(usage);
       delete am;
       return 0;
@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
    }
 
    std::string systemCommand;
-   
+
    std::cout << "Check for output directory :[" << dirNameout << "]."
              <<std::endl;
    if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(dirNameout) )    // dirout not found
@@ -191,10 +191,9 @@ int main(int argc, char *argv[])
       system (systemCommand.c_str());
       if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(dirNameout) ) // be sure it worked
       {
-          std::cout << "KO : not a dir : [" << dirNameout << "] (creation failure ?)" 
+         std::cout << "KO : not a dir : [" << dirNameout << "] (creation failure ?)" 
                     << std::endl;
-      return 0;
-
+         return 0;
       }
       else
       {
@@ -291,11 +290,11 @@ int main(int argc, char *argv[])
       if (verbose)
          std::cout << "Try[" << *it << "]\n";
       f->Load();
-      if (!f->IsReadable())
+      if (!f->Document::IsReadable())
       {
          if (verbose)
             std::cout << "File : [" << *it << "] not gdcm-readable -> skipped !" << std::endl;
-         continue;     
+         continue;
       }
       if (verbose)
          std::cout << "Loaded!\n";
@@ -326,13 +325,13 @@ int main(int argc, char *argv[])
       // drop all unrequested Series
       bool drop = false;
       if (nbSeriesToDrop != 0)
-      {     
+      {
          strSeriesNumber = f->GetEntryString(0x0020, 0x0011 );
          seriesNumber = atoi( strSeriesNumber.c_str() );
          for (j=0;j<nbSeriesToDrop; j++)
          {
             if(seriesNumber == seriesToDrop[j])
-            { 
+            {
                drop = true;
                break;
             }
@@ -351,13 +350,13 @@ int main(int argc, char *argv[])
       GDCM_NAME_SPACE::Util::Tokenize (userFileIdentifier, tokens, token);
 
       char newName[1024];
-      
+
       ///this is a trick to build up a lexicographical compliant name :
       ///     eg : fich001.ima vs fich100.ima as opposed to fich1.ima vs fich100.ima
       std::string name = GDCM_NAME_SPACE::Util::GetName( *it );
-      
+
       std::cout << "name :[" << name << "]\n";
-      
+
       if (hasSkel)
       {
          int imageNum; // Within FileName
@@ -372,14 +371,14 @@ int main(int argc, char *argv[])
        {
          tokens[IND_FileName] = name;
        }
-    
+
          // Patient's Name
-         // Study Instance UID 
+         // Study Instance UID
          // Series Instance UID
          // SerieDescription
          // Serie Number
          // file Name
-           
+
       userFileIdentifier = tokens[IND_PatientName]      + token +
                            tokens[IND_StudyInstanceUID] + token + 
                            tokens[IND_SerieInstanceUID] + token +
@@ -387,11 +386,11 @@ int main(int argc, char *argv[])
                            tokens[IND_SerieDescription] + token +
                            tokens[IND_SerieNumber]      + token +
                            tokens[IND_FileName];
-         
+
       if (verbose) 
          std::cout << "[" << userFileIdentifier  << "] : " << *it << std::endl;
-               
-      // storing in a map ensures automatic sorting !      
+
+      // storing in a map ensures automatic sorting !
       sf[userFileIdentifier] = f;
    }
    
@@ -450,22 +449,22 @@ int main(int argc, char *argv[])
          previousPatientName            = currentPatientName;
          previousStudyInstanceUID       = ""; 
          previousSerieInstanceUID       = "";
-  
+
          currentPatientWriteDir = writeDir + currentPatientName;
 
          systemCommand   = "mkdir " + currentPatientWriteDir;
          if (verbose || listonly)
             std::cout << "[" << systemCommand << "]" << std::endl;
-         if (!listonly)               
+         if (!listonly)
             system ( systemCommand.c_str() );
       }
-      
+
       if (previousStudyInstanceUID != currentStudyInstanceUID)
-      {        
+      {
          previousStudyInstanceUID       = currentStudyInstanceUID;
-         if (verbose)   
+         if (verbose)
             std::cout << "==== === new Study [" << currentStudyInstanceUID << "]"
-                      << std::endl;      
+                      << std::endl;
 
          currentStudyWriteDir  = currentPatientWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
                              + currentStudyInstanceUID;
@@ -487,11 +486,12 @@ int main(int argc, char *argv[])
                             
          if (seriedescr) // more human readable!
             currentSerieWriteDir  = currentStudyWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
-                                  + currentSerieDescription + "_" + currentSerieNumber;
+                                  + currentSerieDescription + "_" + currentSerieNumber
+                                  + "_" + currentSerieInstanceUID;
          else
             currentSerieWriteDir  = currentStudyWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR
                                   + currentSerieInstanceUID;         
-                                 
+                      
          systemCommand   = "mkdir " + currentSerieWriteDir;
          
          if (listonly)
index 47de2ea03fa7e77b73203fe0550ed098d4021f45..6e83fd58b61bb39891213464d89402e7843192a8 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: SplitIntoXCoherentDirectories.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/24 08:03:10 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  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
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
    START_USAGE(usage)
    "\n exXCoherentFileSet :\n                                                 ",
    "Shows the various 'XCoherent' Filesets within a directory                 ",
-   "Optionaly copis the images in a Directories tree                          ",
+   "Optionaly copies the images in a Directories tree                         ",
    "usage: exXCoherentFileSet {dirin=inputDirectoryName}                      ",
    "                           dirout=outputDirectoryName                     ",
    "                       { tag=group-elem | pos | ori } [sort]              ",
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
  
    int loadMode;
    int maxSize;
-   
+
    const char *dirName  = am->ArgMgrGetString("dirin");
    if (dirName == 0)
    {
@@ -96,13 +96,13 @@ int main(int argc, char *argv[])
    bool write =   ( 0 != am->ArgMgrDefined("write") );
    bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
    bool tag     = ( 0 != am->ArgMgrDefined("tag") );
-   
+
    if( copy && write )
    {
       std::cout << "COPY and WRITE are mutually exclusive" << std::endl;
       delete am;
-      return 0;      
-   }   
+      return 0;
+   }
 
    if( (tag && (pos || ori)) || (pos && (tag || ori)) || (ori && (tag || pos)) )
    {
@@ -143,10 +143,13 @@ 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();
-   
+
+   s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL); // Load everything for each File
+   s->SetDirectory(dirName, true);          // true : recursive exploration
+
    GDCM_NAME_SPACE::File *f;
    
    GDCM_NAME_SPACE::DirList dirlist(dirName, true); // recursive exploration
@@ -163,7 +166,7 @@ int main(int argc, char *argv[])
 
       if (write) {
          loadMode = GDCM_NAME_SPACE::LD_ALL; // load any DataElement
-          maxSize  = 0x7fff;                  // load any length
+         maxSize  = 0x7fff;                  // load any length
       } else {
          loadMode = GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW ; 
          maxSize  = 0x0100;
@@ -217,7 +220,13 @@ int main(int argc, char *argv[])
 
    // For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
 
-   //GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();//===> Ignore 'Serie UID"
+  // GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();
+
+   l = s->GetFirstSingleSerieUIDFileSet();
+   if (l == NULL) {
+      std::cout << "No Serie found ?!?" << std::endl;
+      exit (0);
+   }
 
    GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
 
@@ -229,7 +238,7 @@ int main(int argc, char *argv[])
    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
@@ -243,16 +252,19 @@ int main(int argc, char *argv[])
          strStudyUID = studyUID;
    }
 
-//   while (l) // for each 'Single SerieUID FileSet' //===> Ignore 'Serie UID"
-//   { 
+   while (l) // for each 'Single SerieUID FileSet' //===> Ignore 'Serie UID"
+   { 
+ currentSerieWriteDir = "";
       nbFiles = l->size() ;
       if ( l->size() > 2 ) // ignore a Directory with less than 2 images.
                            // Why not ? Just an example, for testing!
       {
           // Just not to make too many modif in the code
-          serieUID = "SingleSerie"; //s->GetCurrentSerieUIDFileSetUID();
+          //serieUID = "SingleSerie"; // s->GetCurrentSerieUIDFileSetUID();
+          serieUID = s->GetCurrentSerieUIDFileSetUID();
+
           GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
+
           // --- for write
           if (write || copy)
           {
@@ -278,17 +290,14 @@ int main(int argc, char *argv[])
                    << serieUID
                    << "]  " << nbFiles << " long" << std::endl;
          std::cout << "-----------------------------------" << std::endl;
-GDCM_NAME_SPACE::Debug::DebugOn(); 
   
          if (ori) 
             xcm = s->SplitOnOrientation(l);
          else if (pos)
             xcm = s->SplitOnPosition(l);
          else if (groupelem != 0) {
-            std:: cout << GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(groupelem[0],groupelem[1])->GetName() << std::endl;
+         // Crashes if DataElement not found
+         //std:: cout << GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(groupelem[0],groupelem[1])->GetName() << std::endl;
  
             xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] );
          }
@@ -301,7 +310,7 @@ GDCM_NAME_SPACE::Debug::DebugOn();
          {
             xCoherentName = (*i).first;
             if (verbose)
-               std::cout << "xCoherentName = " << xCoherentName << std::endl;
+               std::cout << "==========================================xCoherentName = " << xCoherentName << std::endl;
              GDCM_NAME_SPACE::Util::ReplaceSpecChar(xCoherentName, rep);
              // --- for write
              if (write || copy)
@@ -334,11 +343,11 @@ GDCM_NAME_SPACE::Debug::DebugOn();
            // (eg:MIP views) don't have 'Position', now considered as mandatory
            // --> Activated on user demand.
 
-            if (sort) {
+           if (sort) {
               s->OrderFileList((*i).second);  // sort the XCoherent Fileset
               std::cout << "ZSpacing for the file set " << s->GetZSpacing()
                         << std::endl;
-            
+           } 
 
             std::string strSerieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
 
@@ -348,11 +357,9 @@ GDCM_NAME_SPACE::Debug::DebugOn();
             {
                controlCount ++;
                fileName = (*it2)->GetFileName();
-               std::cout << "    " << fileName << std::endl;
-    
                // --- 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) );
@@ -361,7 +368,7 @@ GDCM_NAME_SPACE::Debug::DebugOn();
                   unsigned int dataSize  = fh->GetImageDataRawSize();
                   uint8_t *imageData = fh->GetImageDataRaw();// somewhat important : Loads the Pixels in memory !
                   if (!imageData)
-                     std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl; 
+                     std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;
                   fh->SetWriteTypeToDcmExplVR();
                   fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
                   if (!fh->Write(filenameout))
@@ -379,10 +386,11 @@ GDCM_NAME_SPACE::Debug::DebugOn();
                if (verbose)
                      std::cout << "3 " << systemCommand << std::endl;
             }
-            std::cout << std::endl;   
          }
+         std::cout << std::endl;
       }
-     // l = s->GetNextSingleSerieUIDFileSet(); //===> Ignore 'Serie UID"
+      l = s->GetNextSingleSerieUIDFileSet();
+   }
     
    if ( controlCount == 0 )
       std::cout << "No suitable file was found!" << std::endl;
index 5b5a22633b73347bd44d98f301fd084f7e4fa0b0..bec07d82fc046fbf6fa44669c253048726067d6e 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: SplitIntoXCoherentDirectoriesIgnoreSerieUID.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/01 09:56:42 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  Version:   $Revision: 1.2 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
    "usage: SplitIntoCoherentFileSetIgnoreSerieUID{dirin=inputDirectoryName}   ",
    "                           dirout=outputDirectoryName                     ",
    "                       { tag=group-elem | pos | ori } [sort]              ",
-   "                       [{ write | copy }]                                 ", 
+   "                       [{ write | copy }]                                 ",
    "                       [ { [noshadowseq] | [noshadow][noseq] } ] [debug]  ",
    "  [studyUID = ]                                                           ",
    "       dirin : user wants to analyze *all* the files                      ",
@@ -89,10 +89,18 @@ int main(int argc, char *argv[])
    bool pos  =    ( 0 != am->ArgMgrDefined("pos") ); 
    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 verbose = ( 0 != am->ArgMgrDefined("verbose") );
    bool tag     = ( 0 != am->ArgMgrDefined("tag") );
 
+   if( copy && write )
+   {
+      std::cout << "COPY and WRITE are mutually exclusive" << std::endl;
+      delete am;
+      return 0;
+   }
+
    if( (tag && (pos || ori)) || (pos && (tag || ori)) || (ori && (tag || pos)) )
    {
       std::cout << " POS, ORI and TAG are mutually exclusive" << std::endl;
@@ -133,7 +141,6 @@ 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();
    
@@ -155,14 +162,14 @@ int main(int argc, char *argv[])
       f->SetMaxSizeLoadEntry(0x7fff); // load any length
       f->SetFileName( *it );
       f->Load();
-      l->push_back(f);     
+      l->push_back(f);
    }
 
 
 /* ===========================================================================================*/
    std::string systemCommand;
-   std::string filenameout;   
-   if (write) { 
+   std::string filenameout;
+   if (write) {
       if (verbose)
          std::cout << "Check for output directory :[" << dirNameout << "]."
                    <<std::endl;
@@ -188,12 +195,11 @@ 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;
@@ -201,26 +207,26 @@ int main(int argc, char *argv[])
 
    // For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
 
-   //GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();//===> Ignore 'Serie UID"
+  // GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet();//===> Ignore 'Serie UID"
 
    GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
 
    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
    // The user may add images to a 'Manufacturer Study',
    //          adding new Series to an already existing Study
    std::string strStudyUID;
-   if ( !userDefinedStudy)
+   if ( !userDefinedStudy )
       strStudyUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
    else
       strStudyUID = studyUID;
@@ -233,9 +239,10 @@ int main(int argc, char *argv[])
                            // Why not ? Just an example, for testing!
       {
           // Just not to make too many modif in the code
-          serieUID = "aaaa"; //s->GetCurrentSerieUIDFileSetUID();
+          //serieUID = "SingleSerie"; // s->GetCurrentSerieUIDFileSetUID();
+          serieUID = s->GetCurrentSerieUIDFileSetUID();
           GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
+
           // --- for write
           if (write)
           {
@@ -267,19 +274,19 @@ int main(int argc, char *argv[])
          else if (pos)
             xcm = s->SplitOnPosition(l);
          else if (groupelem != 0) {
+
          std:: cout << GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(groupelem[0],groupelem[1])->GetName() << std::endl;
  
             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)
          {
-             xCoherentName = (*i).first;
+            xCoherentName = (*i).first;
             if (verbose)
                std::cout << "xCoherentName = " << xCoherentName << std::endl;
              GDCM_NAME_SPACE::Util::ReplaceSpecChar(xCoherentName, rep);
@@ -313,7 +320,7 @@ int main(int argc, char *argv[])
            // 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()
@@ -321,7 +328,7 @@ int main(int argc, char *argv[])
            } 
 
             std::string strSerieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
-   
+
             for (GDCM_NAME_SPACE::FileList::iterator it2 =  ((*i).second)->begin();
                                           it2 != ((*i).second)->end();
                                         ++it2)
@@ -333,32 +340,32 @@ int main(int argc, char *argv[])
                // --- for write
                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();
                   uint8_t *imageData = fh->GetImageDataRaw();// somewhat important : Loads the Pixels in memory !
                   if (!imageData)
-                     std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;  
+                     std::cout << "fail to read [" << (*it2)->GetFileName() << std::endl;
                   lastFilename =  GDCM_NAME_SPACE::Util::GetName( fileName );
                   filenameout = xCoherentWriteDir  + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename; 
                   //systemCommand   = "cp " + fileName + " " + filenameout;
                   //system( systemCommand.c_str());
-  
+
                   fh->SetWriteTypeToDcmExplVR();
                   fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
                   if (!fh->Write(filenameout))
                   {
                      std::cout << "Fail to write :[" << filenameout << "]"
                                << std::endl;
-                  } 
+                  }
                   if (verbose)
                      std::cout << "3 " << systemCommand << std::endl;
                   fh->Delete();
-                } 
-               // --- end for write       
+                }
+               // --- end for write
             } 
-            std::cout << std::endl;   
+            std::cout << std::endl;
          }
       }
      // l = s->GetNextSingleSerieUIDFileSet(); //===> Ignore 'Serie UID"
@@ -366,7 +373,7 @@ int main(int argc, char *argv[])
     
    if ( controlCount == 0 )
       std::cout << "No suitable file was found!" << std::endl;
+
    s->Delete();
 /*===============================================================================================*/
    return 0;
index 306bb8c2a83be44e721eeb5d41517a0a517d8b85..da5d5212fc32deec8da7c0067df4362bc17d3a5e 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractOverlaysDCM.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/30 09:15:58 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -236,7 +236,7 @@ str << fileName << ".ovly." << tmp.str() << ".dcm" << std::ends;
 
    } // end on loop on 60xx
 
-   if (f)
+   if (fh)
       fh->Delete();
    if (fileToBuild)
       fileToBuild->Delete();
index 49aab7341402f72c454e69015c207b3b8616325a..23f41749b916db5c2881e30ae182ff678d6b5369 100644 (file)
@@ -4,8 +4,8 @@
   Program:   gdcm
   Module:    $RCSfile: exPresentationState.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/25 14:29:16 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  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
@@ -54,6 +54,10 @@ int main(int argc, char *argv[])
    "       noseq      : user doesn't want to load Sequences                   ",
    "       verbose    : developper wants to run the program in 'verbose mode' ",
    "       debug      : developper wants to run the program in 'debug mode'   ",
+   "                                                                          ",
+   " you can use it as :                                                      ",
+   " for i in `ls PS*`; do exPresentationState PSFile=$i; done                ",
+   " just to see ...                                                          ",
    FINISH_USAGE
 
    // ----- Initialize Arguments Manager ------
@@ -133,14 +137,19 @@ int main(int argc, char *argv[])
    //displaySeekResult(se, 0x0070, 0x0001);
    if (!se)
    {
-         std::cout << "Hopeless : " << std::hex <<  0x0070 << "|" << 0x0001 << std::dec << " doesn't exist..." <<std::endl;
+         std::cout << "[" << PSName << "] : Hopeless (" << std::hex <<  0x0070 << "|" << 0x0001 << std::dec << " doesn't exist...)" <<std::endl;
          exit (0);      
    }
-       
+   std::cout << "\n\n =========================================================================================" <<std::endl;       
    std::cout << "[" << PSName << "] is a gdcm-readable PresentationState file, "
-             << "that (probabely?) holds one or more 'ROI' within [0070|0001] (Graphic Annotation Sequence)\n" <<std::endl; 
+             << "that (probabely?) holds one or more 'ROI' within [0070|0001] (Graphic Annotation Sequence)"   <<std::endl; 
+   std::cout << " =========================================================================================\n\n" <<std::endl;
 
    GDCM_NAME_SPACE::SQItem* currentItem = se->GetFirstSQItem(); // Get the first 'ROI'
+   if (currentItem == NULL)
+   {
+      std::cout << "======== Deal With NOTHING! (Sequence 0070|0001 [Graphic Annotation Sequence] has NO item ?!?)" << std::endl;
+   }
    int i =0;
    while (currentItem != NULL)
    {
@@ -170,6 +179,8 @@ int main(int argc, char *argv[])
    
    f->Delete();
    fPS->Delete();
+   
+   std::cout << "\n\n"  <<std::endl;  
 return 0;
 }
 
@@ -197,7 +208,7 @@ bool dealWithTopLevelItem(GDCM_NAME_SPACE::SQItem* currentItem)
    for(int i=0; tabElement[i]!=0x0000; i++)
    {
       se = CheckIfSequenceExists(currentItem, 0x0070, tabElement[i]);
-      displaySeekResult(se, 0x0070, tabElement[i]);       
+      //displaySeekResult(se, 0x0070, tabElement[i]);       
       if (se != 0)
       {
          res = true;
index 5305fe4dbbe1c4287e4f5b63c72b8dbac784772e..a585765ab5a524cf555052b107503307e255427e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/30 14:55:20 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -151,7 +151,9 @@ int main(int argc, char *argv[])
                                           ++it2)
          {
           // Just to show : GetZSpacing from a GDCM_NAME_SPACE::File may be different        
-             std::cout << (*it2)->GetFileName() << " -->  GetZSpacing() from GDCM_NAME_SPACE::File : " 
+             std::cout << (*it2)->GetFileName() << " -->  Get{X/Y/Z}Spacing() from GDCM_NAME_SPACE::File : " 
+                       << (*it2)->GetXSpacing() << " " 
+                       << (*it2)->GetYSpacing() << " " 
                        << (*it2)->GetZSpacing() << std::endl; 
            fileCount++;      
          }
index 42199db9c0a771632071eefa7ec9f8f1c7f77d65..8f22110c07ab4351c0172118a301ecfe08df978c 100755 (executable)
@@ -1,15 +1,15 @@
 /*=========================================================================
-                                                                                
+
   Program:   gdcm
   Module:    $RCSfile: exXCoherentFileSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/30 14:55:20 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2009/05/28 15:44:34 $
+  Version:   $Revision: 1.16 $
                                                                                 
   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.
@@ -24,7 +24,6 @@
 #include "gdcmArgMgr.h"
 int main(int argc, char *argv[])
 {
-
    START_USAGE(usage)
    "\n exXCoherentFileSet :\n                                                 ",
    "Shows the various 'XCoherent' Filesets within a directory                 ",
@@ -55,7 +54,7 @@ int main(int argc, char *argv[])
    FINISH_USAGE
    
    // ----- Initialize Arguments Manager ------
-  
+
    GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
   
    if (am->ArgMgrDefined("usage") || argc == 1) 
@@ -67,7 +66,7 @@ int main(int argc, char *argv[])
 
    if (am->ArgMgrDefined("debug"))
       GDCM_NAME_SPACE::Debug::DebugOn();
-      
+
    int loadMode = GDCM_NAME_SPACE::LD_ALL;
    if ( am->ArgMgrDefined("noshadowseq") )
       loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
@@ -85,16 +84,16 @@ int main(int argc, char *argv[])
        std::cout <<std::endl
                  << "'dirin=' must be present;" 
                  <<  std::endl;
-       am->ArgMgrUsage(usage); // Display 'usage'  
+       am->ArgMgrUsage(usage); // Display 'usage'
        delete am;
        return 0;
    }
 
-   const char *dirNameout;   
+   const char *dirNameout;
    dirNameout  = am->ArgMgrGetString("dirout",".");
 
-   bool pos  =    ( 0 != am->ArgMgrDefined("pos") ); 
-   bool ori  =    ( 0 != am->ArgMgrDefined("ori") );   
+   bool pos  =    ( 0 != am->ArgMgrDefined("pos") );
+   bool ori  =    ( 0 != am->ArgMgrDefined("ori") );
    bool sort =    ( 0 != am->ArgMgrDefined("sort") );
    bool write =   ( 0 != am->ArgMgrDefined("write") );
    bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
@@ -104,15 +103,15 @@ int main(int argc, char *argv[])
    {
       std::cout << " POS, ORI and TAG are mutually exclusive" << std::endl;
       delete am;
-      return 0;      
+      return 0;
    }
    
    if( (!tag && !pos && !ori))
    {
       std::cout << " One of POS, ORI and TAG is mandatory!" << std::endl;
       delete am;
-      return 0;      
-   }         
+      return 0;
+   }
    int nb;
    uint16_t *groupelem;
    if (tag)
@@ -124,16 +123,16 @@ int main(int argc, char *argv[])
          delete am;
          return 0;
       }
-   }      
-            
+   }
+
    /* if unused Param we give up */
    if ( am->ArgMgrPrintUnusedLabels() )
    {
       am->ArgMgrUsage(usage);
       delete am;
       return 0;
-   } 
+   }
+
    delete am;  // ------ we don't need Arguments Manager any longer ------
    
    GDCM_NAME_SPACE::SerieHelper *s;
@@ -144,7 +143,7 @@ int main(int argc, char *argv[])
    //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'
@@ -212,7 +211,7 @@ int main(int argc, char *argv[])
    std::string lastFilename;
    std::string rep("_");
    int controlCount = 0;
-  
+
    while (l) // for each 'Single SerieUID FileSet'
    { 
       nbFiles = l->size() ;
@@ -221,7 +220,7 @@ int main(int argc, char *argv[])
       {
           serieUID = s->GetCurrentSerieUIDFileSetUID();
           GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
+
           // --- for write
           if (write)
           {
@@ -229,25 +228,25 @@ int main(int argc, char *argv[])
              unsigned int lg = strlen(dirNameout)-1;
              if ( dirNameout[lg] != '/'  &&  dirNameout[lg] != '\\')
                 currentSerieWriteDir = currentSerieWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR;
-    
+
              currentSerieWriteDir = currentSerieWriteDir + serieUID;
              if (verbose)
                 std::cout << "[" << currentSerieWriteDir<< "]" << std::endl;
             // if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(currentSerieWriteDir) )
-             {     
+             {
                 systemCommand   = "mkdir " + currentSerieWriteDir;
                 system( systemCommand.c_str());
                 if (verbose)
                    std::cout <<  "1 " <<systemCommand << std::endl;
-             }
+            }
          } 
           // --- end for write
-    
+
          std::cout << "Split the 'Single SerieUID' FileSet :[" 
                    << serieUID
                    << "]  " << nbFiles << " long" << std::endl;
          std::cout << "-----------------------------------" << std::endl;
-  
+
          if (ori) 
             xcm = s->SplitOnOrientation(l);
          else if (pos)
@@ -266,18 +265,18 @@ int main(int argc, char *argv[])
             GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
              // --- for write
              if (write)
-             { 
+             {
                 xCoherentWriteDir = currentSerieWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ xCoherentName;
                // if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(xCoherentWriteDir) )
-                {      
+                {
                    systemCommand   = "mkdir " + xCoherentWriteDir;
                    system( systemCommand.c_str());
                    if (verbose)
-                      std::cout << systemCommand << std::endl;       
+                      std::cout << systemCommand << std::endl;
                 }
             } 
             // --- end for write
-    
+
             if (ori) 
                std::cout << "Orientation : ";
             else if (pos) 
@@ -286,10 +285,10 @@ int main(int argc, char *argv[])
                std::cout << "Tag (" << std::hex << groupelem[0]
                          << "|" << groupelem[1] << ") value : ";
             std::cout << "[" << (*i).first << "]" << std::endl;
-        
+
             if (verbose)
                std::cout << "xCoherentName [" << xCoherentName << "]" << std::endl;
-    
+
            // Within a 'just to see' program, 
            // OrderFileList() causes trouble, since some files
            // (eg:MIP views) don't have 'Position', now considered as mandatory
@@ -299,7 +298,7 @@ int main(int argc, char *argv[])
               s->OrderFileList((*i).second);  // sort the XCoherent Fileset
               std::cout << "ZSpacing for the file set " << s->GetZSpacing()
                         << std::endl;
-            } 
+            }
 
             for (GDCM_NAME_SPACE::FileList::iterator it =  ((*i).second)->begin();
                                           it != ((*i).second)->end();
@@ -308,7 +307,7 @@ int main(int argc, char *argv[])
                controlCount ++;
                fileName = (*it)->GetFileName();
                std::cout << "    " << fileName << std::endl;
-    
+
                // --- for write
                if (write)
                {  
@@ -319,9 +318,9 @@ int main(int argc, char *argv[])
                   if (verbose)
                      std::cout << "3 " << systemCommand << std::endl;
                 }
-               // --- end for write       
+               // --- end for write
             }
-            std::cout << std::endl;   
+            std::cout << std::endl;
          }
       }
       l = s->GetNextSingleSerieUIDFileSet();