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
31{
32public:
37
40
41protected:
42 GetPolyDataMessage() : MessageBase() { this->m_DefaultBodyType = "GET_POLYDATA"; };
44protected:
45 virtual int GetBodyPackSize() { return 0; };
46 virtual int PackBody() { AllocatePack(); return 1; };
47 virtual int UnpackBody() { return 1; };
48};
49
50
51// A class to manage a point array.
53
54 public:
55
57 typedef std::vector<igtlFloat32> Point;
58
59 public:
64
67
68 protected:
71
72 public:
73
75 void Clear();
76
78 void SetNumberOfPoints(int n);
79
82
85 int SetPoint(unsigned int id, igtlFloat32 * point);
86
88 int SetPoint(unsigned int id, igtlFloat32 x, igtlFloat32 y, igtlFloat32 z);
89
92 int AddPoint(igtlFloat32 * point);
93
95 int AddPoint(igtlFloat32 x, igtlFloat32 y, igtlFloat32 z);
96
98 int GetPoint(unsigned int id, igtlFloat32 & x, igtlFloat32 & y, igtlFloat32 & z);
99
101 int GetPoint(unsigned int id, igtlFloat32 * point);
102
103 private:
105 std::vector< Point > m_Data;
106};
107
108
109// The PolyDataCellArray class is used to pass vertices, lines, polygons, and triangle strips
111
112 public:
113 enum {
114 NULL_POINT = 0xFFFFFFFF,
115 };
116
117 public:
122
125
126 protected:
129
130 public:
131
133 void Clear();
134
136 igtlUint32 GetNumberOfCells();
137
139 void AddCell(int n, igtlUint32 * cell);
140
142 void AddCell(std::list<igtlUint32> cell);
143
152 igtlUint32 GetTotalSize();
153
155 igtlUint32 GetCellSize(unsigned int id);
156
160 int GetCell(unsigned int id, igtlUint32 * cell);
161
163 int GetCell(unsigned int id, std::list<igtlUint32>& cell);
164
165 private:
167 std::vector< std::list<igtlUint32> > m_Data;
168};
169
170
173 public:
174
176 enum {
177 POINT_SCALAR = 0x00,
178 POINT_VECTOR = 0x01,
179 POINT_NORMAL = 0x02,
180 POINT_TENSOR = 0x03,
181 POINT_RGBA = 0x04,
182 CELL_SCALAR = 0x10,
183 CELL_VECTOR = 0x11,
184 CELL_NORMAL = 0x12,
185 CELL_TENSOR = 0x13,
186 CELL_RGBA = 0x14,
187 };
188
189 public:
194
197
198 protected:
201
202 public:
203
205 void Clear();
206
214 int SetType(int t, int n=1);
215
217 igtlUint8 GetType() { return this->m_Type; };
218
222
224 igtlUint32 SetSize(igtlUint32 size);
225
227 igtlUint32 GetSize();
228
230 void SetName(const char * name);
231
233 const char* GetName() { return this->m_Name.c_str(); };
234
236 int SetData(igtlFloat32 * data);
237
239 int GetData(igtlFloat32 * data);
240
242 int SetNthData(unsigned int n, igtlFloat32 * data);
243
245 int GetNthData(unsigned int n, igtlFloat32 * data);
246
247 private:
248
250 igtlUint8 m_Type;
251
253 igtlUint8 m_NComponents;
254
256 igtlUint32 m_Size;
257
259 std::string m_Name;
260
262 std::vector<igtlFloat32> m_Data;
263
264};
265
266
269{
270public:
275
278
279public:
280
282 void Clear();
283
286
289
292
295
298
301
304
307
310
313
316
319
322
324 PolyDataAttribute * GetAttribute(unsigned int id);
325
326protected:
329
330protected:
331
332 virtual int GetBodyPackSize();
333 virtual int PackBody();
334 virtual int UnpackBody();
335
338
341
344
347
350
352 std::vector<PolyDataAttribute::Pointer> m_Attributes;
353
354};
355
356} // namespace igtl
357
358#endif // _igtlPolyDataMessage_h
359
360
361
A class for the GET_POLYDATA message type.
igtlNewMacro(igtl::GetPolyDataMessage)
SmartPointer< const Self > ConstPointer
igtlTypeMacro(igtl::GetPolyDataMessage, igtl::MessageBase)
virtual int GetBodyPackSize()
Gets the size of the serialized body.
virtual int PackBody()
Packs (serialize) the body. Must be implemented in a child class.
SmartPointer< Self > Pointer
virtual int UnpackBody()
Unpacks (deserialize) the body. Must be implemented in a child class.
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.
igtlSetObjectMacro(Vertices, PolyDataCellArray)
Sets an array of vertices.
igtlSetObjectMacro(Lines, PolyDataCellArray)
Sets an array of lines.
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.
virtual int GetBodyPackSize()
Gets the size of the serialized body.
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.
virtual int UnpackBody()
Unpacks (deserialize) the body. Must be implemented in a child class.
PolyDataCellArray::Pointer m_Lines
A pointer to the array of lines.
igtlSetObjectMacro(TriangleStrips, PolyDataCellArray)
Sets an array of triangle strips.
void Clear()
Clears the poly data.
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.
virtual int PackBody()
Packs (serialize) the body. Must be implemented in a child class.
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)
Implements transparent reference counting.
#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