Medical Imaging Interaction Toolkit  2018.4.99-ef453c4b
Medical Imaging Interaction Toolkit
mitkOpenIGTLinkTrackingDevice.h
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 
13 #ifndef MITKOPENIGTLINKTRACKINGDEVICE_H_HEADER_INCLUDED_
14 #define MITKOPENIGTLINKTRACKINGDEVICE_H_HEADER_INCLUDED_
15 
16 #include <mitkIGTConfig.h>
17 #include <mitkTrackingDevice.h>
19 #include <mitkIGTLClient.h>
20 #include <mitkIGTLDeviceSource.h>
22 #include <itkMultiThreader.h>
23 #include <igtlQuaternionTrackingDataMessage.h>
24 #include <igtlTrackingDataMessage.h>
25 #include <igtlTransformMessage.h>
27 
28 namespace mitk
29 {
37  {
38  public:
40  itkFactorylessNewMacro(Self);
41  itkCloneMacro(Self);
42 
44  void SetPortNumber(int portNumber);
45 
47  void SetHostname(std::string hostname);
48 
49  int GetPortNumber();
50 
51  std::string GetHostname();
52 
58  bool StartTracking() override;
59 
64  bool StopTracking() override;
65 
70  bool OpenConnection() override;
71 
75  bool CloseConnection() override;
76 
80  unsigned int GetToolCount() const override;
81 
87  TrackingTool* GetTool(unsigned int toolNumber) const override;
88 
96  bool DiscoverTools(int WaitingTime = 10000);
97 
106  mitk::TrackingTool* AddTool(const char* toolName, const char* fileName);
107 
109  bool AutoDetectToolsAvailable() override;
110 
115  mitk::NavigationToolStorage::Pointer AutoDetectTools() override;
116 
117  bool IsDeviceInstalled() override;
118 
119  itkSetMacro(UpdateRate, int);
120  itkGetConstMacro(UpdateRate, int);
121 
122  protected:
124  ~OpenIGTLinkTrackingDevice() override;
125 
132  bool InternalAddTool(OpenIGTLinkTrackingTool::Pointer tool);
133 
135  void UpdateTools();
137 
140  mitk::IGTLMessage::Pointer ReceiveMessage(int waitingTime);
141 
145  std::vector<OpenIGTLinkTrackingTool::Pointer> GetAllTools();
146 
147  //OpenIGTLink connection class
148  mitk::IGTLClient::Pointer m_OpenIGTLinkClient;
149 
150  //OpenIGTLink pipeline
151  mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLDeviceSource;
152  mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMsgToNavDataFilter;
153 
154  std::vector<OpenIGTLinkTrackingTool::Pointer> m_AllTools;
155 
157 
158  private:
159  enum TrackingMessageType
160  {
161  TDATA, TRANSFORM, QTDATA, UNKNOWN
162  };
163 
164  mitk::OpenIGTLinkTrackingDevice::TrackingMessageType GetMessageTypeFromString(const char* messageTypeString);
165 
168  mitk::NavigationToolStorage::Pointer DiscoverToolsAndConvertToNavigationTools(mitk::OpenIGTLinkTrackingDevice::TrackingMessageType type, int NumberOfMessagesToWait = 50);
169 
170  void AddNewToolForName(std::string name, int i);
171 
172  mitk::NavigationTool::Pointer ConstructDefaultOpenIGTLinkTool(std::string name, std::string identifier);
173  };
174 }//mitk
175 #endif /* MITKOpenIGTLinkTRACKINGDEVICE_H_HEADER_INCLUDED_ */
Interface for all Tracking Tools.
An object of this class represents the MicronTracker device. You can add tools to this device...
DataCollection - Class to facilitate loading/accessing structured data.
#define MITKIGT_EXPORT
std::vector< OpenIGTLinkTrackingTool::Pointer > m_AllTools
vector holding all tools
int m_UpdateRate
holds the update rate in FPS (will be set automatically when the OpenIGTLink connection is establishe...
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Interface for all Tracking Devices.
mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMsgToNavDataFilter
mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLDeviceSource