Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtlImageMessage2.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 __igtlImageMessage2_h
16 #define __igtlImageMessage2_h
17 
18 #include "igtlObject.h"
19 //#include "igtlMacros.h"
20 #include "igtlMacro.h"
21 #include "igtlMath.h"
22 #include "igtlMessageBase.h"
23 
24 
25 #define FRAGMENTED_PACK
26 
27 
28 namespace igtl
29 {
30 
31 
39 {
40 public:
45 
48 
49 
50 protected:
51  GetImageMessage2() : MessageBase() { this->m_DefaultBodyType = "GET_IMAGE"; };
53 protected:
54  virtual int GetBodyPackSize() { return 0; };
55  virtual int PackBody() { AllocatePack(); return 1; };
56  virtual int UnpackBody() { return 1; };
57 };
58 
59 
81 {
82 public:
87 
90 
91 public:
92 
94  enum {
95  COORDINATE_RAS=1,
96  COORDINATE_LPS=2
97  };
98 
100  enum {
101  ENDIAN_BIG=1,
102  ENDIAN_LITTLE=2
103  };
104 
106  enum {
107  DTYPE_SCALAR = 1,
108  DTYPE_VECTOR = 3
109  };
110 
112  enum {
113  TYPE_INT8 = 2,
114  TYPE_UINT8 = 3,
115  TYPE_INT16 = 4,
116  TYPE_UINT16 = 5,
117  TYPE_INT32 = 6,
118  TYPE_UINT32 = 7,
119  TYPE_FLOAT32 = 10,
120  TYPE_FLOAT64 = 11
121  };
122 
123 
124 public:
125 
129  void SetDimensions(int s[3]);
130 
134  void SetDimensions(int i, int j, int k);
135 
137  void GetDimensions(int s[3]);
138 
140  void GetDimensions(int &i, int &j, int &k);
141 
146  int SetSubVolume(int dim[3], int off[3]);
147 
153  int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
154 
156  void GetSubVolume(int dim[3], int off[3]);
157 
160  void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
161 
163  void SetSpacing(float s[3]);
164 
166  void SetSpacing(float si, float sj, float sk);
167 
169  void GetSpacing(float s[3]);
170 
172  void GetSpacing(float &si, float &sj, float &sk);
173 
176  void SetOrigin(float p[3]);
177 
180  void SetOrigin(float px, float py, float pz);
181 
184  void GetOrigin(float p[3]);
185 
188  void GetOrigin(float &px, float &py, float &pz);
189 
192  void SetNormals(float o[3][3]);
193 
195  void SetNormals(float t[3], float s[3], float n[3]);
196 
199  void GetNormals(float o[3][3]);
200 
202  void GetNormals(float t[3], float s[3], float n[3]);
203 
205  void SetNumComponents(int num);
206 
208  int GetNumComponents();
209 
211  void SetMatrix(Matrix4x4& mat);
212 
214  void GetMatrix(Matrix4x4& mat);
215 
217  void SetScalarType(int t) { scalarType = t; };
218 
220  void SetScalarTypeToInt8() { scalarType = TYPE_INT8; };
221 
223  void SetScalarTypeToUint8() { scalarType = TYPE_UINT8; };
224 
226  void SetScalarTypeToInt16() { scalarType = TYPE_INT16; };
227 
229  void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
230 
232  void SetScalarTypeToInt32() { scalarType = TYPE_INT32; };
233 
235  void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
236 
238  int GetScalarType() { return scalarType; };
239 
242  int GetScalarSize() { return ScalarSizeTable[scalarType]; };
243 
245  int GetScalarSize(int type) { return ScalarSizeTable[type]; };
246 
248  void SetEndian(int e) { endian = e; };
249 
251  int GetEndian() { return endian; };
252 
255  // TODO: Should returned value be 64-bit integer?
257  {
258  return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize()*numComponents;
259  };
260 
262  int GetCoordinateSystem() { return coordinate;};
263 
265  void SetCoordinateSystem(int c) {coordinate = c;};
266 
271  {
272  return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize()*numComponents;
273  };
274 
275 
280  virtual void AllocateScalars();
281 
283  virtual void* GetScalarPointer();
284 
285 #ifdef FRAGMENTED_PACK
286  virtual void SetScalarPointer(void * p);
288 
290  void* GetPackPointer();
291 
294  int GetNumberOfPackFragments() { return 3; /* header, image header and image body */ }
295 
297  void* GetPackFragmentPointer(int id);
298 
300  int GetPackFragmentSize(int id);
301 #endif // FRAGMENTED_PACK
302 
303 
304 protected:
305  ImageMessage2();
306  ~ImageMessage2();
307 
308 protected:
309 
310  virtual int GetBodyPackSize();
311 
312 #ifdef FRAGMENTED_PACK
313 public:
316  virtual int Pack();
317 public:
318 #endif //FRAGMENTED_PACK
319 
320  virtual int PackBody();
321  virtual int UnpackBody();
322 
323 #ifdef FRAGMENTED_PACK
324  virtual void AllocatePack(int bodySize);
327 #endif //FRAGMENTED_PACK
328 
330  int dimensions[3];
331 
333  float spacing[3];
334 
336  int subDimensions[3];
337 
340  int subOffset[3];
341 
345 
347  int endian;
348 
351 
354 
357 
359  unsigned char* m_ImageHeader;
360 
362  unsigned char* m_Image;
363 
364 #ifdef FRAGMENTED_PACK
365  unsigned char* m_SinglePack;
367 
374 
377 
380 
381 #endif
382 
384  int ScalarSizeTable[12];
385 };
386 
387 
388 } // namespace igtl
389 
390 #endif // _igtlImageMessage2_h
391 
392 
igtl::ImageMessage2::Pointer
SmartPointer< Self > Pointer
Definition: igtlImageMessage2.h:85
igtlMessageBase.h
igtl::ImageMessage2::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: igtlImageMessage2.h:86
igtl::ImageMessage2::GetImageSize
int GetImageSize()
Definition: igtlImageMessage2.h:256
igtl::GetImageMessage2::PackBody
virtual int PackBody()
Packs (serialize) the body. Must be implemented in a child class.
Definition: igtlImageMessage2.h:55
igtl::ImageMessage2::SetScalarTypeToUint32
void SetScalarTypeToUint32()
Sets the image scalar type to unsigned 32-bit integer.
Definition: igtlImageMessage2.h:235
igtl::GetImageMessage2::UnpackBody
virtual int UnpackBody()
Unpacks (deserialize) the body. Must be implemented in a child class.
Definition: igtlImageMessage2.h:56
igtl::ImageMessage2::SetScalarType
void SetScalarType(int t)
Sets the image scalar type.
Definition: igtlImageMessage2.h:217
igtl::ImageMessage2::SetScalarTypeToInt16
void SetScalarTypeToInt16()
Sets the image scalar type to 16-bit integer.
Definition: igtlImageMessage2.h:226
igtl::ImageMessage2::matrix
Matrix4x4 matrix
Definition: igtlImageMessage2.h:344
igtl::ImageMessage2::GetScalarSize
int GetScalarSize()
Definition: igtlImageMessage2.h:242
igtlMacro.h
igtlNewMacro
#define igtlNewMacro(x)
Definition: igtlMacro.h:431
igtl::GetImageMessage2::Pointer
SmartPointer< Self > Pointer
Definition: igtlImageMessage2.h:43
igtl::GetImageMessage2::~GetImageMessage2
~GetImageMessage2()
Definition: igtlImageMessage2.h:52
igtl::ImageMessage2::SetCoordinateSystem
void SetCoordinateSystem(int c)
Sets coordinate system (COORDINATE_RAS or COORDINATE_LPS)
Definition: igtlImageMessage2.h:265
igtlMath.h
igtl::ImageMessage2::numComponents
int numComponents
A variable for the number of components.
Definition: igtlImageMessage2.h:350
igtl::GetImageMessage2::Superclass
MessageBase Superclass
Definition: igtlImageMessage2.h:42
igtl::MessageBase
Definition: igtlMessageBase.h:55
igtl::ImageMessage2::m_SinglePackSize
int m_SinglePackSize
Definition: igtlImageMessage2.h:370
igtl::ImageMessage2::GetSubVolumeImageSize
int GetSubVolumeImageSize()
Definition: igtlImageMessage2.h:270
igtl::ImageMessage2::SetScalarTypeToInt8
void SetScalarTypeToInt8()
Sets the image scalar type to 8-bit integer.
Definition: igtlImageMessage2.h:220
igtl::GetImageMessage2::GetBodyPackSize
virtual int GetBodyPackSize()
Gets the size of the serialized body.
Definition: igtlImageMessage2.h:54
igtl::ImageMessage2::m_ImageHeader
unsigned char * m_ImageHeader
A pointer to the serialized image header.
Definition: igtlImageMessage2.h:359
igtl::ImageMessage2::SetScalarTypeToInt32
void SetScalarTypeToInt32()
Sets the image scalar type to 32-bit integer.
Definition: igtlImageMessage2.h:232
igtl::ImageMessage2::SetScalarTypeToUint16
void SetScalarTypeToUint16()
Sets the image scalar type to unsigned 16-bit integer.
Definition: igtlImageMessage2.h:229
igtl
The "igtl" namespace contains all OpenIGTLink classes. There are several nested namespaces within the...
Definition: igtlBindMessage.h:25
IGTLCommon_EXPORT
#define IGTLCommon_EXPORT
Definition: igtlWin32Header.h:151
igtl::GetImageMessage2::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: igtlImageMessage2.h:44
igtl::ImageMessage2::m_Image
unsigned char * m_Image
A pointer to the serialized image data.
Definition: igtlImageMessage2.h:362
igtl::ImageMessage2::GetScalarSize
int GetScalarSize(int type)
Gets the size of the specified scalar type. (e.g. 1 byte for 8-bit integer)
Definition: igtlImageMessage2.h:245
igtl::Matrix4x4
float Matrix4x4[4][4]
Definition: igtlMath.h:23
igtl::GetImageMessage2
Definition: igtlImageMessage2.h:38
igtl::ImageMessage2::Superclass
MessageBase Superclass
Definition: igtlImageMessage2.h:84
igtl::ImageMessage2::SetScalarTypeToUint8
void SetScalarTypeToUint8()
Sets the image scalar type to unsigned 8-bit integer.
Definition: igtlImageMessage2.h:223
igtl::ImageMessage2::Self
ImageMessage2 Self
Definition: igtlImageMessage2.h:83
igtl::ImageMessage2::endian
int endian
A variable for the Endian of the scalar values in the image.
Definition: igtlImageMessage2.h:347
igtl::GetImageMessage2::Self
GetImageMessage2 Self
Definition: igtlImageMessage2.h:41
igtl::ImageMessage2::GetScalarType
int GetScalarType()
Gets the image scalar type.
Definition: igtlImageMessage2.h:238
igtl::ImageMessage2::m_ImageSize
int m_ImageSize
Definition: igtlImageMessage2.h:373
igtl::GetImageMessage2::GetImageMessage2
GetImageMessage2()
Definition: igtlImageMessage2.h:51
igtl::ImageMessage2::GetCoordinateSystem
int GetCoordinateSystem()
Returns coordinate system (COORDINATE_RAS or COORDINATE_LPS)
Definition: igtlImageMessage2.h:262
igtl::ImageMessage2::GetNumberOfPackFragments
int GetNumberOfPackFragments()
Definition: igtlImageMessage2.h:294
igtl::ImageMessage2::SetEndian
void SetEndian(int e)
Sets the Endianess of the image scalars. (default is ENDIAN_BIG)
Definition: igtlImageMessage2.h:248
igtl::ImageMessage2::GetEndian
int GetEndian()
Gets the Endianess of the image scalars.
Definition: igtlImageMessage2.h:251
igtl::SmartPointer< Self >
igtlTypeMacro
#define igtlTypeMacro(thisClass, superclass)
Definition: igtlMacro.h:486
igtl::ImageMessage2::scalarType
int scalarType
A variable for the scalar type of the voxels.
Definition: igtlImageMessage2.h:353
igtlObject.h
igtl::ImageMessage2::coordinate
int coordinate
A variable for the scalar type of the voxels.
Definition: igtlImageMessage2.h:356
igtl::ImageMessage2
Definition: igtlImageMessage2.h:80
igtl::ImageMessage2::m_SelfAllocatedImageHeader
int m_SelfAllocatedImageHeader
A flag for the fragmented image pack (allocated by this class).
Definition: igtlImageMessage2.h:379
igtl::ImageMessage2::m_SelfAllocatedImage
int m_SelfAllocatedImage
A flag for the fragmented image pack (allocated by this class).
Definition: igtlImageMessage2.h:376

Generated for OpenIGTLink by Doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2012