Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::VirtualTrackingDevice Class Reference

Class representing a tracking device which generates random positions / orientations. No hardware is needed for tracking device. More...

#include <mitkVirtualTrackingDevice.h>

Inheritance diagram for mitk::VirtualTrackingDevice:
Collaboration diagram for mitk::VirtualTrackingDevice:

Public Member Functions

 mitkClassMacro (VirtualTrackingDevice, TrackingDevice)
 
Pointer Clone () const
 
virtual void SetRefreshRate (unsigned int _arg)
 Sets the refresh rate of the virtual tracking device in ms. More...
 
virtual unsigned int GetRefreshRate () const
 Returns the refresh rate in ms. More...
 
virtual bool StartTracking () override
 Starts the tracking. More...
 
virtual bool StopTracking () override
 Stops the tracking. More...
 
virtual bool OpenConnection () override
 Opens the connection to the device. This have to be done before the tracking is started. More...
 
virtual bool CloseConnection () override
 Closes the connection and clears all resources. More...
 
virtual unsigned int GetToolCount () const override
 
TrackingToolGetTool (unsigned int toolNumber) const override
 
TrackingToolAddTool (const char *toolName)
 Adds a tool to the tracking device. More...
 
virtual void SetBounds (mitk::ScalarType data[])
 Set the tracking volume bounds. More...
 
const mitk::ScalarTypeGetBounds () const
 return the tracking volume bounds More...
 
mitk::ScalarType GetSplineChordLength (unsigned int idx)
 return the approximate length of the spline for tool with index idx in millimeter More...
 
void SetToolSpeed (unsigned int idx, mitk::ScalarType roundsPerSecond)
 sets the speed of the tool idx in rounds per second More...
 
void EnableGaussianNoise ()
 enable addition of Gaussian Noise to tracking coordinates More...
 
void DisableGaussianNoise ()
 disable addition of Gaussian Noise to Trackin coordinates More...
 
void SetParamsForGaussianNoise (double meanDistribution, double deviationDistribution)
 sets the mean distribution and the standard deviation for the Gaussian Noise More...
 
double GetMeanDistribution ()
 returns the mean distribution for the Gaussian Noise More...
 
double GetDeviationDistribution ()
 returns the deviation distribution for the Gaussian Noise More...
 
- Public Member Functions inherited from mitk::TrackingDevice
 mitkClassMacroItkParent (TrackingDevice, itk::Object)
 
virtual mitk::TrackingToolGetToolByName (std::string name) const
 Returns the tool with the given tool name. More...
 
virtual void SetRotationMode (RotationMode r)
 
virtual RotationMode GetRotationMode () const
 
TrackingDeviceState GetState () const
 return current object state (Setup, Ready or Tracking) More...
 
TrackingDeviceType GetType () const
 Deprecated! Use the more specific getDeviceData instead. return device type identifier. More...
 
void SetType (TrackingDeviceType type)
 Deprecated! Use the more specific setDeviceData instead. set device type. More...
 
TrackingDeviceData GetData () const
 return device data More...
 
void SetData (TrackingDeviceData data)
 set device type More...
 
virtual bool IsDeviceInstalled ()
 

Static Public Member Functions

static Pointer New ()
 

Protected Types

typedef mitk::VirtualTrackingTool::SplineType::ControlPointType ControlPointType
 
typedef std::vector< VirtualTrackingTool::Pointer > ToolContainer
 container type for tracking tools More...
 

Protected Member Functions

 VirtualTrackingDevice ()
 
 ~VirtualTrackingDevice ()
 
void TrackTools ()
 This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means generating random numbers for the tool position and orientation. More...
 
void InitializeSpline (mitk::VirtualTrackingTool *t)
 initializes the spline path of the tool t with random control points inside the current tracking volume More...
 
ControlPointType GetRandomPoint ()
 returns a random position inside the tracking volume (defined by m_Bounds) More...
 
mitk::VirtualTrackingToolGetInternalTool (unsigned int idx)
 
- Protected Member Functions inherited from mitk::TrackingDevice
void SetState (TrackingDeviceState state)
 change object state More...
 
 TrackingDevice ()
 
virtual ~TrackingDevice ()
 

Static Protected Member Functions

static ITK_THREAD_RETURN_TYPE ThreadStartTracking (void *data)
 static start method for tracking thread More...
 

