]> Creatis software - gdcm.git/commitdiff
re indent
authorjpr <jpr>
Tue, 20 Sep 2011 16:09:05 +0000 (16:09 +0000)
committerjpr <jpr>
Tue, 20 Sep 2011 16:09:05 +0000 (16:09 +0000)
vtk/test4DSplitter.cxx
vtk/vtkGdcm4DSplitter.cxx
vtk/vtkGdcmReader.h

index 059de647001e64d31b3cb6e3b8188dff60b9ee93..d62d9913bbe84968d4c665754ea1c24e3b87e29e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: test4DSplitter.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/04/20 15:03:54 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2011/09/20 16:09:05 $
+  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
@@ -29,7 +29,6 @@ On Wed, Feb 16, 2011 at 11:51 AM, Roger Bramon Feixas <rogerbramon@gmail.com>
     the same time.
 */
 
-
 #include "gdcmFile.h"
 #include "gdcmSerieHelper.h"
 #include <vtkImageData.h>
@@ -69,7 +68,7 @@ int main(int argc, char *argv[])
 
 // n directories 
 std::string strDirName("/home/jpr/Desktop/patient Andrei Dyn/dyn");
-
+//std::string strDirName("/home/jpr/Desktop/patient Andrei Dyn/dyn2"); // very small sample
    // ----- Begin Processing -----  
    
    unsigned short int grSplit;
@@ -111,7 +110,6 @@ if (1) {
       
    // ==> use SortOnUserFunction !
    spl->setSortOnUserFunction(myCompareFunction0008_0032);  
-   
 
    std::cout << "Everything set" << std::endl;  
    bool res=spl->Go();
@@ -124,7 +122,6 @@ if (1) {
 
    output = spl->GetImageDataVector();
 
-
 std::cout << "--------------------------------" << std::endl;
 std::cout << "Vector size " << output->size()   << std::endl;
 std::cout << "--------------------------------" << std::endl;
@@ -136,7 +133,18 @@ std::cout << "--------------------------------" << std::endl;
       //std::cout << "========================================" << std::endl;
       //(*it)->PrintSelf(std::cout, vtkIndent(2));
    }
-   //delete spl; 
+
+   delete spl;
+
+   // To please valgring  
+   std::vector<vtkImageData*>::iterator it2;       
+   for ( it2 = output->begin(); // for each vtkImageData*
+             it2 != output->end();
+           ++it2)
+   {
+           (*it2)->Delete(); // delete vtkImageData
+   }       
+   delete output;    
 } 
 
 
@@ -165,10 +173,10 @@ for(int i=0; i<3; i++)
    //grSort=0x0018;
    //elSort=0x1060;
  
- // Aquisition Time  : 0008|0032
-spl->setSplitOnTag(0x0008, 0x0032); 
  // Aquisition Time  : 0008|0032
+   spl->setSplitOnTag(0x0008, 0x0032); 
    
-spl->setSortOnPosition();
+   spl->setSortOnPosition();
 
    std::cout << "Everything set" << std::endl;  
    bool res=spl->Go();
@@ -195,7 +203,17 @@ std::cout << "--------------------------------" << std::endl;
       //(*it)->PrintSelf(std::cout, vtkIndent(2));
    }
    
-  // delete spl;
+   delete spl;
+
+   // To please valgring  
+   std::vector<vtkImageData*>::iterator it2;       
+   for ( it2 = output->begin(); // for each vtkImageData*
+             it2 != output->end();
+           ++it2)
+   {
+           (*it2)->Delete(); // delete vtkImageData
+   }       
+   delete output;
 }
 
 // Pour un directory '4D'
index 9cd0bfc9236a1534b960ee036e96b5ce85cb565b..2b26fec546a6b8891b575d402fe9f30dc6e37ea3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcm4DSplitter.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/04/21 09:14:31 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2011/09/20 16:09:05 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -159,7 +159,26 @@ Avoid loosing CPU time using :
  */ 
  vtkGdcm4DSplitter::~vtkGdcm4DSplitter()
  {
-    /// \TODO : delete everything that must be! 
+    /// \TODO : delete everything that must be!
+    
+    GDCM_NAME_SPACE::XCoherentFileSetmap::iterator it;
+    std::vector<GDCM_NAME_SPACE::File*>::iterator it2;
+     
+    for ( it = xcm.begin(); // for each std::vector<gdcm::File*>
+          it != xcm.end();
+        ++it)
+    {      
+       for ( it2 = (*it).second->begin(); // for each gdcm::File*
+             it2 != (*it).second->end();
+           ++it2)
+       {
+           (*it2)->Delete(); // delete gdcm::File
+       }      
+       delete (*it).second; // delete the now empty std::vector<gdcm::File*>
+    }
+    
+    // VectGdcmFileLists is a vector of pointers on elements of xcm : nothing to do!
+  
  }
 
        // Locate Data to process
@@ -335,7 +354,7 @@ void  vtkGdcm4DSplitter::setRecursive(bool recursive)
     //SortOnTag=false;
     SortOnFileName=false;
     SortOnUserFunction=true;
 }
+ }
 
  //  void setSortConvertToFloat(bool conv)
  //  {
