]> Creatis software - gdcm.git/blobdiff - vtk/vtkGdcm4DSplitter.cxx
fixes
[gdcm.git] / vtk / vtkGdcm4DSplitter.cxx
index b039a8b45173ae33c5bb0ce05e26a5c6415011d9..7e06563a749aa5f755a4ee23e62f48dd6013f802 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/04/04 17:01:03 $
+  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
@@ -70,17 +70,28 @@ User will have to specify some points
  - User choosen tag
         void setSplitOnTag(unsigned short splitGroup, unsigned short splitElem);
         void setSplitConvertToFloat(bool conv);
-
+ - UserDefined Function
+        void setSortOnUserFunction (FoncComp f);
 . Choose 'sort' criterion :
 --------------------------
 
  - ImagePositionPatient
-        void setSortOnPosition();
+        void setSortOnPosition(); 
+ - ImageOrientationPatient
+       ==> Only in your dreams!
+       ==> or, please, write a IOP sorter ...
  - User choosen tag
+        ==> WARNING : This one has troubles; do NOT use it, right now!
+        ==> use setSortOnUserFunction instead 
         void setSortOnTag(unsigned short sortGroup, unsigned short sortElem);
         void setSortConvertToFloat(bool conv)
-
-. Execute
+ - UserDefined Function
+        void setSortOnUserFunction (FoncComp f);
+ - File name
+        void setSortOnFileName()
+    
+. Execute :
 -----------
         bool Go();
 
@@ -109,8 +120,8 @@ 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) 
  {
  
  }
@@ -142,8 +153,7 @@ User will have to specify some points
       }
       else
          return (vtkImageData*) NULL;
- }
-       
+ }      
        
  bool vtkGdcm4DSplitter::setDirName(std::string &dirName) 
  {
@@ -188,18 +198,21 @@ User will have to specify some points
 
  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) 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)
  {
-   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()
  {
    if (!SplitOnPosition && !SplitOnOrientation && !SplitOnTag ) 
@@ -344,15 +357,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? 
@@ -376,6 +381,12 @@ 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!
+        // 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));     
@@ -385,7 +396,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);