igtlImageMessage.h
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 ImageMessage: public MessageBase
00030 {
00031 public:
00032 typedef ImageMessage Self;
00033 typedef MessageBase Superclass;
00034 typedef SmartPointer<Self> Pointer;
00035 typedef SmartPointer<const Self> ConstPointer;
00036
00037 igtlTypeMacro(igtl::ImageMessage, igtl::MessageBase)
00038 igtlNewMacro(igtl::ImageMessage);
00039
00040 public:
00041
00042 enum {
00043 COORDINATE_LPS,
00044 COORDINATE_RAS
00045 };
00046
00047 enum {
00048 ENDIAN_BIG,
00049 ENDIAN_LITTLE
00050 };
00051
00052 enum {
00053 DTYPE_SCALAR = 1,
00054 DTYPE_VECTOR = 2
00055 };
00056
00057 enum {
00058 TYPE_INT8 = 2,
00059 TYPE_UINT8 = 3,
00060 TYPE_INT16 = 4,
00061 TYPE_UINT16 = 5,
00062 TYPE_INT32 = 6,
00063 TYPE_UINT32 = 7,
00064 TYPE_FLOAT32 = 10,
00065 TYPE_FLOAT64 = 11
00066 };
00067
00068
00069 public:
00070
00071
00072 void SetDimensions(int s[3]);
00073 void SetDimensions(int i, int j, int k);
00074 void GetDimensions(int s[3]);
00075 void GetDimensions(int &i, int &j, int &k);
00076
00077
00078 int SetSubVolume(int dim[3], int off[3]);
00079 int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
00080 void GetSubVolume(int dim[3], int off[3]);
00081 void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
00082
00083
00084 void SetSpacing(float s[3]);
00085 void SetSpacing(float si, float sj, float sk);
00086 void GetSpacing(float s[3]);
00087 void GetSpacing(float &si, float &sj, float &sk);
00088
00089
00090 void SetOrigin(float p[3]);
00091 void SetOrigin(float px, float py, float pz);
00092 void GetOrigin(float p[3]);
00093 void GetOrigin(float &px, float &py, float &pz);
00094
00095
00096 void SetNormals(float o[3][3]);
00097 void SetNormals(float t[3], float s[3], float n[3]);
00098 void GetNormals(float o[3][3]);
00099 void GetNormals(float t[3], float s[3], float n[3]);
00100
00101
00102 void SetMatrix(Matrix4x4& mat);
00103 void GetMatrix(Matrix4x4& mat);
00104
00105
00106 void SetScalarType(int t) { scalarType = t; };
00107 void SetScalarTypeToInt8() { scalarType = TYPE_INT8; };
00108 void SetScalarTypeToUint8() { scalarType = TYPE_UINT8; };
00109 void SetScalarTypeToInt16() { scalarType = TYPE_INT16; };
00110 void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
00111 void SetScalarTypeToInt32() { scalarType = TYPE_INT32; };
00112 void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
00113 int GetScalarType() { return scalarType; };
00114 int GetScalarSize() { return ScalarSizeTable[scalarType]; };
00115 int GetScalarSize(int type) { return ScalarSizeTable[type]; };
00116
00117
00118 void SetEndian(int e) { endian = e; };
00119 int GetEndian() { return endian; };
00120
00121
00122 int GetImageSize()
00123 {
00124 return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize();
00125 };
00126
00127 int GetSubVolumeImageSize()
00128 {
00129 return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize();
00130 };
00131
00132 void AllocateScalars();
00133 void* GetScalarPointer();
00134
00135 protected:
00136 ImageMessage();
00137 ~ImageMessage();
00138
00139 protected:
00140
00141 virtual int GetBodyPackSize();
00142 virtual int PackBody();
00143 virtual int UnpackBody();
00144
00145 int dimensions[3];
00146 float spacing[3];
00147 int subDimensions[3];
00148 int subOffset[3];
00149
00150 Matrix4x4 matrix;
00151
00152 int endian;
00153 int dataType;
00154 int scalarType;
00155 int coordinate;
00156
00157 unsigned char* m_ImageHeader;
00158 unsigned char* m_Image;
00159
00160 int ScalarSizeTable[12];
00161 };
00162
00163
00164 }
00165
00166 #endif // _igtlImageMessage_h
00167
00168
00169