]> Creatis software - gdcm.git/commitdiff
Fixes (Sort on tag still buggy...)
authorjpr <jpr>
Wed, 30 Mar 2011 14:49:04 +0000 (14:49 +0000)
committerjpr <jpr>
Wed, 30 Mar 2011 14:49:04 +0000 (14:49 +0000)
vtk/vtkGdcm4DSplitter.cxx
vtk/vtkGdcm4DSplitter.h

index b039a8b45173ae33c5bb0ce05e26a5c6415011d9..3f632c28c2d575274924f1c0cd26392df6f7bee2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcm4DSplitter.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/03/29 15:45:38 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2011/03/30 14:49:04 $
+  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
@@ -68,9 +68,12 @@ 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);
 . Choose 'sort' criterion :
 --------------------------
 
@@ -186,18 +189,20 @@ User will have to specify some points
     return true;
  }      
 
- bool vtkGdcm4DSplitter::CompareOnSortTagConvertToFloat(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
/*static */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) printf ("%04x %04x\n", this->SortGroup,this->SortElem);
    if (verbose) std :: cout << file1->GetEntryString(SortGroup,SortElem).c_str() << " : " 
                             << atof(file1->GetEntryString(SortGroup,SortElem).c_str())
                             << std::endl;
-   return atof(file1->GetEntryString(SortGroup,SortElem).c_str()) < atof(file2->GetEntryString(SortGroup,SortElem).c_str());  
+*/
+//   return atof(file1->GetEntryString(vtkGdcm4DSplitter::SortGroup,vtkGdcm4DSplitter::SortElem).c_str()) < atof(file2->GetEntryString(vtkGdcm4DSplitter::SortGroup,vtkGdcm4DSplitter::SortElem).c_str()); 
+   return atof(file1->GetEntryString(SortGroup,SortElem).c_str()) < atof(file2->GetEntryString(SortGroup,SortElem).c_str()); 
  } 
 
