RTK  2.5.0
Reconstruction Toolkit
rtkXimImageIO.h
Go to the documentation of this file.
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  * https://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 rtkXimImageIO_h
20 #define rtkXimImageIO_h
21 
22 #include "RTKExport.h"
23 #include "rtkMacro.h"
24 
25 // itk include
26 #include <itkImageIOBase.h>
27 
28 #if defined(_MSC_VER) && (_MSC_VER < 1600)
29 // SR: taken from
30 //#include "msinttypes/stdint.h"
31 #else
32 # include <cstdint>
33 #endif
34 
35 namespace rtk
36 {
37 
47 class RTK_EXPORT XimImageIO : public itk::ImageIOBase
48 {
49 public:
51  using Self = XimImageIO;
54  using PixelType = signed short int;
55  using Int4 = itk::int32_t; // int of 4 bytes as in xim docs
56 
57  typedef struct xim_header
58  {
59  // Actual Header:
60  char sFileType[32];
70  // Header after pixel-data:
74  unsigned int nPixelOffset;
75  double dCollX1;
76  double dCollX2;
77  double dCollY1;
78  double dCollY2;
79  double dCollRtn;
80  double dCouchVrt;
81  double dCouchLng;
82  double dCouchLat;
83  double dIDUResolutionX; // MUST BE CALCULATED
84  double dIDUResolutionY; //
85  double dImageResolutionX; //
86  double dImageResolutionY; //
87  double dEnergy;
88  double dDoseRate;
89  double dXRayKV;
90  double dXRayMA;
91  double dCTProjectionAngle; // KVSourceRtn in file
92  double dDetectorOffsetX; // KVDetectorLat
93  double dDetectorOffsetY; // KVDetectorLng
99  // double dGating4DInfoTime;
100  } Xim_header;
101 
103  : Superclass()
104  {}
105 
107  itkNewMacro(Self);
108 
110 #ifdef itkOverrideGetNameOfClassMacro
111  itkOverrideGetNameOfClassMacro(XimImageIO);
112 #else
113  itkTypeMacro(XimImageIO, itk::ImageIOBase);
114 #endif
115 
116 
117  /*-------- This part of the interface deals with reading data. ------ */
118  void
119  ReadImageInformation() override;
120 
121  bool
122  CanReadFile(const char * FileNameToRead) override;
123 
124  void
125  Read(void * buffer) override;
126 
127  /*-------- This part of the interfaces deals with writing data. ----- */
128  virtual void
129  WriteImageInformation(bool /*keepOfStream*/)
130  {}
131 
132  void
134  {
135  WriteImageInformation(false);
136  }
137 
138  bool
139  CanWriteFile(const char * filename) override;
140 
141  void
142  Write(const void * buffer) override;
143 
144 private:
145  template <typename T>
146  size_t
147  SetPropertyValue(char * property_name, Int4 value_length, FILE * fp, Xim_header * xim);
148 
151 
152 }; // end class XimImageIO
153 
154 } // namespace rtk
155 
156 #endif /* end #define __rtkXimImageIO_h */
itk::int32_t Int4
Definition: rtkXimImageIO.h:55
signed short int PixelType
Definition: rtkXimImageIO.h:54
Class for reading Xim Image file format.
Definition: rtkXimImageIO.h:47
void WriteImageInformation() override
virtual void WriteImageInformation(bool)