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_IMGMETA_H 00018 #define __IGTL_IMGMETA_H 00019 00020 #include "igtl_win32header.h" 00021 #include "igtl_util.h" 00022 #include "igtl_types.h" 00023 #include "igtl_image.h" 00024 00025 #define IGTL_IMGMETA_ELEMENT_SIZE 260 00026 00027 /* Scalar type */ 00028 /* Use the same numbers as IMAGE */ 00029 /* 00030 #define IGTL_IMGMETA_STYPE_TYPE_INT8 2 00031 #define IGTL_IMGMETA_STYPE_TYPE_UINT8 3 00032 #define IGTL_IMGMETA_STYPE_TYPE_INT16 4 00033 #define IGTL_IMGMETA_STYPE_TYPE_UINT16 5 00034 #define IGTL_IMGMETA_STYPE_TYPE_INT32 6 00035 #define IGTL_IMGMETA_STYPE_TYPE_UINT32 7 00036 #define IGTL_IMGMETA_STYPE_TYPE_FLOAT32 10 00037 #define IGTL_IMGMETA_STYPE_TYPE_FLOAT64 11 00038 */ 00039 00040 #define IGTL_IMGMETA_LEN_NAME 64 00041 #define IGTL_IMGMETA_LEN_DEVICE_NAME 20 00042 #define IGTL_IMGMETA_LEN_MODALITY 32 00043 #define IGTL_IMGMETA_LEN_PATIENT_NAME 64 00044 #define IGTL_IMGMETA_LEN_PATIENT_ID 64 00045 00046 00047 #ifdef __cplusplus 00048 extern "C" { 00049 #endif 00050 00051 #pragma pack(1) /* For 1-byte boundary in memroy */ 00052 00053 /* 00054 * Image meta data OpenIGTLinik protocol 00055 * 00056 * IMAGEMETA is a message type to transfer a list of images available in a server. 00057 * A IMGMETA message may contain information of multiple images. 00058 * The client determins the number of image meta by the size of the body included 00059 * in the message header (see igtl_imgmeta_getdata_n() macro). 00060 */ 00061 00062 typedef struct { 00063 char name[IGTL_IMGMETA_LEN_NAME]; /* name / description */ 00064 char device_name[IGTL_IMGMETA_LEN_DEVICE_NAME]; /* device name to query the IMAGE and COLORT */ 00065 char modality[IGTL_IMGMETA_LEN_MODALITY]; /* modality name */ 00066 char patient_name[IGTL_IMGMETA_LEN_PATIENT_NAME]; /* patient name */ 00067 char patient_id[IGTL_IMGMETA_LEN_PATIENT_ID]; /* patient ID (MRN etc.) */ 00068 igtl_uint64 timestamp; /* scan time */ 00069 igtl_uint16 size[3]; /* entire image volume size */ 00070 igtl_uint8 scalar_type; /* scalar type. see scalar_type in IMAGE message */ 00071 igtl_uint8 reserved; 00072 } igtl_imgmeta_element; 00073 00074 #pragma pack() 00075 00076 00077 /* 00078 * Macros for image meta data size 00079 * 00080 * igtl_imgmeta_get_data_size(n) calculates the size of body based on the number 00081 * of images.The size of body is used in the message header. 00082 * igtl_imgmeta_get_data_n(size) calculates the number of images in the body, based on 00083 * the body size. This function may be used when a client program parses IMGMETA message. 00084 * 00085 */ 00086 00087 #define igtl_imgmeta_get_data_size(n) ((n) * IGTL_IMGMETA_ELEMENT_SIZE) 00088 #define igtl_imgmeta_get_data_n(size) ((size) / IGTL_IMGMETA_ELEMENT_SIZE) 00089 00090 00091 /* 00092 * Byte order conversion for the image meta data 00093 * 00094 * This function converts endianness of each member variable 00095 * in igtl_imgmeta_element from host byte order to network byte order, 00096 * or vice versa. 00097 */ 00098 00099 void igtl_export igtl_imgmeta_convert_byte_order(igtl_imgmeta_element* metalist, int nitem); 00100 00101 00102 /* 00103 * CRC calculation 00104 * 00105 * This function calculates CRC of image meta data body. 00106 * 00107 */ 00108 00109 igtl_uint64 igtl_export igtl_imgmeta_get_crc(igtl_imgmeta_element* metalist, int nitem); 00110 00111 #ifdef __cplusplus 00112 } 00113 #endif 00114 00115 #endif /* __IGTL_IMGMETA_H */ 00116