00001 /*========================================================================= 00002 00003 Program: OpenIGTLink Library 00004 Module: $RCSfile$ 00005 Language: C 00006 Date: $Date: 2009-11-17 22:53:00 -0500 (Tue, 17 Nov 2009) $ 00007 Version: $Revision: 5366 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notices for more information. 00014 00015 =========================================================================*/ 00016 00017 #ifndef __IGTL_LBMETA_H 00018 #define __IGTL_LBMETA_H 00019 00020 #include "igtl_win32header.h" 00021 #include "igtl_util.h" 00022 #include "igtl_types.h" 00023 00024 #define IGTL_LBMETA_ELEMENT_SIZE 116 00025 00026 #define IGTL_LBMETA_LEN_NAME 64 00027 #define IGTL_LBMETA_LEN_DEVICE_NAME 20 00028 #define IGTL_LBMETA_LEN_OWNER 20 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 /* 00035 * Label meta data in OpenIGTLinik protocol 00036 * 00037 * LBMETA is a data type to send a list of label image data available in a server. 00038 * In OpenIGTLink protocol, actual label data is transfered as an IMAGE message. 00039 * LBMETA message lets the receiving client know which IMAGE data are available 00040 * as label maps. 00041 * Multiple labels in a LBMETA message can point the same IMAGE message, if there 00042 * are multiple lables are recoreded in a single IMAGE mesage. For example, given 00043 * the following label map as IMAGE data with name "LableImage1": 00044 * 00045 * 0 0 0 1 0 0 value | name / description 00046 * 2 0 1 1 1 0 --------+---------------------------- 00047 * 2 2 1 1 1 0 0 | None 00048 * 2 2 2 1 0 0 1 | Liver 00049 * 2 2 2 2 0 0 2 | Kidney 00050 * 00051 * To send the label information recorded in "LabelImage1," one can create 00052 * a following LBMETA message: 00053 * 00054 * DATA | Contents 00055 * ---------------+--------------------------- 00056 * NAME 1 | Liver 00057 * IMAGE NAME 1 | LabelImage 00058 * Labe l | 1 00059 * RGBA 1 | 0xFF0000 00060 * SIZE 1 | (6, 5, 1) 00061 * OWNER 1 | 00062 * --------------+--------------------------- 00063 * NAME 2 | Kidney 00064 * IMAGE NAME 2 | LabelImage 00065 * Labe 2 | 2 00066 * RGBA 2 | 0xFF2222 00067 * SIZE 2 | (6, 5, 1) 00068 * OWNER 2 | 00069 * --------------+--------------------------- 00070 * 00071 * ... .... 00072 * 00073 * --------------+--------------------------- 00074 * 00075 * The client determins the number of image meta by the size of the body included 00076 * in the message header (see igtl_lbmeta_getdata_n() macro). 00077 */ 00078 00079 #pragma pack(1) /* For 1-byte boundary in memroy */ 00080 00081 typedef struct { 00082 char name[IGTL_LBMETA_LEN_NAME]; /* name / description */ 00083 char device_name[IGTL_LBMETA_LEN_DEVICE_NAME]; /* device name to query the IMAGE */ 00084 igtl_uint8 label; /* label */ 00085 igtl_uint8 reserved; 00086 igtl_uint8 rgba[4]; /* Color in RGBA. default: (0, 0, 0, 0) */ 00087 igtl_uint16 size[3]; /* Number of pixels in each direction */ 00088 char owner[IGTL_LBMETA_LEN_OWNER];/* Device name of the owner image. (can be empty) */ 00089 } igtl_lbmeta_element; 00090 00091 #pragma pack() 00092 00093 00094 /* 00095 * Macros for label meta data size 00096 * 00097 * igtl_lbmeta_get_data_size(n) calculates the size of body based on the number 00098 * of images.The size of body is used in the message header. 00099 * igtl_lbmeta_get_data_n(size) calculates the number of images in the body, based on 00100 * the body size. This function may be used when a client program parses LBMETA message. 00101 * 00102 */ 00103 00104 #define igtl_lbmeta_get_data_size(n) ((n) * IGTL_LBMETA_ELEMENT_SIZE) 00105 #define igtl_lbmeta_get_data_n(size) ((size) / IGTL_LBMETA_ELEMENT_SIZE) 00106 00107 00108 /* 00109 * Byte order conversion for the image meta data 00110 * 00111 * This function converts endianness of each member variable 00112 * in igtl_lbmeta_element from host byte order to network byte order, 00113 * or vice versa. 00114 */ 00115 00116 void igtl_export igtl_lbmeta_convert_byte_order(igtl_lbmeta_element* metalist, int nitem); 00117 00118 00119 /* 00120 * CRC calculation 00121 * 00122 * This function calculates CRC of image meta data body. 00123 * 00124 */ 00125 00126 igtl_uint64 igtl_export igtl_lbmeta_get_crc(igtl_lbmeta_element* metalist, int nitem); 00127 00128 #ifdef __cplusplus 00129 } 00130 #endif 00131 00132 #endif /* __IGTL_LBMETA_H */ 00133 00134 00135