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
- 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 :
--------------------------
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()
{
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));
// 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);
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:
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;