Protected Attributes

ToolContainer m_AllTools
 container for all tracking tools More...
 
itk::FastMutexLock::Pointer m_ToolsMutex
 mutex for coordinated access of tool container More...
 
itk::MultiThreader::Pointer m_MultiThreader
 MultiThreader that starts continuous tracking update. More...
 
int m_ThreadID
 
unsigned int m_RefreshRate
 refresh rate of the internal tracking thread in milliseconds (NOT refreshs per second!) More...
 
unsigned int m_NumberOfControlPoints
 number of control points for the random path generation More...
 
mitk::ScalarType m_Bounds [6]
 bounding box of the tracking volume stored as {xMin, xMax, yMin, yMax, zMin, zMax} More...
 
bool m_GaussianNoiseEnabled
 adding Gaussian Noise to tracking coordinates or not, false by default More...
 
double m_MeanDistributionParam
 
double m_DeviationDistributionParam
 mean distribution for Gaussion Noise, 0.0 by default More...
 
- Protected Attributes inherited from mitk::TrackingDevice
TrackingDeviceData m_Data
 current device Data More...
 
bool m_StopTracking
 signal stop to tracking thread More...
 
itk::FastMutexLock::Pointer m_StopTrackingMutex
 mutex to control access to m_StopTracking More...
 
itk::FastMutexLock::Pointer m_TrackingFinishedMutex
 mutex to manage control flow of StopTracking() More...
 
itk::FastMutexLock::Pointer m_StateMutex
 mutex to control access to m_State More...
 
RotationMode m_RotationMode
 defines the rotation mode Standard or Transposed, Standard is default More...
 

Additional Inherited Members

- Public Types inherited from mitk::TrackingDevice
enum  RotationMode { RotationStandard, RotationTransposed }
 
enum  TrackingDeviceState { Setup, Ready, Tracking }
 

Detailed Description

Class representing a tracking device which generates random positions / orientations. No hardware is needed for tracking device.

Documentation This TrackingDevice class does not interface with a physical tracking device. It simulates a tracking device by moving the tools on a randomly generated spline path.

Definition at line 39 of file mitkVirtualTrackingDevice.h.

Member Typedef Documentation

typedef std::vector<VirtualTrackingTool::Pointer> mitk::VirtualTrackingDevice::ToolContainer
protected

container type for tracking tools

Definition at line 204 of file mitkVirtualTrackingDevice.h.

Constructor & Destructor Documentation

mitk::VirtualTrackingDevice::VirtualTrackingDevice ( )
protected
mitk::VirtualTrackingDevice::~VirtualTrackingDevice ( )
protected

Definition at line 42 of file mitkVirtualTrackingDevice.cpp.

Member Function Documentation

mitk::TrackingTool * mitk::VirtualTrackingDevice::AddTool ( const char *  toolName)

Adds a tool to the tracking device.

The tool will have a random path on which it will move around. The path is created with a spline function and random control points inside the tracking volume.

Parameters
toolNameThe tool which will be added.
Returns
Returns true if the tool has been added, false otherwise.

Definition at line 61 of file mitkVirtualTrackingDevice.cpp.

References mitk::VirtualTrackingTool::New().

Pointer mitk::VirtualTrackingDevice::Clone ( ) const
bool mitk::VirtualTrackingDevice::CloseConnection ( )
overridevirtual

Closes the connection and clears all resources.

Implements mitk::TrackingDevice.

Definition at line 174 of file mitkVirtualTrackingDevice.cpp.

References Setup().

void mitk::VirtualTrackingDevice::DisableGaussianNoise ( )

disable addition of Gaussian Noise to Trackin coordinates

Definition at line 315 of file mitkVirtualTrackingDevice.cpp.

void mitk::VirtualTrackingDevice::EnableGaussianNoise ( )

enable addition of Gaussian Noise to tracking coordinates

Definition at line 310 of file mitkVirtualTrackingDevice.cpp.

const mitk::ScalarType* mitk::VirtualTrackingDevice::GetBounds ( ) const
inline

return the tracking volume bounds

This will return the tracking volume as an axis aligned bounding box defined by the six bounds values xMin, xMax, yMin, yMax, zMin, zMax

Definition at line 131 of file mitkVirtualTrackingDevice.h.

double mitk::VirtualTrackingDevice::GetDeviationDistribution ( )

