ITK  4.4.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 
162  itkSetMacro(LoadPrivateTags, bool);
163  itkGetConstMacro(LoadPrivateTags, bool);
164  itkBooleanMacro(LoadPrivateTags);
166 
167 #if defined( ITKIO_DEPRECATED_GDCM1_API )
168 
174  void GetPatientName(char *name);
175 
176  void GetPatientID(char *id);
177 
178  void GetPatientSex(char *sex);
179 
180  void GetPatientAge(char *age);
181 
182  void GetStudyID(char *id);
183 
184  void GetPatientDOB(char *dob);
185 
186  void GetStudyDescription(char *desc);
187 
188  void GetBodyPart(char *part);
189 
190  void GetNumberOfSeriesInStudy(char *series);
191 
192  void GetNumberOfStudyRelatedSeries(char *series);
193 
194  void GetStudyDate(char *date);
195 
196  void GetModality(char *modality);
197 
198  void GetManufacturer(char *manu);
199 
200  void GetInstitution(char *ins);
201 
202  void GetModel(char *model);
203 
204  void GetScanOptions(char *options);
205 #endif
206 
210  bool GetValueFromTag(const std::string & tag, std::string & value);
211 
218  static bool GetLabelFromTag(const std::string & tag,
219  std::string & labelId);
220 
221 #if defined( ITKIO_DEPRECATED_GDCM1_API )
222 
229  virtual void SetMaxSizeLoadEntry( const long ) {}
230 
236  virtual void SetLoadSequences( const bool ) {}
237  virtual bool GetLoadSequences () const { return true; }
238  virtual void LoadSequencesOn () {}
239  virtual void LoadSequencesOff () {}
241 
250  static void SetLoadSequencesDefault(bool) {}
251  static void LoadSequencesDefaultOn() {}
252  static void LoadSequencesDefaultOff() {}
253  static bool GetLoadSequencesDefault() { return true; }
255 
264  static void SetLoadPrivateTagsDefault(bool) {}
265  static void LoadPrivateTagsDefaultOn() {}
266  static void LoadPrivateTagsDefaultOff() {}
267  static bool GetLoadPrivateTagsDefault() { return true; }
268 #endif
269 
270 
272  typedef enum { JPEG = 0, JPEG2000, JPEGLS, RLE } TCompressionType;
273  itkSetEnumMacro(CompressionType, TCompressionType);
274  itkGetEnumMacro(CompressionType, TCompressionType);
276 
277 protected:
278  GDCMImageIO();
279  ~GDCMImageIO();
280  void PrintSelf(std::ostream & os, Indent indent) const;
281 
282  bool OpenGDCMFileForReading(std::ifstream & os, const char *filename);
283 
284  bool OpenGDCMFileForWriting(std::ofstream & os, const char *filename);
285 
286  void InternalReadImageInformation(std::ifstream & file);
287 
290 
291  std::string m_UIDPrefix;
292  std::string m_StudyInstanceUID;
293  std::string m_SeriesInstanceUID;
295 
297 
299 
300 private:
301  GDCMImageIO(const Self &); //purposely not implemented
302  void operator=(const Self &); //purposely not implemented
303 
304 #if defined( ITKIO_DEPRECATED_GDCM1_API )
305  std::string m_PatientName;
306  std::string m_PatientID;
307  std::string m_PatientDOB;
308  std::string m_StudyID;
309  std::string m_StudyDescription;
310  std::string m_BodyPart;
313  std::string m_PatientSex;
314  std::string m_PatientAge;
315  std::string m_StudyDate;
316  std::string m_Modality;
317  std::string m_Manufacturer;
318  std::string m_Institution;
319  std::string m_Model;
320  std::string m_ScanOptions;
321 #endif
322 
327 
329  InternalHeader * m_DICOMHeader;
330 };
331 } // end namespace itk
332 
333 #endif // __itkGDCMImageIO_h
334