00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date $ 00006 Version: $Revision $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkClaronTool.h" 00019 #include <stdio.h> 00020 #include <vector> 00021 #include <iostream> 00022 00023 mitk::ClaronTool::ClaronTool() :InternalTrackingTool() 00024 { 00025 } 00026 00027 mitk::ClaronTool::~ClaronTool(void) 00028 { 00029 } 00030 00031 std::string mitk::ClaronTool::GetCalibrationName() 00032 { 00033 return &m_CalibrationName[0]; 00034 } 00035 00036 void mitk::ClaronTool::SetCalibrationName(std::string name) 00037 { 00038 this->m_CalibrationName=name; 00039 } 00040 00041 bool mitk::ClaronTool::LoadFile(const char* filename) 00042 { 00043 if (filename==NULL) 00044 { 00045 return false; 00046 } 00047 else 00048 { 00049 return this->LoadFile(std::string(filename)); 00050 } 00051 } 00052 00053 bool mitk::ClaronTool::LoadFile(std::string filename) 00054 { 00055 //This method is not really "loading" a file. It is saving the filename and 00056 //parsing the calibration name out of the filename. The calibration name is 00057 //later used by the tracking device to really load the file. 00058 00059 if (filename.empty()) 00060 { 00061 return false; 00062 } 00063 else 00064 { 00065 m_Filename = filename; 00066 00067 int end = m_Filename.length(); 00068 int start = end; 00069 00070 //check whether the path is given in Windows format 00071 while( (start!=0) && (filename[start-1]!='\\') ) start--; 00072 00073 //if not (start==0) perhaps it is given in Linux format 00074 if (start==0) 00075 { 00076 start = end; 00077 while( (start!=0) && (filename[start-1]!='/') ) 00078 { 00079 start--; 00080 } 00081 } 00082 00083 //if there are no \ and no / in the string something must be wrong... 00084 if (start==0) return false; 00085 00086 this->m_CalibrationName = m_Filename.substr(start,end); 00087 00088 return true; 00089 } 00090 } 00091 00092 std::string mitk::ClaronTool::GetFile() 00093 { 00094 return m_Filename; 00095 } 00096 00097 void mitk::ClaronTool::SetToolHandle (mitk::claronToolHandle handle) 00098 { 00099 this->m_ToolHandle = handle; 00100 } 00101 00102 mitk::claronToolHandle mitk::ClaronTool::GetToolHandle() 00103 { 00104 return this->m_ToolHandle; 00105 }