returns the deviation distribution for the Gaussian Noise

Definition at line 326 of file mitkVirtualTrackingDevice.cpp.

mitk::VirtualTrackingTool * mitk::VirtualTrackingDevice::GetInternalTool ( unsigned int  idx)
protected

Definition at line 205 of file mitkVirtualTrackingDevice.cpp.

double mitk::VirtualTrackingDevice::GetMeanDistribution ( )

returns the mean distribution for the Gaussian Noise

Definition at line 331 of file mitkVirtualTrackingDevice.cpp.

mitk::VirtualTrackingDevice::ControlPointType mitk::VirtualTrackingDevice::GetRandomPoint ( )
protected

returns a random position inside the tracking volume (defined by m_Bounds)

Definition at line 300 of file mitkVirtualTrackingDevice.cpp.

virtual unsigned int mitk::VirtualTrackingDevice::GetRefreshRate ( ) const
virtual

Returns the refresh rate in ms.

Returns
Returns the refresh rate in ms.
mitk::ScalarType mitk::VirtualTrackingDevice::GetSplineChordLength ( unsigned int  idx)

return the approximate length of the spline for tool with index idx in millimeter

if the index idx is not a valid tool index, a std::invalid_argument exception is thrown. GetSplineChordLength() returns the distance between all control points of the spline in millimeter. This can be used as an approximation for the length of the spline path.

Definition at line 184 of file mitkVirtualTrackingDevice.cpp.

References mitk::VirtualTrackingTool::GetSplineLength().

mitk::TrackingTool * mitk::VirtualTrackingDevice::GetTool ( unsigned int  toolNumber) const
overridevirtual
Parameters
toolNumberThe number of the tool which should be given back.
Returns
Returns the tool which the number "toolNumber". Returns NULL, if there is no tool with this number.

Implements mitk::TrackingDevice.

Definition at line 120 of file mitkVirtualTrackingDevice.cpp.

unsigned int mitk::VirtualTrackingDevice::GetToolCount ( ) const
overridevirtual
Returns
Returns the number of tools which have been added to the device.

Implements mitk::TrackingDevice.

Definition at line 114 of file mitkVirtualTrackingDevice.cpp.

void mitk::VirtualTrackingDevice::InitializeSpline ( mitk::VirtualTrackingTool t)
protected
mitk::VirtualTrackingDevice::mitkClassMacro ( VirtualTrackingDevice  ,
TrackingDevice   
)
static Pointer mitk::VirtualTrackingDevice::New ( )
static
bool mitk::VirtualTrackingDevice::OpenConnection ( )
overridevirtual

Opens the connection to the device. This have to be done before the tracking is started.

Exceptions
mitk::IGTExceptionThrows an exception if there are two less control points to start the the virtual device.

Implements mitk::TrackingDevice.

Definition at line 128 of file mitkVirtualTrackingDevice.cpp.

References mitkThrowException.

virtual void mitk::VirtualTrackingDevice::SetBounds ( mitk::ScalarType  data[])
virtual

Set the tracking volume bounds.

This will set the tracking volume as an axis aligned bounding box defined by the six bounds values xMin, xMax, yMin, yMax, zMin, zMax. Note that the random path of existing tools will not be updated with the new tracking volume. Tools that are created after calling SetBounds() will use the new tracking volume

void mitk::VirtualTrackingDevice::SetParamsForGaussianNoise ( double  meanDistribution,
double  deviationDistribution 
)

sets the mean distribution and the standard deviation for the Gaussian Noise

Definition at line 320 of file mitkVirtualTrackingDevice.cpp.

virtual void mitk::VirtualTrackingDevice::SetRefreshRate ( unsigned int  _arg)
virtual

Sets the refresh rate of the virtual tracking device in ms.

Warning
This refresh rate is not guaranteed. A thread is used to refresh the positions of the virtual tools. However, this thread may not run at all during this refresh time period.
Returns
Sets the refresh rate of the virtual tracking device in ms
void mitk::VirtualTrackingDevice::SetToolSpeed ( unsigned int  idx,
mitk::ScalarType  roundsPerSecond 
)

sets the speed of the tool idx in rounds per second

The virtual tools will travel along a closed spline path. This method sets the speed of a tool as a factor of how many rounds per second the tool should move. A setting of 1.0 will indicate one complete round per second. Together with GetSplineChordLength(), the speed in millimeter per second can be estimated. roundsPerSecond must be positive and larger than 0.0001.

