Medical Imaging Interaction Toolkit  2018.4.99-bd7b41ba
Medical Imaging Interaction Toolkit
mitkNPOptitrackTrackingTypeInformation.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
16 
17 namespace mitk
18 {
20  {
21  return "NP Optitrack";
22  }
23 
25  {
27  return data;
28  }
29 
31  {
34  }
35 
37  {
38  }
39 
41  TrackingDevice::Pointer trackingDevice,
42  NavigationToolStorage::Pointer navigationTools,
43  std::string* errorMessage,
44  std::vector<int>* toolCorrespondencesInToolStorage)
45  {
46  mitk::TrackingDeviceSource::Pointer returnValue = mitk::TrackingDeviceSource::New();
47  mitk::OptitrackTrackingDevice::Pointer thisDevice = dynamic_cast<mitk::OptitrackTrackingDevice*>(trackingDevice.GetPointer());
48  *toolCorrespondencesInToolStorage = std::vector<int>();
49 
50  //OpenConnection with Optitrack
51  thisDevice->OpenConnection();
52 
53  //add the tools to the tracking device
54  for (unsigned int i = 0; i < navigationTools->GetToolCount(); i++)
55  {
56  mitk::NavigationTool::Pointer thisNavigationTool = navigationTools->GetTool(i);
57  toolCorrespondencesInToolStorage->push_back(i);
58  bool toolAddSuccess = thisDevice->AddToolByDefinitionFile(thisNavigationTool->GetCalibrationFile());
59  thisDevice->GetOptitrackTool(i)->SetToolName(thisNavigationTool->GetToolName().c_str());
60  if (!toolAddSuccess)
61  {
62  //todo error handling
63  errorMessage->append("Can't add tool, is the toolfile valid?");
64  return nullptr;
65  }
66  //thisDevice->GetTool(i)->SetToolTip(thisNavigationTool->GetToolTipPosition(),thisNavigationTool->GetToolAxisOrientation());
67  }
68  returnValue->SetTrackingDevice(thisDevice);
69  return returnValue;
70  }
71 }
TrackingDeviceSource::Pointer CreateTrackingDeviceSource(TrackingDevice::Pointer trackingDevice, NavigationToolStorage::Pointer navigationTools, std::string *errorMessage, std::vector< int > *toolCorrespondencesInToolStorage) override
An object of this class represents the Optitrack device. You can add tools to this device...
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< TrackingDeviceData > m_TrackingDeviceData