This class offers methods to read objects of the class NavigationTool from the harddisc. The tools have to be saved in a special format by the class NavigationToolWriter to be loadable. More...
#include <mitkNavigationToolReader.h>
Public Types | |
typedef NavigationToolReader | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
mitk::NavigationTool::Pointer | DoRead (std::string filename) |
This method reads a navigation tool from a file. | |
virtual std::string | GetErrorMessage () |
Static Public Member Functions | |
static Pointer | New (mitk::DataStorage::Pointer _arg) |
Protected Member Functions | |
NavigationToolReader (mitk::DataStorage::Pointer dataStorage) | |
~NavigationToolReader () | |
mitk::NavigationTool::Pointer | ConvertDataNodeToNavigationTool (mitk::DataNode::Pointer node, std::string toolPath) |
std::string | GetFileWithoutPath (std::string FileWithPath) |
Protected Attributes | |
std::string | m_ErrorMessage |
mitk::DataStorage::Pointer | m_DataStorage |
Friends | |
class | mitk::NavigationToolStorageDeserializer |
This class offers methods to read objects of the class NavigationTool from the harddisc. The tools have to be saved in a special format by the class NavigationToolWriter to be loadable.
Documentation
Definition at line 39 of file mitkNavigationToolReader.h.
typedef itk::SmartPointer<const Self> mitk::NavigationToolReader::ConstPointer |
Definition at line 43 of file mitkNavigationToolReader.h.
typedef itk::SmartPointer<Self> mitk::NavigationToolReader::Pointer |
Definition at line 43 of file mitkNavigationToolReader.h.
Definition at line 43 of file mitkNavigationToolReader.h.
typedef itk::Object mitk::NavigationToolReader::Superclass |
Definition at line 43 of file mitkNavigationToolReader.h.
mitk::NavigationToolReader::NavigationToolReader | ( | mitk::DataStorage::Pointer | dataStorage ) | [protected] |
Definition at line 30 of file mitkNavigationToolReader.cpp.
References m_DataStorage.
{ m_DataStorage = dataStorage; }
mitk::NavigationToolReader::~NavigationToolReader | ( | ) | [protected] |
Definition at line 35 of file mitkNavigationToolReader.cpp.
{ }
mitk::NavigationTool::Pointer mitk::NavigationToolReader::ConvertDataNodeToNavigationTool | ( | mitk::DataNode::Pointer | node, |
std::string | toolPath | ||
) | [protected] |
Definition at line 74 of file mitkNavigationToolReader.cpp.
References mitk::DataNode::New(), and mitk::NavigationTool::New().
{ mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New(); //DateTreeNode with Name and Surface mitk::DataNode::Pointer newNode = mitk::DataNode::New(); newNode->SetName(node->GetName()); newNode->SetData(node->GetData()); m_DataStorage->Add(newNode); returnValue->SetDataNode(newNode); //Identifier std::string identifier; node->GetStringProperty("identifier",identifier); returnValue->SetIdentifier(identifier); //Serial Number std::string serial; node->GetStringProperty("serial number",serial); returnValue->SetSerialNumber(serial); //Tracking Device int device_type; node->GetIntProperty("tracking device type",device_type); returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type)); //Tool Type int type; node->GetIntProperty("tracking tool type",type); returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type)); //Calibration File Name std::string calibration_filename; node->GetStringProperty("toolfileName",calibration_filename); std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename; returnValue->SetCalibrationFile(calibration_filename_with_path); return returnValue; }
mitk::NavigationTool::Pointer mitk::NavigationToolReader::DoRead | ( | std::string | filename ) |
This method reads a navigation tool from a file.
filename | The filename where the tool is stored, "C:\temp\myTool.igtTool" for example. |
Definition at line 40 of file mitkNavigationToolReader.cpp.
References mitk::StandardFileLocations::GetInstance(), mitk::StandardFileLocations::GetOptionDirectory(), and mitk::SceneIO::New().
{ //decompress all files into a temporary directory std::ifstream file( filename.c_str(), std::ios::binary ); if (!file.good()) { m_ErrorMessage = "Cannot open '" + filename + "' for reading"; return NULL; } std::string tempDirectory = mitk::StandardFileLocations::GetInstance()->GetOptionDirectory() + "\\" +GetFileWithoutPath(filename); Poco::Zip::Decompress unzipper( file, Poco::Path( tempDirectory ) ); unzipper.decompressAllFiles(); //use SceneSerialization to load the DataStorage mitk::SceneIO::Pointer mySceneIO = mitk::SceneIO::New(); mitk::DataStorage::Pointer loadedStorage = mySceneIO->LoadScene(tempDirectory + Poco::Path::separator() + GetFileWithoutPath(filename) + ".storage"); if (loadedStorage->GetAll()->size()==0 || loadedStorage.IsNull()) { m_ErrorMessage = "Invalid file: cannot parse tool data."; return NULL; } //convert the DataStorage back to a NavigationTool-Object mitk::DataNode::Pointer myNode = loadedStorage->GetAll()->ElementAt(0); mitk::NavigationTool::Pointer returnValue = ConvertDataNodeToNavigationTool(myNode, tempDirectory); //delete the data-storage file which is not needed any more. The toolfile must be left in the temporary directory becauses it is linked in the datatreenode of the tool std::remove((std::string(tempDirectory + Poco::Path::separator() + GetFileWithoutPath(filename) + ".storage")).c_str()); return returnValue; }
virtual const char* mitk::NavigationToolReader::GetClassName | ( | ) | const [virtual] |
virtual std::string mitk::NavigationToolReader::GetErrorMessage | ( | ) | [virtual] |
std::string mitk::NavigationToolReader::GetFileWithoutPath | ( | std::string | FileWithPath ) | [protected] |
Definition at line 114 of file mitkNavigationToolReader.cpp.
{ std::string returnValue = ""; returnValue = FileWithPath.substr(FileWithPath.rfind("/")+1, FileWithPath.length()); //dirty hack: Windows path seperators if (returnValue.size() == FileWithPath.size()) returnValue = FileWithPath.substr(FileWithPath.rfind("\\")+1, FileWithPath.length()); return returnValue; }
static Pointer mitk::NavigationToolReader::New | ( | mitk::DataStorage::Pointer | _arg ) | [inline, static] |
Definition at line 44 of file mitkNavigationToolReader.h.
Referenced by mitk::NavigationToolStorageDeserializer::Deserialize(), and QmitkNavigationToolManagementWidget::OnLoadSingleTool().
:\temp\myTool.igtTool" for example.
friend class mitk::NavigationToolStorageDeserializer [friend] |
Definition at line 41 of file mitkNavigationToolReader.h.
Definition at line 63 of file mitkNavigationToolReader.h.
Referenced by NavigationToolReader().
std::string mitk::NavigationToolReader::m_ErrorMessage [protected] |
Definition at line 61 of file mitkNavigationToolReader.h.