Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __igtlImageMessage_h
00018 #define __igtlImageMessage_h
00019
00020 #include "igtlObject.h"
00021
00022 #include "igtlMacro.h"
00023 #include "igtlMath.h"
00024 #include "igtlMessageBase.h"
00025
00026 namespace igtl
00027 {
00028
00029 class IGTLCommon_EXPORT GetImageMessage: public MessageBase
00030 {
00031 public:
00032 typedef GetImageMessage Self;
00033 typedef MessageBase Superclass;
00034 typedef SmartPointer<Self> Pointer;
00035 typedef SmartPointer<const Self> ConstPointer;
00036
00037 igtlTypeMacro(igtl::GetImageMessage, igtl::MessageBase);
00038 igtlNewMacro(igtl::GetImageMessage);
00039
00040 protected:
00041 GetImageMessage() : MessageBase() { this->m_DefaultBodyType = "GET_IMAGE"; };
00042 ~GetImageMessage() {};
00043 protected:
00044 virtual int GetBodyPackSize() { return 0; };
00045 virtual int PackBody() { AllocatePack(); return 1; };
00046 virtual int UnpackBody() { return 1; };
00047 };
00048
00049
00050 class IGTLCommon_EXPORT ImageMessage: public MessageBase
00051 {
00052 public:
00053 typedef ImageMessage Self;
00054 typedef MessageBase Superclass;
00055 typedef SmartPointer<Self> Pointer;
00056 typedef SmartPointer<const Self> ConstPointer;
00057
00058 igtlTypeMacro(igtl::ImageMessage, igtl::MessageBase)
00059 igtlNewMacro(igtl::ImageMessage);
00060
00061 public:
00062
00063 enum {
00064 COORDINATE_LPS,
00065 COORDINATE_RAS
00066 };
00067
00068 enum {
00069 ENDIAN_BIG,
00070 ENDIAN_LITTLE
00071 };
00072
00073 enum {
00074 DTYPE_SCALAR = 1,
00075 DTYPE_VECTOR = 3
00076 };
00077
00078 enum {
00079 TYPE_INT8 = 2,
00080 TYPE_UINT8 = 3,
00081 TYPE_INT16 = 4,
00082 TYPE_UINT16 = 5,
00083 TYPE_INT32 = 6,
00084 TYPE_UINT32 = 7,
00085 TYPE_FLOAT32 = 10,
00086 TYPE_FLOAT64 = 11
00087 };
00088
00089
00090 public:
00091
00092
00093
00094
00095 void SetDimensions(int s[3]);
00096 void SetDimensions(int i, int j, int k);
00097 void GetDimensions(int s[3]);
00098 void GetDimensions(int &i, int &j, int &k);
00099
00100
00101
00102
00103 int SetSubVolume(int dim[3], int off[3]);
00104 int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
00105 void GetSubVolume(int dim[3], int off[3]);
00106 void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
00107
00108
00109 void SetSpacing(float s[3]);
00110 void SetSpacing(float si, float sj, float sk);
00111 void GetSpacing(float s[3]);
00112 void GetSpacing(float &si, float &sj, float &sk);
00113
00114
00115 void SetOrigin(float p[3]);
00116 void SetOrigin(float px, float py, float pz);
00117 void GetOrigin(float p[3]);
00118 void GetOrigin(float &px, float &py, float &pz);
00119
00120
00121 void SetNormals(float o[3][3]);
00122 void SetNormals(float t[3], float s[3], float n[3]);
00123 void GetNormals(float o[3][3]);
00124 void GetNormals(float t[3], float s[3], float n[3]);
00125
00126
00127 void SetNumComponents(int num);
00128 int GetNumComponents();
00129
00130
00131 void SetMatrix(Matrix4x4& mat);
00132 void GetMatrix(Matrix4x4& mat);
00133
00134
00135 void SetScalarType(int t) { scalarType = t; };
00136 void SetScalarTypeToInt8() { scalarType = TYPE_INT8; };
00137 void SetScalarTypeToUint8() { scalarType = TYPE_UINT8; };
00138 void SetScalarTypeToInt16() { scalarType = TYPE_INT16; };
00139 void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
00140 void SetScalarTypeToInt32() { scalarType = TYPE_INT32; };
00141 void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
00142 int GetScalarType() { return scalarType; };
00143 int GetScalarSize() { return ScalarSizeTable[scalarType]; };
00144 int GetScalarSize(int type) { return ScalarSizeTable[type]; };
00145
00146
00147 void SetEndian(int e) { endian = e; };
00148 int GetEndian() { return endian; };
00149
00150
00151 int GetImageSize()
00152 {
00153 return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize()*numComponents;
00154 };
00155
00156 int GetSubVolumeImageSize()
00157 {
00158 return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize()*numComponents;
00159 };
00160
00161 void AllocateScalars();
00162 void* GetScalarPointer();
00163
00164 protected:
00165 ImageMessage();
00166 ~ImageMessage();
00167
00168 protected:
00169
00170 virtual int GetBodyPackSize();
00171 virtual int PackBody();
00172 virtual int UnpackBody();
00173
00174 int dimensions[3];
00175 float spacing[3];
00176 int subDimensions[3];
00177 int subOffset[3];
00178
00179 Matrix4x4 matrix;
00180
00181 int endian;
00182 int dataType;
00183 int numComponents;
00184 int scalarType;
00185 int coordinate;
00186
00187 unsigned char* m_ImageHeader;
00188 unsigned char* m_Image;
00189
00190 int ScalarSizeTable[12];
00191 };
00192
00193
00194 }
00195
00196 #endif // _igtlImageMessage_h
00197
00198
00199