]> Creatis software - gdcm.git/blobdiff - Example/exXCoherentFileSet.cxx
Use New(), Delete();
[gdcm.git] / Example / exXCoherentFileSet.cxx
index b2af110e7bc00b2e7dbc9eef87da2cf35958ab9b..db2dd0e107f150f894b84c0caef7ef576cb93036 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exXCoherentFileSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/02 10:08:18 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/11/14 15:55:17 $
+  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
@@ -84,15 +84,15 @@ int main(int argc, char *argv[])
 
    // FIXME : check only one of them is set !
 
-   bool pos = am->ArgMgrDefined("pos");
-   bool ori = am->ArgMgrDefined("ori");
-   bool tag = am->ArgMgrDefined("tag");
+   int pos = am->ArgMgrDefined("pos");
+   int ori = am->ArgMgrDefined("ori");
    
    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
 
@@ -143,14 +144,14 @@ int main(int argc, char *argv[])
       {
          std::cout << "Split the 'Single SerieUID' FileSet :[" 
                    << s->GetCurrentSerieUIDFileSetUID()
-           << "]  " << nbFiles << " long" << std::endl;
+                   << "]  " << nbFiles << " long" << std::endl;
          std::cout << "-----------------------------------" << std::endl;
   
          if (ori) 
             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,7 +162,7 @@ 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 : ";
     
@@ -186,7 +187,7 @@ int main(int argc, char *argv[])
       l = s->GetNextSingleSerieUIDFileSet();
    } 
   
-   delete s;
+   s->Delete();
 
    return 0;
 }