]> Creatis software - clitk.git/blob - common/rtkHndImageIO.h
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / common / rtkHndImageIO.h
1 /*=========================================================================
2  *
3  *  Copyright RTK 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 #ifndef __rtkHndImageIO_h
20 #define __rtkHndImageIO_h
21
22 // itk include
23 #include <itkImageIOBase.h>
24
25 #if defined (_MSC_VER) && (_MSC_VER < 1600)
26 //SR: taken from
27 //#include "msinttypes/stdint.h"
28 #else
29 #include <stdint.h>
30 #endif
31
32 namespace rtk {
33
34 /** \class HndImageIO
35  * \brief Class for reading Hnd Image file format
36  *
37  * Reads Hnd files (file format used by Varian for Obi raw data).
38  *
39  * \author Simon Rit
40  *
41  * \ingroup IOFilters
42  */
43 class HndImageIO : public itk::ImageIOBase
44 {
45 public:
46 /** Standard class typedefs. */
47   typedef HndImageIO              Self;
48   typedef itk::ImageIOBase        Superclass;
49   typedef itk::SmartPointer<Self> Pointer;
50   typedef signed short int        PixelType;
51
52   typedef struct hnd_header {
53     char sFileType[32];
54     unsigned int FileLength;
55     char sChecksumSpec[4];
56     unsigned int nCheckSum;
57     char sCreationDate[8];
58     char sCreationTime[8];
59     char sPatientID[16];
60     unsigned int nPatientSer;
61     char sSeriesID[16];
62     unsigned int nSeriesSer;
63     char sSliceID[16];
64     unsigned int nSliceSer;
65     unsigned int SizeX;
66     unsigned int SizeY;
67     double dSliceZPos;
68     char sModality[16];
69     unsigned int nWindow;
70     unsigned int nLevel;
71     unsigned int nPixelOffset;
72     char sImageType[4];
73     double dGantryRtn;
74     double dSAD;
75     double dSFD;
76     double dCollX1;
77     double dCollX2;
78     double dCollY1;
79     double dCollY2;
80     double dCollRtn;
81     double dFieldX;
82     double dFieldY;
83     double dBladeX1;
84     double dBladeX2;
85     double dBladeY1;
86     double dBladeY2;
87     double dIDUPosLng;
88     double dIDUPosLat;
89     double dIDUPosVrt;
90     double dIDUPosRtn;
91     double dPatientSupportAngle;
92     double dTableTopEccentricAngle;
93     double dCouchVrt;
94     double dCouchLng;
95     double dCouchLat;
96     double dIDUResolutionX;
97     double dIDUResolutionY;
98     double dImageResolutionX;
99     double dImageResolutionY;
100     double dEnergy;
101     double dDoseRate;
102     double dXRayKV;
103     double dXRayMA;
104     double dMetersetExposure;
105     double dAcqAdjustment;
106     double dCTProjectionAngle;
107     double dCTNormChamber;
108     double dGatingTimeTag;
109     double dGating4DInfoX;
110     double dGating4DInfoY;
111     double dGating4DInfoZ;
112     double dGating4DInfoTime;
113     } Hnd_header;
114
115   HndImageIO() : Superclass() {}
116
117   /** Method for creation through the object factory. */
118   itkNewMacro(Self);
119
120   /** Run-time type information (and related methods). */
121   itkTypeMacro(HndImageIO, itk::ImageIOBase);
122
123   /*-------- This part of the interface deals with reading data. ------ */
124   virtual void ReadImageInformation();
125
126   virtual bool CanReadFile( const char* FileNameToRead );
127
128   virtual void Read(void * buffer);
129
130   /*-------- This part of the interfaces deals with writing data. ----- */
131   virtual void WriteImageInformation(bool /*keepOfStream*/) { }
132
133   virtual void WriteImageInformation() { WriteImageInformation(false); }
134
135   virtual bool CanWriteFile(const char* filename);
136
137   virtual void Write(const void* buffer);
138
139 }; // end class HndImageIO
140
141 } // end namespace
142
143 #endif /* end #define __rtkHndImageIO_h */