RTK  2.6.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  itkOverrideGetNameOfClassMacro(XimImageIO);
111 
112  /*-------- This part of the interface deals with reading data. ------ */
113  void
114  ReadImageInformation() override;
115 
116  bool
117  CanReadFile(const char * FileNameToRead) override;
118 
119  void
120  Read(void * buffer) override;
121 
122  /*-------- This part of the interfaces deals with writing data. ----- */
123  virtual void
124  WriteImageInformation(bool /*keepOfStream*/)
125  {}
126 
127  void
129  {
130  WriteImageInformation(false);
131  }
132 
133  bool
134  CanWriteFile(const char * filename) override;
135 
136  void
137  Write(const void * buffer) override;
138 
139 private:
140  template <typename T>
141  size_t
142  SetPropertyValue(char * property_name, Int4 value_length, FILE * fp, Xim_header * xim);
143 
146 
147 }; // end class XimImageIO
148 
149 } // namespace rtk
150 
151 #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)