Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtlTrackingDataMessage.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Open IGT Link Library
00004   Module:    $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink2_beta/Source/igtlImgmetaMessage.h $
00005   Language:  C++
00006   Date:      $Date: 2009-12-16 23:58:02 -0500 (Wed, 16 Dec 2009) $
00007   Version:   $Revision: 5466 $
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 __igtlTrackingDataMessage_h
00018 #define __igtlTrackingDataMessage_h
00019 
00020 #include <vector>
00021 #include <string>
00022 
00023 #include "igtlObject.h"
00024 //#include "igtlMacros.h"
00025 #include "igtlMath.h"
00026 #include "igtlMessageBase.h"
00027 #include "igtlTypes.h"
00028 
00029 
00030 namespace igtl
00031 {
00032 
00033 class IGTLCommon_EXPORT TrackingDataElement: public Object
00034 {
00035 public:
00036   typedef TrackingDataElement               Self;
00037   typedef Object                         Superclass;
00038   typedef SmartPointer<Self>             Pointer;
00039   typedef SmartPointer<const Self>       ConstPointer;
00040 
00041   igtlTypeMacro(igtl::TrackingDataElement, igtl::Object);
00042   igtlNewMacro(igtl::TrackingDataElement);
00043 
00044   // Tracking data type
00045   enum {
00046     TYPE_TRACKER  = 1,  /* Tracker */
00047     TYPE_6D       = 2,  /* 6D instrument (regular instrument) */
00048     TYPE_3D       = 3,  /* 3D instrument (only tip of the instrument defined) */
00049     TYPE_5D       = 4,  /* 5D instrument (tip and handle are defined,
00050                            but not the normal vector) */
00051   };
00052 
00053 public:
00054   int           SetName(const char* name);
00055   const char*   GetName()                            { return this->m_Name.c_str(); };
00056 
00057   int           SetType(igtlUint8 type);
00058   igtlUint8     GetType()                            { return this->m_Type; };
00059 
00060   void SetPosition(float p[3]);
00061   void GetPosition(float p[3]);
00062 
00063   void SetPosition(float px, float py, float pz);
00064   void GetPosition(float* px, float* py, float* pz);
00065 
00066   void SetMatrix(Matrix4x4& mat);
00067   void GetMatrix(Matrix4x4& mat);
00068 
00069 protected:
00070   TrackingDataElement();
00071   ~TrackingDataElement();
00072 
00073 protected:
00074 
00075   std::string   m_Name;          /* Name / description (< 20 bytes) */
00076   igtlUint8     m_Type;          /* Tracking data type (TYPE_TRACKER, TYPE_6D, TYPE_3D, TYPE_5D) */
00077   Matrix4x4     m_Matrix;        /* Transform matrix */
00078 };
00079 
00080 
00081 class IGTLCommon_EXPORT StartTrackingDataMessage: public MessageBase
00082 {
00083 
00084 public:
00085   typedef StartTrackingDataMessage       Self;
00086   typedef MessageBase                    Superclass;
00087   typedef SmartPointer<Self>             Pointer;
00088   typedef SmartPointer<const Self>       ConstPointer;
00089 
00090   igtlTypeMacro(igtl::StartTrackingDataMessage, igtl::MessageBase);
00091   igtlNewMacro(igtl::StartTrackingDataMessage);
00092 
00093 public:
00094   void         SetResolution(igtlInt32 res)  { this->m_Resolution = res; }; // ms
00095   igtlInt32    GetResolution()               { return this->m_Resolution; };
00096 
00097   int          SetCoordinateName(const char* name);
00098   const char*  GetCoordinateName()            { return this->m_CoordinateName.c_str(); };
00099 
00100 protected:
00101   StartTrackingDataMessage();
00102   ~StartTrackingDataMessage();
00103 
00104 protected:
00105   virtual int  GetBodyPackSize();
00106   virtual int  PackBody();
00107   virtual int  UnpackBody();
00108 
00109 protected:
00110   igtlInt32     m_Resolution;     /* Minimum time between two frames (ms). Use 0 for as fast as possible. */
00111   std::string   m_CoordinateName; /* Name of the coordinate system */
00112 
00113 };
00114 
00115 
00116 class IGTLCommon_EXPORT StopTrackingDataMessage: public MessageBase
00117 {
00118 public:
00119   typedef StopTrackingDataMessage        Self;
00120   typedef MessageBase                    Superclass;
00121   typedef SmartPointer<Self>             Pointer;
00122   typedef SmartPointer<const Self>       ConstPointer;
00123 
00124   igtlTypeMacro(igtl::StopTrackingDataMessage, igtl::MessageBase);
00125   igtlNewMacro(igtl::StopTrackingDataMessage);
00126 
00127 protected:
00128   StopTrackingDataMessage() : MessageBase() { this->m_DefaultBodyType  = "STP_TDATA"; };
00129   ~StopTrackingDataMessage() {};
00130 
00131 protected:
00132   virtual int  GetBodyPackSize() { return 0; };
00133   virtual int  PackBody()        { AllocatePack(); return 1; };
00134   virtual int  UnpackBody()      { return 1; };
00135 
00136 };
00137 
00138 
00139 class IGTLCommon_EXPORT RTSTrackingDataMessage: public MessageBase
00140 {
00141 public:
00142   typedef RTSTrackingDataMessage         Self;
00143   typedef MessageBase                    Superclass;
00144   typedef SmartPointer<Self>             Pointer;
00145   typedef SmartPointer<const Self>       ConstPointer;
00146 
00147   // Status type
00148   enum {
00149     STATUS_SUCCESS = 0,
00150     STATUS_ERROR = 1
00151   };
00152 
00153 
00154   igtlTypeMacro(igtl::RTSTrackingDataMessage, igtl::MessageBase);
00155   igtlNewMacro(igtl::RTSTrackingDataMessage);
00156 
00157   void          SetStatus(igtlUint8 status){ this->m_Status = status; }
00158   igtlUint8     GetStatus()                { return this->m_Status; };
00159 
00160 protected:
00161   RTSTrackingDataMessage() : MessageBase(), m_Status(0) { this->m_DefaultBodyType  = "RTS_TDATA"; };
00162   ~RTSTrackingDataMessage() {};
00163 
00164   igtlUint8 m_Status;
00165 
00166 protected:
00167   virtual int  GetBodyPackSize();
00168   virtual int  PackBody();
00169   virtual int  UnpackBody();
00170 
00171 };
00172 
00173 
00174 
00175 class IGTLCommon_EXPORT TrackingDataMessage: public MessageBase
00176 {
00177 public:
00178   typedef TrackingDataMessage            Self;
00179   typedef MessageBase                    Superclass;
00180   typedef SmartPointer<Self>             Pointer;
00181   typedef SmartPointer<const Self>       ConstPointer;
00182 
00183   igtlTypeMacro(igtl::TrackingDataMessage, igtl::MessageBase);
00184   igtlNewMacro(igtl::TrackingDataMessage);
00185 
00186 public:
00187   int  AddTrackingDataElement(TrackingDataElement::Pointer& elem);
00188   void ClearTrackingDataElements();
00189 
00190   int  GetNumberOfTrackingDataElements();
00191   inline int  GetNumberOfTrackingDataElement() { return GetNumberOfTrackingDataElements(); }; // will be removed.
00192   void GetTrackingDataElement(int index, TrackingDataElement::Pointer& elem);
00193 
00194 
00195 protected:
00196   TrackingDataMessage();
00197   ~TrackingDataMessage();
00198   
00199 protected:
00200 
00201   virtual int  GetBodyPackSize();
00202   virtual int  PackBody();
00203   virtual int  UnpackBody();
00204   
00205   std::vector<TrackingDataElement::Pointer> m_TrackingDataList;
00206   
00207 };
00208 
00209 
00210 } // namespace igtl
00211 
00212 #endif // _igtlTrackingDataMessage_h
00213 
00214 
00215 
00216 

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