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 
26 namespace igtl
27 {
28 
31 {
32 public:
37 
40 
41 protected:
42  GetPolyDataMessage() : MessageBase() { this->m_DefaultBodyType = "GET_POLYDATA"; };
44 protected:
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:
61  typedef Object Superclass;
64 
67 
68  protected:
71 
72  public:
73 
75  void Clear();
76 
78  void SetNumberOfPoints(int n);
79 
81  int GetNumberOfPoints();
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 
221  igtlUint32 GetNumberOfComponents();
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 {
270 public:
275 
278 
279 public:
280 
282  void Clear();
283 
286 
289 
292 
295 
298 
301 
304 
307 
309  igtlSetObjectMacro(TriangleStrips, PolyDataCellArray);
310 
312  igtlGetObjectMacro(TriangleStrips, PolyDataCellArray);
313 
315  void ClearAttributes();
316 
318  void AddAttribute(PolyDataAttribute * att);
319 
321  int GetNumberOfAttributes();
322 
324  PolyDataAttribute * GetAttribute(unsigned int id);
325 
326 protected:
327  PolyDataMessage();
328  ~PolyDataMessage();
329 
330 protected:
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 
PolyDataCellArray::Pointer m_Polygons
A pointer to the array of polygons.
SmartPointer< Self > Pointer
std::vector< PolyDataAttribute::Pointer > m_Attributes
A list of pointers to the attributes.
igtlUint8 GetType()
Gets the attribute type.
#define igtlTypeMacro(thisClass, superclass)
Definition: igtlMacro.h:486
PolyDataCellArray::Pointer m_Lines
A pointer to the array of lines.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
A class for the POLYDATA message type.
const char * GetName()
Gets the name of the attribute.
#define igtlGetObjectMacro(name, type)
Definition: igtlMacro.h:341
std::vector< igtlFloat32 > Point
A vector to represent coordinates of a point.
virtual int GetBodyPackSize()
Gets the size of the serialized body.
SmartPointer< Self > Pointer
Attribute class used for passing attribute data.
PolyDataPointArray::Pointer m_Points
A pointer to the array of points.
#define IGTLCommon_EXPORT
virtual int PackBody()
Packs (serialize) the body. Must be implemented in a child class.
SmartPointer< const Self > ConstPointer
virtual int UnpackBody()
Unpacks (deserialize) the body. Must be implemented in a child class.
SmartPointer< Self > Pointer
PolyDataCellArray::Pointer m_Vertices
A pointer to the array of vertices.
A class for the GET_POLYDATA message type.
SmartPointer< const Self > ConstPointer
#define igtlSetObjectMacro(name, type)
Definition: igtlMacro.h:328
#define igtlNewMacro(x)
Definition: igtlMacro.h:431
SmartPointer< const Self > ConstPointer
Base class for most igtl classes.
Definition: igtlObject.h:60
PolyDataCellArray::Pointer m_TriangleStrips
A pointer to the array of triangle strips.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer

Generated at Mon Nov 11 2013 00:36:45 for OpenIGTLink by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2012