Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkClaronTool.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 
13 #include "mitkClaronTool.h"
14 #include <cstdio>
15 #include <vector>
16 #include <iostream>
17 
19 {
20 }
21 
23 {
24 }
25 
27 {
28  return &m_CalibrationName[0];
29 }
30 
32 {
33  this->m_CalibrationName=name;
34 }
35 
36 bool mitk::ClaronTool::LoadFile(const char* filename)
37 {
38  if (filename==nullptr)
39  {
40  return false;
41  }
42  else
43  {
44  return this->LoadFile(std::string(filename));
45  }
46 }
47 
48 bool mitk::ClaronTool::LoadFile(std::string filename)
49 {
50  //This method is not really "loading" a file. It is saving the filename and
51  //parsing the calibration name out of the filename. The calibration name is
52  //later used by the tracking device to really load the file.
53 
54  if (filename.empty())
55  {
56  return false;
57  }
58  else
59  {
60  m_Filename = filename;
61 
62  int end = m_Filename.length();
63  int start = end;
64 
65  //check whether the path is given in Windows format
66  while( (start!=0) && (filename[start-1]!='\\') ) start--;
67 
68  //if not (start==0) perhaps it is given in Linux format
69  if (start==0)
70  {
71  start = end;
72  while( (start!=0) && (filename[start-1]!='/') )
73  {
74  start--;
75  }
76  }
77 
78  //if there are no \ and no / in the string something must be wrong...
79  if (start==0) return false;
80 
81  this->m_CalibrationName = m_Filename.substr(start,end);
82 
83  return true;
84  }
85 }
86 
88 {
89  return m_Filename;
90 }
91 
93 {
94  this->m_ToolHandle = handle;
95 }
96 
98 {
99  return this->m_ToolHandle;
100 }
Interface for all Tracking Tools.
int claronToolHandle
std::string m_CalibrationName
Variable which holds the Tool&#39;s calibration name.
std::string m_Filename
Variable to check filename&#39;s format and to get back complete filename.
~ClaronTool() override
void SetCalibrationName(std::string name)
Sets the calibration name of the tool. Be careful, only use this method if you know what you are doin...
std::string GetFile()
claronToolHandle GetToolHandle()
claronToolHandle m_ToolHandle
Tool handle variable from tracking device.
bool LoadFile(const char *filename)
Loads a tool calibration file. Without this file the tool can not be tracked!
void SetToolHandle(claronToolHandle handle)
Sets the handle of the tool.
std::string GetCalibrationName()