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
28namespace igtl
29{
30
31
39{
40public:
45
48
49protected:
50 GetImageMessage2() : MessageBase() { this->m_SendMessageType = "GET_IMAGE"; };
52protected:
53 virtual int CalculateContentBufferSize() { return 0; };
54 virtual int PackContent() { AllocateBuffer(); return 1; };
55 virtual int UnpackContent() { return 1; };
56};
57
58
80{
81public:
86
89
90public:
91
93 enum {
94 COORDINATE_RAS=1,
95 COORDINATE_LPS=2
96 };
97
99 enum {
100 ENDIAN_BIG=1,
101 ENDIAN_LITTLE=2
102 };
103
105 enum {
106 DTYPE_SCALAR = 1,
107 DTYPE_VECTOR = 3
108 };
109
111 enum {
112 TYPE_INT8 = 2,
113 TYPE_UINT8 = 3,
114 TYPE_INT16 = 4,
115 TYPE_UINT16 = 5,
116 TYPE_INT32 = 6,
117 TYPE_UINT32 = 7,
118 TYPE_FLOAT32 = 10,
119 TYPE_FLOAT64 = 11
120 };
121
122
123public:
124
128 void SetDimensions(int s[3]);
129
133 void SetDimensions(int i, int j, int k);
134
136 void GetDimensions(int s[3]);
137
139 void GetDimensions(int &i, int &j, int &k);
140
145 int SetSubVolume(int dim[3], int off[3]);
146
152 int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
153
155 void GetSubVolume(int dim[3], int off[3]);
156
159 void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
160
162 void SetSpacing(float s[3]);
163
165 void SetSpacing(float si, float sj, float sk);
166
168 void GetSpacing(float s[3]);
169
171 void GetSpacing(float &si, float &sj, float &sk);
172
175 void SetOrigin(float p[3]);
176
179 void SetOrigin(float px, float py, float pz);
180
183 void GetOrigin(float p[3]);
184
187 void GetOrigin(float &px, float &py, float &pz);
188
191 void SetNormals(float o[3][3]);
192
194 void SetNormals(float t[3], float s[3], float n[3]);
195
198 void GetNormals(float o[3][3]);
199
201 void GetNormals(float t[3], float s[3], float n[3]);
202
204 void SetNumComponents(int num);
205
208
210 void SetMatrix(Matrix4x4& mat);
211
213 void GetMatrix(Matrix4x4& mat);
214
216 void SetScalarType(int t) { scalarType = t; };
217
219 void SetScalarTypeToInt8() { scalarType = TYPE_INT8; };
220
222 void SetScalarTypeToUint8() { scalarType = TYPE_UINT8; };
223
225 void SetScalarTypeToInt16() { scalarType = TYPE_INT16; };
226
228 void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
229
231 void SetScalarTypeToInt32() { scalarType = TYPE_INT32; };
232
234 void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
235
237 int GetScalarType() { return scalarType; };
238
241 int GetScalarSize() { return ScalarSizeTable[scalarType]; };
242
244 int GetScalarSize(int type) { return ScalarSizeTable[type]; };
245
247 void SetEndian(int e) { endian = e; };
248
250 int GetEndian() { return endian; };
251
254 // TODO: Should returned value be 64-bit integer?
256 {
257 return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize()*numComponents;
258 };
259
261 int GetCoordinateSystem() { return coordinate;};
262
264 void SetCoordinateSystem(int c) {coordinate = c;};
265
270 {
271 return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize()*numComponents;
272 };
273
274
279 virtual void AllocateScalars();
280
282 virtual void* GetScalarPointer();
283
284#ifdef FRAGMENTED_PACK
286 virtual void SetScalarPointer(void * p);
287
290
293 int GetNumberOfPackFragments() { return 3; /* header, image header and image body */ }
294
297
300#endif // FRAGMENTED_PACK
301
302
303protected:
306
307protected:
308
310
311#ifdef FRAGMENTED_PACK
312public:
315 virtual int Pack();
316public:
317#endif //FRAGMENTED_PACK
318
319 virtual int PackContent();
320 virtual int UnpackContent();
321
322#ifdef FRAGMENTED_PACK
325 virtual void AllocateBuffer(int contentSize);
326#endif //FRAGMENTED_PACK
327
329 int dimensions[3];
330
332 float spacing[3];
333
335 int subDimensions[3];
336
339 int subOffset[3];
340
344
347
350
353
356
358 unsigned char* m_ImageHeader;
359
361 unsigned char* m_Image;
362
363#ifdef FRAGMENTED_PACK
365 unsigned char* m_SinglePack;
366
373
376
379
380#endif
381
383 int ScalarSizeTable[12];
384};
385
386
387} // namespace igtl
388
389#endif // _igtlImageMessage2_h
igtlNewMacro(igtl::GetImageMessage2)
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
virtual int CalculateContentBufferSize()
Gets the size of the serialized content.
virtual int UnpackContent()
Unpacks (deserialize) the content. Must be implemented in all child classes.
virtual int PackContent()
Packs (serialize) the content. Must be implemented in all child classes.
igtlTypeMacro(igtl::GetImageMessage2, igtl::MessageBase)
unsigned char * m_SinglePack
A pointer to the serialized data (for backward compatibility with the conventional packing)
int m_SelfAllocatedImageHeader
A flag for the fragmented image pack (allocated by this class).
void SetScalarTypeToInt16()
Sets the image scalar type to 16-bit integer.
virtual int UnpackContent()
Unpacks (deserialize) the content. Must be implemented in all child classes.
void SetScalarTypeToInt32()
Sets the image scalar type to 32-bit integer.
void GetSubVolume(int dim[3], int off[3])
Gets sub-volume dimensions and offset using arrays of the dimensions and the offset.
void SetEndian(int e)
Sets the Endianess of the image scalars. (default is ENDIAN_BIG)
int scalarType
A variable for the scalar type of the voxels.
int GetCoordinateSystem()
Returns coordinate system (COORDINATE_RAS or COORDINATE_LPS)
void SetNormals(float t[3], float s[3], float n[3])
Sets the orientation of the image by the normal vectors for the i, j and k indeces.
int m_SelfAllocatedImage
A flag for the fragmented image pack (allocated by this class).
virtual void AllocateBuffer(int contentSize)
int GetNumComponents()
Gets the number of components for each voxel.
int GetEndian()
Gets the Endianess of the image scalars.
void GetMatrix(Matrix4x4 &mat)
Gets the origin/orientation matrix.
virtual int Pack()
void SetScalarTypeToUint32()
Sets the image scalar type to unsigned 32-bit integer.
virtual void * GetScalarPointer()
Gets a pointer to the scalar data.
void GetNormals(float o[3][3])
void GetNormals(float t[3], float s[3], float n[3])
Gets the orientation of the image using the normal vectors for the i, j and k indeces.
void SetScalarTypeToInt8()
Sets the image scalar type to 8-bit integer.
void SetNumComponents(int num)
Sets the number of components for each voxel.
void SetSpacing(float s[3])
Sets spacings by an array of spacing values in i, j and k directions.
virtual void AllocateScalars()
void SetScalarTypeToUint16()
Sets the image scalar type to unsigned 16-bit integer.
void GetSpacing(float s[3])
Gets spacings using an array of spacing values in i, j and k directions.
unsigned char * m_Image
A pointer to the serialized image data.
void SetSpacing(float si, float sj, float sk)
Sets spacings by spacing values in i, j and k directions.
SmartPointer< const Self > ConstPointer
int GetPackFragmentSize(int id)
Gets the size of the specified fragment. (for fragmented pack support)
void GetOrigin(float &px, float &py, float &pz)
SmartPointer< Self > Pointer
virtual void SetScalarPointer(void *p)
Sets the pointer to the scalar data (for fragmented pack support).
void SetOrigin(float p[3])
void SetScalarType(int t)
Sets the image scalar type.
unsigned char * m_ImageHeader
A pointer to the serialized image header.
void * GetBufferPointer()
Gets a pointer to the scalar data (for fragmented pack support).
void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk)
int SetSubVolume(int dim[3], int off[3])
void SetScalarTypeToUint8()
Sets the image scalar type to unsigned 8-bit integer.
int GetScalarSize(int type)
Gets the size of the specified scalar type. (e.g. 1 byte for 8-bit integer)
int coordinate
A variable for the scalar type of the voxels.
int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk)
void GetDimensions(int &i, int &j, int &k)
Gets image dimensions as the numbers of pixels in i, j and k directions.
void SetNormals(float o[3][3])
virtual int PackContent()
Packs (serialize) the content. Must be implemented in all child classes.
void SetMatrix(Matrix4x4 &mat)
Sets the origin/orientation matrix.
void * GetPackFragmentPointer(int id)
Gets a pointer to the specified fragment of the packed data. (for fragmented pack support)
int numComponents
A variable for the number of components.
void GetDimensions(int s[3])
Gets image dimensions as an array of the numbers of pixels in i, j and k directions.
int GetScalarType()
Gets the image scalar type.
void GetSpacing(float &si, float &sj, float &sk)
Gets spacings using spacing values in i, j and k directions.
int endian
A variable for the Endian of the scalar values in the image.
virtual int CalculateContentBufferSize()
Gets the size of the serialized content.
void SetDimensions(int s[3])
void GetOrigin(float p[3])
void SetOrigin(float px, float py, float pz)
void SetCoordinateSystem(int c)
Sets coordinate system (COORDINATE_RAS or COORDINATE_LPS)
void SetDimensions(int i, int j, int k)
Implements transparent reference counting.
#define igtlTypeMacro(thisClass, superclass)
Definition igtlMacro.h:484
#define igtlNewMacro(x)
Definition igtlMacro.h:431
#define IGTLCommon_EXPORT
The "igtl" namespace contains all OpenIGTLink classes. There are several nested namespaces within the...
float Matrix4x4[4][4]
Definition igtlMath.h:23

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