7 #ifndef __vtkPlusDevice_h 8 #define __vtkPlusDevice_h 11 #include "igsioCommon.h" 12 #include "PlusConfigure.h" 15 #include "vtkPlusDataCollectionExport.h" 18 #include <vtkImageAlgorithm.h> 19 #include <vtkMultiThreader.h> 20 #include <vtkStdString.h> 32 class vtkXMLDataElement;
60 class vtkPlusDataCollectionExport
vtkPlusDevice :
public vtkImageAlgorithm
65 virtual void PrintSelf(ostream& os, vtkIndent indent)
VTK_OVERRIDE;
79 virtual std::string GetSdkVersion();
82 virtual PlusStatus ReadConfiguration(vtkXMLDataElement*);
85 virtual PlusStatus WriteConfiguration(vtkXMLDataElement*);
106 virtual bool IsResettable();
118 static PlusStatus GetToolReferenceFrameFromTrackedFrame(igsioTrackedFrame& aFrame, std::string& aToolReferenceFrameName);
132 virtual PlusStatus SetBufferSize(
vtkPlusChannel& aChannel,
int FrameBufferSize,
const std::string& aSourceId = std::string(
""));
134 virtual PlusStatus GetBufferSize(
vtkPlusChannel& aChannel,
int& outVal,
const std::string& aSourceId = std::string(
""));
137 virtual void SetStartTime(
double startTime);
140 virtual double GetStartTime();
143 virtual bool IsTracker()
const;
145 virtual bool IsVirtual()
const;
154 void ClearAllBuffers();
157 virtual PlusStatus WriteToolsToSequenceFile(
const std::string& filename,
bool useCompression =
false);
163 double GetInternalUpdateRate()
const;
180 PlusStatus GetVideoSourcesByPortName(
const char* aPortName, std::vector<vtkPlusDataSource*>& sources);
181 PlusStatus GetVideoSourcesByPortName(
const std::string& aPortName, std::vector<vtkPlusDataSource*>& sources);
193 virtual int GetNumberOfTools()
const;
199 std::vector<vtkPlusDataSource*> GetVideoSources()
const;
217 virtual int GetNumberOfVideoSources()
const;
233 virtual int GetNumberOfFieldDataSources()
const;
236 void SetToolReferenceFrameName(
const std::string& frameName);
238 std::string GetToolReferenceFrameName()
const;
241 virtual bool GetCorrectlyConfigured()
const;
247 void SetToolsBufferSize(
int aBufferSize);
250 void SetFieldDataSourcesBufferSize(
int aBufferSize);
253 virtual void SetLocalTimeOffsetSec(
double aTimeOffsetSec);
254 virtual double GetLocalTimeOffsetSec()
const;
272 PlusStatus GetInputDevices(std::vector<vtkPlusDevice*>& outDeviceList)
const;
276 PlusStatus GetInputDevicesRecursive(std::vector<vtkPlusDevice*>& outDeviceList)
const;
280 virtual std::string GetParameter(
const std::string&
key)
const;
281 virtual PlusStatus GetParameter(
const std::string&
key, std::string& outValue)
const;
294 virtual double GetAcquisitionRate()
const;
298 virtual bool IsRecording()
const;
301 virtual std::string GetDeviceId()
const;
303 void SetDeviceId(
const std::string&
id);
309 virtual unsigned long GetFrameNumber()
const;
319 virtual double GetFrameTimeStamp()
const;
325 vtkSetMacro(UpdateWithDesiredTimestamp,
int);
330 vtkGetMacro(UpdateWithDesiredTimestamp,
int);
335 vtkBooleanMacro(UpdateWithDesiredTimestamp,
int);
341 vtkSetMacro(DesiredTimestamp,
double);
343 vtkGetMacro(DesiredTimestamp,
double);
346 vtkGetMacro(TimestampClosestToDesired,
double);
349 virtual int GetConnected()
const;
350 virtual bool IsConnected()
const;
389 virtual int OutputChannelCount()
const;
408 virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*);
414 virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*);
417 vtkSetMacro(MissingInputGracePeriodSec,
double);
418 double GetMissingInputGracePeriodSec()
const;
424 virtual PlusStatus CreateDefaultOutputChannel(
const char* channelId = NULL,
bool addSource =
true);
430 virtual PlusStatus GetImageMetaData(igsioCommon::ImageMetaDataList& imageMetaDataItems);
437 virtual PlusStatus GetImage(
const std::string& requestedImageId, std::string& assignedImageId,
const std::string& imageReferencFrameName, vtkImageData* imageData, vtkMatrix4x4* ijkToReferenceTransform);
443 virtual PlusStatus SendText(
const std::string& textToSend, std::string* textReceived = NULL);
446 static void* vtkDataCaptureThread(vtkMultiThreader::ThreadInfo*
data);
469 virtual PlusStatus AddVideoItemToVideoSources(
const std::vector<vtkPlusDataSource*>& videoSources,
const igsioVideoFrame& frame,
long frameNumber,
double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
470 double filteredTimestamp = UNDEFINED_TIMESTAMP,
const igsioFieldMapType* customFields = NULL);
475 virtual PlusStatus AddVideoItemToVideoSources(
const std::vector<vtkPlusDataSource*>& videoSources,
void* imageDataPtr, US_IMAGE_ORIENTATION usImageOrientation,
const FrameSizeType& frameSizeInPx,
476 igsioCommon::VTKScalarPixelType pixelType,
unsigned int numberOfScalarComponents, US_IMAGE_TYPE imageType,
int numberOfBytesToSkip,
long frameNumber,
double unfilteredTimestamp = UNDEFINED_TIMESTAMP,
477 double filteredTimestamp = UNDEFINED_TIMESTAMP,
const igsioFieldMapType* customFields = NULL);
484 virtual PlusStatus ToolTimeStampedUpdate(
const std::string& aToolSourceId, vtkMatrix4x4* matrix, ToolStatus status,
unsigned long frameNumber,
double unfilteredtimestamp,
const igsioFieldMapType* customFields = NULL);
492 virtual PlusStatus ToolTimeStampedUpdateWithoutFiltering(
const std::string& aToolSourceId, vtkMatrix4x4* matrix, ToolStatus status,
double unfilteredtimestamp,
double filteredtimestamp,
const igsioFieldMapType* customFields = NULL);
497 vtkXMLDataElement* FindThisDeviceElement(vtkXMLDataElement* rootXMLElement);
501 vtkXMLDataElement* FindOutputChannelElement(vtkXMLDataElement* rootXMLElement,
const char* aChannelId);
505 vtkXMLDataElement* FindInputChannelElement(vtkXMLDataElement* rootXMLElement,
const char* aChannelId);
509 virtual void InternalWriteOutputChannels(vtkXMLDataElement* rootXMLElement);
513 virtual void InternalWriteInputChannels(vtkXMLDataElement* rootXMLElement);
516 PlusStatus EnsureUniqueDataSourceId(
const std::string& aSourceId);
518 vtkSetMacro(CorrectlyConfigured,
bool);
520 vtkSetMacro(StartThreadForInternalUpdates,
bool);
521 bool GetStartThreadForInternalUpdates()
const;
523 vtkSetMacro(RecordingStartTime,
double);
524 double GetRecordingStartTime()
const;
528 bool HasGracePeriodExpired();
623 #define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement) \ 624 if( Superclass::ReadConfiguration(rootConfigElement) != PLUS_SUCCESS ) \ 626 LOG_ERROR("Unable to continue reading configuration of "<<this->GetClassName()<<". Generic device configuration reading failed."); \ 629 vtkXMLDataElement* deviceConfig = this->FindThisDeviceElement(rootConfigElement); \ 630 if (deviceConfig == NULL) \ 632 LOG_ERROR("Unable to continue configuration of "<<this->GetClassName()<<". Could not find corresponding element."); \ 636 #define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement) \ 637 if( Superclass::WriteConfiguration(rootConfigElement) == PLUS_FAIL ) \ 639 LOG_ERROR("Unable to continue writing configuration of "<<this->GetClassName()<<". Generic device configuration writing failed."); \ 642 vtkXMLDataElement* deviceConfig = this->FindThisDeviceElement(rootConfigElement); \ 643 if (deviceConfig == NULL) \ 645 LOG_ERROR("Cannot find or add "<<this->GetClassName()<<" device in XML tree"); \ DataSourceContainer::const_iterator DataSourceContainerConstIterator
static const int VIRTUAL_DEVICE_FRAME_RATE
std::string ToolReferenceFrameName
static const std::string RFMODE_PORT_NAME
vtkPlusDataCollector * DataCollector
Abstract interface for tracker and video devices.
std::vector< vtkPlusDevice * >::const_iterator DeviceCollectionConstIterator
std::map< std::string, vtkPlusDataSource * > DataSourceContainer
static const std::string PARAMETER_XML_ELEMENT_TAG
ChannelContainer InputChannels
static const std::string BMODE_PORT_NAME
bool RequirePortNameInDeviceSetConfiguration
StreamBufferMapContainer::iterator StreamBufferMapContainerIterator
std::vector< vtkPlusDevice * > DeviceCollection
DataSourceContainer VideoSources
std::map< std::string, std::string > Parameters
bool RequireImageOrientationInConfiguration
StreamBufferContainer::const_iterator StreamBufferContainerConstIterator
DataSourceContainer Tools
double LocalTimeOffsetSec
vtkMultiThreader * Threader
DataSourceContainer Fields
std::vector< vtkPlusBuffer * > StreamBufferContainer
double MissingInputGracePeriodSec
unsigned long FrameNumber
Manages devices that record image or positional data.
double RecordingStartTime
int OutputNeedsInitialization
StreamBufferMapContainer::const_iterator StreamBufferMapContainerConstIterator
vtkIGSIORecursiveCriticalSection * UpdateMutex
ChannelContainer::const_iterator ChannelContainerConstIterator
StreamBufferItem * CurrentStreamBufferItem
double InternalUpdateRate
int UpdateWithDesiredTimestamp
const char const char * value
bool StartThreadForInternalUpdates
static const std::string PARAMETERS_XML_ELEMENT_TAG
std::vector< vtkPlusDevice * >::iterator DeviceCollectionIterator
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
ChannelContainer OutputChannels
Direction vectors of rods y
double TimestampClosestToDesired
std::set< std::string > ReportedUnknownTools
std::vector< vtkPlusChannel * > ChannelContainer
StreamBufferContainer::iterator StreamBufferContainerIterator
class for generating basic html tags
ChannelContainer::iterator ChannelContainerIterator
std::map< int, vtkPlusBuffer * > StreamBufferMapContainer
Interface to a 3D positioning tool, video source, or generalized data stream.