RTK  1.4.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  * 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 <stdint.h>
32 #endif
33 
34 namespace rtk {
35 
46 {
47 public:
49  typedef XimImageIO Self;
52  typedef signed short int PixelType;
53  typedef itk::int32_t Int4; // int of 4 bytes as in xim docs
54 
55  typedef struct xim_header {
56  //Actual Header:
57  char sFileType[32];
59  Int4 SizeX;
60  Int4 SizeY;
67  //Header after pixel-data:
69  Int4 * histogramData;
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 
99  XimImageIO() : Superclass() {}
100 
102  itkNewMacro(Self);
103 
105  itkTypeMacro(XimImageIO, itk::ImageIOBase);
106 
107  /*-------- This part of the interface deals with reading data. ------ */
108  void ReadImageInformation() ITK_OVERRIDE;
109 
110  bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE;
111 
112  void Read(void * buffer) ITK_OVERRIDE;
113 
114  /*-------- This part of the interfaces deals with writing data. ----- */
115  virtual void WriteImageInformation(bool /*keepOfStream*/) { }
116 
117  void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); }
118 
119  bool CanWriteFile(const char* filename) ITK_OVERRIDE;
120 
121  void Write(const void* buffer) ITK_OVERRIDE;
122 
123 private:
124  template<typename T> size_t SetPropertyValue(char *property_name, Int4 value_length, FILE *fp, Xim_header *xim);
125  template<typename T> T get_diff(char vsub, FILE* &fp);
126 
129 
130 }; // end class XimImageIO
131 
132 } // end namespace
133 
134 #endif /* end #define __rtkXimImageIO_h */
vcl_size_t SetPropertyValue(char *property_name, Int4 value_length, FILE *fp, Xim_header *xim)
itk::SmartPointer< Self > Pointer
Definition: rtkXimImageIO.h:51
itk::int32_t Int4
Definition: rtkXimImageIO.h:53
signed short int PixelType
Definition: rtkXimImageIO.h:52
void Write(const void *buffer) override
struct rtk::XimImageIO::xim_header Xim_header
void ReadImageInformation() override
bool CanWriteFile(const char *filename) override
bool CanReadFile(const char *FileNameToRead) override
T get_diff(char vsub, FILE *&fp)
Class for reading Xim Image file format.
Definition: rtkXimImageIO.h:45
void WriteImageInformation() override
XimImageIO Self
Definition: rtkXimImageIO.h:49
virtual void WriteImageInformation(bool)
void Read(void *buffer) override
itk::ImageIOBase Superclass
Definition: rtkXimImageIO.h:50
::int32_t int32_t