Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNavigationDataToMessageFilter.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkPropertyList.h"
19 #include "mitkProperties.h"
20 
23  m_PositionEpsilon(0.0f), m_OrientationEpsilon(0.0f), m_CovErrorEpsilon(0.0f), m_TimeStampEpsilon(0.0f)
24 {
25  this->SetNumberOfRequiredInputs(1);
26 }
27 
29 {
30 }
31 
32 
33 //void mitk::NavigationDataToMessageFilter::SetInput( unsigned int idx, const NavigationData* nd )
34 //{
35 // if (idx > 0)
36 // throw std::invalid_argument("mitk::NavigationDataToMessageFilter: only one input is supported");
37 // // Process object is not const-correct so the const_cast is required here
38 // this->ProcessObject::SetNthInput(idx, const_cast<NavigationData*>(nd));
39 // this->CreateOutputsForAllInputs();
40 //}
41 
42 
43 //void mitk::NavigationDataToMessageFilter::SetInput( const NavigationData* nd )
44 //{
45 // // Process object is not const-correct so the const_cast is required here
46 // this->ProcessObject::SetNthInput(0, const_cast<NavigationData*>(nd));
47 // this->CreateOutputsForAllInputs();
48 //}
49 
50 
52 {
53  /* update outputs with tracking data from tools */
54  for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i)
55  {
56  mitk::NavigationData* output = this->GetOutput(i);
57  assert(output);
58  const mitk::NavigationData* input = this->GetInput(i);
59  assert(input);
60 
61  /* check for differences, then send message. */
62  if ((output->GetPosition() - input->GetPosition()).GetNorm() > m_PositionEpsilon)
63  m_PositionChangedMessage.Send(input->GetPosition(), i);
64 
65  if ((output->GetOrientation() - input->GetOrientation()).magnitude() > m_OrientationEpsilon)
66  m_OrientationChangedMessage.Send(input->GetOrientation(), i);
67 
68  if ((output->GetCovErrorMatrix().GetVnlMatrix() - input->GetCovErrorMatrix().GetVnlMatrix()).absolute_value_max() > m_CovErrorEpsilon)
69  m_ErrorChangedMessage.Send(input->GetCovErrorMatrix(), i);
70 
71  if (fabs(output->GetIGTTimeStamp() - input->GetIGTTimeStamp()) > m_TimeStampEpsilon)
72  m_TimeStampChangedMessage.Send(input->GetIGTTimeStamp(), i);
73 
74  if (input->IsDataValid() != output->IsDataValid())
75  m_DataValidChangedMessage.Send(input->IsDataValid(), i);
76 
77  output->Graft(input); // Because this is a NavigationDataToNavigationData Filter, we need to copy the input to the output to provide up to date navigation data objects
78  }
79 }
NavigationDataToNavigationDataFilter is the base class of all filters that receive NavigationDatas as...
Navigation Data.
DataCollection - Class to facilitate loading/accessing structured data.
virtual OrientationType GetOrientation() const
returns the orientation of the NavigationData object
virtual CovarianceMatrixType GetCovErrorMatrix() const
gets the 6x6 Error Covariance Matrix of the NavigationData object
virtual TimeStampType GetIGTTimeStamp() const
gets the IGT timestamp of the NavigationData object
virtual void GenerateData() override
filter execute method
virtual bool IsDataValid() const
returns true if the object contains valid data
virtual PositionType GetPosition() const
returns position of the NavigationData object
virtual void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.