PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
igtlPlusTrackedFrameMessage.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2  Program: Plus
3  Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4  See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #ifndef __igtlPlusTrackedFrameMessage_h
8 #define __igtlPlusTrackedFrameMessage_h
9 
10 #include "vtkPlusOpenIGTLinkExport.h"
11 
12 #include "igsioTrackedFrame.h"
13 #include "igtl_types.h"
14 #include "igtl_win32header.h"
15 #include "igtlMessageBase.h"
16 #include "igtlObject.h"
17 #include "igtl_header.h"
18 #include "igtl_util.h"
19 #include "vtkMatrix4x4.h"
20 #include "vtkSmartPointer.h"
21 #include <string>
22 
23 namespace igtl
24 {
25  // This command prevents 4-byte alignment in the struct (which enables m_FrameSize[3])
26 #pragma pack(1) /* For 1-byte boundary in memory */
27 
33  class vtkPlusOpenIGTLinkExport PlusTrackedFrameMessage: public MessageBase
34  {
35  public:
36  igtlTypeMacro(igtl::PlusTrackedFrameMessage, igtl::MessageBase);
37  igtlNewMacro(igtl::PlusTrackedFrameMessage);
38 
39  public:
41  virtual igtl::MessageBase::Pointer Clone();
42 
44  PlusStatus SetTrackedFrame(const igsioTrackedFrame& trackedFrame, const std::vector<igsioTransformName>& requestedTransforms);
45 
47  igsioTrackedFrame GetTrackedFrame();
48 
50  PlusStatus SetEmbeddedImageTransform(vtkSmartPointer<vtkMatrix4x4> matrix);
51 
53  vtkSmartPointer<vtkMatrix4x4> GetEmbeddedImageTransform();
54 
55  protected:
57  {
58  public:
60  : m_ScalarType()
61  , m_NumberOfComponents(0)
62  , m_ImageType(0)
63  , m_ImageDataSizeInBytes(0)
64  , m_XmlDataSizeInBytes(0)
65  , m_ImageOrientation(0)
66  {
67  m_FrameSize[0] = m_FrameSize[1] = m_FrameSize[2] = 0;
68  for (int i = 0; i < 4; ++i)
69  {
70  for (int j = 0; j < 4; ++j)
71  {
72  m_EmbeddedImageTransform[i][j] = (i == j) ? 1.f : 0.f;
73  }
74  }
75  }
76 
78  {
79  size_t headersize = 0;
80  headersize += sizeof(igtl_uint16); // m_ScalarType
81  headersize += sizeof(igtl_uint16); // m_NumberOfComponents
82  headersize += sizeof(igtl_uint16); // m_ImageType
83  headersize += sizeof(igtl_uint16) * 3; // m_FrameSize[3]
84  headersize += sizeof(igtl_uint32); // m_ImageDataSizeInBytes
85  headersize += sizeof(igtl_uint32); // m_XmlDataSizeInBytes
86  headersize += sizeof(igtl_uint16); // m_ImageOrientation
87  headersize += sizeof(igtl::Matrix4x4); // m_EmbeddedImageTransform[4][4]
88 
89  return headersize;
90  }
91 
93  {
94  if (igtl_is_little_endian())
95  {
96  m_ScalarType = BYTE_SWAP_INT16(m_ScalarType);
97  m_NumberOfComponents = BYTE_SWAP_INT16(m_NumberOfComponents);
98  m_ImageType = BYTE_SWAP_INT16(m_ImageType);
99  m_FrameSize[0] = BYTE_SWAP_INT16(m_FrameSize[0]);
100  m_FrameSize[1] = BYTE_SWAP_INT16(m_FrameSize[1]);
101  m_FrameSize[2] = BYTE_SWAP_INT16(m_FrameSize[2]);
102  m_ImageDataSizeInBytes = BYTE_SWAP_INT32(m_ImageDataSizeInBytes);
103  m_XmlDataSizeInBytes = BYTE_SWAP_INT32(m_XmlDataSizeInBytes);
104  m_ImageOrientation = BYTE_SWAP_INT16(m_ImageOrientation);
105  }
106  }
107 
108  igtl_uint16 m_ScalarType; /* scalar type */
109  igtl_uint16 m_NumberOfComponents; /* number of scalar components */
110  igtl_uint16 m_ImageType; /* image type */
111  igtl_uint16 m_FrameSize[3]; /* entire image volume size */
112  igtl_uint32 m_ImageDataSizeInBytes; /* size of the image, in bytes */
113  igtl_uint32 m_XmlDataSizeInBytes; /* size of the xml data, in bytes */
114  igtl_uint16 m_ImageOrientation; /* orientation of the image */
115  igtl::Matrix4x4 m_EmbeddedImageTransform; /* matrix representing the IJK to world transformation */
116  };
117 
118  virtual igtlUint64 CalculateContentBufferSize();
119  virtual int PackContent();
120  virtual int UnpackContent();
121 
124 
125  igsioTrackedFrame m_TrackedFrame;
127 
129  };
130 
131 #pragma pack()
132 
133 } // namespace igtl
134 
135 #endif
igsioStatus PlusStatus
Definition: PlusCommon.h:40
for i
IGTL message helper class for tracked frame messages.