creaImageIOOutputModel.h

Go to the documentation of this file.
00001 #ifndef __creaImageIOoutputModel_h_INCLUDED__
00002 #define __creaImageIOoutputModel_h_INCLUDED__
00003 #if defined (USE_XERCES)
00004 #include <creaImageIOOutputModelParser.h>
00005 #endif
00006 #if defined(USE_GDCM2)
00007 #include <gdcmScanner.h>
00008 #endif
00009 
00010 #include <vector>
00011 #include <string>
00012 
00013 #define OUTPUTMODEL_TAG_i       ""
00014 #define OUTPUTMODEL_TAG_0       "TAG_BEGIN"
00015 #define OUTPUTMODEL_TAG_1       "TAG_END"
00016 #define OUTPUTMODEL_TAG_2       "TAG_STEP"
00017 #define OUTPUTMODEL_TAG_3       "DICOM_TAG"
00018 #define OUTPUTMODEL_TAG_4       "ANCHOR"
00019 #define OUTPUTMODEL_TAG(i)      OUTPUTMODEL_TAG_ ## i
00020 
00021 namespace creaImageIO
00022 {
00023 
00024         class  OutputModel 
00025         {
00026         public:
00027                 OutputModel(){}
00028                 virtual ~OutputModel();
00029                 double orderFilesWithZspacing(std::vector<std::string> &im);
00030 
00031 #if defined(USE_XERCES)
00032                 OutputModel(OutputModelParser *i_outparser);
00033         
00034                 // Test if we need to check the "dicom" tag if it exists on database
00035                 void setDB(const std::string i_db, const std::string i_table);
00036 
00037                 const std::string getTag();
00038 
00039         private:
00040 
00041                 OutputModelParser *m_outparser;
00042 
00043                 // dimensions of output
00044                 int dim;
00045 
00046                 // index to indicate if one model is available to perform sorting
00047                 bool bmodel;
00048                 
00049                 // index to indicate of a "DICOM" tag is selected to perform sorting
00050                 // not necessary a dicom tag
00051                 // for the moment only Gimmick Tag format accepted but should be GDCM2 format or GDCM1.3 too
00052                 bool bDicom;
00053 
00054                 // database name
00055                 std::string m_dbname;
00056                 
00057                 std::string m_tag;
00058 #if defined(USE_GDCM)
00059                 //m_tag1;
00060                 template<typename T>
00061                 //void getReadValues(const std::vector<std :: string> i_filenames, std::vector<T> &o_val);
00062                 double orderFiles(std::vector<std::string> im, std::vector<std::string> &out);
00063 
00064 #endif
00065 #if defined(USE_GDCM2)
00066                 gdcm::Tag       m_tag2;
00067 
00068                 template<typename T>
00069                 void getScanValues(const std::vector<std :: string> i_filenames, const std::string i_stag, std::map<std::string,T> &o_val);
00070         
00071                 /*template<typename T>
00072                 T getTypeTag();*/
00073 #endif
00074 
00075                 // the initial value to start sorting
00076                 int tag_begin;
00077 
00078                 // the final value to end sorting
00079                 int tag_end;
00080 
00081                 // step for the values
00082                 int tag_step;
00083 
00084                 // if the sorting is not the same for the set of data, we include another OutputModel
00085                 // 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
00086                 OutputModel *m_model;
00087 
00088                 // indicates if the sorting tag is present in database or not
00089                 bool b_db;
00090 
00091                 std::string m_db;
00092 
00093                 std::string m_table;
00094 
00095                 template<typename T>
00096                 void getValues(const std::vector<std::string> i_filenames,const std::string i_tag, std::map< std::string, T> &o_val);
00097                 template<typename T>
00098                 void getDBValues(const std::vector<std::string> i_filenames, const std::string i_stag, std::map<std::string,T> &o_val);
00099 
00100                 void sort(const std::vector<std::string> i_filenames, std::vector<std::string> &o_sort, int level);
00101 
00102                 bool checkModel(std::map<std::string, std::string> i_model, const std::string i_val);
00103 #endif
00104         };
00105         
00106 /*
00107          template <class T>
00108          class OutputSort
00109          {
00110          public :
00111                  std::map <std::string, T> values;
00112                  std::map<std::string, T> tags;
00113 
00114                  void setTag(T i_tag, const std::string name)
00115                  {
00116                          tags[name] = i_tag;
00117                  }
00118 
00119                  void sort (const std::map<std::string, T> i_values, std::vector<std::string> &o_sort)
00120                  {
00121                         std::map<std::string, T>::const_iterator it_val; 
00122                         for(T index = tags[OUTPUTMODEL_TAG(0)]; index <= tags[OUTPUTMODEL_TAG(1)]; index += tags[OUTPUTMODEL_TAG(2)])
00123                         {
00124                                 //std::map<std::string, T>::const_iterator it_val; 
00125                                 for(it_val = i_values.begin();it_val != i_values.end(); it_val++)
00126                                 {
00127                                         if(it_val->second.c_str()  == index)
00128                                         {
00129                                                 o_sort.push_back(it_val->first.c_str());
00130                                                 break;
00131                                         }
00132                                 }
00133                          }
00134                  }
00135          };
00136 */
00137         
00138 } // namespace creaImageIO
00139 #endif //__creaImageIOoutputModel_h_INCLUDED__