]> Creatis software - gdcm.git/blob - vtk/vtkGdcm4DSplitter.h
Allow user to pass a std::vector<GDCM_NAME_SPACE::File *>
[gdcm.git] / vtk / vtkGdcm4DSplitter.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: vtkGdcm4DSplitter.h,v $
5   Language:  C++
6   Date:      $Date: 2011/04/13 13:30:58 $
7   Version:   $Revision: 1.9 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef _VTKGDCM4DSPLITTER_H_
20 #define _VTKGDCM4DSPLITTER_H_
21
22 #include <vector>
23 #include <vtkImageData.h>
24 #include "gdcmDirList.h"
25 #include "gdcmFile.h"
26 #include "gdcmSerieHelper.h"
27
28 typedef  bool (*FoncComp)(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
29
30 #define CALL_MEMBER_FONC(object, ptrToFoncMember)  ((object).*(ptrToFoncMember))
31
32    typedef struct 
33    {
34       std::string strIPP;
35       double dist;
36       GDCM_NAME_SPACE::File *file;
37    } ELEM;
38    
39    
40 //namespace GDCM_NAME_SPACE
41 //{
42   class vtkGdcm4DSplitter {
43     public:
44 //-----------------------------------------------------------------------------
45
46        vtkGdcm4DSplitter();
47        ~vtkGdcm4DSplitter();
48
49        // Locate Data to process
50        // ======================
51        void setRecursive(bool recursive);
52        bool setDirName     (std::string &dirName);
53        bool setVectDirName (std::vector<std::string> &vectDirName);
54        bool setVectFileName(std::vector<std::string> &vectFileName);
55        
56        bool setVectGdcmFile(std::vector<GDCM_NAME_SPACE::File *> *vectGdcmFile);
57
58        // Split
59        // =====
60        void setSplitOnPosition();
61        void setSplitOnOrientation();
62        void setSplitOnTag(unsigned short int splitGroup, unsigned short int splitElem);
63
64        void setSplitConvertToFloat(bool conv);
65
66        void setSplitOnly(bool s);
67        
68        // Sort
69        // ====
70        void setSortOnPosition();
71       // use setSortOnUserFunction, instead!
72       // void setSortOnTag(unsigned short int sortGroup, unsigned short int sortElem)
73       //                                   {SortOnPosition=false; SortOnOrientation=false; SortOnTag=true; SortOnFileName=false; SortOnUserFunction=false;
74       //                                    SortGroup=sortGroup;  SortElem=sortElem;}
75
76        void setSortOnUserFunction (FoncComp f);
77
78        //void setSortConvertToFloat(bool conv);
79
80        void setSortOnFileName();
81
82        // SortOnOrientation : not yet made; IOP sorter missing!
83        //inline void setSortOnOrientation(){SortOnPosition=false; SortOnOrientation=true;  SortOnTag=false; SortOnFileName=false; SortOnUserFunction=false;}
84
85         std::vector<vtkImageData*> *GetImageDataVector();
86         vtkImageData *GetImageData();
87
88         std::vector< GDCM_NAME_SPACE::FileList *> *GetVectGdcmFileLists();
89         
90         bool Go();
91
92     protected:
93     private:
94        bool CompareOnSortTag              (GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
95        bool CompareOnSortTagConvertToFloat(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
96        void reorgXCoherentFileSetmap      (GDCM_NAME_SPACE::XCoherentFileSetmap &xcm);
97        bool sortVectElem(std::vector<ELEM> *le);
98
99     // Data
100     // ----
101     public:
102     protected:
103     private:
104        std::string DirName;
105        std::vector<std::string> VectDirName;
106        std::vector<std::string> VectFileName;
107
108        bool SplitOnPosition;
109        bool SplitOnOrientation;
110        bool SplitOnTag;
111
112        unsigned short int SplitGroup;
113        unsigned short int SplitElem;
114        bool SplitConvertToFloat;
115        bool SplitOnly;
116  
117        bool SortOnPosition;
118        bool SortOnOrientation;
119        bool SortOnTag;
120        bool SortOnFileName;
121        bool SortOnUserFunction;
122
123        FoncComp UserCompareFunction;
124
125        unsigned short int SortGroup;
126        unsigned short int SortElem;
127        bool SortConvertToFloat;
128
129        bool Recursive;
130        int TypeDir;
131        //int TypeResult;
132        bool verbose;
133        std::vector<vtkImageData*> *ImageDataVector;
134        vtkImageData *ImageData;
135        //std::vector<GDCM_NAME_SPACE::File *> VectGdcmFile;
136        GDCM_NAME_SPACE::FileList *VectGdcmFile; 
137        GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
138        //std::vector<std::vector<GDCM_NAME_SPACE::File *> > VectGdcmFileLists;
139        std::vector<GDCM_NAME_SPACE::FileList *> VectGdcmFileLists;
140   };
141
142 //} // end namespace gdcm
143
144 //-----------------------------------------------------------------------------
145 #endif