Medical Imaging Interaction Toolkit  2022.04.99-194dd5d8
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 <igtlQuaternionTrackingDataMessage.h>
23 #include <igtlTrackingDataMessage.h>
24 #include <igtlTransformMessage.h>
26 
27 namespace mitk
28 {
36  {
37  public:
39  itkFactorylessNewMacro(Self);
40  itkCloneMacro(Self);
41 
43  void SetPortNumber(int portNumber);
44 
46  void SetHostname(std::string hostname);
47 
48  int GetPortNumber();
49 
50  std::string GetHostname();
51 
57  bool StartTracking() override;
58 
63  bool StopTracking() override;
64 
69  bool OpenConnection() override;
70 
74  bool CloseConnection() override;
75 
79  unsigned int GetToolCount() const override;
80 
86  TrackingTool* GetTool(unsigned int toolNumber) const override;
87 
95  bool DiscoverTools(int WaitingTime = 10000);
96 
105  mitk::TrackingTool* AddTool(const char* toolName, const char* fileName);
106 
108  bool AutoDetectToolsAvailable() override;
109 
114  mitk::NavigationToolStorage::Pointer AutoDetectTools() override;
115 
116  bool IsDeviceInstalled() override;
117 
118  itkSetMacro(UpdateRate, int);
119  itkGetConstMacro(UpdateRate, int);
120 
121  protected:
123  ~OpenIGTLinkTrackingDevice() override;
124 
131  bool InternalAddTool(OpenIGTLinkTrackingTool::Pointer tool);
132 
134  void UpdateTools();
136 
139  mitk::IGTLMessage::Pointer ReceiveMessage(int waitingTime);
140 
144  std::vector<OpenIGTLinkTrackingTool::Pointer> GetAllTools();
145 
146  //OpenIGTLink connection class
147  mitk::IGTLClient::Pointer m_OpenIGTLinkClient;
148 
149  //OpenIGTLink pipeline
150  mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLDeviceSource;
151  mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMsgToNavDataFilter;
152 
153  std::vector<OpenIGTLinkTrackingTool::Pointer> m_AllTools;
154 
156 
157  private:
158  enum TrackingMessageType
159  {
160  TDATA, TRANSFORM, QTDATA, UNKNOWN
161  };
162 
163  mitk::OpenIGTLinkTrackingDevice::TrackingMessageType GetMessageTypeFromString(const char* messageTypeString);
164 
167  mitk::NavigationToolStorage::Pointer DiscoverToolsAndConvertToNavigationTools(mitk::OpenIGTLinkTrackingDevice::TrackingMessageType type, int NumberOfMessagesToWait = 50);
168 
169  void AddNewToolForName(std::string name, int i);
170 
171  mitk::NavigationTool::Pointer ConstructDefaultOpenIGTLinkTool(std::string name, std::string identifier);
172  };
173 }//mitk
174 #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:36
Interface for all Tracking Devices.
mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMsgToNavDataFilter
mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLDeviceSource