]> Creatis software - gdcm.git/blob - vtk/vtkGdcm4DSplitter.h
c643a95af3e1eb8d2c9116a4aba38e6d5091760a
[gdcm.git] / vtk / vtkGdcm4DSplitter.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: vtkGdcm4DSplitter.h,v $
5   Language:  C++
6   Date:      $Date: 2011/04/15 15:14:40 $
7   Version:   $Revision: 1.10 $
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        bool SetFlipY(bool f) { FlipY = f;}
59
60        // Split
61        // =====
62        void setSplitOnPosition();
63        void setSplitOnOrientation();
64        void setSplitOnTag(unsigned short int splitGroup, unsigned short int splitElem);
65
66        void setSplitConvertToFloat(bool conv);
67
68        void setSplitOnly(bool s);
69        
70        // Sort
71        // ====
72        void setSortOnPosition();
73       // use setSortOnUserFunction, instead!
74       // void setSortOnTag(unsigned short int sortGroup, unsigned short int sortElem)
75       //                                   {SortOnPosition=false; SortOnOrientation=false; SortOnTag=true; SortOnFileName=false; SortOnUserFunction=false;
76       //                                    SortGroup=sortGroup;  SortElem=sortElem;}
77
78        void setSortOnUserFunction (FoncComp f);
79
80        //void setSortConvertToFloat(bool conv);
81
82        void setSortOnFileName();
83
84        // SortOnOrientation : not yet made; IOP sorter missing!
85        //inline void setSortOnOrientation(){SortOnPosition=false; SortOnOrientation=true;  SortOnTag=false; SortOnFileName=false; SortOnUserFunction=false;}
86
87         std::vector<vtkImageData*> *GetImageDataVector();
88         vtkImageData *GetImageData();
89
90         std::vector< GDCM_NAME_SPACE::FileList *> *GetVectGdcmFileLists();
91         
92         bool Go();
93
94     protected:
95     private:
96        bool CompareOnSortTag              (GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
97        bool CompareOnSortTagConvertToFloat(GDCM_NAME_SPACE::File *file1, GDCM_NAME_SPACE::File *file2);
98        void reorgXCoherentFileSetmap      (GDCM_NAME_SPACE::XCoherentFileSetmap &xcm);
99        bool sortVectElem(std::vector<ELEM> *le);
100
101     // Data
102     // ----
103     public:
104     protected:
105     private:
106        std::string DirName;
107        std::vector<std::string> VectDirName;
108        std::vector<std::string> VectFileName;
109
110        bool SplitOnPosition;
111        bool SplitOnOrientation;
112        bool SplitOnTag;
113
114        unsigned short int SplitGroup;
115        unsigned short int SplitElem;
116        bool SplitConvertToFloat;
117        bool SplitOnly;
118  
119        bool SortOnPosition;
120        bool SortOnOrientation;
121        bool SortOnTag;
122        bool SortOnFileName;
123        bool SortOnUserFunction;
124
125        FoncComp UserCompareFunction;
126
127        unsigned short int SortGroup;
128        unsigned short int SortElem;
129        bool SortConvertToFloat;
130
131        bool Recursive;
132        int TypeDir;
133        //int TypeResult;
134        bool verbose;
135        std::vector<vtkImageData*> *ImageDataVector;
136        vtkImageData *ImageData;
137        //std::vector<GDCM_NAME_SPACE::File *> VectGdcmFile;
138        GDCM_NAME_SPACE::FileList *VectGdcmFile; 
139        GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
140        //std::vector<std::vector<GDCM_NAME_SPACE::File *> > VectGdcmFileLists;
141        std::vector<GDCM_NAME_SPACE::FileList *> VectGdcmFileLists;
142        bool FlipY;
143   };
144
145 //} // end namespace gdcm
146
147 //-----------------------------------------------------------------------------
148 #endif