]> Creatis software - clitk.git/blob - common/clitkDicomRTDoseIO.h
Set Directions to CropImage Like
[clitk.git] / common / clitkDicomRTDoseIO.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 clitkDicomRTDoseIO_h
19 #define clitkDicomRTDoseIO_h
20
21 // clitk include
22 #include "clitkCommon.h"
23
24 // itk include
25 #include <itkImageIOBase.h>
26 #include <gdcmFile.h>
27 #if GDCM_MAJOR_VERSION >= 2
28   #include <gdcmImageReader.h>
29 #endif
30
31 // std include
32 #include <fstream>
33
34 namespace clitk
35 {
36
37 //====================================================================
38 // Class for reading Vox Image file format
39 class DicomRTDoseIO: public itk::ImageIOBase
40 {
41 public:
42   /** Standard class typedefs. */
43   typedef DicomRTDoseIO              Self;
44   typedef itk::ImageIOBase        Superclass;
45   typedef itk::SmartPointer<Self> Pointer;
46   typedef signed short int        PixelType;
47
48   DicomRTDoseIO():Superclass() {
49     mustWriteHeader = false;
50 #if GDCM_MAJOR_VERSION < 2
51     m_GdcmFile=NULL;
52 #endif
53   }
54
55   /** Method for creation through the object factory. */
56   itkNewMacro(Self);
57
58   /** Run-time type information (and related methods). */
59   itkTypeMacro(DicomRTDoseIO, ImageIOBase);
60
61   /*-------- This part of the interface deals with reading data. ------ */
62   virtual void ReadImageInformation() ITK_OVERRIDE;
63   virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE;
64   virtual void Read(void * buffer) ITK_OVERRIDE;
65
66   /*-------- This part of the interfaces deals with writing data. ----- */
67   virtual void WriteImageInformation(bool keepOfStream);
68   virtual void WriteImageInformation() ITK_OVERRIDE {
69     WriteImageInformation(false);
70   }
71   virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE;
72   virtual void Write(const void* buffer) ITK_OVERRIDE;
73
74 protected:
75   template <class T> void dose_copy_raw (float *img_out, T *img_in, int nvox, float scale);
76
77   bool mustWriteHeader;
78   int m_HeaderSize;
79   std::ofstream file;
80 #if GDCM_MAJOR_VERSION >= 2
81   gdcm::ImageReader m_GdcmImageReader;
82 #else
83   gdcm::File *m_GdcmFile;
84 #endif
85   float m_DoseScaling;
86 }; // end class DicomRTDoseIO
87
88 } // end namespace
89
90 #endif /* end #define clitkDicomRTDoseIO_h */
91