- bool vtkGdcm4DSplitter::CompareOnSortTag(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
/*static */bool vtkGdcm4DSplitter::CompareOnSortTag(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2)
  {
-   return file1->GetEntryString(SortGroup,SortElem) < file2->GetEntryString(SortGroup,SortElem);  
+   return file1->GetEntryString(vtkGdcm4DSplitter::SortGroup,vtkGdcm4DSplitter::SortElem) < file2->GetEntryString(vtkGdcm4DSplitter::SortGroup,vtkGdcm4DSplitter::SortElem);  
  }
    
  bool vtkGdcm4DSplitter::Go()
@@ -376,6 +381,9 @@ User will have to specify some points
       {  
          if (verbose) std::cout << "SortOnTag" << std::endl;   
          printf ("--> %04x %04x\n", SortGroup,SortElem);
+         std::cout << "Sorry, troubles not solved yet; use SortOnUserFunction, right now!" << std::endl;
+        /*        ==> WARNING : This one has troubles; do NOT use it, right now!
          if ( SortConvertToFloat )
             s->SetUserLessThanFunction( reinterpret_cast<bool (*)(gdcm13::File*, gdcm13::File*)> 
                                                                  ( &vtkGdcm4DSplitter::CompareOnSortTagConvertToFloat));     
@@ -385,7 +393,19 @@ User will have to specify some points
        
          // Anything like this, in GDCM2? 
          s->UserOrdering((*i).second);
-         if (verbose) std::cout << "Out of SortOnTag" << std::endl;
+        */
+
+         //if (verbose) std::cout << "Out of SortOnTag" << std::endl;
+         std::cout << "NO ordering performed  :-( " << std::endl;
+      }
+      
+      else if (SortOnUserFunction)
+      {   
+          if (verbose) std::cout << "SortOnUserFunction" << std::endl;
+          s->SetUserLessThanFunction( UserCompareFunction );
+         // Anything like this, in GDCM2? 
+         s->UserOrdering((*i).second);
+         if (verbose) std::cout << "Out of SortOnUserFunction" << std::endl;   
       }
 
        reader->SetCoherentFileList((*i).second);
index 04d8abbffc78f6b7359ad89fac6946bbfe15c6ff..7cd99916e20e80fd491c030e2fb1523594614317 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcm4DSplitter.h,v $
   Language:  C++
-  Date:      $Date: 2011/03/29 12:49:27 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2011/03/30 14:49:04 $
+  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
 #include <vtkImageData.h>
 #include "gdcmDirList.h" 
 
+typedef  bool (*FoncComp)                       (GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
+//typedef  bool (vtkGdcm4DSplitter::*MembFoncComp)(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
+#define CALL_MEMBER_FONC(object, ptrToFoncMember)  ((object).*(ptrToFoncMember)) 
 //namespace GDCM_NAME_SPACE 
-//{ 
+//{
   class vtkGdcm4DSplitter {
     public:
     
@@ -34,6 +38,8 @@
        bool setVectDirName(std::vector<std::string> &vectDirName);
        bool setVectFileName(std::vector<std::string> &vectFileName);       
        
+       // Split
+       // =====
        inline void setSplitOnPosition()   {SplitOnPosition=true;  SplitOnOrientation=false; SplitOnTag=false;}
        inline void setSplitOnOrientation(){SplitOnPosition=false; SplitOnOrientation=true;  SplitOnTag=false;}
        inline void setSplitOnTag(unsigned short int splitGroup, unsigned short int splitElem)       
                                            SplitGroup=splitGroup;    SplitElem=splitElem;}
        inline void setSplitConvertToFloat(bool conv) {SplitConvertToFloat=conv;}
        
-       inline void setSortOnPosition()   {SortOnPosition=true;  SortOnOrientation=false; SortOnTag=false; SortOnFileName=false;}
-       // SortOnOrientation : not yet made
-       //inline void setSortOnOrientation(){SortOnPosition=false; SortOnOrientation=true;  SortOnTag=false; SortOnFileName=false;}     
+       // Sort
+       // ====
+       inline void setSortOnPosition()   {SortOnPosition=true; SortOnOrientation=false; SortOnTag=false; SortOnFileName=false; SortOnUserFunction=false;
+                                          SortOnPosition=true;}
+  
        inline void setSortOnTag(unsigned short int sortGroup, unsigned short int sortElem)       
-                                         {SortOnPosition=false; SortOnOrientation=false; SortOnTag=true; SortOnFileName=false;
-                                          SortGroup=sortGroup;     SortElem=sortElem;}
+                                         {SortOnPosition=false; SortOnOrientation=false; SortOnTag=true; SortOnFileName=false; SortOnUserFunction=false;
+                                          SortGroup=sortGroup;  SortElem=sortElem;}
+  
+       inline void setSortOnUserFunction (FoncComp f) 
+                                         { UserCompareFunction=f;
+                                           SortOnPosition=false; SortOnOrientation=false; SortOnTag=false; SortOnFileName=false; SortOnUserFunction=true;}
+
        inline void setSortConvertToFloat(bool conv) {SortConvertToFloat=conv;}
                                     
-       inline void setSortOnFileName()   {SortOnPosition=false; SortOnOrientation=false; SortOnTag=false; SortOnFileName=true;}
+       inline void setSortOnFileName()   {SortOnPosition=false; SortOnOrientation=false; SortOnTag=false; SortOnFileName=true; SortOnUserFunction=false;}
+       
        inline void setRecursive(bool recursive) { Recursive=recursive;}
 
+       // SortOnOrientation : not yet made
+       //inline void setSortOnOrientation(){SortOnPosition=false; SortOnOrientation=true;  SortOnTag=false; SortOnFileName=false; SortOnUserFunction=false;}   
+       
         std::vector<vtkImageData*> *GetImageDataVector();
         vtkImageData *GetImageData();
 
        bool SortOnOrientation;
        bool SortOnTag;    
        bool SortOnFileName;
-
+       bool SortOnUserFunction;
+       
+       FoncComp UserCompareFunction;
+       
        unsigned short int SortGroup;
        unsigned short int SortElem;
        bool SortConvertToFloat;