PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
PlusStreamBufferItem.cxx
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 #include "PlusConfigure.h"
8 #include "PlusStreamBufferItem.h"
9 #include "vtkMatrix4x4.h"
10 
11 //----------------------------------------------------------------------------
12 // DataBufferItem
13 //----------------------------------------------------------------------------
15  : FilteredTimeStamp(0)
16  , UnfilteredTimeStamp(0)
17  , Index(0)
18  , Uid(0)
19  , ValidTransformData(false)
20  , Matrix(vtkSmartPointer<vtkMatrix4x4>::New())
21  , Status(TOOL_OK)
22 {
23 }
24 
25 //----------------------------------------------------------------------------
27 {
28 }
29 
30 //----------------------------------------------------------------------------
32 {
33  this->Matrix = vtkSmartPointer<vtkMatrix4x4>::New();
34  this->Status = TOOL_OK;
35  *this = dataItem;
36 }
37 
38 //----------------------------------------------------------------------------
40 {
41  // Handle self-assignment
42  if (this == &dataItem)
43  {
44  return *this;
45  }
46 
47  this->Frame = dataItem.Frame;
48  this->FilteredTimeStamp = dataItem.FilteredTimeStamp;
50  this->Index = dataItem.Index;
51  this->Uid = dataItem.Uid;
52  this->FrameFields = dataItem.FrameFields;
53  this->Status = dataItem.Status;
54  this->Matrix->DeepCopy(dataItem.Matrix);
55  this->ValidTransformData = dataItem.ValidTransformData;
56 
57  return *this;
58 }
59 
60 //----------------------------------------------------------------------------
61 void StreamBufferItem::SetFrameField(std::string fieldName, std::string fieldValue, igsioFrameFieldFlags flags)
62 {
63  this->FrameFields[fieldName].first = flags;
64  this->FrameFields[fieldName].second = fieldValue;
65 }
66 
67 //----------------------------------------------------------------------------
68 std::string StreamBufferItem::GetFrameField(const std::string& fieldName) const
69 {
70  if (fieldName.empty())
71  {
72  LOG_ERROR("Unable to get frame field: field name is NULL!");
73  return "";
74  }
75 
76  igsioFieldMapType::const_iterator fieldIterator;
77  fieldIterator = this->FrameFields.find(fieldName);
78  if (fieldIterator != this->FrameFields.end())
79  {
80  return fieldIterator->second.second;
81  }
82  return "";
83 }
84 
85 //----------------------------------------------------------------------------
87 {
88  if (fieldName == NULL)
89  {
90  LOG_DEBUG("Failed to delete frame field - field name is NULL!");
91  return PLUS_FAIL;
92  }
93 
94  igsioFieldMapType::iterator field = this->FrameFields.find(fieldName);
95  if (field != this->FrameFields.end())
96  {
97  this->FrameFields.erase(field);
98  return PLUS_SUCCESS;
99  }
100  LOG_DEBUG("Failed to delete frame field - could find field " << fieldName);
101  return PLUS_FAIL;
102 }
103 
104 //----------------------------------------------------------------------------
105 PlusStatus StreamBufferItem::DeleteFrameField(const std::string& fieldName)
106 {
107  return this->DeleteFrameField(fieldName.c_str());
108 }
109 
110 //----------------------------------------------------------------------------
112 {
113  if (dataItem == NULL)
114  {
115  LOG_ERROR("Failed to deep copy data buffer item - buffer item NULL!");
116  return PLUS_FAIL;
117  }
118 
119  (*this) = (*dataItem);
120 
121  return PLUS_SUCCESS;
122 }
123 
124 //----------------------------------------------------------------------------
126 {
127  if (matrix == NULL)
128  {
129  LOG_ERROR("Failed to set matrix - input matrix is NULL!");
130  return PLUS_FAIL;
131  }
132 
133  ValidTransformData = true;
134 
135  this->Matrix->DeepCopy(matrix);
136 
137  return PLUS_SUCCESS;
138 }
139 
140 //----------------------------------------------------------------------------
141 PlusStatus StreamBufferItem::GetMatrix(vtkMatrix4x4* outputMatrix)
142 {
143  if (outputMatrix == NULL)
144  {
145  LOG_ERROR("Failed to copy matrix - output matrix is NULL!");
146  return PLUS_FAIL;
147  }
148 
149  outputMatrix->DeepCopy(this->Matrix);
150 
151  return PLUS_SUCCESS;
152 }
153 
154 //----------------------------------------------------------------------------
155 void StreamBufferItem::SetStatus(ToolStatus status)
156 {
157  this->Status = status;
158 }
159 
160 //----------------------------------------------------------------------------
161 ToolStatus StreamBufferItem::GetStatus() const
162 {
163  return this->Status;
164 }
165 
166 //----------------------------------------------------------------------------
168 {
169  return this->FrameFields.size() > 0;
170 }
ToolStatus GetStatus() const
igsioFieldMapType FrameFields
igsioStatus PlusStatus
Definition: PlusCommon.h:40
PlusStatus DeleteFrameField(const char *fieldName)
#define PLUS_FAIL
Definition: PlusCommon.h:43
bool HasValidFieldData() const
std::string GetFrameField(const std::string &fieldName) const
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
vtkSmartPointer< vtkMatrix4x4 > Matrix
PlusStatus GetMatrix(vtkMatrix4x4 *outputMatrix)
StreamBufferItem & operator=(StreamBufferItem const &dataItem)
igsioVideoFrame Frame
BufferItemUidType Uid
PlusStatus DeepCopy(StreamBufferItem *dataItem)
void SetFrameField(std::string fieldName, std::string fieldValue, igsioFrameFieldFlags flags=FRAMEFIELD_NONE)
const char int const char int flags
Definition: phidget22.h:2552
PlusStatus SetMatrix(vtkMatrix4x4 *matrix)
void SetStatus(ToolStatus status)