PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusBuffer.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 /*=========================================================================
8 The following copyright notice is applicable to parts of this file:
9 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
10 All rights reserved.
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12 =========================================================================*/
13 
14 #ifndef __vtkPlusDataBuffer_h
15 #define __vtkPlusDataBuffer_h
16 
17 // Local includes
18 #include "igsioCommon.h"
19 #include "PlusConfigure.h"
20 #include "vtkPlusDataCollectionExport.h"
21 #include "PlusStreamBufferItem.h"
23 
24 //#include "igsioTrackedFrame.h"
25 
26 // VTK includes
27 #include <vtkObject.h>
28 
29 class vtkPlusDevice;
30 enum ToolStatus;
31 
32 //class vtkIGSIOTrackedFrameList;
33 
34 class vtkPlusDataCollectionExport vtkPlusBuffer : public vtkObject
35 {
36 public:
38  {
39  READ_FILTERED_AND_UNFILTERED_TIMESTAMPS = 0,
41  READ_FILTERED_IGNORE_UNFILTERED_TIMESTAMPS
42  };
43 
46  {
49  CLOSEST_TIME
50  };
51 
52  static vtkPlusBuffer* New();
53  vtkTypeMacro(vtkPlusBuffer, vtkObject);
54  virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
55 
60  virtual PlusStatus SetBufferSize(int n);
62  virtual int GetBufferSize();
63 
71  virtual PlusStatus AddItem(vtkImageData* frame,
72  US_IMAGE_ORIENTATION usImageOrientation,
73  US_IMAGE_TYPE imageType,
74  long frameNumber,
75  const std::array<int, 3>& clipRectangleOrigin,
76  const std::array<int, 3>& clipRectangleSize,
77  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
78  double filteredTimestamp = UNDEFINED_TIMESTAMP,
79  const igsioFieldMapType* customFields = NULL);
87  virtual PlusStatus AddItem(const igsioVideoFrame* frame,
88  long frameNumber,
89  const std::array<int, 3>& clipRectangleOrigin,
90  const std::array<int, 3>& clipRectangleSize,
91  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
92  double filteredTimestamp = UNDEFINED_TIMESTAMP,
93  const igsioFieldMapType* customFields = NULL);
103  virtual PlusStatus AddItem(void* imageDataPtr,
104  US_IMAGE_ORIENTATION usImageOrientation,
105  const FrameSizeType& inputFrameSizeInPx,
107  unsigned int numberOfScalarComponents,
108  US_IMAGE_TYPE imageType,
109  int numberOfBytesToSkip,
110  long frameNumber,
111  const std::array<int, 3>& clipRectangleOrigin,
112  const std::array<int, 3>& clipRectangleSize,
113  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
114  double filteredTimestamp = UNDEFINED_TIMESTAMP,
115  const igsioFieldMapType* customFields = NULL,
116  vtkStreamingVolumeFrame* encodedFrame = NULL);
117 
127  virtual PlusStatus AddItem(void* imageDataPtr,
128  const FrameSizeType& frameSize,
129  unsigned int frameSizeInBytes,
130  US_IMAGE_TYPE imageType,
131  long frameNumber,
132  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
133  double filteredTimestamp = UNDEFINED_TIMESTAMP,
134  const igsioFieldMapType* customFields = NULL);
135 
142  virtual PlusStatus AddItem(const igsioFieldMapType& fields,
143  long frameNumber,
144  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
145  double filteredTimestamp = UNDEFINED_TIMESTAMP);
146 
152  PlusStatus AddTimeStampedItem(vtkMatrix4x4* matrix, ToolStatus status, unsigned long frameNumber, double unfilteredTimestamp, double filteredTimestamp = UNDEFINED_TIMESTAMP, const igsioFieldMapType* customFields = NULL);
153 
155  virtual ItemStatus GetStreamBufferItem(BufferItemUidType uid, StreamBufferItem* bufferItem);
158  {
159  return this->GetStreamBufferItem(this->GetLatestItemUidInBuffer(), bufferItem);
160  };
163  {
164  return this->GetStreamBufferItem(this->GetOldestItemUidInBuffer(), bufferItem);
165  };
167  virtual ItemStatus GetStreamBufferItemFromTime(double time, StreamBufferItem* bufferItem, DataItemTemporalInterpolationType interpolation);
168  virtual PlusStatus ModifyBufferItemFrameField(BufferItemUidType uid, const std::string& key, const std::string& value);
169 
171  virtual ItemStatus GetLatestTimeStamp(double& latestTimestamp);
172 
174  virtual ItemStatus GetOldestTimeStamp(double& oldestTimestamp);
175 
177  virtual ItemStatus GetTimeStamp(BufferItemUidType uid, double& timestamp);
178 
180  virtual bool GetLatestItemHasValidVideoData();
181 
183  virtual bool GetLatestItemHasValidTransformData();
184 
186  virtual bool GetLatestItemHasValidFieldData();
187 
189  virtual ItemStatus GetIndex(const BufferItemUidType uid, unsigned long& index);
190 
195  ItemStatus GetBufferIndexFromTime(const double time, int& bufferIndex);
196 
199  {
200  return this->StreamBuffer->GetOldestItemUidInBuffer();
201  }
203  {
204  return this->StreamBuffer->GetLatestItemUidInBuffer();
205  }
207  {
208  return this->StreamBuffer->GetItemUidFromTime(time, uid);
209  }
210 
212  virtual void SetLocalTimeOffsetSec(double offsetSec);
214  virtual double GetLocalTimeOffsetSec();
215 
217  virtual int GetNumberOfItems()
218  {
219  return this->StreamBuffer->GetNumberOfItems();
220  }
221 
229  virtual double GetFrameRate(bool ideal = false, double* framePeriodStdevSecPtr = NULL)
230  {
231  return this->StreamBuffer->GetFrameRate(ideal, framePeriodStdevSecPtr);
232  }
233 
235  vtkSetMacro(MaxAllowedTimeDifference, double);
237  vtkGetMacro(MaxAllowedTimeDifference, double);
238 
247  PlusStatus CopyTransformFromTrackedFrameList(vtkIGSIOTrackedFrameList* sourceTrackedFrameList, TIMESTAMP_FILTERING_OPTION timestampFiltering, igsioTransformName& transformName);
248 
249 
251  virtual void DeepCopy(vtkPlusBuffer* buffer);
252 
254  virtual void Clear();
255 
257  virtual void SetAveragedItemsForFiltering(int averagedItemsForFiltering);
258 
259  virtual int GetAveragedItemsForFiltering();
260 
262  virtual void SetStartTime(double startTime);
264  virtual double GetStartTime();
265 
267  virtual PlusStatus GetTimeStampReportTable(vtkTable* timeStampReportTable);
268 
270  void SetTimeStampReporting(bool enable);
272  bool GetTimeStampReporting();
273 
275  PlusStatus SetFrameSize(unsigned int x, unsigned int y, unsigned int z, bool allocateFrames = true);
277  PlusStatus SetFrameSize(const FrameSizeType& frameSize, bool allocateFrames = true);
279  virtual FrameSizeType GetFrameSize() const;
280  virtual PlusStatus GetFrameSize(unsigned int& _arg1, unsigned int& _arg2, unsigned int& _arg3) const;
281 
283  PlusStatus SetPixelType(igsioCommon::VTKScalarPixelType pixelType);
285  vtkGetMacro(PixelType, igsioCommon::VTKScalarPixelType);
286 
288  PlusStatus SetNumberOfScalarComponents(unsigned int numberOfScalarComponents);
290  vtkGetMacro(NumberOfScalarComponents, unsigned int);
291 
293  PlusStatus SetImageType(US_IMAGE_TYPE imageType);
295  vtkGetMacro(ImageType, US_IMAGE_TYPE);
296 
298  PlusStatus SetImageOrientation(US_IMAGE_ORIENTATION imageOrientation);
300  vtkGetMacro(ImageOrientation, US_IMAGE_ORIENTATION);
301 
303  int GetNumberOfBytesPerScalar();
304 
309  int GetNumberOfBytesPerPixel();
310 
312  PlusStatus CopyImagesFromTrackedFrameList(vtkIGSIOTrackedFrameList* sourceTrackedFrameList, TIMESTAMP_FILTERING_OPTION timestampFiltering, bool copyFrameFields);
313 
315  virtual PlusStatus WriteToSequenceFile(const char* filename, bool useCompression = false);
316 
317  vtkGetStringMacro(DescriptiveName);
318  vtkSetStringMacro(DescriptiveName);
319 
320 protected:
321  vtkPlusBuffer();
322  ~vtkPlusBuffer();
323 
325  virtual PlusStatus AllocateMemoryForFrames();
326 
331  virtual bool CheckFrameFormat(const FrameSizeType& frameSizeInPx, igsioCommon::VTKScalarPixelType pixelType, US_IMAGE_TYPE imgType, int numberOfScalarComponents);
332 
334  PlusStatus GetPrevNextBufferItemFromTime(double time, StreamBufferItem& itemA, StreamBufferItem& itemB);
335 
341  virtual ItemStatus GetInterpolatedStreamBufferItemFromTime(double time, StreamBufferItem* bufferItem);
342 
344  virtual ItemStatus GetStreamBufferItemFromExactTime(double time, StreamBufferItem* bufferItem);
345 
347  virtual ItemStatus GetStreamBufferItemFromClosestTime(double time, StreamBufferItem* bufferItem);
348 
349 protected:
351  FrameSizeType FrameSize;
352 
355 
358 
360  US_IMAGE_TYPE ImageType;
361 
363  US_IMAGE_ORIENTATION ImageOrientation;
364 
368 
371 
373 
374 private:
376  void operator=(const vtkPlusBuffer&);
377 };
378 
379 #endif
const char * key
Definition: phidget22.h:5111
virtual ItemStatus GetOldestStreamBufferItem(StreamBufferItem *bufferItem)
DataItemTemporalInterpolationType
Definition: vtkPlusBuffer.h:45
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
FrameSizeType FrameSize
double * timestamp
Definition: phidget22.h:3432
igsioStatus PlusStatus
Definition: PlusCommon.h:40
virtual ItemStatus GetItemUidFromTime(double time, BufferItemUidType &uid)
This class stores an fixed number of timestamped items. It provides element retrieval based on timest...
US_IMAGE_ORIENTATION ImageOrientation
vtkPlusTimestampedCircularBuffer StreamItemCircularBuffer
double MaxAllowedTimeDifference
#define VTK_OVERRIDE
Definition: PlusCommon.h:49
virtual BufferItemUidType GetLatestItemUidInBuffer()
US_IMAGE_TYPE ImageType
virtual int GetNumberOfItems()
PhidgetGPS_Time * time
Definition: phidget22.h:3623
virtual double GetFrameRate(bool ideal=false, double *framePeriodStdevSecPtr=NULL)
unsigned int NumberOfScalarComponents
int x
Definition: phidget22.h:4265
const char const char * value
Definition: phidget22.h:5111
StreamItemCircularBuffer * StreamBuffer
int VTKScalarPixelType
Definition: PlusCommon.h:55
igsioCommon::VTKScalarPixelType PixelType
Direction vectors of rods y
Definition: algo3.m:15
virtual BufferItemUidType GetOldestItemUidInBuffer()
unsigned long long BufferItemUidType
char * DescriptiveName
virtual ItemStatus GetLatestStreamBufferItem(StreamBufferItem *bufferItem)