]> Creatis software - clitk.git/blob - common/clitkDicomRTDoseIO.h
Converted plastimatch dicom RT dose reader in ITK IO format.
[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://oncora1.lyon.fnclcc.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
28 // std include
29 #include <fstream>
30
31 namespace clitk
32 {
33
34 //====================================================================
35 // Class for reading Vox Image file format
36 class DicomRTDoseIO: public itk::ImageIOBase
37 {
38 public:
39   /** Standard class typedefs. */
40   typedef DicomRTDoseIO              Self;
41   typedef itk::ImageIOBase        Superclass;
42   typedef itk::SmartPointer<Self> Pointer;
43   typedef signed short int        PixelType;
44
45   DicomRTDoseIO():Superclass() {
46     mustWriteHeader = false;
47     m_GdcmFile=NULL;
48   }
49
50   /** Method for creation through the object factory. */
51   itkNewMacro(Self);
52
53   /** Run-time type information (and related methods). */
54   itkTypeMacro(DicomRTDoseIO, ImageIOBase);
55
56   /*-------- This part of the interface deals with reading data. ------ */
57   virtual void ReadImageInformation();
58   virtual bool CanReadFile( const char* FileNameToRead );
59   virtual void Read(void * buffer);
60
61   /*-------- This part of the interfaces deals with writing data. ----- */
62   virtual void WriteImageInformation(bool keepOfStream);
63   virtual void WriteImageInformation() {
64     WriteImageInformation(false);
65   }
66   virtual bool CanWriteFile(const char* filename);
67   virtual void Write(const void* buffer);
68
69 protected:
70   template <class T> void dose_copy_raw (float *img_out, T *img_in, int nvox, float scale);
71
72   bool mustWriteHeader;
73   int m_HeaderSize;
74   std::ofstream file;
75   gdcm::File *m_GdcmFile;
76   float m_DoseScaling;
77 }; // end class DicomRTDoseIO
78
79 } // end namespace
80
81 #endif /* end #define clitkDicomRTDoseIO_h */
82