@@ -428,10 +447,10 @@ void  vtkGdcm4DSplitter::setRecursive(bool recursive)
    }
 
    GDCM_NAME_SPACE::FileList *l;
-   
+
    GDCM_NAME_SPACE::SerieHelper *s;  
    s = GDCM_NAME_SPACE::SerieHelper::New();
-   
+
 //
 // Load the gdcm::File* set, according to user's requierements
 // ------------------------------------------------------------
@@ -471,7 +490,7 @@ std::cout << l->size() << " gdcm::File read" << std::endl;
                xcm = s->SplitOnTagValueConvertToFloat(l, SplitGroup, SplitElem);
             }
   }
-  
+
    if (xcm.size() == 0)
    {
       if(verbose)
@@ -483,10 +502,10 @@ std::cout << l->size() << " gdcm::File read" << std::endl;
       std::cout << xcm.size() << " XCoherent entries found" << std::endl;
    }
 
-// put here, to avoid segfault when unaware user sets SplitOnly to true, and the asks for ImageDataVector
-ImageDataVector = new std::vector<vtkImageData*>;
+   // put here, to avoid segfault when unaware user sets SplitOnly to true, and the asks for ImageDataVector
+   ImageDataVector = new std::vector<vtkImageData*>;
 
-std::cout <<"SplitOnly " << SplitOnly << std::endl;
+   std::cout <<"SplitOnly " << SplitOnly << std::endl;
    if(SplitOnly)
       return true;   
 //
@@ -496,15 +515,15 @@ std::cout <<"SplitOnly " << SplitOnly << std::endl;
 //   ImageDataVector = new std::vector<vtkImageData*>;
 
    /// \TODO move inside the loop, or be clever using vtk!
-  // vtkGdcmReader *reader = vtkGdcmReader::New(); // move inside the loop, or be clever using vtk!
-   
- // XCoherentFileSetmap map < critère de split, FileList (= std::vector de gdcm::File*) >
+    vtkGdcmReader *reader = vtkGdcmReader::New(); // move inside the loop, or be clever using vtk!
+
  // XCoherentFileSetmap map < critère de split, FileList (= std::vector de gdcm::File*) >
 
    for (GDCM_NAME_SPACE::XCoherentFileSetmap::iterator i = xcm.begin(); 
-                                                  i != xcm.end();
-                                                ++i)
+                                                       i != xcm.end();
+                                                     ++i)
    {
-      vtkGdcmReader *reader = vtkGdcmReader::New(); /// \TODO FIXME : unable to delete!
+      //vtkGdcmReader *reader = vtkGdcmReader::New(); /// \TODO FIXME : unable to delete!
       
       reader->SetFlipY(FlipY);
       // better user SetFileLowerLeft()
@@ -598,7 +617,7 @@ std::cout <<"SplitOnly " << SplitOnly << std::endl;
        //std::cout << std::endl;
    }
 
-   //reader->Delete();  // \TODO : fix
+   reader->Delete();  // \TODO : fix
    s->Delete(); 
   // f->Delete();
    delete l;
@@ -634,7 +653,7 @@ GDCM_NAME_SPACE::FileList *vtkGdcm4DSplitter::getGdcmFileList()
       GDCM_NAME_SPACE::DirList dirlist(DirName, Recursive); // NO recursive exploration
       fileNames = dirlist.GetFilenames(); // all the file names
    }
-   
+
    else if (TypeDir == 2) // a std::vector of directory names was set as input
    {
       int nbDir = VectDirName.size();
@@ -673,6 +692,7 @@ GDCM_NAME_SPACE::FileList *vtkGdcm4DSplitter::getGdcmFileList()
                                                 ++it)
       {
          int maxSize  = 0x7fff;         // load Elements of any length
+         /// \TODO ? gdcm::File are never free'd
          f = GDCM_NAME_SPACE::File::New();
          f->SetMaxSizeLoadEntry(maxSize);
          f->SetFileName( *it );
@@ -770,12 +790,12 @@ bool vtkGdcm4DSplitter::sortVectElem(std::vector<ELEM> *fileList)
 //to right, "y" is posterior to anterior, and "z" is foot to head (RAH).
 
    //iop is calculated based on the file file
-   float cosines[6];
+   float  cosines[6];
    double normal[3];
    double ipp[3];
    double dist;
    double min = 0, max = 0;
-   bool first = true;
+   bool   first = true;
    
    //double ZSpacing; // useless here! // JPR
    bool DirectOrder = true; // remove it!
index e9846b545bd746424dfcd72b0dd30c61bf6f7a75..da612c0f11af71b6a53795208f4ad99e8916e564 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmReader.h,v $
   Language:  C++
-  Date:      $Date: 2011/03/31 12:37:54 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2011/09/20 16:09:05 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -73,7 +73,7 @@ public:
    vtkGetMacro(KeepOverlays, bool);
    vtkBooleanMacro(KeepOverlays, bool);
 
-//  Implementation note: when FileLowerLeft (gdcm2) is set to on the image is not flipped
+//  Implementation note: when FileLowerLeft (gdcm2) is set to on, the image is not flipped
 // upside down as VTK would expect, use this option only if you know what you are doing.   
   // vtkSetMacro(FileLowerLeft, bool);
   // vtkGetMacro(FileLowerLeft, bool);