Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkNavigationDataPlayerBase.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 for exceptions
16 #include "mitkIGTException.h"
17 
19  : m_Repeat(false)
20 {
21  this->SetName("Navigation Data Player Source");
22 }
23 
25 {
26 }
27 
29 {
30  this->Modified(); // make sure that we need to be updated
31  Superclass::UpdateOutputInformation();
32 }
33 
35 {
37 }
38 
40 {
41  m_NavigationDataSet = navigationDataSet;
42  m_NavigationDataSetIterator = navigationDataSet->Begin();
43 
44  this->InitPlayer();
45 }
46 
48 {
49  return m_NavigationDataSet.IsNull() ? 0 : m_NavigationDataSet->Size();
50 }
51 
53 {
55 }
56 
58 {
59  if ( m_NavigationDataSet.IsNull() )
60  {
62  << "NavigationDataSet has to be set before initializing player.";
63  }
64 
65  if (GetNumberOfOutputs() == 0)
66  {
67  unsigned int requiredOutputs = m_NavigationDataSet->GetNumberOfTools();
68  this->SetNumberOfRequiredOutputs(requiredOutputs);
69 
70  for (unsigned int n = this->GetNumberOfOutputs(); n < requiredOutputs; ++n)
71  {
72  DataObjectPointer newOutput = this->MakeOutput(n);
73  this->SetNthOutput(n, newOutput);
74  this->Modified();
75  }
76  }
77  else if (GetNumberOfOutputs() != m_NavigationDataSet->GetNumberOfTools())
78  {
80  << "Number of tools cannot be changed in existing player. Please create "
81  << "a new player, if the NavigationDataSet has another number of tools now.";
82  }
83 
84  this->Modified();
85  this->GenerateData();
86 }
87 
89 {
90  for (unsigned int index = 0; index < m_NavigationDataSet->GetNumberOfTools(); index++)
91  {
92  mitk::NavigationData* output = this->GetOutput(index);
93  assert(output);
94 
95  mitk::NavigationData::Pointer nd = mitk::NavigationData::New();
97  mitk::NavigationData::OrientationType orientation(0.0,0.0,0.0,0.0);
98  position.Fill(0.0);
99 
100  nd->SetPosition(position);
101  nd->SetOrientation(orientation);
102  nd->SetDataValid(false);
103 
104  output->Graft(nd);
105  }
106 }
static Pointer New()
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
void UpdateOutputInformation() override
Used for pipeline update just to tell the pipeline that we always have to update. ...
Navigation Data.
NavigationDataSet::Pointer m_NavigationDataSet
An object of this class represents an exception of the MITK-IGT module.
mitk::NavigationDataSet::NavigationDataSetConstIterator m_NavigationDataSetIterator
Iterator always points to the NavigationData object which is in the outputs at the moment...
mitk::Quaternion OrientationType
Type that holds the orientation part of the tracking data.
void GraftEmptyOutput()
Convenience method for subclasses. When there are no further mitk::NavigationData objects available...
void GenerateData() override=0
Every subclass hast to implement this method. See ITK filter documentation for details.
void SetNavigationDataSet(NavigationDataSet::Pointer navigationDataSet)
Set mitk::NavigationDataSet for playing. Player is initialized by call to mitk::NavigationDataPlayerB...
itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
#define mitkThrowException(classname)
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
bool IsAtEnd()
This method checks if player arrived at end of file.
void InitPlayer()
Initializes the outputs of this NavigationDataSource. Aftwer calling this method, the first Navigatio...
unsigned int GetNumberOfSnapshots()
Getter for the size of the mitk::NavigationDataSet used in this object.
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...