Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtl_tdata.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   OpenIGTLink Library
00004   Module:    $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink2_beta/Source/igtlutil/igtl_position.h $
00005   Language:  C
00006   Date:      $Date: 2009-11-13 11:37:44 -0500 (Fri, 13 Nov 2009) $
00007   Version:   $Revision: 5335 $
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_TDATA_H
00018 #define __IGTL_TDATA_H
00019 
00020 #include "igtl_win32header.h"
00021 #include "igtl_util.h"
00022 #include "igtl_types.h"
00023 
00024 #define  IGTL_TDATA_ELEMENT_SIZE           70
00025 #define  IGTL_STT_TDATA_SIZE               36
00026 #define  IGTL_RTS_TDATA_SIZE               1
00027 
00028 #define  IGTL_TDATA_LEN_NAME               20  /* Maximum length of tracking instrument name */
00029 #define  IGTL_STT_TDATA_LEN_COORDNAME      32  /* Maximum length of coordinate system name */
00030 
00031 #define  IGTL_TDATA_TYPE_TRACKER           1  /* Tracker */
00032 #define  IGTL_TDATA_TYPE_6D                2  /* 6D instrument (regular instrument) */
00033 #define  IGTL_TDATA_TYPE_3D                3  /* 3D instrument (only tip of the instrument defined) */
00034 #define  IGTL_TDATA_TYPE_5D                4  /* 5D instrument (tip and handle are defined,
00035                                                  but not the normal vector) */
00036 
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 #pragma pack(1)     /* For 1-byte boundary in memroy */
00043 /*
00044  * Status data header for OpenIGTLinik protocol
00045  *
00046  */
00047 
00048 typedef struct {
00049   char         name[IGTL_TDATA_LEN_NAME];  /* Name of instrument / tracker */
00050   igtl_uint8   type;           /* Tracking data type (1-4) */
00051   igtl_uint8   reserved;       /* Reserved byte */
00052   igtl_float32 transform[12];  /* same as TRANSFORM */
00053 } igtl_tdata_element;
00054 
00055 
00056 typedef struct {
00057   igtl_int32   resolution;     /* Minimum time between two frames. Use 0 for as fast as possible. */
00058                                /* If e.g. 50 ms is specified, the maximum update rate will be 20 Hz. */
00059   char         coord_name[IGTL_STT_TDATA_LEN_COORDNAME]; /* Name of the coordinate system */
00060 } igtl_stt_tdata;
00061 
00062 typedef struct {
00063   igtl_int8    status;         /* 0: Success 1: Error */
00064 } igtl_rts_tdata;
00065 
00066 #pragma pack()
00067 
00068 /*
00069  * Macros for tdata data size
00070  *
00071  * igtl_tdata_get_data_size(n) calculates the size of body based on the number
00072  * of tdatas. The size of body is used in the message header.
00073  * igtl_tdata_get_data_n(size) calculates the number of tdatas in the body, based on
00074  * the body size. This function may be used when a client program parses a TDATA message.
00075  *
00076  */
00077 
00078 #define igtl_tdata_get_data_size(n)  ((n) * IGTL_TDATA_ELEMENT_SIZE)
00079 #define igtl_tdata_get_data_n(size)  ((size) / IGTL_TDATA_ELEMENT_SIZE)
00080 
00081 /*
00082  * Byte order conversion for an array of TDATA, STT_TDATA and RTS_TDATA data structure
00083  *
00084  * This function converts endianness of each element in an array of
00085  * igtl_tdata_element from host byte order to network byte order,
00086  * or vice versa.
00087  */
00088 
00089 void igtl_export igtl_tdata_convert_byte_order(igtl_tdata_element* tdatalist, int nelem);
00090 void igtl_export igtl_stt_tdata_convert_byte_order(igtl_stt_tdata* stt_tdata);
00091 void igtl_export igtl_rts_tdata_convert_byte_order(igtl_rts_tdata* rts_tdata);
00092 
00093 
00094 /*
00095  * CRC calculation
00096  *
00097  * These functions calculate CRC of TDATA, STT_TDATA and RTS_TDATA messages
00098  *
00099  */
00100 
00101 igtl_uint64 igtl_export igtl_tdata_get_crc(igtl_tdata_element* tdatalist, int nelem);
00102 igtl_uint64 igtl_export igtl_stt_tdata_get_crc(igtl_stt_tdata* stt_tdata);
00103 igtl_uint64 igtl_export igtl_rts_tdata_get_crc(igtl_rts_tdata* rts_tdata);
00104 
00105 #ifdef __cplusplus
00106 }
00107 #endif
00108 
00109 #endif /* __IGTL_TDATA_H */
00110 
00111 
00112 

Generated at Wed Apr 27 2011 00:08:07 for OpenIGTLink by doxygen 1.7.4 written by Dimitri van Heesch, © 1997-2000