Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNavigationTool.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 
17 #include "mitkNavigationTool.h"
18 #include "mitkIGTException.h"
19 #include "mitkNavigationData.h"
20 #include "Poco/File.h"
22 
23 mitk::NavigationTool::NavigationTool() : m_Identifier("None"),
24  m_Type(mitk::NavigationTool::Unknown),
25  m_CalibrationFile("none"),
26  m_SerialNumber(""),
27  m_TrackingDeviceType(mitk::UnspecifiedTrackingTypeInformation::GetTrackingDeviceName()),
28  m_ToolRegistrationLandmarks(mitk::PointSet::New()),
29  m_ToolCalibrationLandmarks(mitk::PointSet::New()),
30  m_ToolTipOrientation(mitk::Quaternion(0,0,0,1))
31  {
32  m_ToolTipPosition[0] = 0;
33  m_ToolTipPosition[1] = 0;
34  m_ToolTipPosition[2] = 0;
35  }
36 
38  {
39 
40  }
41 
43  {
45  returnValue->SetPosition(this->m_ToolTipPosition);
46  returnValue->SetOrientation(this->m_ToolTipOrientation);
47  return returnValue->GetAffineTransform3D();
48  }
49 
50 void mitk::NavigationTool::Graft( const DataObject *data )
51 {
52  // Attempt to cast data to an NavigationData
53  const Self* nd;
54  try
55  {
56  nd = dynamic_cast<const Self *>( data );
57  }
58  catch( ... )
59  {
60  mitkThrowException(mitk::IGTException) << "mitk::NavigationData::Graft cannot cast "
61  << typeid(data).name() << " to "
62  << typeid(const Self *).name() ;
63  }
64  if (!nd)
65  {
66  // pointer could not be cast back down
67  mitkThrowException(mitk::IGTException) << "mitk::NavigationData::Graft cannot cast "
68  << typeid(data).name() << " to "
69  << typeid(const Self *).name() ;
70  }
71  // Now copy anything that is needed
72  m_Identifier = nd->GetIdentifier();
73  m_Type = nd->GetType();
74  m_DataNode->SetName(nd->GetDataNode()->GetName());
75  m_DataNode->SetData(nd->GetDataNode()->GetData());
76  m_SpatialObject = nd->GetSpatialObject();
77  m_TrackingTool = nd->GetTrackingTool();
78  m_CalibrationFile = nd->GetCalibrationFile();
79  m_SerialNumber = nd->GetSerialNumber();
80  m_TrackingDeviceType = nd->GetTrackingDeviceType();
81  m_ToolRegistrationLandmarks = nd->GetToolRegistrationLandmarks();
82  m_ToolCalibrationLandmarks = nd->GetToolCalibrationLandmarks();
83  m_ToolTipPosition = nd->GetToolTipPosition();
84  m_ToolTipOrientation = nd->GetToolTipOrientation();
85 
86 }
87 
89  {
90  if( (m_ToolTipPosition[0] == 0) &&
91  (m_ToolTipPosition[1] == 0) &&
92  (m_ToolTipPosition[2] == 0) &&
93  (m_ToolTipOrientation.x() == 0) &&
94  (m_ToolTipOrientation.y() == 0) &&
95  (m_ToolTipOrientation.z() == 0) &&
96  (m_ToolTipOrientation.r() == 1))
97  return false;
98  else return true;
99  }
100 
102  {
103  //check if file does exist:
104  if (filename=="")
105  {
106  m_CalibrationFile = "none";
107  }
108  else
109  {
110  Poco::File myFile(filename);
111  if (myFile.exists())
112  m_CalibrationFile = filename;
113  else
114  m_CalibrationFile = "none";
115  }
116  }
117 
119  {
120  if (this->m_DataNode.IsNull()) {return "";}
121  else {return m_DataNode->GetName();}
122  }
123 
125  {
126  if (this->m_DataNode.IsNull()) {return nullptr;}
127  else if (this->m_DataNode->GetData() == nullptr) {return nullptr;}
128  else {return dynamic_cast<mitk::Surface*>(m_DataNode->GetData());}
129  }
static Pointer New()
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
itk::SmartPointer< Self > Pointer
mitk::Point3D m_ToolTipPosition
Holds the position of the tool tip.
virtual void Graft(const DataObject *data) override
Graft the data and information from one NavigationTool to another.
An object of this class represents an exception of the MITK-IGT module.
DataCollection - Class to facilitate loading/accessing structured data.
An object of this class represents a navigation tool in the view of the software. A few informations ...
void SetCalibrationFile(const std::string filename)
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:79
static const std::string filename
vnl_quaternion< ScalarType > Quaternion
mitk::AffineTransform3D::Pointer GetToolTipTransform()
#define mitkThrowException(classname)
Type information for unspecified or invalid tracking devices. This is often used as default or for te...
mitk::Surface::Pointer GetToolSurface()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.