Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtl_qtdata.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_QTDATA_H
00018 #define __IGTL_QTDATA_H
00019 
00020 #include "igtl_win32header.h"
00021 #include "igtl_util.h"
00022 #include "igtl_types.h"
00023 
00024 #define  IGTL_QTDATA_ELEMENT_SIZE           50
00025 #define  IGTL_STT_QTDATA_SIZE               36
00026 #define  IGTL_RTS_QTDATA_SIZE               1
00027 
00028 #define  IGTL_QTDATA_LEN_NAME               20  /* Maximum length of tracking instrument name */
00029 #define  IGTL_STT_QTDATA_LEN_COORDNAME      32  /* Maximum length of coordinate system name */
00030 
00031 #define  IGTL_QTDATA_TYPE_TRACKER           1  /* Tracker */
00032 #define  IGTL_QTDATA_TYPE_6D                2  /* 6D instrument (regular instrument) */
00033 #define  IGTL_QTDATA_TYPE_3D                3  /* 3D instrument (only tip of the instrument defined) */
00034 #define  IGTL_QTDATA_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_QTDATA_LEN_NAME];  /* Name of instrument / tracker */
00050   igtl_uint8   type;           /* Tracking data type (1-4) */
00051   igtl_uint8   reserved;       /* Reserved byte */
00052   igtl_float32 position[3];    /* position (x, y, z) */
00053   igtl_float32 quaternion[4];  /* orientation as quaternion (qx, qy, qz, w) */
00054 } igtl_qtdata_element;
00055 
00056 
00057 typedef struct {
00058   igtl_int32   resolution;     /* Minimum time between two frames. Use 0 for as fast as possible. */
00059                                /* If e.g. 50 ms is specified, the maximum update rate will be 20 Hz. */
00060   char         coord_name[IGTL_STT_QTDATA_LEN_COORDNAME]; /* Name of the coordinate system */
00061 } igtl_stt_qtdata;
00062 
00063 typedef struct {
00064   igtl_int8    status;         /* 0: Success 1: Error */
00065 } igtl_rts_qtdata;
00066 
00067 #pragma pack()
00068 
00069 /*
00070  * Macros for qtdata data size
00071  *
00072  * igtl_qtdata_get_data_size(n) calculates the size of body based on the number
00073  * of qtdatas. The size of body is used in the message header.
00074  * igtl_qtdata_get_data_n(size) calculates the number of qtdatas in the body, based on
00075  * the body size. This function may be used when a client program parses a QTDATA message.
00076  *
00077  */
00078 
00079 #define igtl_qtdata_get_data_size(n)  ((n) * IGTL_QTDATA_ELEMENT_SIZE)
00080 #define igtl_qtdata_get_data_n(size)  ((size) / IGTL_QTDATA_ELEMENT_SIZE)
00081 
00082 /*
00083  * Byte order conversion for an array of QTDATA, STT_QTDATA and RTS_QTDATA data structure
00084  *
00085  * This function converts endianness of each element in an array of
00086  * igtl_qtdata_element from host byte order to network byte order,
00087  * or vice versa.
00088  */
00089 
00090 void igtl_export igtl_qtdata_convert_byte_order(igtl_qtdata_element* qtdatalist, int nelem);
00091 void igtl_export igtl_stt_qtdata_convert_byte_order(igtl_stt_qtdata* stt_qtdata);
00092 void igtl_export igtl_rts_qtdata_convert_byte_order(igtl_rts_qtdata* rts_qtdata);
00093 
00094 
00095 /*
00096  * CRC calculation
00097  *
00098  * These functions calculate CRC of QTDATA, STT_QTDATA and RTS_QTDATA messages
00099  *
00100  */
00101 
00102 igtl_uint64 igtl_export igtl_qtdata_get_crc(igtl_qtdata_element* qtdatalist, int nelem);
00103 igtl_uint64 igtl_export igtl_stt_qtdata_get_crc(igtl_stt_qtdata* stt_qtdata);
00104 igtl_uint64 igtl_export igtl_rts_qtdata_get_crc(igtl_rts_qtdata* rts_qtdata);
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif
00109 
00110 #endif /* __IGTL_QTDATA_H */
00111 
00112 
00113 

Generated at Sat Dec 3 2011 08:54:20 for OpenIGTLink by doxygen 1.7.4 written by Dimitri van Heesch, © 1997-2000