]> Creatis software - gdcm.git/blobdiff - vtk/vtkGdcm4DSplitter.cxx
Fix GetImageDataVector() vs GetImageData()
[gdcm.git] / vtk / vtkGdcm4DSplitter.cxx
index 3f632c28c2d575274924f1c0cd26392df6f7bee2..352b14705392ae82c338ba66a55d1cdbcc332926 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcm4DSplitter.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/03/30 14:49:04 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2011/04/08 00:11:36 $
+  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
@@ -68,30 +68,42 @@ User will have to specify some points
  - ImageOrientationPatient
         void setSplitOnOrientation();
  - User choosen tag
-        ==> WARNING : This one has troubles; do NOT use it, right now!
         void setSplitOnTag(unsigned short splitGroup, unsigned short splitElem);
         void setSplitConvertToFloat(bool conv);
  - UserDefined Function
         void setSortOnUserFunction (FoncComp f);
  
+ for 'true' 3D image sets :
+   - if you want to get a single 3D vtkImageData, use SplitOnOrientation -i.e. no split-
+   - if you want to get a vector of 2D vtkImageData, use SplitOnPosition  -i.e. one slice in each 'XCoherent filesite'-
+
+ for 'true' 4D multi-orientation image sets (i.e. a stack of axial + sagital + coronal images, at different instants ...)
+   --> this is 5D, right?
+   Nothing done, yet.
+
 . Choose 'sort' criterion :
 --------------------------
 
  - ImagePositionPatient
-        void setSortOnPosition();
- - User choosen tag
-        void setSortOnTag(unsigned short sortGroup, unsigned short sortElem);
-        void setSortConvertToFloat(bool conv)
-
-. Execute
+        void setSortOnPosition(); 
+ - ImageOrientationPatient
+       ==> Only in your dreams!
+       ==> or, please, write a IOP sorter ...
+ - UserDefined Function
+        void setSortOnUserFunction (FoncComp f);
+ - File name
+        void setSortOnFileName()
+  
+. Execute :
 -----------
         bool Go();
 
 . Get the result
 ----------------
 
- -a single vtkImageData:
-        vtkImageData *GetImageData();
+// -a single vtkImageData:
+//        vtkImageData *GetImageData();
 - a vector of vtkImageData
         std::vector<vtkImageData*> *GetImageDataVector();
 
@@ -112,15 +124,16 @@ User will have to specify some points
                  SortOnPosition(false),  SortOnOrientation(false),  SortOnTag(false), 
                  SortGroup(0),  SortElem(0), SortConvertToFloat(false),
 
-                 Recursive(false), TypeDir(0), 
-                 verbose(true) 
+                 Recursive(false), TypeDir(0),
+                 verbose(false) 
  {
  
  }
 
  std::vector<vtkImageData*> * vtkGdcm4DSplitter::GetImageDataVector() 
- {
- if (verbose) std::cout << "TypeDir " << TypeDir << std::endl;
+ { 
+/*
+ if (verbose) std::cout << "GetImageDataVector : TypeResult " << TypeResult << std::endl;
     if (TypeResult == 2)
        return ImageDataVector;
     else
@@ -132,21 +145,26 @@ User will have to specify some points
       }
       else
          return (std::vector<vtkImageData*>*) NULL;
+*/
+     return ImageDataVector;
  }
  
  vtkImageData *vtkGdcm4DSplitter::GetImageData() 
  {
+ /*
+  if (verbose) std::cout << "GetImageData : TypeResult " << TypeResult << std::endl;
     if (TypeResult == 1)
        return ImageData;
     else
-      if (TypeResult == 1)
+      if (TypeResult == 2)
       {
          return (*ImageDataVector)[0];      
       }
       else
          return (vtkImageData*) NULL;
- }
-       
+*/
+   return (*ImageDataVector)[0]; 
+ }      
        
  bool vtkGdcm4DSplitter::setDirName(std::string &dirName) 
  {
@@ -189,10 +207,10 @@ User will have to specify some points
     return true;
  }      
 
/*static */bool vtkGdcm4DSplitter::CompareOnSortTagConvertToFloat(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
+ bool vtkGdcm4DSplitter::CompareOnSortTagConvertToFloat(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
  { 
   /* if (verbose) printf ("%04x %04x\n", this->SortGroup,this->SortElem);
-   if (verbose) std :: cout << file1->GetEntryString(SortGroup,SortElem).c_str() << " : " 
+     if (verbose) std :: cout << file1->GetEntryString(SortGroup,SortElem).c_str() << " : " 
                             << atof(file1->GetEntryString(SortGroup,SortElem).c_str())
                             << std::endl;
 */
@@ -200,11 +218,12 @@ User will have to specify some points
    return atof(file1->GetEntryString(SortGroup,SortElem).c_str()) < atof(file2->GetEntryString(SortGroup,SortElem).c_str()); 
  } 
 
/*static */bool vtkGdcm4DSplitter::CompareOnSortTag(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
+ bool vtkGdcm4DSplitter::CompareOnSortTag(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
  {
    return file1->GetEntryString(vtkGdcm4DSplitter::SortGroup,vtkGdcm4DSplitter::SortElem) < file2->GetEntryString(vtkGdcm4DSplitter::SortGroup,vtkGdcm4DSplitter::SortElem);  
  }
-   
  bool vtkGdcm4DSplitter::Go()
  {
    if (!SplitOnPosition && !SplitOnOrientation && !SplitOnTag ) 
@@ -349,15 +368,7 @@ User will have to specify some points
       else if (SortOnOrientation)
       {
               if (verbose) std::cout << "SortOnOrientation" << std::endl;
-             /// \TODO SortOnOrientation()
-           // Within a 'just to see' program, 
-           // OrderFileList() causes trouble, since some files
-           // (eg:MIP views) don't have 'Position', now considered as mandatory
-           // --> Activated on user demand.
-   
-           // Information is in :      
-           // 0020,0032 : Image Position Patient
-           // 0020,0030 : Image Position (RET)
+            /// \TODO SortOnOrientation()
       
             // we still miss an algo to sort an Orientation, given by 6 cosines!
             //  Anything like this, in GDCM2? 
@@ -384,6 +395,9 @@ User will have to specify some points
          std::cout << "Sorry, troubles not solved yet; use SortOnUserFunction, right now!" << std::endl;
  
         /*        ==> WARNING : This one has troubles; do NOT use it, right now!
+        // a pointer to fonction cannot be casted as a pointer to member function!
+        // Use SortOnUserFunction, instead!
+
          if ( SortConvertToFloat )
             s->SetUserLessThanFunction( reinterpret_cast<bool (*)(gdcm13::File*, gdcm13::File*)> 
                                                                  ( &vtkGdcm4DSplitter::CompareOnSortTagConvertToFloat));     
@@ -412,10 +426,19 @@ User will have to specify some points
        reader->Update();
        
        /// \TODO : remove the following
-       //if (verbose) reader->GetOutput()->PrintSelf(std::cout, vtkIndent(2));
+       if (verbose) {
+          std::cout << "reader->GetOutput() :" << std::endl;
+          reader->GetOutput()->PrintSelf(std::cout, vtkIndent(2));
+       }
        
        ImageDataVector->push_back(reader->GetOutput() );
-
+       
+       std::vector<vtkImageData*>::iterator it; 
+       if (verbose)      
+       for(it=ImageDataVector->begin(); it!=ImageDataVector->end(); ++it) {
+         std::cout << "-in vtkGdcm4DSplitter--------------------------" << std::endl;
+         (*it)->PrintSelf(std::cout, vtkIndent(2));
+       }
        std::cout << std::endl;
    }