CustusX  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxIGTLinkUSStatusMessage.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
34 #include "igtl_header.h"
35 #include <string.h>
36 #include "igtl_us_status.h"
37 
38 namespace cx
39 {
40 
42  igtl::MessageBase(),
43  mProbeType(0)
44 {
45  AllocatePack();
46  m_StatusMessage = m_Body;
47  m_StatusMessage = NULL;
48 
49  for (int i = 0; i < 3; i ++)
50  {
51  mDataOrigin[i] = 0.0;
52  }
53 
54  m_DefaultBodyType = "CX_US_ST";
55 }
56 
58 {}
59 
61 {
62  mProbeType = probeType;
63 }
65 {
66  return mProbeType;
67 }
69 {
70  mDataOrigin[0] = o[0];
71  mDataOrigin[1] = o[1];
72  mDataOrigin[2] = o[2];
73 }
74 void IGTLinkUSStatusMessage::SetOrigin(double oi, double oj, double ok)
75 {
76  mDataOrigin[0] = oi;
77  mDataOrigin[1] = oj;
78  mDataOrigin[2] = ok;
79 }
80 
82 {
83  o[0] = mDataOrigin[0];
84  o[1] = mDataOrigin[1];
85  o[2] = mDataOrigin[2];
86 }
87 
88 const double* IGTLinkUSStatusMessage::GetOrigin() const
89 {
90  return mDataOrigin;
91 }
92 
93 void IGTLinkUSStatusMessage::GetOrigin(double &oi, double &oj, double &ok)
94 {
95  oi = mDataOrigin[0];
96  oj = mDataOrigin[1];
97  ok = mDataOrigin[2];
98 }
99 
101 {
102  mDepthStart = depthStart;
103 }
105 {
106  return mDepthStart;
107 }
109 {
110  mDepthEnd = depthEnd;
111 }
113 {
114  return mDepthEnd;
115 }
117 {
118  mWidth = width;
119 }
121 {
122  return mWidth;
123 }
124 void IGTLinkUSStatusMessage::SetDataFormat(std::string dataFormat)
125 {
126  mDataFormat = dataFormat;
127 }
129 {
130  return mDataFormat;
131 }
132 
134 {
135  // Allocate pack
136  AllocatePack();
137  m_StatusMessage = this->m_Body;
138 
139  // Set pointers
141 
142  //Copy data
143  statusMessage->originX = static_cast<igtl_float64>(this->mDataOrigin[0]);
144  statusMessage->originY = static_cast<igtl_float64>(this->mDataOrigin[1]);
145  statusMessage->originZ = static_cast<igtl_float64>(this->mDataOrigin[2]);
146  statusMessage->depthStart = static_cast<igtl_float64>(this->mDepthStart);
147  statusMessage->depthEnd = static_cast<igtl_float64>(this->mDepthEnd);
148  statusMessage->width = static_cast<igtl_float64>(this->mWidth);
149 
150  statusMessage->probeType = static_cast<igtl_int32>(this->mProbeType);
151  //TODO: string dataformat
152 
153  /*int originMemSpace = sizeof(igtl_float64)*3;
154  memcpy((*void)this->m_StatusMessage, (void*) mDataOrigin, originMemSpace);
155  memcpy((*void)this->m_StatusMessage[originMemSpace], (void*) mNewStatus, sizeof(igtl_uint8));*/
156 
157  // Convert byte order from host to network
158  igtl_us_status_convert_byte_order(statusMessage);
159 
160  return 1;
161 }
162 
164 {
166 }
167 
169 {
170  m_StatusMessage = this->m_Body;
171 
172  // Set pointers
174 
175  // Convert byte order from network to host
176  igtl_us_status_convert_byte_order(statusMessage);
177 
178  //Copy data
179  this->mDataOrigin[0] = statusMessage->originX;
180  this->mDataOrigin[1] = statusMessage->originY;
181  this->mDataOrigin[2] = statusMessage->originZ;
182  this->mDepthStart = statusMessage->depthStart;
183  this->mDepthEnd = statusMessage->depthEnd;
184  this->mWidth = statusMessage->width;
185  this->mProbeType = statusMessage->probeType;
186  //TODO: dataformat
187 
188  return 1;
189 }
190 }
#define IGTL_US_STATUS_HEADER_SIZE
void igtl_export igtl_us_status_convert_byte_order(igtl_us_status_message *message)