Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtl_ndarray.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_NDARRAY_H
18 #define __IGTL_NDARRAY_H
19 
20 #include "igtl_win32header.h"
21 #include "igtl_util.h"
22 #include "igtl_types.h"
23 #include "igtl_win32header.h"
24 
25 #define IGTL_NDARRAY_HEADER_SIZE 2
26 
27 /* Scalar type */
28 #define IGTL_NDARRAY_STYPE_TYPE_INT8 2
29 #define IGTL_NDARRAY_STYPE_TYPE_UINT8 3
30 #define IGTL_NDARRAY_STYPE_TYPE_INT16 4
31 #define IGTL_NDARRAY_STYPE_TYPE_UINT16 5
32 #define IGTL_NDARRAY_STYPE_TYPE_INT32 6
33 #define IGTL_NDARRAY_STYPE_TYPE_UINT32 7
34 #define IGTL_NDARRAY_STYPE_TYPE_FLOAT32 10
35 #define IGTL_NDARRAY_STYPE_TYPE_FLOAT64 11
36 #define IGTL_NDARRAY_STYPE_TYPE_COMPLEX 13
37 
38 #define IGTL_NDARRAY_HOST_TO_NETWORK 0
39 #define IGTL_NDARRAY_NETWORK_TO_HOST 1
40 
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * NDARRAY is a data type, which is designed to transfer N-dimensional numerical array.
48  * The message body consists of N-D array header, size table, and N-D array body.
49  */
50 
51 typedef struct {
52  igtl_uint8 type; /* Scalar type (2:int8 3:uint8 4:int16 5:uint16 6:int32
53  7:uint32 10:float32 11:float64 13:complex) */
54  igtl_uint8 dim; /* Dimension of array */
55  igtl_uint16 * size; /* Array size */
56  void * array;
58 
59 
60 /*
61  * Initialize igtl_ndarray_info
62  */
64 
65 
66 /*
67  * Allocate / free ndarray
68  *
69  * Allocate size array and ND-array pointed from igtl_ndarray_info.
70  * 'type' and 'dim' in igtl_ndarray_info must be specified before
71  * calling igtl_ndarray_alloc_info().
72  */
73 
74 int igtl_export igtl_ndarray_alloc_info(igtl_ndarray_info * info, const igtl_uint16 * size);
76 
77 
78 /*
79  * Unpack NDARRAY message
80  *
81  * Extract information in a byte array of NDARRAY messages and store
82  * it in a igtl_ndarray_info structure. 'type' argument specifies
83  * a message type prefix (none, GET_, STT_, STP_ or RTS_) by IGTL_TYPE_PREFIX_* macro.
84  * Returns 1 if success, otherwise 0.
85  */
86 
87 int igtl_export igtl_ndarray_unpack(int type, void * byte_array, igtl_ndarray_info * info, igtl_uint64 pack_size);
88 
89 
90 /*
91  * Pack NDARRAY message
92  *
93  * Convert an igtl_ndarray_info structure to a byte array.
94  * 'byte_array' should be allocated prior to calling igtl_ndarray_pack() with memory size
95  * calculated by igtl_ndarray_get_size(). 'type' argument specifies a message type prefix
96  * (none, or GET_) by IGTL_TYPE_PREFIX_* macro. Returns 1 if success, otherwise 0.
97  */
98 
99 int igtl_export igtl_ndarray_pack(igtl_ndarray_info * info, void * byte_array, int type);
100 
101 
102 /*
103  * N-D array data size
104  *
105  * This function calculates size of N-D array body including
106  * size table (defined by UINT16[dim]) and array data.
107  */
108 
109  igtl_uint64 igtl_export igtl_ndarray_get_size(igtl_ndarray_info * info, int type);
110 
111 /*
112  * CRC calculation
113  *
114  * This function calculates CRC of image data body including header
115  * and array of pixel data.
116  *
117  */
118 
119 igtl_uint64 igtl_export igtl_ndarray_get_crc(igtl_ndarray_info * info, int type, void* byte_array);
120 
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* __IGTL_NDARRAY_H */
127 

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