ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGDCMImageIO.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkGDCMImageIO_h
00029 #define __itkGDCMImageIO_h
00030 
00031 #define ITKIO_DEPRECATED_GDCM1_API
00032 
00033 #include "itkImageIOBase.h"
00034 #include <fstream>
00035 #include <string>
00036 
00037 namespace itk
00038 {
00085 class InternalHeader;
00086 class ITK_EXPORT GDCMImageIO:public ImageIOBase
00087 {
00088 public:
00090   typedef GDCMImageIO          Self;
00091   typedef ImageIOBase          Superclass;
00092   typedef SmartPointer< Self > Pointer;
00093 
00095   itkNewMacro(Self);
00096 
00098   itkTypeMacro(GDCMImageIO, Superclass);
00099 
00100   /*-------- This part of the interface deals with reading data. ------ */
00101 
00104   virtual bool CanReadFile(const char *);
00105 
00107   virtual void ReadImageInformation();
00108 
00110   virtual void Read(void *buffer);
00111 
00115   itkGetEnumMacro(InternalComponentType, IOComponentType);
00116 
00117   /*-------- This part of the interfaces deals with writing data. ----- */
00118 
00121   virtual bool CanWriteFile(const char *);
00122 
00125   virtual void WriteImageInformation();
00126 
00129   virtual void Write(const void *buffer);
00130 
00134   itkGetConstMacro(RescaleSlope, double);
00135   itkGetConstMacro(RescaleIntercept, double);
00137 
00142   itkGetStringMacro(UIDPrefix);
00143   itkSetStringMacro(UIDPrefix);
00145 
00147   itkGetStringMacro(StudyInstanceUID);
00148   itkGetStringMacro(SeriesInstanceUID);
00149   itkGetStringMacro(FrameOfReferenceInstanceUID);
00151 
00154   itkSetMacro(KeepOriginalUID, bool);
00155   itkGetConstMacro(KeepOriginalUID, bool);
00156   itkBooleanMacro(KeepOriginalUID);
00158 
00159 #if defined( ITKIO_DEPRECATED_GDCM1_API )
00160 
00166   void GetPatientName(char *name);
00167 
00168   void GetPatientID(char *id);
00169 
00170   void GetPatientSex(char *sex);
00171 
00172   void GetPatientAge(char *age);
00173 
00174   void GetStudyID(char *id);
00175 
00176   void GetPatientDOB(char *dob);
00177 
00178   void GetStudyDescription(char *desc);
00179 
00180   void GetBodyPart(char *part);
00181 
00182   void GetNumberOfSeriesInStudy(char *series);
00183 
00184   void GetNumberOfStudyRelatedSeries(char *series);
00185 
00186   void GetStudyDate(char *date);
00187 
00188   void GetModality(char *modality);
00189 
00190   void GetManufacturer(char *manu);
00191 
00192   void GetInstitution(char *ins);
00193 
00194   void GetModel(char *model);
00195 
00196   void GetScanOptions(char *options);
00197 
00203   bool GetValueFromTag(const std::string & tag, std::string & value);
00204 
00211   static bool GetLabelFromTag(const std::string & tag,
00212                               std::string & labelId);
00213 #endif
00214 
00215 #if defined( ITKIO_DEPRECATED_GDCM1_API )
00216 
00223   virtual void SetMaxSizeLoadEntry( const long ) {}
00224 
00230   virtual void SetLoadSequences( const bool ) {}
00231   virtual bool GetLoadSequences () const { return true; }
00232   virtual void LoadSequencesOn () {}
00233   virtual void LoadSequencesOff () {}
00235 
00241   virtual void SetLoadPrivateTags( const bool ) {}
00242   virtual bool GetLoadPrivateTags() const { return true; }
00243   virtual void LoadPrivateTagsOn () {}
00244   virtual void LoadPrivateTagsOff () {}
00246 
00255   static void SetLoadSequencesDefault(bool) {}
00256   static void LoadSequencesDefaultOn() {}
00257   static void LoadSequencesDefaultOff() {}
00258   static bool GetLoadSequencesDefault() { return true; }
00260 
00269   static void SetLoadPrivateTagsDefault(bool) {}
00270   static void LoadPrivateTagsDefaultOn() {}
00271   static void LoadPrivateTagsDefaultOff() {}
00272   static bool GetLoadPrivateTagsDefault() { return true; }
00273 #endif
00274 
00275 
00277   typedef enum { JPEG = 0, JPEG2000, JPEGLS, RLE } TCompressionType;
00278   itkSetEnumMacro(CompressionType, TCompressionType);
00279   itkGetEnumMacro(CompressionType, TCompressionType);
00281 
00282 protected:
00283   GDCMImageIO();
00284   ~GDCMImageIO();
00285   void PrintSelf(std::ostream & os, Indent indent) const;
00286 
00287   bool OpenGDCMFileForReading(std::ifstream & os, const char *filename);
00288 
00289   bool OpenGDCMFileForWriting(std::ofstream & os, const char *filename);
00290 
00291   void InternalReadImageInformation(std::ifstream & file);
00292 
00293   double m_RescaleSlope;
00294   double m_RescaleIntercept;
00295 
00296   std::string m_UIDPrefix;
00297   std::string m_StudyInstanceUID;
00298   std::string m_SeriesInstanceUID;
00299   std::string m_FrameOfReferenceInstanceUID;
00300 
00301   bool m_KeepOriginalUID;
00302 private:
00303   GDCMImageIO(const Self &);    //purposely not implemented
00304   void operator=(const Self &); //purposely not implemented
00305 
00306 #if defined( ITKIO_DEPRECATED_GDCM1_API )
00307   std::string m_PatientName;
00308   std::string m_PatientID;
00309   std::string m_PatientDOB;
00310   std::string m_StudyID;
00311   std::string m_StudyDescription;
00312   std::string m_BodyPart;
00313   std::string m_NumberOfSeriesInStudy;
00314   std::string m_NumberOfStudyRelatedSeries;
00315   std::string m_PatientSex;
00316   std::string m_PatientAge;
00317   std::string m_StudyDate;
00318   std::string m_Modality;
00319   std::string m_Manufacturer;
00320   std::string m_Institution;
00321   std::string m_Model;
00322   std::string m_ScanOptions;
00323 #endif
00324 
00327   unsigned int     m_GlobalNumberOfDimensions;
00328   TCompressionType m_CompressionType;
00329 
00330   ImageIOBase::IOComponentType m_InternalComponentType;
00331   InternalHeader *             m_DICOMHeader;
00332 };
00333 } // end namespace itk
00334 
00335 #endif // __itkGDCMImageIO_h
00336