MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNDIAuroraTypeInformation.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14
15#include "mitkIGTHardwareException.h"
17
18namespace mitk
19{
21 {
22 return "NDI Aurora";
23 }
24
26 {
27 TrackingDeviceData data = { NDIAuroraTypeInformation::GetTrackingDeviceName(), "Aurora Compact", "NDIAuroraCompactFG_Dome.stl", "A" };
28 return data;
29 }
30
32 {
33 TrackingDeviceData data = { NDIAuroraTypeInformation::GetTrackingDeviceName(), "Aurora Planar (Cube)", "NDIAurora.stl", "9" };
34 return data;
35 }
36
38 {
39 TrackingDeviceData data = { NDIAuroraTypeInformation::GetTrackingDeviceName(), "Aurora Planar (Dome)", "NDIAuroraPlanarFG_Dome.stl", "A" };
40 return data;
41 }
42
44 {
45 TrackingDeviceData data = { NDIAuroraTypeInformation::GetTrackingDeviceName(), "Aurora Tabletop", "NDIAuroraTabletopFG_Dome.stl", "A" };
46 return data;
47 }
48
57
61
62 mitk::TrackingDeviceSource::Pointer NDIAuroraTypeInformation::CreateTrackingDeviceSource(
63 mitk::TrackingDevice::Pointer trackingDevice,
64 mitk::NavigationToolStorage::Pointer navigationTools,
65 std::string* errorMessage,
66 std::vector<int>* toolCorrespondencesInToolStorage)
67 {
68 MITK_DEBUG << "Creating Aurora tracking device.";
69 mitk::TrackingDeviceSource::Pointer returnValue = mitk::TrackingDeviceSource::New();
70 mitk::NDITrackingDevice::Pointer thisDevice = dynamic_cast<mitk::NDITrackingDevice*>(trackingDevice.GetPointer());
71
72 try
73 {
74 //connect to aurora to dectect tools automatically
75 thisDevice->OpenConnection();
76 }
78 {
79 errorMessage->append("Hardware error on opening the connection (");
80 errorMessage->append(e.GetDescription());
81 errorMessage->append(")");
82 return nullptr;
83 }
84 catch (mitk::IGTException& e)
85 {
86 errorMessage->append("Error on opening the connection (");
87 errorMessage->append(e.GetDescription());
88 errorMessage->append(")");
89 return nullptr;
90 }
91
92 //now search for automatically detected tools in the tool storage and save them
93 mitk::NavigationToolStorage::Pointer newToolStorageInRightOrder = mitk::NavigationToolStorage::New();
94 std::vector<unsigned int> alreadyFoundTools = std::vector<unsigned int>();
95 *toolCorrespondencesInToolStorage = std::vector<int>();
96 for (unsigned int i = 0; i < thisDevice->GetToolCount(); i++)
97 {
98 bool toolFound = false;
99 for (unsigned int j = 0; j < navigationTools->GetToolCount(); j++)
100 {
101 //check if the serial number is the same to identify the tool
102 if ((dynamic_cast<mitk::NDIPassiveTool*>(thisDevice->GetTool(i)))->GetSerialNumber() == navigationTools->GetTool(j)->GetSerialNumber())
103 {
104 //check if this tool was already added to make sure that every tool is only added once (in case of same serial numbers)
105 bool toolAlreadyAdded = false;
106 for (unsigned int k = 0; k < alreadyFoundTools.size(); k++)
107 {
108 if (alreadyFoundTools.at(k) == j)
109 {
110 toolAlreadyAdded = true;
111 }
112 }
113
114 if (!toolAlreadyAdded)
115 {
116 //add tool in right order
117 newToolStorageInRightOrder->AddTool(navigationTools->GetTool(j));
118 toolCorrespondencesInToolStorage->push_back(j);
119 //adapt name of tool
120 dynamic_cast<mitk::NDIPassiveTool*>(thisDevice->GetTool(i))->SetToolName(navigationTools->GetTool(j)->GetToolName());
121 //set tip of tool
122 dynamic_cast<mitk::NDIPassiveTool*>(thisDevice->GetTool(i))->SetToolTipPosition(navigationTools->GetTool(j)->GetToolTipPosition(), navigationTools->GetTool(j)->GetToolAxisOrientation());
123 //rember that this tool was already found
124 alreadyFoundTools.push_back(j);
125
126 toolFound = true;
127 break;
128 }
129 }
130 }
131 if (!toolFound)
132 {
133 errorMessage->append("Error: did not find every automatically detected tool in the loaded tool storage: aborting initialization.");
134 return nullptr;
135 }
136 }
137
138 //And resort them (this was done in TrackingToolBoxWorker before).
139 for (unsigned int i = 0; i < newToolStorageInRightOrder->GetToolCount(); i++)
140 {
141 navigationTools->AssignToolNumber(newToolStorageInRightOrder->GetTool(i)->GetIdentifier(), i);
142 }
143
144 returnValue->SetTrackingDevice(thisDevice);
145 MITK_DEBUG << "Number of tools of created tracking device: " << thisDevice->GetToolCount();
146 MITK_DEBUG << "Number of outputs of created source: " << returnValue->GetNumberOfOutputs();
147 return returnValue;
148 }
149}
An object of this class represents an exception of the MITK-IGT module.
An object of this class represents an exception of the MITK-IGT module which are releated to the hard...
static TrackingDeviceData GetDeviceDataAuroraPlanarDome()
static TrackingDeviceData GetDeviceDataAuroraTabletop()
static TrackingDeviceData GetDeviceDataAuroraCompact()
static TrackingDeviceData GetDeviceDataAuroraPlanarCube()
TrackingDeviceSource::Pointer CreateTrackingDeviceSource(mitk::TrackingDevice::Pointer trackingDevice, mitk::NavigationToolStorage::Pointer navigationTools, std::string *errorMessage, std::vector< int > *toolCorrespondencesInToolStorage) override
Implementation of a passive NDI optical tool.
superclass for specific NDI tracking Devices that use serial communication.
std::vector< TrackingDeviceData > m_TrackingDeviceData
virtual void SetToolName(const std::string _arg)
Sets the name of the tool.
virtual void SetToolTipPosition(Point3D toolTipPosition, Quaternion orientation, ScalarType eps=0.0)
defines a tool tip for this tool in tool coordinates. GetPosition() and GetOrientation() return the d...
IGT Exceptions.