]> Creatis software - gdcm.git/blobdiff - Example/exXCoherentFileSet.cxx
Hope application can link against non-installed version of gdcm
[gdcm.git] / Example / exXCoherentFileSet.cxx
index 311373f1d6141b35ce8c2e4d1762f560f557aa88..5f0dcfb7f2bca0b856815ef6b74373cdad58e0f8 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exXCoherentFileSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/04 08:59:08 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2006/07/26 17:05:25 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
          loadMode |= gdcm::LD_NOSEQ;
    }
 
-   char *dirName  = am->ArgMgrGetString("dirin",(char *)0);
+   const char *dirName  = am->ArgMgrGetString("dirin");
    if (dirName == 0)
    {
        std::cout <<std::endl
@@ -86,13 +86,13 @@ int main(int argc, char *argv[])
 
    int pos = am->ArgMgrDefined("pos");
    int ori = am->ArgMgrDefined("ori");
-   int tag = am->ArgMgrDefined("tag");
    
    int nb;
    uint16_t *groupelem;
-   if (tag)
+   groupelem = am->ArgMgrGetXInt16Enum("tag", &nb);
+
+   if (groupelem != 0)
    {
-      groupelem = am->ArgMgrGetXInt16Enum("tag", &nb); 
       if (nb != 1)
       {
          std::cout << "TAG : one and only one group,elem!" << std::endl;
@@ -115,9 +115,10 @@ int main(int argc, char *argv[])
                  
    gdcm::SerieHelper *s;
   
-   s = new gdcm::SerieHelper();
+   s = gdcm::SerieHelper::New();
    s->SetLoadMode(gdcm::LD_ALL);     // Load everything for each File
-   //s->AddRestriction(tagKey, valueToCheck); // Keep only files where
+   //gdcm::TagKey t(0x0020,0x0013);
+   //s->AddRestriction(t, "340", gdcm::GDCM_LESS); // Keep only files where
                                               // restriction is true
    s->SetDirectory(dirName, true); // true : recursive exploration
 
@@ -150,7 +151,7 @@ int main(int argc, char *argv[])
             xcm = s->SplitOnOrientation(l);
          if (pos)
             xcm = s->SplitOnPosition(l);
-         if (tag)
+         if (groupelem != 0)
             xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] );
     
          for (gdcm::XCoherentFileSetmap::iterator i = xcm.begin();
@@ -161,21 +162,22 @@ int main(int argc, char *argv[])
                std::cout << "Orientation : ";
             if (pos) 
                std::cout << "Position : ";
-            if (tag)    
+            if (groupelem != 0)    
                std::cout << "Tag (" << std::hex << groupelem[0] 
                                  << "|" << groupelem[1] << ") value : ";
     
              std::cout << "[" << (*i).first << "]" << std::endl;
     
-           // Nowadays OrderFileList() causes trouble, since some files
-           // (MIP views) don't have 'Position', now considered as mandatory
+           // Within a 'just to see' program, 
+           // OrderFileList() causes trouble, since some files
+           // (eg:MIP views) don't have 'Position', now considered as mandatory
            // Commented out for the moment.
    
            //s->OrderFileList((*i).second);  // sort the XCoherent Fileset
     
-            for (std::vector<gdcm::File* >::iterator it =  ((*i).second)->begin();
-                                                     it != ((*i).second)->end();
-                                                   ++it)
+            for (gdcm::FileList::iterator it =  ((*i).second)->begin();
+                                          it != ((*i).second)->end();
+                                        ++it)
             {
                fileName = (*it)->GetFileName();
                std::cout << "    " << fileName << std::endl;
@@ -186,7 +188,7 @@ int main(int argc, char *argv[])
       l = s->GetNextSingleSerieUIDFileSet();
    } 
   
-   delete s;
+   s->Delete();
 
    return 0;
 }