forked from openigtlink/OpenIGTLink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathigtlVideoMetaMessage.h
233 lines (163 loc) · 7.58 KB
/
igtlVideoMetaMessage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*=========================================================================
Program: The OpenIGTLink Library
Language: C++
Web page: http://openigtlink.org/
Copyright (c) Insight Software Consortium. All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __igtlVideoMetaMessage_h
#define __igtlVideoMetaMessage_h
#include <vector>
#include <string>
#include "igtlObject.h"
#include "igtlMath.h"
#include "igtlMessageBase.h"
#include "igtlTypes.h"
#include "igtlVideoMessage.h"
namespace igtl
{
/// A class to manage meta data of images.
class IGTLCommon_EXPORT VideoMetaElement: public Object
{
public:
typedef VideoMetaElement Self;
typedef Object Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
igtlTypeMacro(igtl::VideoMetaElement, igtl::Object);
igtlNewMacro(igtl::VideoMetaElement);
public:
/// Sets the image name/description. The string 'name' must not exceed 64 characters.
int SetName(const char* name);
/// Gets the image name/description.
const char* GetName() { return this->m_Name.c_str(); };
/// Sets the device name (message name). The string 'devname' must not exceed 20
/// characters.
int SetDeviceName(const char* devname);
/// Gets the device name (message name).
const char* GetDeviceName() { return this->m_DeviceName.c_str(); };
/// Sets the zoom level of the camera (e.g. +4, -4).
void SetZoomLevel(igtlInt16 level) {this->m_ZoomLevel = level;};
/// Gets the zoom level of the camera (e.g. +4, -4).
igtlInt16 GetZoomLevel() { return this->m_ZoomLevel; };
/// Sets the focal length of the camera (e.g. +50.0mm, +200.0mm).
void SetFocalLength(igtlFloat64 length) {this->m_FocalLength = length;};
/// Gets the focal length of the camera (e.g.+50.0mm, +200.0mm).
igtlFloat64 GetFocalLength() { return this->m_FocalLength; };
/// Sets the patient name. The string 'patname' must not exceed 64 characters.
int SetPatientName(const char* patname);
/// Gets the patient name.
const char* GetPatientName() { return this->m_PatientName.c_str(); };
/// Sets the patient ID. The string 'patid' must not exceed 64 characters.
int SetPatientID(const char* patid);
/// Gets the patient ID.
const char* GetPatientID() { return this->m_PatientID.c_str(); }
/// Sets the size of the image by the numbers of voxels in i, j, and k directions.
void SetSize(igtlUint16 si, igtlUint16 sj, igtlUint16 sk);
/// Gets the size of the image by the numbers of voxels in i, j, and k directions.
void GetSize(igtlUint16& si, igtlUint16& sj, igtlUint16& sk);
/// Sets the origin/orientation matrix.
void SetMatrix(Matrix4x4& mat);
/// Gets the origin/orientation matrix.
void GetMatrix(Matrix4x4& mat);
/// Sets spacings by spacing values in i, j and k directions.
void SetSpacing(float si, float sj, float sk);
/// Gets spacings using spacing values in i, j and k directions.
void GetSpacing(float &si, float &sj, float &sk);
/// Sets the coordinates of the origin by positions along the first (R or L), second (A or P)
/// and the third (S) axes.
void SetOrigin(float px, float py, float pz);
/// Gets the coordinates of the origin by positions along the first (R or L), second (A or P)
/// and the third (S) axes.
void GetOrigin(float &px, float &py, float &pz);
/// Sets the orientation of the image by the normal vectors for the i, j and k indeces.
void SetNormals(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 GetNormals(float t[3], float s[3], float n[3]);
/// Sets the scalar type of the image
void SetScalarType(igtlUint8 type);
/// Gets the scalar type of the image.
igtlUint8 GetScalarType();
protected:
VideoMetaElement();
~VideoMetaElement();
protected:
/// name / description (<= 64 bytes)
std::string m_Name;
/// device name to query the IMAGE and COLORT
std::string m_DeviceName;
/// patient name (<= 64 bytes)
std::string m_PatientName;
/// patient ID (MRN etc.) (<= 64 bytes)
std::string m_PatientID;
/// Zoom level of the camera
igtlInt16 m_ZoomLevel;
/// Focal length of the camera
igtlFloat64 m_FocalLength;
/// A vector containing the spacings of the voxels in i, j and k directions.
float spacing[3];
/// A matrix representing the origin and the orientation of the image,
/// if the camera is attached with tracking device.
/// The matrix is set to identity by default
Matrix4x4 matrix;
/// entire image volume size, if the video is from ultrasound
igtlUint16 m_Size[3];
/// scalar type. see scalar_type in Video message
igtlUint8 m_ScalarType;
};
/// A class for the GET_IMGMETA message type.
class IGTLCommon_EXPORT GetVideoMetaMessage: public MessageBase
{
public:
typedef GetVideoMetaMessage Self;
typedef MessageBase Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
igtlTypeMacro(igtl::GetVideoMetaMessage, igtl::MessageBase);
igtlNewMacro(igtl::GetVideoMetaMessage);
protected:
GetVideoMetaMessage() : MessageBase() { this->m_SendMessageType = "GET_VMETA"; };
~GetVideoMetaMessage() {};
protected:
virtual int CalculateContentBufferSize() { return 0; };
virtual int PackContent() { AllocateBuffer(); return 1; };
virtual int UnpackContent() { return 1; };
};
/// The IMGMETA message is used to transfer image meta information which are not
/// available in the IMAGE message type, such as patient name, medical record number,
/// modality etc. An IMGMETA message can contain meta data for multiple images.
/// This message type may be used to obtain a list of images available in
/// the remote system, such as image database or commercial image-guided surgery (IGS) system.
class IGTLCommon_EXPORT VideoMetaMessage: public MessageBase
{
public:
typedef VideoMetaMessage Self;
typedef MessageBase Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
igtlTypeMacro(igtl::VideoMetaMessage, igtl::MessageBase);
igtlNewMacro(igtl::VideoMetaMessage);
public:
/// Adds an video meta element to the list. Returns the number of elements after
/// adding the image meta element.
int AddVideoMetaElement(VideoMetaElement::Pointer& elem);
/// Clears the all image meta elements in the list.
void ClearVideoMetaElement();
/// Gets the number of the image meta elements in the list.
int GetNumberOfVideoMetaElement();
/// Gets the image meta data specified by the index.
void GetVideoMetaElement(int index, VideoMetaElement::Pointer& elem);
protected:
VideoMetaMessage();
~VideoMetaMessage();
protected:
virtual int CalculateContentBufferSize();
virtual int PackContent();
virtual int UnpackContent();
/// A list of pointers to image meta data.
std::vector<VideoMetaElement::Pointer> m_VideoMetaList;
};
} // namespace igtl
#endif // _igtlVideoMetaMessage_h