Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtlImageMessage.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: The OpenIGTLink Library
4  Language: C++
5  Web page: http://openigtlink.org/
6 
7  Copyright (c) Insight Software Consortium. All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 =========================================================================*/
14 
15 #ifndef __igtlImageMessage_h
16 #define __igtlImageMessage_h
17 
18 #include "igtlObject.h"
19 #include "igtlMacro.h"
20 #include "igtlMath.h"
21 #include "igtlMessageBase.h"
22 
23 namespace igtl
24 {
25 
26 // A class for the GEt_IMAGE message type.
28 {
29 public:
34 
37 
38 protected:
39 
40  GetImageMessage() : HeaderOnlyMessageBase() { this->m_DefaultBodyType = "GET_IMAGE"; };
42 
43 };
44 
45 
60 {
61 public:
62  typedef ImageMessage Self;
66 
69 
70 public:
71 
73  enum {
74  COORDINATE_RAS=1,
75  COORDINATE_LPS=2
76  };
77 
79  enum {
80  ENDIAN_BIG=1,
81  ENDIAN_LITTLE=2
82  };
83 
85  enum {
86  DTYPE_SCALAR = 1,
87  DTYPE_VECTOR = 3
88  };
89 
91  enum {
92  TYPE_INT8 = 2,
93  TYPE_UINT8 = 3,
94  TYPE_INT16 = 4,
95  TYPE_UINT16 = 5,
96  TYPE_INT32 = 6,
97  TYPE_UINT32 = 7,
98  TYPE_FLOAT32 = 10,
99  TYPE_FLOAT64 = 11
100  };
101 
102 
103 public:
104 
108  void SetDimensions(int s[3]);
109 
113  void SetDimensions(int i, int j, int k);
114 
116  void GetDimensions(int s[3]);
117 
119  void GetDimensions(int &i, int &j, int &k);
120 
125  int SetSubVolume(int dim[3], int off[3]);
126 
132  int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
133 
135  void GetSubVolume(int dim[3], int off[3]);
136 
139  void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
140 
142  void SetSpacing(float s[3]);
143 
145  void SetSpacing(float si, float sj, float sk);
146 
148  void GetSpacing(float s[3]);
149 
151  void GetSpacing(float &si, float &sj, float &sk);
152 
155  void SetOrigin(float p[3]);
156 
159  void SetOrigin(float px, float py, float pz);
160 
163  void GetOrigin(float p[3]);
164 
167  void GetOrigin(float &px, float &py, float &pz);
168 
171  void SetNormals(float o[3][3]);
172 
174  void SetNormals(float t[3], float s[3], float n[3]);
175 
178  void GetNormals(float o[3][3]);
179 
181  void GetNormals(float t[3], float s[3], float n[3]);
182 
184  void SetNumComponents(int num);
185 
187  int GetNumComponents();
188 
190  void SetMatrix(Matrix4x4& mat);
191 
193  void GetMatrix(Matrix4x4& mat);
194 
196  void SetScalarType(int t) { scalarType = t; };
197 
199  void SetScalarTypeToInt8() { scalarType = TYPE_INT8; };
200 
202  void SetScalarTypeToUint8() { scalarType = TYPE_UINT8; };
203 
205  void SetScalarTypeToInt16() { scalarType = TYPE_INT16; };
206 
208  void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
209 
211  void SetScalarTypeToInt32() { scalarType = TYPE_INT32; };
212 
214  void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
215 
217  int GetScalarType() { return scalarType; };
218 
221  int GetScalarSize() { return ScalarSizeTable[scalarType]; };
222 
224  int GetScalarSize(int type) { return ScalarSizeTable[type]; };
225 
227  void SetEndian(int e) { endian = e; };
228 
230  int GetEndian() { return endian; };
231 
236  {
237  return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize()*numComponents;
238  };
239 
241  int GetCoordinateSystem() { return coordinate;};
242 
244  void SetCoordinateSystem(int c) {coordinate = c;};
245 
246 
251  {
252  return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize()*numComponents;
253  };
254 
257  void AllocateScalars();
258 
260  void* GetScalarPointer();
261 
262 protected:
263  ImageMessage();
264  ~ImageMessage();
265 
266 protected:
267 
268  virtual int GetBodyPackSize();
269  virtual int PackBody();
270  virtual int UnpackBody();
271 
273  int dimensions[3];
274 
276  float spacing[3];
277 
279  int subDimensions[3];
280 
283  int subOffset[3];
284 
288 
290  int endian;
291 
294 
297 
300 
302  unsigned char* m_ImageHeader;
303 
305  unsigned char* m_Image;
306 
308  int ScalarSizeTable[12];
309 };
310 
311 
312 } // namespace igtl
313 
314 #endif // _igtlImageMessage_h
315 
316 
A class for header-only message types, which are used for quearying.
void SetCoordinateSystem(int c)
Sets coordinate system (COORDINATE_RAS or COORDINATE_LPS)
void SetScalarType(int t)
Sets the image scalar type.
#define igtlTypeMacro(thisClass, superclass)
Definition: igtlMacro.h:486
void SetScalarTypeToInt16()
Sets the image scalar type to 16-bit integer.
SmartPointer< const Self > ConstPointer
GetImageMessage Self
The "igtl" namespace contains all OpenIGTLink classes. There are several nested namespaces within the...
unsigned char * m_Image
A pointer to the serialized image data.
int GetScalarType()
Gets the image scalar type.
void SetScalarTypeToUint8()
Sets the image scalar type to unsigned 8-bit integer.
int coordinate
A variable for the scalar type of the voxels.
SmartPointer< Self > Pointer
void SetScalarTypeToUint16()
Sets the image scalar type to unsigned 16-bit integer.
HeaderOnlyMessageBase Superclass
void SetScalarTypeToInt8()
Sets the image scalar type to 8-bit integer.
int GetScalarSize(int type)
Gets the size of the specified scalar type. (e.g. 1 byte for 8-bit integer)
void SetScalarTypeToUint32()
Sets the image scalar type to unsigned 32-bit integer.
#define IGTLCommon_EXPORT
SmartPointer< Self > Pointer
int GetCoordinateSystem()
Returns coordinate system (COORDINATE_RAS or COORDINATE_LPS)
MessageBase Superclass
int numComponents
A variable for the number of components.
SmartPointer< const Self > ConstPointer
unsigned char * m_ImageHeader
A pointer to the serialized image header.
int scalarType
A variable for the scalar type of the voxels.
void SetEndian(int e)
Sets the Endianess of the image scalars. (default is ENDIAN_BIG)
int endian
A variable for the Endian of the scalar values in the image.
int GetEndian()
Gets the Endianess of the image scalars.
void SetScalarTypeToInt32()
Sets the image scalar type to 32-bit integer.
#define igtlNewMacro(x)
Definition: igtlMacro.h:431
float Matrix4x4[4][4]
Definition: igtlMath.h:23

Generated at Mon Dec 23 2019 00:49:23 for OpenIGTLink by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2012