]> Creatis software - creaImageIO.git/blob - src/creaImageIOOutputModel.h
f2b121ae11a1bae5975143f2be00dfb53f81e692
[creaImageIO.git] / src / creaImageIOOutputModel.h
1 #ifndef __creaImageIOoutputModel_h_INCLUDED__
2 #define __creaImageIOoutputModel_h_INCLUDED__
3 #if defined (USE_XERCES)
4 #include <creaImageIOOutputModelParser.h>
5 #endif
6 #if defined(USE_GDCM2)
7 #include <gdcmScanner.h>
8 #endif
9
10 #include <vector>
11 #include <string>
12
13 #define OUTPUTMODEL_TAG_i       ""
14 #define OUTPUTMODEL_TAG_0       "TAG_BEGIN"
15 #define OUTPUTMODEL_TAG_1       "TAG_END"
16 #define OUTPUTMODEL_TAG_2       "TAG_STEP"
17 #define OUTPUTMODEL_TAG_3       "DICOM_TAG"
18 #define OUTPUTMODEL_TAG_4       "ANCHOR"
19 #define OUTPUTMODEL_TAG(i)      OUTPUTMODEL_TAG_ ## i
20
21 namespace creaImageIO
22 {
23
24         class  OutputModel 
25         {
26         public:
27                 OutputModel(){}
28                 virtual ~OutputModel();
29                 double orderFilesWithZspacing(std::vector<std::string> &im);
30
31 #if defined(USE_XERCES)
32                 OutputModel(OutputModelParser *i_outparser);
33         
34                 // Test if we need to check the "dicom" tag if it exists on database
35                 void setDB(const std::string i_db, const std::string i_table);
36
37                 const std::string getTag();
38
39         private:
40
41                 OutputModelParser *m_outparser;
42
43                 // dimensions of output
44                 int dim;
45
46                 // index to indicate if one model is available to perform sorting
47                 bool bmodel;
48                 
49                 // index to indicate of a "DICOM" tag is selected to perform sorting
50                 // not necessary a dicom tag
51                 // for the moment only Gimmick Tag format accepted but should be GDCM2 format or GDCM1.3 too
52                 bool bDicom;
53
54                 // database name
55                 std::string m_dbname;
56                 
57                 std::string m_tag;
58 #if defined(USE_GDCM)
59                 //m_tag1;
60                 template<typename T>
61                 //void getReadValues(const std::vector<std :: string> i_filenames, std::vector<T> &o_val);
62                 double orderFiles(std::vector<std::string> im, std::vector<std::string> &out);
63
64 #endif
65 #if defined(USE_GDCM2)
66                 gdcm::Tag       m_tag2;
67
68                 template<typename T>
69                 void getScanValues(const std::vector<std :: string> i_filenames, const std::string i_stag, std::map<std::string,T> &o_val);
70         
71                 /*template<typename T>
72                 T getTypeTag();*/
73 #endif
74
75                 // the initial value to start sorting
76                 int tag_begin;
77
78                 // the final value to end sorting
79                 int tag_end;
80
81                 // step for the values
82                 int tag_step;
83
84                 // if the sorting is not the same for the set of data, we include another OutputModel
85                 // ex : if we want a step = 20 for the 100 first values, next a step = 10 for the next 100 and step = 1 for the lastest value
86                 OutputModel *m_model;
87
88                 // indicates if the sorting tag is present in database or not
89                 bool b_db;
90
91                 std::string m_db;
92
93                 std::string m_table;
94
95                 template<typename T>
96                 void getValues(const std::vector<std::string> i_filenames,const std::string i_tag, std::map< std::string, T> &o_val);
97                 template<typename T>
98                 void getDBValues(const std::vector<std::string> i_filenames, const std::string i_stag, std::map<std::string,T> &o_val);
99
100                 void sort(const std::vector<std::string> i_filenames, std::vector<std::string> &o_sort, int level);
101
102                 bool checkModel(std::map<std::string, std::string> i_model, const std::string i_val);
103 #endif
104         };
105         
106 /*
107          template <class T>
108          class OutputSort
109          {
110          public :
111                  std::map <std::string, T> values;
112                  std::map<std::string, T> tags;
113
114                  void setTag(T i_tag, const std::string name)
115                  {
116                          tags[name] = i_tag;
117                  }
118
119                  void sort (const std::map<std::string, T> i_values, std::vector<std::string> &o_sort)
120                  {
121                         std::map<std::string, T>::const_iterator it_val; 
122                         for(T index = tags[OUTPUTMODEL_TAG(0)]; index <= tags[OUTPUTMODEL_TAG(1)]; index += tags[OUTPUTMODEL_TAG(2)])
123                         {
124                                 //std::map<std::string, T>::const_iterator it_val; 
125                                 for(it_val = i_values.begin();it_val != i_values.end(); it_val++)
126                                 {
127                                         if(it_val->second.c_str()  == index)
128                                         {
129                                                 o_sort.push_back(it_val->first.c_str());
130                                                 break;
131                                         }
132                                 }
133                          }
134                  }
135          };
136 */
137         
138 } // namespace creaImageIO
139 #endif //__creaImageIOoutputModel_h_INCLUDED__