MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkIGTLTrackingDataDeviceSource.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 "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
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}
Connects a mitk::IGTLDevice to a MITK-OpenIGTLink-Message-Filter-Pipeline.
A wrapper for the OpenIGTLink message type.
void SetMessage(igtl::MessageBase::Pointer msg)
Sets the OpenIGTLink message.
void GenerateData() override
filter execute method
IGT Exceptions.