Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtl_polydata.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: The OpenIGTLink Library
4  Module: $HeadURL: $
5  Language: C
6  Date: $Date: 2010-11-23 14:47:40 -0500 (Tue, 23 Nov 2010) $
7  Version: $Revision: 6958 $
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 __IGTL_POLYDATA_H
18 #define __IGTL_POLYDATA_H
19 
20 #include "igtl_win32header.h"
21 #include "igtl_header.h"
22 #include "igtl_util.h"
23 #include "igtl_types.h"
24 #include "igtl_win32header.h"
25 
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /* Scalar type for point data */
32 #define IGTL_POLYDATA_TYPE_INT8 2
33 #define IGTL_POLYDATA_TYPE_UINT8 3
34 #define IGTL_POLYDATA_TYPE_INT16 4
35 #define IGTL_POLYDATA_TYPE_UINT16 5
36 #define IGTL_POLYDATA_TYPE_INT32 6
37 #define IGTL_POLYDATA_TYPE_UINT32 7
38 #define IGTL_POLYDATA_TYPE_FLOAT32 10
39 #define IGTL_POLYDATA_TYPE_FLOAT64 11
40 
41 
42 #pragma pack(1) /* For 1-byte boundary in memroy */
43 
44 /*
45  * POLYDATA Header
46  */
47 typedef struct {
48  igtl_uint32 npoints; /* Number of points */
49  igtl_uint8 type_point; /* Type of points */
50  igtl_uint8 reserved; /* Points */
51 
52  igtl_uint32 nvertices; /* Number of vertices */
53  igtl_uint32 size_vertices; /* Size of vertices */
54 
55  igtl_uint32 nlines; /* Number of lines */
56  igtl_uint32 size_lines; /* Size of lines */
57 
58  igtl_uint32 npolygons; /* Number of polygons */
59  igtl_uint32 size_polygons; /* Size of polygons */
60 
61  igtl_uint32 ntriangle_strips; /* Number of triangle strips */
62  igtl_uint32 size_triangle_strips; /* Size of triangle strips */
63 
64 
65 
67 
68 #pragma pack(0)
69 
70 /*
71  * POLYDATA info
72  */
73 typedef struct {
75  void * points; /* Points */
76  igtl_uint32 * vertices; /* Vertices -- array of (N, i1, i2, i3 ...iN) */
77  igtl_uint32 * lines; /* Lines -- array of (N, i1, i2, i3 ...iN) */
78  igtl_uint32 * polygons; /* Polygons -- array of (N, i1, i2, i3 ...iN) */
79  igtl_uint32 * triangle_strips; /* Triangle strips -- array of (N, i1, i2, i3 ...iN) */
81 
82 
83 /*
84  * Initialize igtl_polydata_info
85  */
87 
88 /*
89  * Allocate / free an array of igtl_polydata_info structure
90  *
91  * Allocate / free an array of igtl_polydata_child_info in polydata_info with length of 'ncmessages.'
92  * Return 1 if the array is successfully allocated/freed
93  */
94 
97 
98 /*
99  * Unpack POLYDATA message
100  *
101  * Extract information about child messages in a byte array of POLYDATA messages and store
102  * it in a igtl_polydata_info structure. 'type' argument specifies a message type prefix
103  * (none, GET_, STT_, STP_ or RTS_) by IGTL_TYPE_PREFIX_* macro.
104  * Returns 1 if success, otherwise 0.
105  */
106 
107 int igtl_export igtl_polydata_unpack(int type, void * byte_array, igtl_polydata_info * info, igtl_uint64 size);
108 
109 /*
110  * Pack POLYDATA message
111  *
112  * Convert an igtl_polydata_info structure to a byte array.
113  * 'byte_array' should be allocated prior to calling igtl_polydata_pack() with memory size
114  * calculated by igtl_polydata_get_size(). 'type' argument specifies a message type prefix
115  * (none, GET_, STT_, STP_ or RTS_) by IGTL_TYPE_PREFIX_* macro.
116  * Returns 1 if success, otherwise 0.
117  */
118 
119 int igtl_export igtl_polydata_pack(igtl_polydata_info * info, void * byte_array, int type);
120 
121 /*
122  * Polydata data size
123  *
124  * igtl_polydata_get_size() calculates the size of polydata header, consisting of
125  * POLYDATA hearder section (including number of child messages) and
126  * name table section based on a igtl_polydata_header.
127  * The size returned from this function does not include size of child message data.
128  * 'type' argument specifies a message type prefix
129  * (none, GET_, STT_, STP_ or RTS_) by IGTL_TYPE_PREFIX_* macro.
130  */
131 
132 igtl_uint64 igtl_export igtl_polydata_get_size(igtl_polydata_info * info, int type);
133 
134 
135 /*
136  * CRC calculation
137  *
138  * This function calculates CRC of POLYDATA message. Note that 'info' is used only for
139  * getting size of the message.
140  *
141  */
142 
143 igtl_uint64 igtl_export igtl_polydata_get_crc(igtl_polydata_info * info, int type, void* polydata_message);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* __IGTL_POLYDATA_H */
150 
151 
152 

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