RTK  2.0.1
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  * 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 rtkXimImageIO_h
20 #define rtkXimImageIO_h
21 
22 #include "rtkMacro.h"
23 
24 // itk include
25 #include <itkImageIOBase.h>
26 
27 #if defined (_MSC_VER) && (_MSC_VER < 1600)
28 //SR: taken from
29 //#include "msinttypes/stdint.h"
30 #else
31 #include <cstdint>
32 #endif
33 
34 namespace rtk {
35 
46 {
47 public:
49  using Self = XimImageIO;
52  using PixelType = signed short int;
53  using Int4 = itk::int32_t; // int of 4 bytes as in xim docs
54 
55  typedef struct xim_header {
56  //Actual Header:
57  char sFileType[32];
67  //Header after pixel-data:
71  unsigned int nPixelOffset;
72  double dCollX1;
73  double dCollX2;
74  double dCollY1;
75  double dCollY2;
76  double dCollRtn;
77  double dCouchVrt;
78  double dCouchLng;
79  double dCouchLat;
80  double dIDUResolutionX; //MUST BE CALCULATED
81  double dIDUResolutionY; //
84  double dEnergy;
85  double dDoseRate;
86  double dXRayKV;
87  double dXRayMA;
88  double dCTProjectionAngle; //KVSourceRtn in file
89  double dDetectorOffsetX; // KVDetectorLat
90  double dDetectorOffsetY; // KVDetectorLng
96  //double dGating4DInfoTime;
97  } Xim_header;
98 
100 
102  itkNewMacro(Self);
103 
105  itkTypeMacro(XimImageIO, itk::ImageIOBase);
106 
107  /*-------- This part of the interface deals with reading data. ------ */
108  void ReadImageInformation() override;
109 
110  bool CanReadFile( const char* FileNameToRead ) override;
111 
112  void Read(void * buffer) override;
113 
114  /*-------- This part of the interfaces deals with writing data. ----- */
115  virtual void WriteImageInformation(bool /*keepOfStream*/) { }
116 
117  void WriteImageInformation() override { WriteImageInformation(false); }
118 
119  bool CanWriteFile(const char* filename) override;
120 
121  void Write(const void* buffer) override;
122 
123 private:
124  template<typename T> size_t SetPropertyValue(char *property_name, Int4 value_length, FILE *fp, Xim_header *xim);
125 
128 
129 }; // end class XimImageIO
130 
131 } // end namespace
132 
133 #endif /* end #define __rtkXimImageIO_h */
vcl_size_t SetPropertyValue(char *property_name, Int4 value_length, FILE *fp, Xim_header *xim)
itk::int32_t Int4
Definition: rtkXimImageIO.h:53
void Write(const void *buffer) override
signed short int PixelType
Definition: rtkXimImageIO.h:52
struct rtk::XimImageIO::xim_header Xim_header
void ReadImageInformation() override
bool CanWriteFile(const char *filename) override
bool CanReadFile(const char *FileNameToRead) override
Class for reading Xim Image file format.
Definition: rtkXimImageIO.h:45
void WriteImageInformation() override
virtual void WriteImageInformation(bool)
void Read(void *buffer) override
::int32_t int32_t