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: Open IGT Link Library
4  Module: $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlImageMessage.h $
5  Language: C++
6  Date: $Date: 2011-03-24 00:08:23 -0400 (Thu, 24 Mar 2011) $
7  Version: $Revision: 7354 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notices for more information.
14 
15 =========================================================================*/
16 
17 #ifndef __igtlImageMessage_h
18 #define __igtlImageMessage_h
19 
20 #include "igtlObject.h"
21 //#include "igtlMacros.h"
22 #include "igtlMacro.h"
23 #include "igtlMath.h"
24 #include "igtlMessageBase.h"
25 
26 namespace igtl
27 {
28 
30 {
31 public:
36 
39 
40 protected:
41  GetImageMessage() : MessageBase() { this->m_DefaultBodyType = "GET_IMAGE"; };
43 protected:
44  virtual int GetBodyPackSize() { return 0; };
45  virtual int PackBody() { AllocatePack(); return 1; };
46  virtual int UnpackBody() { return 1; };
47 };
48 
49 
51 {
52 public:
53  typedef ImageMessage Self;
57 
60 
61 public:
62 
63  enum {
65  COORDINATE_RAS
66  };
67 
68  enum {
70  ENDIAN_LITTLE
71  };
72 
73  enum {
74  DTYPE_SCALAR = 1,
75  DTYPE_VECTOR = 3
76  };
77 
78  enum {
79  TYPE_INT8 = 2,
80  TYPE_UINT8 = 3,
81  TYPE_INT16 = 4,
82  TYPE_UINT16 = 5,
83  TYPE_INT32 = 6,
84  TYPE_UINT32 = 7,
85  TYPE_FLOAT32 = 10,
86  TYPE_FLOAT64 = 11
87  };
88 
89 
90 public:
91 
92  // Image dimensions.
93  // SetDimensions() should be called prior to SetSubVolume(), since SetDimensions()
94  // sets subvolume parameters automatically assuming that subvolume = entire volume.
95  void SetDimensions(int s[3]);
96  void SetDimensions(int i, int j, int k);
97  void GetDimensions(int s[3]);
98  void GetDimensions(int &i, int &j, int &k);
99 
100  // Sub-volume dimensions and offset.
101  // SetSubVolume() should be called after calling SetDiemensions(), since SetDimensions()
102  // reset the subvolume parameters automatically.
103  int SetSubVolume(int dim[3], int off[3]);
104  int SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
105  void GetSubVolume(int dim[3], int off[3]);
106  void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
107 
108  // Spacings
109  void SetSpacing(float s[3]);
110  void SetSpacing(float si, float sj, float sk);
111  void GetSpacing(float s[3]);
112  void GetSpacing(float &si, float &sj, float &sk);
113 
114  // Origin coordinate
115  void SetOrigin(float p[3]);
116  void SetOrigin(float px, float py, float pz);
117  void GetOrigin(float p[3]);
118  void GetOrigin(float &px, float &py, float &pz);
119 
120  // Image orientation
121  void SetNormals(float o[3][3]);
122  void SetNormals(float t[3], float s[3], float n[3]);
123  void GetNormals(float o[3][3]);
124  void GetNormals(float t[3], float s[3], float n[3]);
125 
126  // Number of components
127  void SetNumComponents(int num);
128  int GetNumComponents();
129 
130  // Origin/orientation matrix
131  void SetMatrix(Matrix4x4& mat);
132  void GetMatrix(Matrix4x4& mat);
133 
134  // Image scalar type
135  void SetScalarType(int t) { scalarType = t; };
136  void SetScalarTypeToInt8() { scalarType = TYPE_INT8; };
137  void SetScalarTypeToUint8() { scalarType = TYPE_UINT8; };
138  void SetScalarTypeToInt16() { scalarType = TYPE_INT16; };
139  void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
140  void SetScalarTypeToInt32() { scalarType = TYPE_INT32; };
141  void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
142  int GetScalarType() { return scalarType; };
143  int GetScalarSize() { return ScalarSizeTable[scalarType]; };
144  int GetScalarSize(int type) { return ScalarSizeTable[type]; };
145 
146  // Endian of image scalar (default is ENDIAN_BIG)
147  void SetEndian(int e) { endian = e; };
148  int GetEndian() { return endian; };
149 
150  // TBD: Should returned value be 64-bit integer?
151  int GetImageSize()
152  {
153  return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize()*numComponents;
154  };
155 
156  int GetSubVolumeImageSize()
157  {
158  return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize()*numComponents;
159  };
160 
161  void AllocateScalars();
162  void* GetScalarPointer();
163 
164 protected:
165  ImageMessage();
166  ~ImageMessage();
167 
168 protected:
169 
170  virtual int GetBodyPackSize();
171  virtual int PackBody();
172  virtual int UnpackBody();
173 
174  int dimensions[3];
175  float spacing[3];
176  int subDimensions[3];
177  int subOffset[3];
178 
180 
181  int endian;
182  int dataType;
186 
187  unsigned char* m_ImageHeader;
188  unsigned char* m_Image;
189 
190  int ScalarSizeTable[12];
191 };
192 
193 
194 } // namespace igtl
195 
196 #endif // _igtlImageMessage_h
197 
198 
199 

Generated at Thu Mar 20 2014 16:32:06 for OpenIGTLink by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2000