]> Creatis software - gdcm.git/blob - vtk/vtkGdcm4DSplitter.h
482f509c915aee1218925ecba624c976817c2610
[gdcm.git] / vtk / vtkGdcm4DSplitter.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: vtkGdcm4DSplitter.h,v $
5   Language:  C++
6   Date:      $Date: 2011/04/20 15:03:54 $
7   Version:   $Revision: 1.12 $
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        void 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       GDCM_NAME_SPACE::FileList * getGdcmFileList();
101  
102     // Data
103     // ----
104     public:
105     protected:
106     private:
107     
108        //
109        // Set by user
110        //
111        std::string DirName;
112        std::vector<std::string> VectDirName;
113        std::vector<std::string> VectFileName;
114
115        bool SplitOnPosition;
116        bool SplitOnOrientation;
117        bool SplitOnTag;
118
119        unsigned short int SplitGroup;
120        unsigned short int SplitElem;
121        bool SplitConvertToFloat;
122        bool SplitOnly;
123  
124        bool SortOnPosition;
125        bool SortOnOrientation;
126        //bool SortOnTag;
127        bool SortOnFileName;
128        bool SortOnUserFunction;
129
130        FoncComp UserCompareFunction;
131
132        //unsigned short int SortGroup;
133        //unsigned short int SortElem;
134        //bool SortConvertToFloat;
135
136        bool Recursive;
137        bool FlipY;
138        bool verbose;
139        
140        //
141        // needed, to work
142        //       
143        int TypeDir;
144        GDCM_NAME_SPACE::XCoherentFileSetmap xcm;
145        
146        //
147        // may be got by user
148        //
149        std::vector<vtkImageData*> *ImageDataVector;
150        GDCM_NAME_SPACE::FileList *VectGdcmFile;       // std::vector of gdcm::File*
151        
152        std::vector<GDCM_NAME_SPACE::FileList *> VectGdcmFileLists; // result of the splitting operation
153   };
154
155 //} // end namespace gdcm
156
157 //-----------------------------------------------------------------------------
158 #endif