ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkGDCMImageIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkGDCMImageIO_h
29 #define __itkGDCMImageIO_h
30 
31 #define ITKIO_DEPRECATED_GDCM1_API
32 
33 #include "itkImageIOBase.h"
34 #include <fstream>
35 #include <string>
36 
37 namespace itk
38 {
85 class InternalHeader;
86 class ITK_EXPORT GDCMImageIO:public ImageIOBase
87 {
88 public:
90  typedef GDCMImageIO Self;
93 
95  itkNewMacro(Self);
96 
98  itkTypeMacro(GDCMImageIO, Superclass);
99 
100  /*-------- This part of the interface deals with reading data. ------ */
101 
104  virtual bool CanReadFile(const char *);
105 
107  virtual void ReadImageInformation();
108 
110  virtual void Read(void *buffer);
111 
115  itkGetEnumMacro(InternalComponentType, IOComponentType);
116 
117  /*-------- This part of the interfaces deals with writing data. ----- */
118 
121  virtual bool CanWriteFile(const char *);
122 
125  virtual void WriteImageInformation();
126 
129  virtual void Write(const void *buffer);
130 
134  itkGetConstMacro(RescaleSlope, double);
135  itkGetConstMacro(RescaleIntercept, double);
137 
142  itkGetStringMacro(UIDPrefix);
143  itkSetStringMacro(UIDPrefix);
145 
147  itkGetStringMacro(StudyInstanceUID);
148  itkGetStringMacro(SeriesInstanceUID);
149  itkGetStringMacro(FrameOfReferenceInstanceUID);
151 
154  itkSetMacro(KeepOriginalUID, bool);
155  itkGetConstMacro(KeepOriginalUID, bool);
156  itkBooleanMacro(KeepOriginalUID);
158 
159 #if defined( ITKIO_DEPRECATED_GDCM1_API )
160 
166  void GetPatientName(char *name);
167 
168  void GetPatientID(char *id);
169 
170  void GetPatientSex(char *sex);
171 
172  void GetPatientAge(char *age);
173 
174  void GetStudyID(char *id);
175 
176  void GetPatientDOB(char *dob);
177 
178  void GetStudyDescription(char *desc);
179 
180  void GetBodyPart(char *part);
181 
182  void GetNumberOfSeriesInStudy(char *series);
183 
184  void GetNumberOfStudyRelatedSeries(char *series);
185 
186  void GetStudyDate(char *date);
187 
188  void GetModality(char *modality);
189 
190  void GetManufacturer(char *manu);
191 
192  void GetInstitution(char *ins);
193 
194  void GetModel(char *model);
195 
196  void GetScanOptions(char *options);
197 
203  bool GetValueFromTag(const std::string & tag, std::string & value);
204 
211  static bool GetLabelFromTag(const std::string & tag,
212  std::string & labelId);
213 #endif
214 
215 #if defined( ITKIO_DEPRECATED_GDCM1_API )
216 
223  virtual void SetMaxSizeLoadEntry( const long ) {}
224 
230  virtual void SetLoadSequences( const bool ) {}
231  virtual bool GetLoadSequences () const { return true; }
232  virtual void LoadSequencesOn () {}
233  virtual void LoadSequencesOff () {}
235 
241  virtual void SetLoadPrivateTags( const bool ) {}
242  virtual bool GetLoadPrivateTags() const { return true; }
243  virtual void LoadPrivateTagsOn () {}
244  virtual void LoadPrivateTagsOff () {}
246 
255  static void SetLoadSequencesDefault(bool) {}
256  static void LoadSequencesDefaultOn() {}
257  static void LoadSequencesDefaultOff() {}
258  static bool GetLoadSequencesDefault() { return true; }
260 
269  static void SetLoadPrivateTagsDefault(bool) {}
270  static void LoadPrivateTagsDefaultOn() {}
271  static void LoadPrivateTagsDefaultOff() {}
272  static bool GetLoadPrivateTagsDefault() { return true; }
273 #endif
274 
275 
277  typedef enum { JPEG = 0, JPEG2000, JPEGLS, RLE } TCompressionType;
278  itkSetEnumMacro(CompressionType, TCompressionType);
279  itkGetEnumMacro(CompressionType, TCompressionType);
281 
282 protected:
283  GDCMImageIO();
284  ~GDCMImageIO();
285  void PrintSelf(std::ostream & os, Indent indent) const;
286 
287  bool OpenGDCMFileForReading(std::ifstream & os, const char *filename);
288 
289  bool OpenGDCMFileForWriting(std::ofstream & os, const char *filename);
290 
291  void InternalReadImageInformation(std::ifstream & file);
292 
295 
296  std::string m_UIDPrefix;
297  std::string m_StudyInstanceUID;
298  std::string m_SeriesInstanceUID;
300 
302 private:
303  GDCMImageIO(const Self &); //purposely not implemented
304  void operator=(const Self &); //purposely not implemented
305 
306 #if defined( ITKIO_DEPRECATED_GDCM1_API )
307  std::string m_PatientName;
308  std::string m_PatientID;
309  std::string m_PatientDOB;
310  std::string m_StudyID;
311  std::string m_StudyDescription;
312  std::string m_BodyPart;
315  std::string m_PatientSex;
316  std::string m_PatientAge;
317  std::string m_StudyDate;
318  std::string m_Modality;
319  std::string m_Manufacturer;
320  std::string m_Institution;
321  std::string m_Model;
322  std::string m_ScanOptions;
323 #endif
324 
329 
331  InternalHeader * m_DICOMHeader;
332 };
333 } // end namespace itk
334 
335 #endif // __itkGDCMImageIO_h
336