Difference between revisions of "OpenIGTLink/Library/Tutorial"

From NAMIC Wiki
Jump to: navigation, search
(New page: << OpenIGTLink <div class="floatright">__TOC__</div> *Create Open IGT Link message using igtlutil)
 
Line 2: Line 2:
 
<div class="floatright">__TOC__</div>
 
<div class="floatright">__TOC__</div>
  
*Create Open IGT Link message using igtlutil
+
=Create Open IGT Link message using igtlutil=
 +
The igtlutil c functions are available from Source/igtlutil in the Open IGT Link Library.
 +
 
 +
The followings are example codes to create Open IGT Link message.
 +
 
 +
Include declarations for transformation data:
 +
  #include "igtl_util.h"
 +
  #include "igtl_header.h"
 +
  #include "igtl_transform.h"
 +
 
 +
Transform package creation:
 +
  /********** pack data body **********/
 +
  igtl_float32 transform[12];
 +
 
 +
  transform[0] = tx;
 +
  transform[1] = ty;
 +
  transform[2] = tz;
 +
  transform[3] = sx;
 +
  transform[4] = sy;
 +
  transform[5] = sz;
 +
  transform[6] = nx;
 +
  transform[7] = ny;
 +
  transform[8] = nz;
 +
  transform[9] = px;
 +
  transform[10] = py;
 +
  transform[11] = pz;
 +
 
 +
  igtl_transform_convert_byte_order(transform);  /* convert endian if necessary */
 +
 
 +
  /********** general header **********/ 
 +
  igtl_header header;
 +
  igtl_uint64 crc = crc64(0, 0, 0LL);          /* initial crc */
 +
  header.version  = IGTL_HEADER_VERSION;
 +
  header.timestamp = 0;
 +
  header.body_size = IGTL_TRANSFORM_SIZE;
 +
  header.crc      = crc64((unsigned char*)transform, IGTL_TRANSFORM_SIZE, crc);
 +
 
 +
  strncpy(header.name, "TRANSFORM", 12);      /* Device Type: should be "TRANSFORM" */
 +
  strncpy(header.device_name, "Tracker", 20);    /* Device name */
 +
 
 +
  igtl_header_convert_byte_order(h);  /* convert endian if necessary */
 +
 
 +
Then send package (in case of BSD socket)
 +
  send(sock, (void*) &header, IGTL_HEADER_SIZE, 0);
 +
  send(sock, (void*) transform, IGTL_TRANSFORM_SIZE, 0);

Revision as of 15:09, 25 June 2008

Home < OpenIGTLink < Library < Tutorial

<< OpenIGTLink

Create Open IGT Link message using igtlutil

The igtlutil c functions are available from Source/igtlutil in the Open IGT Link Library.

The followings are example codes to create Open IGT Link message.

Include declarations for transformation data:

 #include "igtl_util.h"
 #include "igtl_header.h"
 #include "igtl_transform.h"

Transform package creation:

 /********** pack data body **********/
 igtl_float32 transform[12];
 
 transform[0] = tx;
 transform[1] = ty;
 transform[2] = tz;
 transform[3] = sx;
 transform[4] = sy;
 transform[5] = sz;
 transform[6] = nx;
 transform[7] = ny;
 transform[8] = nz;
 transform[9] = px;
 transform[10] = py;
 transform[11] = pz;
 
 igtl_transform_convert_byte_order(transform);  /* convert endian if necessary */
 
 /********** general header **********/  
 igtl_header header;
 igtl_uint64 crc = crc64(0, 0, 0LL);          /* initial crc */
 header.version   = IGTL_HEADER_VERSION;
 header.timestamp = 0;
 header.body_size = IGTL_TRANSFORM_SIZE;
 header.crc       = crc64((unsigned char*)transform, IGTL_TRANSFORM_SIZE, crc);
 
 strncpy(header.name, "TRANSFORM", 12);       /* Device Type: should be "TRANSFORM" */
 strncpy(header.device_name, "Tracker", 20);    /* Device name */
 
 igtl_header_convert_byte_order(h);   /* convert endian if necessary */

Then send package (in case of BSD socket)

 send(sock, (void*) &header, IGTL_HEADER_SIZE, 0);
 send(sock, (void*) transform, IGTL_TRANSFORM_SIZE, 0);