14#include "mitkException.h"
18 m_DataValid(false), m_IGTTimeStamp(0), m_Name()
38 this->SetMessage(message);
39 this->SetName(message->GetDeviceName());
48 msg =
dynamic_cast<const Self *
>(data);
52 itkExceptionMacro( <<
"mitk::IGTLMessage::Graft cannot cast "
53 <<
typeid(data).name() <<
" to "
54 <<
typeid(
const Self *).name() );
60 itkExceptionMacro( <<
"mitk::IGTLMessage::Graft cannot cast "
61 <<
typeid(data).name() <<
" to "
62 <<
typeid(
const Self *).name() );
66 this->SetMessage(msg->GetMessage());
67 this->SetDataValid(msg->IsDataValid());
68 this->SetIGTTimeStamp(msg->GetIGTTimeStamp());
69 this->SetName(msg->GetName());
76 unsigned int frac = 0;
77 m_Message->GetTimeStamp(&ts, &frac);
78 this->SetName(m_Message->GetDeviceName());
79 double timestamp = ts * 1000.0 + frac;
80 this->SetIGTTimeStamp(timestamp);
81 this->SetDataValid(
true);
92 os << indent <<
"name: " << this->GetName() << std::endl;
93 os << indent <<
"type: " << this->GetIGTLMessageType() << std::endl;
94 os << indent <<
"valid: " << this->IsDataValid() << std::endl;
95 os << indent <<
"timestamp: " << this->GetIGTTimeStamp() << std::endl;
96 os << indent <<
"OpenIGTLinkMessage: " << std::endl;
98 this->Superclass::PrintSelf(os, indent);
103 std::stringstream output;
111 this->Superclass::CopyInformation( data );
113 const Self * nd =
nullptr;
116 nd =
dynamic_cast<const Self*
>(data);
121 itkExceptionMacro(<<
"mitk::IGTLMessage::CopyInformation() cannot cast "
122 <<
typeid(data).name() <<
" to "
123 <<
typeid(Self*).name() );
128 itkExceptionMacro(<<
"mitk::IGTLMessage::CopyInformation() cannot cast "
129 <<
typeid(data).name() <<
" to "
130 <<
typeid(Self*).name() );
137 ScalarType ,
bool verbose)
139 bool returnValue =
true;
141 if( std::string(rightHandSide.GetName()) != std::string(leftHandSide.GetName()) )
145 MITK_INFO <<
"[( IGTLMessage )] Name differs.";
146 MITK_INFO <<
"leftHandSide is " << leftHandSide.GetName()
147 <<
"rightHandSide is " << rightHandSide.GetName();
152 if( rightHandSide.GetIGTTimeStamp() != leftHandSide.GetIGTTimeStamp() )
156 MITK_INFO <<
"[( IGTLMessage )] IGTTimeStamp differs.";
157 MITK_INFO <<
"leftHandSide is " << leftHandSide.GetIGTTimeStamp()
158 <<
"rightHandSide is " << rightHandSide.GetIGTTimeStamp();
168 return this->m_Message->GetDeviceType();
171template <
typename IGTLMessageType >
174 return dynamic_cast<IGTLMessageType*
>(this->m_Message);
A wrapper for the OpenIGTLink message type.
igtl::MessageBase::Pointer m_Message
holds the actual OpenIGTLink message
void CopyInformation(const DataObject *data) override
copy meta data of a IGTLMessage object
virtual bool IsDataValid() const
returns true if the object contains valid data
std::string ToString() const
void Graft(const DataObject *data) override
Graft the data and information from one IGTLMessage to another.
const char * GetIGTLMessageType() const
IGTLMessageType * GetMessage() const
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Prints the object information to the given stream os.
void SetMessage(igtl::MessageBase::Pointer msg)
Sets the OpenIGTLink message.
MITKIGTBASE_EXPORT bool Equal(const mitk::NavigationData &leftHandSide, const mitk::NavigationData &rightHandSide, ScalarType eps=mitk::eps, bool verbose=false)
Equal A function comparing two navigation data objects for beeing equal in meta- and imagedata.