Warning
Tool speed is currently not used. : use tool speed

Definition at line 193 of file mitkVirtualTrackingDevice.cpp.

References mitk::VirtualTrackingTool::SetVelocity().

bool mitk::VirtualTrackingDevice::StartTracking ( )
overridevirtual

Starts the tracking.

After StartTracking() is called, the tools will move on their spline paths with a constant velocity that can be set with SetToolSpeed(). The standard velocity is 10 seconds for one complete cycle along the spline path.

Warning
tool speed is not yet used in the current version
Returns
Returns true if the tracking is started. Returns false if there was an error.

Implements mitk::TrackingDevice.

Definition at line 76 of file mitkVirtualTrackingDevice.cpp.

References mitk::IGTTimeStamp::GetInstance(), mitk::New(), and mitk::IGTTimeStamp::Start().

bool mitk::VirtualTrackingDevice::StopTracking ( )
overridevirtual

Stops the tracking.

Returns
Returns true if the tracking is stopped. Returns false if there was an error.

Reimplemented from mitk::TrackingDevice.

Definition at line 96 of file mitkVirtualTrackingDevice.cpp.

References mitk::IGTTimeStamp::GetInstance(), and mitk::IGTTimeStamp::Stop().

ITK_THREAD_RETURN_TYPE mitk::VirtualTrackingDevice::ThreadStartTracking ( void *  data)
staticprotected

static start method for tracking thread

Definition at line 279 of file mitkVirtualTrackingDevice.cpp.

References m_ThreadID, and TrackTools().

void mitk::VirtualTrackingDevice::TrackTools ( )
protected

This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means generating random numbers for the tool position and orientation.

Exceptions
mitk::IGTExceptionThrows an mitk::IGTException if there is an error during virtual tool tracking.

Definition at line 214 of file mitkVirtualTrackingDevice.cpp.

References mitk::itk2vtk().

Referenced by ThreadStartTracking().

Member Data Documentation

ToolContainer mitk::VirtualTrackingDevice::m_AllTools
protected

container for all tracking tools

Definition at line 205 of file mitkVirtualTrackingDevice.h.

mitk::ScalarType mitk::VirtualTrackingDevice::m_Bounds[6]
protected

bounding box of the tracking volume stored as {xMin, xMax, yMin, yMax, zMin, zMax}

Definition at line 214 of file mitkVirtualTrackingDevice.h.

Referenced by VirtualTrackingDevice().

double mitk::VirtualTrackingDevice::m_DeviationDistributionParam
protected

mean distribution for Gaussion Noise, 0.0 by default

deviation distribution for Gaussian Noise, 1.0 by default

Definition at line 217 of file mitkVirtualTrackingDevice.h.

bool mitk::VirtualTrackingDevice::m_GaussianNoiseEnabled
protected

adding Gaussian Noise to tracking coordinates or not, false by default

Definition at line 215 of file mitkVirtualTrackingDevice.h.

double mitk::VirtualTrackingDevice::m_MeanDistributionParam
protected

Definition at line 216 of file mitkVirtualTrackingDevice.h.

itk::MultiThreader::Pointer mitk::VirtualTrackingDevice::m_MultiThreader
protected

MultiThreader that starts continuous tracking update.

Definition at line 208 of file mitkVirtualTrackingDevice.h.

unsigned int mitk::VirtualTrackingDevice::m_NumberOfControlPoints
protected

number of control points for the random path generation

Definition at line 212 of file mitkVirtualTrackingDevice.h.

unsigned int mitk::VirtualTrackingDevice::m_RefreshRate
protected

refresh rate of the internal tracking thread in milliseconds (NOT refreshs per second!)

Definition at line 211 of file mitkVirtualTrackingDevice.h.

int mitk::VirtualTrackingDevice::m_ThreadID
protected

Definition at line 209 of file mitkVirtualTrackingDevice.h.

Referenced by ThreadStartTracking().

itk::FastMutexLock::Pointer mitk::VirtualTrackingDevice::m_ToolsMutex
protected

mutex for coordinated access of tool container

Definition at line 206 of file mitkVirtualTrackingDevice.h.

Referenced by VirtualTrackingDevice().


The documentation for this class was generated from the following files: