15 #include "mitkIGTException.h" 20 #include <itksys/SystemTools.hxx> 21 #include <itkMutexLockHolder.h> 29 m_AllTools(), m_ToolsMutex(nullptr), m_MultiThreader(nullptr), m_ThreadID(-1), m_RefreshRate(100), m_NumberOfControlPoints(20), m_GaussianNoiseEnabled(false),
30 m_MeanDistributionParam(0.0), m_DeviationDistributionParam(1.0)
64 t->SetToolName(toolName);
114 return static_cast<unsigned int>(this->
m_AllTools.size());
131 srand(time(
nullptr));
144 SplineType::ControlPointListType controlPoints;
151 SplineType::ControlPointType pos;
153 length += controlPoints.at(i - 1).EuclideanDistanceTo(pos);
154 controlPoints.push_back(pos);
156 controlPoints.push_back(controlPoints.at(0));
157 length += controlPoints.at(controlPoints.size() - 2).EuclideanDistanceTo(controlPoints.at(controlPoints.size() - 1));
160 SplineType::KnotListType knotList;
161 knotList.push_back(0.0);
163 knotList.push_back(i);
173 bool returnValue =
true;
187 throw std::invalid_argument(
"invalid index");
192 if (roundsPerSecond < 0.0001)
193 throw std::invalid_argument(
"Minimum tool speed is 0.0001 rounds per second");
199 throw std::invalid_argument(
"invalid index");
219 bool localStopTracking;
231 mitk::VirtualTrackingTool::Pointer currentTool = this->
GetInternalTool(i);
234 pos = currentTool->GetSpline()->EvaluateSpline(t);
241 std::random_device rd;
242 std::mt19937 generator(rd());
244 double noise = dist(generator);
248 currentTool->SetPosition(mp);
261 currentTool->SetOrientation(quat);
264 currentTool->SetTrackingError(2 * (rand() / (RAND_MAX + 1.0)));
265 currentTool->SetDataValid(
true);
266 currentTool->Modified();
279 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
280 if (pInfo ==
nullptr)
282 return ITK_THREAD_RETURN_VALUE;
284 if (pInfo->UserData ==
nullptr)
286 return ITK_THREAD_RETURN_VALUE;
290 if (trackingDevice !=
nullptr)
294 return ITK_THREAD_RETURN_VALUE;
void EnableGaussianNoise()
enable addition of Gaussian Noise to tracking coordinates
itk::FastMutexLock::Pointer m_ToolsMutex
mutex for coordinated access of tool container
double GetDeviationDistribution()
returns the deviation distribution for the Gaussian Noise
unsigned int m_NumberOfControlPoints
number of control points for the random path generation
ToolContainer m_AllTools
container for all tracking tools
itk::FastMutexLock::Pointer m_TrackingFinishedMutex
mutex to manage control flow of StopTracking()
static ITK_THREAD_RETURN_TYPE ThreadStartTracking(void *data)
static start method for tracking thread
TrackingTool * AddTool(const char *toolName)
Adds a tool to the tracking device.
bool m_GaussianNoiseEnabled
adding Gaussian Noise to tracking coordinates or not, false by default
double m_DeviationDistributionParam
mean distribution for Gaussion Noise, 0.0 by default
TrackingTool * GetTool(unsigned int toolNumber) const override
An object of this class represents an exception of the MITK-IGT module.
DataCollection - Class to facilitate loading/accessing structured data.
void SetParamsForGaussianNoise(double meanDistribution, double deviationDistribution)
sets the mean distribution and the standard deviation for the Gaussian Noise
itk::MutexLockHolder< itk::FastMutexLock > MutexLockHolder
TrackingDeviceState GetState() const
return current object state (Setup, Ready or Tracking)
itk::MultiThreader::Pointer m_MultiThreader
MultiThreader that starts continuous tracking update.
double GetMeanDistribution()
returns the mean distribution for the Gaussian Noise
void DisableGaussianNoise()
disable addition of Gaussian Noise to Trackin coordinates
mitk::VirtualTrackingTool * GetInternalTool(unsigned int idx)
bool m_StopTracking
signal stop to tracking thread
void TrackTools()
This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means ge...
bool CloseConnection() override
Closes the connection and clears all resources.
Interface for all Tracking Devices.
static IGTTimeStamp * GetInstance()
returns a pointer to the current instance of mitkTimeStamp
vnl_quaternion< ScalarType > Quaternion
void Start(itk::Object::Pointer device)
starts the time-acquisition
bool OpenConnection() override
Opens the connection to the device. This have to be done before the tracking is started.
mitk::VirtualTrackingTool::SplineType::ControlPointType ControlPointType
bool StartTracking() override
Starts the tracking.
unsigned int m_RefreshRate
refresh rate of the internal tracking thread in milliseconds (NOT refreshs per second!) ...
void InitializeSpline(mitk::VirtualTrackingTool *t)
initializes the spline path of the tool t with random control points inside the current tracking volu...
TrackingDeviceData m_Data
current device Data
void itk2vtk(const Tin &in, Tout &out)
#define mitkThrowException(classname)
mitk::ScalarType m_Bounds[6]
bounding box of the tracking volume stored as {xMin, xMax, yMin, yMax, zMin, zMax} ...
itk::FastMutexLock::Pointer m_StopTrackingMutex
mutex to control access to m_StopTracking
unsigned int GetToolCount() const override
void Stop(itk::Object::Pointer device)
stops the time-acqusition
void SetToolSpeed(unsigned int idx, mitk::ScalarType roundsPerSecond)
sets the speed of the tool idx in rounds per second
~VirtualTrackingDevice() override
void SetState(TrackingDeviceState state)
change object state
ControlPointType GetRandomPoint()
returns a random position inside the tracking volume (defined by m_Bounds)
Class representing a tracking device which generates random positions / orientations. No hardware is needed for tracking device.
bool StopTracking() override
Stops the tracking.
mitk::ScalarType GetSplineChordLength(unsigned int idx)
return the approximate length of the spline for tool with index idx in millimeter ...
double m_MeanDistributionParam