Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtlPolyDataMessage.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 __igtlPolyDataMessage_h
16#define __igtlPolyDataMessage_h
17
18#include <string>
19
20#include "igtlObject.h"
21#include "igtlMacro.h"
22#include "igtlMath.h"
23#include "igtlMessageBase.h"
24#include "igtlTypes.h"
25
26namespace igtl
27{
28
49
52{
53public:
58
61
62 bool GetStatus() const;
63 void SetStatus(bool status);
64
65protected:
66 RTSPolyDataMessage() : MessageBase() { this->m_SendMessageType = "RTS_POLYDATA"; };
68
69protected:
71 virtual int PackContent();
72 virtual int UnpackContent();
73
74protected:
76 igtl_uint8 m_Status;
77};
78
81{
82public:
87
90
91protected:
92 StopPolyDataMessage() : MessageBase() { this->m_SendMessageType = "STP_POLYDATA"; };
94protected:
95 virtual int GetBodyPackSize() { return 0; };
96 virtual int PackBody() { AllocatePack(); return 1; };
97 virtual int UnpackBody() { return 1; };
98};
99
102{
103public:
108
111
112protected:
113 StartPolyDataMessage() : MessageBase() { this->m_SendMessageType = "STT_POLYDATA"; };
115protected:
116 virtual int GetBodyPackSize() { return 0; };
117 virtual int PackBody() { AllocatePack(); return 1; };
118 virtual int UnpackBody() { return 1; };
119};
120
121
122
123// A class to manage a point array.
125
126 public:
127
129 typedef std::vector<igtlFloat32> Point;
130
131 public:
136
139
140 protected:
143
144 public:
145
147 void Clear();
148
150 void SetNumberOfPoints(int n);
151
154
157 int SetPoint(unsigned int id, igtlFloat32 * point);
158
160 int SetPoint(unsigned int id, igtlFloat32 x, igtlFloat32 y, igtlFloat32 z);
161
164 int AddPoint(igtlFloat32 * point);
165
167 int AddPoint(igtlFloat32 x, igtlFloat32 y, igtlFloat32 z);
168
170 int GetPoint(unsigned int id, igtlFloat32 & x, igtlFloat32 & y, igtlFloat32 & z);
171
173 int GetPoint(unsigned int id, igtlFloat32 * point);
174
175 private:
177 std::vector< Point > m_Data;
178};
179
180
181// The PolyDataCellArray class is used to pass vertices, lines, polygons, and triangle strips
183
184 public:
185 enum {
186 NULL_POINT = 0xFFFFFFFF,
187 };
188
189 public:
194
197
198 protected:
201
202 public:
203
205 void Clear();
206
208 igtlUint32 GetNumberOfCells();
209
211 void AddCell(int n, igtlUint32 * cell);
212
214 void AddCell(std::list<igtlUint32> cell);
215
224 igtlUint32 GetTotalSize();
225
227 igtlUint32 GetCellSize(unsigned int id);
228
232 int GetCell(unsigned int id, igtlUint32 * cell);
233
235 int GetCell(unsigned int id, std::list<igtlUint32>& cell);
236
237 private:
239 std::vector< std::list<igtlUint32> > m_Data;
240};
241
242
245 public:
246
248 enum {
249 POINT_SCALAR = 0x00,
250 POINT_VECTOR = 0x01,
251 POINT_NORMAL = 0x02,
252 POINT_TENSOR = 0x03,
253 POINT_RGBA = 0x04,
254 CELL_SCALAR = 0x10,
255 CELL_VECTOR = 0x11,
256 CELL_NORMAL = 0x12,
257 CELL_TENSOR = 0x13,
258 CELL_RGBA = 0x14,
259 };
260
261 public:
266
269
270 protected:
273
274 public:
275
277 void Clear();
278
286 int SetType(int t, int n=1);
287
289 igtlUint8 GetType() { return this->m_Type; };
290
294
296 igtlUint32 SetSize(igtlUint32 size);
297
299 igtlUint32 GetSize();
300
302 void SetName(const char * name);
303
305 const char* GetName() { return this->m_Name.c_str(); };
306
308 int SetData(igtlFloat32 * data);
309
311 int GetData(igtlFloat32 * data);
312
314 int SetNthData(unsigned int n, igtlFloat32 * data);
315
317 int GetNthData(unsigned int n, igtlFloat32 * data);
318
319 private:
320
322 igtlUint8 m_Type;
323
325 igtlUint8 m_NComponents;
326
328 igtlUint32 m_Size;
329
331 std::string m_Name;
332
334 std::vector<igtlFloat32> m_Data;
335
336};
337
338
341{
342public:
347
350
351public:
352
354 void Clear();
355
358
361
364
367
370
373
376
379
382
385
388
391
394
396 PolyDataAttribute * GetAttribute(unsigned int id);
397
398protected:
401
402protected:
403
405 virtual int PackContent();
406 virtual int UnpackContent();
407
410
413
416
419
422
424 std::vector<PolyDataAttribute::Pointer> m_Attributes;
425
426};
427
428} // namespace igtl
429
430#endif // _igtlPolyDataMessage_h
A class for the GET_POLYDATA message type.
igtlNewMacro(igtl::GetPolyDataMessage)
virtual int UnpackContent()
Unpacks (deserialize) the content. Must be implemented in all child classes.
SmartPointer< const Self > ConstPointer
igtlTypeMacro(igtl::GetPolyDataMessage, igtl::MessageBase)
SmartPointer< Self > Pointer
virtual int PackContent()
Packs (serialize) the content. Must be implemented in all child classes.
virtual int CalculateContentBufferSize()
Gets the size of the serialized content.
Base class for most igtl classes.
Definition igtlObject.h:61
Attribute class used for passing attribute data.
int GetNthData(unsigned int n, igtlFloat32 *data)
Gets the Nth data.
void Clear()
Clears the attributes.
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
int SetData(igtlFloat32 *data)
Sets the attribute by byte array.
const char * GetName()
Gets the name of the attribute.
int SetNthData(unsigned int n, igtlFloat32 *data)
Sets the Nth data.
igtlNewMacro(igtl::PolyDataAttribute)
igtlUint32 GetSize()
Gets the size of the attribute.
int GetData(igtlFloat32 *data)
Gets the attribute as a byte array.
void SetName(const char *name)
Sets the name of the attribute.
igtlUint32 GetNumberOfComponents()
igtlTypeMacro(igtl::PolyDataAttribute, igtl::Object)
igtlUint8 GetType()
Gets the attribute type.
igtlUint32 SetSize(igtlUint32 size)
Sets the size of the attribute.
int SetType(int t, int n=1)
SmartPointer< const Self > ConstPointer
void AddCell(std::list< igtlUint32 > cell)
Adds an array of cells stored in 'cell'.
void AddCell(int n, igtlUint32 *cell)
Adds an array of cells stored in 'cell'. The number of cells is specified by 'n'.
int GetCell(unsigned int id, std::list< igtlUint32 > &cell)
Gets the cell specified by the 'id'. A list of points in the cell will be stored in the 'cell'.
igtlUint32 GetTotalSize()
SmartPointer< Self > Pointer
igtlUint32 GetCellSize(unsigned int id)
Gets the size of the cell specified by 'id'.
igtlTypeMacro(igtl::PolyDataCellArray, igtl::Object)
void Clear()
Clears the cell array.
igtlUint32 GetNumberOfCells()
Gets the number of cells in the array.
int GetCell(unsigned int id, igtlUint32 *cell)
igtlNewMacro(igtl::PolyDataCellArray)
A class for the POLYDATA message type.
SmartPointer< Self > Pointer
igtlSetObjectMacro(Points, PolyDataPointArray)
Sets an array of points.
PolyDataCellArray::Pointer m_TriangleStrips
A pointer to the array of triangle strips.
igtlTypeMacro(igtl::PolyDataMessage, igtl::MessageBase)
igtlGetObjectMacro(Points, PolyDataPointArray)
Gets an array of points.
virtual int CalculateContentBufferSize()
Gets the size of the serialized content.
igtlSetObjectMacro(Vertices, PolyDataCellArray)
Sets an array of vertices.
virtual int UnpackContent()
Unpacks (deserialize) the content. Must be implemented in all child classes.
igtlSetObjectMacro(Lines, PolyDataCellArray)
Sets an array of lines.
virtual int PackContent()
Packs (serialize) the content. Must be implemented in all child classes.
igtlGetObjectMacro(Polygons, PolyDataCellArray)
Gets an array of polygons.
PolyDataAttribute * GetAttribute(unsigned int id)
Gets an attribute specified by 'id'.
void AddAttribute(PolyDataAttribute *att)
Adds an attribute.
SmartPointer< const Self > ConstPointer
PolyDataCellArray::Pointer m_Polygons
A pointer to the array of polygons.
void ClearAttributes()
Clears the attributes.
std::vector< PolyDataAttribute::Pointer > m_Attributes
A list of pointers to the attributes.
PolyDataPointArray::Pointer m_Points
A pointer to the array of points.
PolyDataCellArray::Pointer m_Vertices
A pointer to the array of vertices.
igtlGetObjectMacro(Lines, PolyDataCellArray)
Gets an array of lines.
igtlGetObjectMacro(Vertices, PolyDataCellArray)
Gets an array of vertices.
PolyDataCellArray::Pointer m_Lines
A pointer to the array of lines.
igtlSetObjectMacro(TriangleStrips, PolyDataCellArray)
Sets an array of triangle strips.
void Clear()
Clears the polydata.
igtlNewMacro(igtl::PolyDataMessage)
igtlSetObjectMacro(Polygons, PolyDataCellArray)
Sets an array of polygons.
int GetNumberOfAttributes()
Gets the number of attributes.
igtlGetObjectMacro(TriangleStrips, PolyDataCellArray)
Gets an array of triangle strips.
int GetPoint(unsigned int id, igtlFloat32 &x, igtlFloat32 &y, igtlFloat32 &z)
Gets the coordinates of the point specified by 'id'.
void Clear()
Clears the all points in the list.
std::vector< igtlFloat32 > Point
A vector to represent coordinates of a point.
igtlTypeMacro(igtl::PolyDataPointArray, igtl::Object)
void SetNumberOfPoints(int n)
Sets the number of points. This function will change the size of the list.
int SetPoint(unsigned int id, igtlFloat32 x, igtlFloat32 y, igtlFloat32 z)
Substitutes the point specified by 'id' with a point specified by 'x', 'y' and 'z'.
SmartPointer< Self > Pointer
int AddPoint(igtlFloat32 x, igtlFloat32 y, igtlFloat32 z)
Adds a point 'point' specified by 'x', 'y' and 'z'.
SmartPointer< const Self > ConstPointer
igtlNewMacro(igtl::PolyDataPointArray)
int GetNumberOfPoints()
Gets the number of points in the list.
int GetPoint(unsigned int id, igtlFloat32 *point)
Gets the coordinates of the point specified by 'id'.
int SetPoint(unsigned int id, igtlFloat32 *point)
int AddPoint(igtlFloat32 *point)
A class for the RTS_POLYDATA message type.
virtual int UnpackContent()
Unpacks (deserialize) the content. Must be implemented in all child classes.
SmartPointer< Self > Pointer
igtlNewMacro(igtl::RTSPolyDataMessage)
igtlTypeMacro(igtl::RTSPolyDataMessage, igtl::MessageBase)
void SetStatus(bool status)
virtual int PackContent()
Packs (serialize) the content. Must be implemented in all child classes.
igtl_uint8 m_Status
Result of the previous GET_POLYDATA/POLYDATA message.
virtual int CalculateContentBufferSize()
Gets the size of the serialized content.
SmartPointer< const Self > ConstPointer
Implements transparent reference counting.
A class for the STT_POLYDATA message type.
igtlTypeMacro(igtl::StartPolyDataMessage, igtl::MessageBase)
igtlNewMacro(igtl::StartPolyDataMessage)
SmartPointer< const Self > ConstPointer
A class for the STP_POLYDATA message type.
SmartPointer< const Self > ConstPointer
igtlNewMacro(igtl::StopPolyDataMessage)
igtlTypeMacro(igtl::StopPolyDataMessage, igtl::MessageBase)
SmartPointer< Self > Pointer
#define IGTLCommon_EXPORT
The "igtl" namespace contains all OpenIGTLink classes. There are several nested namespaces within the...

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