PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusDataSource.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 // .NAME vtkPlusDataSource - interfaces VTK to a handheld 3D positioning tool or video source
8 // .SECTION Description
9 // The vtkPlusDataSource provides an interface between a tracked object or video stream in
10 // the real world and a virtual object.
11 // .SECTION see also
12 // vtkPlusDevice vtkPlusBuffer vtkPlusChannel
13 
14 #ifndef __vtkPlusDataSource_h
15 #define __vtkPlusDataSource_h
16 
17 // Local includes
18 #include "vtkPlusDataCollectionExport.h"
19 #include "vtkPlusBuffer.h"
20 #include "vtkPlusDevice.h"
21 
22 // VTK includes
23 #include <vtkObject.h>
24 
32 class vtkPlusBuffer;
33 
35 {
40 };
41 
42 class vtkPlusDataCollectionExport vtkPlusDataSource : public vtkObject
43 {
44  typedef std::map< std::string, std::string > CustomPropertyMap;
45  typedef CustomPropertyMap::iterator CustomPropertyMapIterator;
46  typedef CustomPropertyMap::const_iterator CustomPropertyMapConstIterator;
47 
48 public:
49  static std::string DATA_SOURCE_TYPE_TOOL_TAG;
50  static std::string DATA_SOURCE_TYPE_VIDEO_TAG;
51  static std::string DATA_SOURCE_TYPE_FIELDDATA_TAG;
52 
53 public:
54  static vtkPlusDataSource* New();
55  vtkTypeMacro(vtkPlusDataSource, vtkObject);
56  virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
57 
59  virtual PlusStatus ReadConfiguration(vtkXMLDataElement* toolElement, bool requirePortNameInSourceConfiguration = false, bool requireImageOrientationInChannelConfiguration = false, const std::string& aDescriptiveNameForBuffer = std::string(""));
61  virtual PlusStatus WriteConfiguration(vtkXMLDataElement* toolElement);
63  virtual PlusStatus WriteCompactConfiguration(vtkXMLDataElement* toolElement);
64 
67  PlusStatus SetId(const char* aSourceId);
68  PlusStatus SetId(const std::string& aSourceId);
69  PlusStatus SetSourceId(const std::string& aSourceId);
71  vtkGetStdStringMacro(Id);
72  std::string GetSourceId() const;
73 
75  PlusStatus SetReferenceCoordinateFrameName(const char* referenceName);
76  PlusStatus SetReferenceCoordinateFrameName(const std::string& referenceName);
78  vtkGetStdStringMacro(ReferenceCoordinateFrameName);
79 
80  std::string GetTransformName() const;
81 
83  PlusStatus SetImageType(US_IMAGE_TYPE imageType);
85  US_IMAGE_TYPE GetImageType();
86 
88  PlusStatus SetInputFrameSize(unsigned int x, unsigned int y, unsigned int z);
90  PlusStatus SetInputFrameSize(const FrameSizeType& frameSize);
92  FrameSizeType GetInputFrameSize() const;
93 
98  virtual FrameSizeType GetOutputFrameSize() const;
99  virtual PlusStatus GetOutputFrameSize(unsigned int& _arg1, unsigned int& _arg2, unsigned int& _arg3) const;
100 
102  virtual void SetStartTime(double startTime);
104  virtual double GetStartTime();
105 
107  virtual int GetNumberOfItems();
108 
110  virtual ItemStatus GetIndex(const BufferItemUidType uid, unsigned long& index);
111 
119  virtual double GetFrameRate(bool ideal = false, double* framePeriodStdevSecPtr = NULL);
120 
122  virtual BufferItemUidType GetOldestItemUidInBuffer();
123  virtual BufferItemUidType GetLatestItemUidInBuffer();
124  virtual ItemStatus GetItemUidFromTime(double time, BufferItemUidType& uid);
125 
127  virtual bool GetLatestItemHasValidVideoData();
128 
130  virtual bool GetLatestItemHasValidTransformData();
131 
133  virtual bool GetLatestItemHasValidFieldData();
134 
136  virtual ItemStatus GetStreamBufferItem(BufferItemUidType uid, StreamBufferItem* bufferItem);
138  virtual ItemStatus GetLatestStreamBufferItem(StreamBufferItem* bufferItem);
140  virtual ItemStatus GetOldestStreamBufferItem(StreamBufferItem* bufferItem);
142  virtual ItemStatus GetStreamBufferItemFromTime(double time, StreamBufferItem* bufferItem, vtkPlusBuffer::DataItemTemporalInterpolationType interpolation);
144  virtual PlusStatus ModifyBufferItemFrameField(BufferItemUidType uid, const std::string& key, const std::string& value);
145 
147  virtual PlusStatus DeepCopyBufferTo(vtkPlusBuffer& bufferToFill);
148 
150  virtual void Clear();
151 
153  virtual PlusStatus WriteToSequenceFile(const char* filename, bool useCompression = false);
154 
156  virtual PlusStatus GetTimeStampReportTable(vtkTable* timeStampReportTable);
157 
159  void SetTimeStampReporting(bool enable);
161  bool GetTimeStampReporting();
162 
167  virtual PlusStatus SetBufferSize(int n);
169  virtual int GetBufferSize();
170 
172  virtual ItemStatus GetLatestTimeStamp(double& latestTimestamp);
173 
175  virtual ItemStatus GetOldestTimeStamp(double& oldestTimestamp);
176 
178  virtual ItemStatus GetTimeStamp(BufferItemUidType uid, double& timestamp);
179 
181  virtual void SetLocalTimeOffsetSec(double offsetSec);
183  virtual double GetLocalTimeOffsetSec();
184 
191  virtual PlusStatus AddItem(vtkImageData* frame,
192  US_IMAGE_ORIENTATION usImageOrientation,
193  US_IMAGE_TYPE imageType,
194  long frameNumber,
195  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
196  double filteredTimestamp = UNDEFINED_TIMESTAMP,
197  const igsioFieldMapType* customFields = NULL);
198 
205  virtual PlusStatus AddItem(const igsioVideoFrame* frame,
206  long frameNumber,
207  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
208  double filteredTimestamp = UNDEFINED_TIMESTAMP,
209  const igsioFieldMapType* customFields = NULL);
210 
219  virtual PlusStatus AddItem(void* imageDataPtr,
220  US_IMAGE_ORIENTATION usImageOrientation,
221  const FrameSizeType& frameSizeInPx,
223  unsigned int numberOfScalarComponents,
224  US_IMAGE_TYPE imageType,
225  int numberOfBytesToSkip,
226  long frameNumber,
227  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
228  double filteredTimestamp = UNDEFINED_TIMESTAMP,
229  const igsioFieldMapType* customFields = NULL);
230 
239  virtual PlusStatus AddItem(void* imageDataPtr,
240  const FrameSizeType& frameSize,
241  unsigned int frameSizeInBytes,
242  US_IMAGE_TYPE imageType,
243  long frameNumber,
244  double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
245  double filteredTimestamp = UNDEFINED_TIMESTAMP,
246  const igsioFieldMapType* customFields = NULL);
247 
254  virtual PlusStatus AddItem(const igsioFieldMapType& customFields, long frameNumber, double unfilteredTimestamp = UNDEFINED_TIMESTAMP, double filteredTimestamp = UNDEFINED_TIMESTAMP);
255 
261  PlusStatus AddTimeStampedItem(vtkMatrix4x4* matrix, ToolStatus status, unsigned long frameNumber, double unfilteredTimestamp, double filteredTimestamp = UNDEFINED_TIMESTAMP, const igsioFieldMapType* customFields = NULL);
262 
264  // TODO : consider a re-design of this idea
265  void SetDevice(vtkPlusDevice* _arg) { this->Device = _arg; }
266  vtkPlusDevice* GetDevice() { return this->Device; }
267 
269  vtkGetStdStringMacro(PortName);
271  PlusStatus SetPortName(const std::string& portName);
272  PlusStatus SetPortName(const char* portName);
273 
275  PlusStatus SetPixelType(igsioCommon::VTKScalarPixelType pixelType);
277  virtual igsioCommon::VTKScalarPixelType GetPixelType();
278 
280  PlusStatus SetNumberOfScalarComponents(unsigned int numberOfScalarComponents);
282  virtual unsigned int GetNumberOfScalarComponents();
283 
288  int GetNumberOfBytesPerPixel();
289 
297  virtual PlusStatus SetInputImageOrientation(US_IMAGE_ORIENTATION imageOrientation);
302  virtual US_IMAGE_ORIENTATION GetInputImageOrientation();
303 
308  virtual PlusStatus SetOutputImageOrientation(US_IMAGE_ORIENTATION imageOrientation);
309  virtual US_IMAGE_ORIENTATION GetOutputImageOrientation();
310 
312  vtkGetMacroConst(Type, DataSourceType);
313  vtkSetMacro(Type, DataSourceType);
314 
316  vtkGetMacroConst(FrameNumber, unsigned long);
317  vtkSetMacro(FrameNumber, unsigned long);
318 
323  std::string GetCustomProperty(const std::string& propertyName);
329  void SetCustomProperty(const std::string& propertyName, const std::string& propertyValue);
330 
332  void DeepCopy(const vtkPlusDataSource& source);
333 
338  std::array<int, 3> GetClipRectangleSize() const;
339 
344  std::array<int, 3> GetClipRectangleOrigin() const;
345 
351  void SetClipRectangleSize(const std::array<int, 3> _arg);
352 
357  void SetClipRectangleOrigin(const std::array<int, 3> _arg);
358 
359 protected:
361  virtual vtkPlusBuffer* GetBuffer() const;
362 
363 protected:
366 
368 
369  std::string PortName;
371  US_IMAGE_ORIENTATION InputImageOrientation;
372 
374 
375  unsigned long FrameNumber;
376 
377  std::string Id;
379 
381 
382  CustomPropertyMap CustomProperties;
383 
385  std::array<int, 3> ClipRectangleOrigin;
387  std::array<int, 3> ClipRectangleSize;
388 
389  FrameSizeType InputFrameSize;
390 
391 private:
393  void operator=(const vtkPlusDataSource&);
394 
395 };
396 
397 #endif
vtkPlusBuffer * Buffer
vtkPlusDevice * Device
const char * key
Definition: phidget22.h:5111
DataSourceType Type
DataItemTemporalInterpolationType
Definition: vtkPlusBuffer.h:45
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
std::string ReferenceCoordinateFrameName
const char * source
Definition: phidget22.h:2461
double * timestamp
Definition: phidget22.h:3432
igsioStatus PlusStatus
Definition: PlusCommon.h:40
static std::string DATA_SOURCE_TYPE_FIELDDATA_TAG
static std::string DATA_SOURCE_TYPE_VIDEO_TAG
#define VTK_OVERRIDE
Definition: PlusCommon.h:49
PhidgetGPS_Time * time
Definition: phidget22.h:3623
FrameSizeType InputFrameSize
CustomPropertyMap CustomProperties
DataSourceType
std::array< int, 3 > ClipRectangleSize
US_IMAGE_ORIENTATION InputImageOrientation
void SetDevice(vtkPlusDevice *_arg)
int x
Definition: phidget22.h:4265
unsigned long FrameNumber
const char const char * value
Definition: phidget22.h:5111
static std::string DATA_SOURCE_TYPE_TOOL_TAG
int VTKScalarPixelType
Definition: PlusCommon.h:55
vtkPlusDevice * GetDevice()
Direction vectors of rods y
Definition: algo3.m:15
std::array< int, 3 > ClipRectangleOrigin
unsigned long long BufferItemUidType
Interface to a 3D positioning tool, video source, or generalized data stream.