Medical Imaging Interaction Toolkit  2016.11.0
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,
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 
19 // include for exceptions
20 #include "mitkIGTException.h"
21 
23  : m_Repeat(false)
24 {
25  this->SetName("Navigation Data Player Source");
26 }
27 
29 {
30 }
31 
33 {
34  this->Modified(); // make sure that we need to be updated
35  Superclass::UpdateOutputInformation();
36 }
37 
39 {
40  return m_NavigationDataSetIterator == m_NavigationDataSet->End();
41 }
42 
44 {
45  m_NavigationDataSet = navigationDataSet;
46  m_NavigationDataSetIterator = navigationDataSet->Begin();
47 
48  this->InitPlayer();
49 }
50 
52 {
53  return m_NavigationDataSet.IsNull() ? 0 : m_NavigationDataSet->Size();
54 }
55 
57 {
58  return m_NavigationDataSet.IsNull() ? 0 : m_NavigationDataSetIterator - m_NavigationDataSet->Begin();
59 }
60 
62 {
63  if ( m_NavigationDataSet.IsNull() )
64  {
66  << "NavigationDataSet has to be set before initializing player.";
67  }
68 
69  if (GetNumberOfOutputs() == 0)
70  {
71  int requiredOutputs = m_NavigationDataSet->GetNumberOfTools();
72  this->SetNumberOfRequiredOutputs(requiredOutputs);
73 
74  for (unsigned int n = this->GetNumberOfOutputs(); n < requiredOutputs; ++n)
75  {
76  DataObjectPointer newOutput = this->MakeOutput(n);
77  this->SetNthOutput(n, newOutput);
78  this->Modified();
79  }
80  }
81  else if (GetNumberOfOutputs() != m_NavigationDataSet->GetNumberOfTools())
82  {
84  << "Number of tools cannot be changed in existing player. Please create "
85  << "a new player, if the NavigationDataSet has another number of tools now.";
86  }
87 
88  this->Modified();
89  this->GenerateData();
90 }
91 
93 {
94  for (unsigned int index = 0; index < m_NavigationDataSet->GetNumberOfTools(); index++)
95  {
96  mitk::NavigationData* output = this->GetOutput(index);
97  assert(output);
98 
101  mitk::NavigationData::OrientationType orientation(0.0,0.0,0.0,0.0);
102  position.Fill(0.0);
103 
104  nd->SetPosition(position);
105  nd->SetOrientation(orientation);
106  nd->SetDataValid(false);
107 
108  output->Graft(nd);
109  }
110 }
static Pointer New()
itk::SmartPointer< Self > Pointer
virtual void UpdateOutputInformation() override
Used for pipeline update just to tell the pipeline that we always have to update. ...
Navigation Data.
An object of this class represents an exception of the MITK-IGT module.
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 SetNavigationDataSet(NavigationDataSet::Pointer navigationDataSet)
Set mitk::NavigationDataSet for playing. Player is initialized by call to mitk::NavigationDataPlayerB...
#define mitkThrowException(classname)
virtual 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...