Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkIGTLTrackingDataDeviceSource.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 
15 #include "mitkIGTLMessage.h"
16 
17 //Microservices
18 #include <usGetModuleContext.h>
19 #include <usModule.h>
20 #include <usServiceProperties.h>
21 #include <usModuleContext.h>
22 
23 //itk
24 #include <itkCommand.h>
25 
27  : mitk::IGTLDeviceSource() , m_trackingDataType(UNKNOWN)
28 {
29  this->SetName("IGTLDeviceSource (tracking data)");
30 }
31 
33 {
34 }
35 
37 {
38  if (m_IGTLDevice.IsNull())
39  return;
40 
41  /* update output with message from the device */
42  IGTLMessage* msgOut = this->GetOutput();
43  assert(msgOut);
44  igtl::MessageBase::Pointer msgIn;
45  switch (m_trackingDataType)
46  {
47  case UNKNOWN:
48  {
49  igtl::MessageBase::Pointer msgInTDATA = dynamic_cast<igtl::MessageBase*>(m_IGTLDevice->GetNextTrackingDataMessage().GetPointer());
50  igtl::MessageBase::Pointer msgInTRANSFORM = dynamic_cast<igtl::MessageBase*>(m_IGTLDevice->GetNextTransformMessage().GetPointer());
51  if (msgInTDATA.IsNull() && msgInTRANSFORM.IsNotNull()) { msgIn = msgInTRANSFORM; }
52  else if (msgInTDATA.IsNotNull() && msgInTRANSFORM.IsNull()) { msgIn = msgInTDATA; }
53  else if (msgInTDATA.IsNotNull() && msgInTRANSFORM.IsNotNull())
54  {
55  MITK_INFO << "Found both: TDATA and TRANSFORM messages. Using TRANSFORM as default.";
56  }
57  }
58  break;
59  case TDATA:
60  msgIn = dynamic_cast<igtl::MessageBase*>(m_IGTLDevice->GetNextTrackingDataMessage().GetPointer());
61  break;
62  case QTDATA:
63  MITK_WARN << "Receiving QTDATA is not implemented yet!";
64  break;
65  case TRANSFORM:
66  msgIn = dynamic_cast<igtl::MessageBase*>(m_IGTLDevice->GetNextTransformMessage().GetPointer());
67  break;
68  }
69 
70  if (msgIn.IsNotNull())
71  {
72  assert(msgIn);
73  msgOut->SetMessage(msgIn);
74  msgOut->SetName(msgIn->GetDeviceName());
75  }
76 }
void GenerateData() override
filter execute method
#define MITK_INFO
Definition: mitkLogMacros.h:18
void SetMessage(igtl::MessageBase::Pointer msg)
Sets the OpenIGTLink message.
Connects a mitk::IGTLDevice to a MITK-OpenIGTLink-Message-Filter-Pipeline.
DataCollection - Class to facilitate loading/accessing structured data.
mitk::IGTLDevice::Pointer m_IGTLDevice
virtual void SetName(const char *_arg)
set the name of the IGTLMessage object
IGTLMessage * GetOutput(void)
return the output (output with id 0) of the filter
#define MITK_WARN
Definition: mitkLogMacros.h:19
A wrapper for the OpenIGTLink message type.
virtual void SetName(std::string _arg)
Sets the human readable name of this source. There is also a default name, but you can use this metho...