]> Creatis software - clitk.git/blob - tools/clitkUpdateVRTagDicomGenericFilter.h
Do not use Series Details
[clitk.git] / tools / clitkUpdateVRTagDicomGenericFilter.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkUpdateVRTagDicomGenericFilter_h
19 #define clitkUpdateVRTagDicomGenericFilter_h
20
21 /* =================================================
22  * @file   clitkUpdateVRTagDicomGenericFilter.h
23  * @author 
24  * @date   
25  * 
26  * @brief 
27  * 
28  ===================================================*/
29
30
31 // clitk include
32 #include "clitkIO.h"
33 #include "clitkImageCommon.h"
34 #include "clitkUpdateVRTagDicom_ggo.h"
35
36 //itk include
37 #include "itkLightObject.h"
38 #include "itkGDCMImageIO.h"
39 #include "itkMetaDataDictionary.h"
40 #include "itkGDCMSeriesFileNames.h"
41 #include "itkImageSeriesReader.h"
42 #include "itkImageSeriesWriter.h"
43 #include "itkImageFileReader.h"
44 #include "itkImageFileWriter.h"
45 #include <vector>
46 #include <itksys/SystemTools.hxx>
47 enum valrep_t {VR_AE,
48                                 VR_AS,
49                                 VR_AT,
50                                 VR_CS,
51                                 VR_DA,
52                                 VR_DS,
53                                 VR_DT,
54                                 VR_FL,
55                                 VR_FD,
56                                 VR_IS,
57                                 VR_LO,
58                                 VR_LT,
59                                 VR_OB,
60                                 VR_OF,
61                                 VR_OW,
62                                 VR_PN,
63                                 VR_SH,
64                                 VR_SL,
65                                 VR_SQ,
66                                 VR_SS,
67                                 VR_ST,
68                                 VR_TM,
69                                 VR_UI,
70                                 VR_UL,
71                                 VR_UN,
72                                 VR_US,
73                                 VR_UT};
74 namespace clitk 
75 {
76   template<class args_info_type>
77   class ITK_EXPORT UpdateVRTagDicomGenericFilter : public itk::LightObject
78   {
79   public:
80     //----------------------------------------
81     // ITK
82     //----------------------------------------
83     typedef UpdateVRTagDicomGenericFilter   Self;
84     typedef itk::LightObject                          Superclass;
85     typedef itk::SmartPointer<Self>                   Pointer;
86     typedef itk::SmartPointer<const Self>             ConstPointer;
87    
88     // Method for creation through the object factory
89     itkNewMacro(Self);
90
91     // Run-time type information (and related methods)
92     itkTypeMacro( UpdateVRTagDicomGenericFilter, LightObject );
93
94
95     //----------------------------------------
96     // Typedefs
97     //----------------------------------------
98
99
100     //----------------------------------------
101     // Set & Get
102     //----------------------------------------
103     void SetArgsInfo(const args_info_type & a)
104     {
105       m_ArgsInfo=a;
106       m_Verbose=m_ArgsInfo.verbose_flag;
107       m_InputFileName=m_ArgsInfo.input_arg;
108     }
109
110
111     //----------------------------------------
112     // Update
113     //----------------------------------------
114     void Update();
115
116   protected:
117
118     //----------------------------------------
119     // Constructor & Destructor
120     //----------------------------------------
121     UpdateVRTagDicomGenericFilter();
122     ~UpdateVRTagDicomGenericFilter() {};
123
124
125     //----------------------------------------
126     // Templated members
127     //----------------------------------------
128     template <unsigned int Dimension>  void UpdateWithDim(std::string PixelType);
129     template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
130     template <unsigned int Dimension, class PixelType> void ReadDataElement(std::ifstream& f, std::ifstream& model);
131     template <unsigned int Dimension, class PixelType> void ReadDicomObject(std::ifstream& f, std::ifstream& model);
132     template <unsigned int Dimension, class PixelType> void InitVRMap();
133     template <unsigned int Dimension, class PixelType> void UpdateVRMap();
134
135
136     //----------------------------------------
137     // Data members
138     //----------------------------------------
139     args_info_type m_ArgsInfo;
140     bool m_Verbose;
141     std::string m_InputFileName;
142     int counter;
143     uint16_t Group;
144     uint16_t Element;
145     std::string VR;
146     uint32_t Length;
147     uint32_t LengthModel;
148     char* Value;
149     char* ValueModel;
150     std::map<std::string, valrep_t> VRMap;
151     std::map<std::string, std::string> VRMapModel;
152
153     std::ofstream output;
154     std::ifstream f;
155     std::ifstream model;
156
157     unsigned long size;
158     unsigned long endSQ;
159
160   };
161
162 //Copy dicom dictionary
163 void CopyDictionary (itk::MetaDataDictionary &fromDict, itk::MetaDataDictionary &toDict);
164
165 //convert to std::string
166 template <typename T> std::string NumberToString ( T Number );
167 template <typename T> std::string int_to_hex ( T Number );
168 std::string string_to_hex( std::string &input );
169
170 } // end namespace clitk
171
172 #ifndef ITK_MANUAL_INSTANTIATION
173 #include "clitkUpdateVRTagDicomGenericFilter.txx"
174 #endif
175
176 #endif // #define clitkUpdateVRTagDicomGenericFilter_h