15 #include "igtlQuaternionTrackingDataMessage.h" 16 #include "igtlTrackingDataMessage.h" 17 #include "igtlTransformMessage.h" 18 #include "igtlPositionMessage.h" 21 #include <itksys/SystemTools.hxx> 26 this->SetNumberOfRequiredOutputs(1);
27 this->SetNthOutput(0, output.GetPointer());
28 this->SetNumberOfRequiredInputs(1);
64 this->ProcessObject::SetNthInput(0, const_cast<NavigationData*>(nd));
71 this->ProcessObject::SetNthInput(idx, const_cast<NavigationData*>(nd));
77 if (this->GetNumberOfInputs() < 1)
79 return static_cast<const NavigationData*
>(this->ProcessObject::GetInput(0));
84 if (this->GetNumberOfInputs() < 1)
86 return static_cast<const NavigationData*
>(this->ProcessObject::GetInput(idx));
95 this->SetNumberOfIndexedOutputs(1);
101 this->SetNumberOfIndexedOutputs(1);
107 this->SetNumberOfIndexedOutputs(1);
113 this->SetNumberOfIndexedOutputs(this->GetNumberOfIndexedInputs());
121 for (
unsigned int idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx)
125 DataObjectPointer newOutput = this->
MakeOutput(idx);
126 this->SetNthOutput(idx, newOutput);
133 igtl::Matrix4x4 igtlTransform)
135 const mitk::AffineTransform3D::MatrixType& matrix = trans->GetMatrix();
138 for (
unsigned int r = 0; r < 3; r++)
140 for (
unsigned int c = 0; c < 3; c++)
142 igtlTransform[r][c] = matrix(r, c);
144 igtlTransform[r][3] = position[r];
146 for (
unsigned int c = 0; c < 3; c++)
148 igtlTransform[3][c] = 0.0;
150 igtlTransform[3][3] = 1.0;
156 for (
unsigned int i = 0; i < this->GetNumberOfIndexedInputs(); ++i)
171 igtl::PositionMessage::Pointer posMsg = igtl::PositionMessage::New();
172 posMsg->SetPosition(pos[0], pos[1], pos[2]);
173 posMsg->SetQuaternion(ori[0], ori[1], ori[2], ori[3]);
175 posMsg->SetTimeStamp(timestamp);
176 posMsg->SetDeviceName(input->
GetName());
187 for (
unsigned int i = 0; i < this->GetNumberOfIndexedInputs(); ++i)
202 igtl::Matrix4x4 igtlTransform;
206 igtl::TransformMessage::Pointer transMsg = igtl::TransformMessage::New();
207 transMsg->SetMatrix(igtlTransform);
208 transMsg->SetPosition(position[0], position[1], position[2]);
210 transMsg->SetTimeStamp(timestamp);
211 transMsg->SetDeviceName(input->
GetName());
220 igtl::TimeStamp::Pointer timestamp = igtl::TimeStamp::New();
221 timestamp->SetTime(IGTTimeStamp / 1000, (
int)(IGTTimeStamp) % 1000);
231 igtl::QuaternionTrackingDataMessage::Pointer qtdMsg =
232 igtl::QuaternionTrackingDataMessage::New();
237 for (
unsigned int index = 0; index < this->GetNumberOfIndexedInputs(); index++)
247 igtl::QuaternionTrackingDataElement::Pointer tde =
248 igtl::QuaternionTrackingDataElement::New();
249 tde->SetPosition(pos[0], pos[1], pos[2]);
250 tde->SetQuaternion(ori[0], ori[1], ori[2], ori[3]);
254 qtdMsg->AddQuaternionTrackingDataElement(tde);
266 igtl::TrackingDataMessage::Pointer tdMsg = igtl::TrackingDataMessage::New();
271 for (
unsigned int i = 0; i < this->GetNumberOfIndexedInputs(); ++i)
284 igtl::Matrix4x4 igtlTransform;
288 igtl::TrackingDataElement::Pointer tde = igtl::TrackingDataElement::New();
289 tde->SetMatrix(igtlTransform);
290 tde->SetPosition(position[0], position[1], position[2]);
291 tde->SetName(input->
GetName());
292 tde->SetType(igtl::TrackingDataElement::TYPE_6D);
293 tdMsg->AddTrackingDataElement(tde);
298 tdMsg->SetTimeStamp(timestamp);
301 tdMsg->SetDeviceName(
"MITK OpenIGTLink Source");
314 for (DataObjectPointerArraySizeType i = 0;
315 i < UpstreamFilter->GetNumberOfOutputs(); i++)
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
void SetMessage(igtl::MessageBase::Pointer msg)
Sets the OpenIGTLink message.
itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
mitk::AffineTransform3D::Pointer GetAffineTransform3D() const
Calculate AffineTransform3D from the transformation held by this NavigationData. TODO: should throw a...
unsigned int m_CurrentTimeStep
Indicates the current timestamp.
igtl::TimeStamp::Pointer ConvertToIGTLTimeStamp(double IGTTimeStamp)
virtual const char * GetName() const
returns the name of the NavigationData object
virtual void GenerateDataModeSendQTDataMsg()
Generates the output.
Constants for most interaction classes, due to the generic StateMachines.
mitk::Quaternion OrientationType
Type that holds the orientation part of the tracking data.
Time stamp in milliseconds.
virtual void SetType(std::string _arg)
void ConvertAffineTransformationIntoIGTLMatrix(mitk::AffineTransform3D *trans, igtl::Matrix4x4 igtlTransform)
virtual void GenerateDataModeSendQTransMsg()
Generates the output for ModeSendQTransMsg.
void GenerateData() override
filter execute method
virtual PositionType GetPosition() const
returns position of the NavigationData object
virtual void ConnectTo(mitk::NavigationDataSource *UpstreamFilter)
Connects the input of this filter to the outputs of the given NavigationDataSource.
virtual TimeStampType GetIGTTimeStamp() const
gets the IGT timestamp of the NavigationData object in milliseconds Please note, that there is also t...
IGTLMessage * GetOutput(void)
return the output (output with id 0) of the filter
virtual void CreateOutputsForAllInputs()
create output objects according to OperationMode for all inputs
A wrapper for the OpenIGTLink message type.
OperationMode m_OperationMode
Stores the mode. See enum OperationMode.
virtual void SetInput(const mitk::NavigationData *NavigationData)
Sets one input NavigationData.
virtual void GenerateDataModeSendTransMsg()
Generates the output for ModeSendTransMsg.
itk::AffineGeometryFrame< ScalarType, 3 >::TransformType AffineTransform3D
const mitk::NavigationData * GetInput()
Returns the input of this filter.
virtual void GenerateDataModeSendTDataMsg()
Generates the output for ModeSendTDataMsg.
NavigationDataToIGTLMessageFilter()
virtual OrientationType GetOrientation() const
returns the orientation of the NavigationData object
~NavigationDataToIGTLMessageFilter() override
virtual bool IsDataValid() const
returns true if the object contains valid data
virtual void SetOperationMode(OperationMode mode)
Sets the mode of this filter.
OperationMode
There are four different operation modes.