MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataPlayerBase.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found 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
27
29{
30 this->Modified(); // make sure that we need to be updated
31 Superclass::UpdateOutputInformation();
32}
33
35{
36 return m_NavigationDataSetIterator == m_NavigationDataSet->End();
37}
38
39void mitk::NavigationDataPlayerBase::SetNavigationDataSet(NavigationDataSet::Pointer navigationDataSet)
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{
54 return m_NavigationDataSet.IsNull() ? 0 : m_NavigationDataSetIterator - m_NavigationDataSet->Begin();
55}
56
58{
59 if ( m_NavigationDataSet.IsNull() )
60 {
61 mitkThrowException(mitk::IGTException)
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 {
79 mitkThrowException(mitk::IGTException)
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}
An object of this class represents an exception of the MITK-IGT module.
unsigned int GetNumberOfSnapshots()
Getter for the size of the mitk::NavigationDataSet used in this object.
bool IsAtEnd()
This method checks if player arrived at end of file.
void UpdateOutputInformation() override
Used for pipeline update just to tell the pipeline that we always have to update.
void SetNavigationDataSet(NavigationDataSet::Pointer navigationDataSet)
Set mitk::NavigationDataSet for playing. Player is initialized by call to mitk::NavigationDataPlayerB...
void GraftEmptyOutput()
Convenience method for subclasses. When there are no further mitk::NavigationData objects available,...
void InitPlayer()
Initializes the outputs of this NavigationDataSource. Aftwer calling this method, the first Navigatio...
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
mitk::Quaternion OrientationType
Type that holds the orientation part of the tracking data.
mitk::Point3D PositionType
Type that holds the position part of the tracking data.