This class offers methods to write objects of the class navigation tool permanently to the harddisk. The objects are saved in a special fileformat which can be read by the class NavigationToolReader to restore the object. More...
#include <mitkNavigationToolWriter.h>
Public Types | |
| typedef NavigationToolWriter | Self |
| typedef itk::Object | Superclass |
| typedef itk::SmartPointer< Self > | Pointer |
| typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
| virtual const char * | GetClassName () const |
| bool | DoWrite (std::string FileName, mitk::NavigationTool::Pointer Tool) |
| Writes a navigation tool to a file. | |
| virtual std::string | GetErrorMessage () |
Static Public Member Functions | |
| static Pointer | New () |
Protected Member Functions | |
| NavigationToolWriter () | |
| ~NavigationToolWriter () | |
| mitk::DataNode::Pointer | ConvertToDataNode (mitk::NavigationTool::Pointer Tool) |
| std::string | GetFileWithoutPath (std::string FileWithPath) |
Protected Attributes | |
| std::string | m_ErrorMessage |
Friends | |
| class | mitk::NavigationToolStorageSerializer |
This class offers methods to write objects of the class navigation tool permanently to the harddisk. The objects are saved in a special fileformat which can be read by the class NavigationToolReader to restore the object.
Documentation
Definition at line 40 of file mitkNavigationToolWriter.h.
| typedef itk::SmartPointer<const Self> mitk::NavigationToolWriter::ConstPointer |
Definition at line 45 of file mitkNavigationToolWriter.h.
| typedef itk::SmartPointer<Self> mitk::NavigationToolWriter::Pointer |
Definition at line 45 of file mitkNavigationToolWriter.h.
Definition at line 45 of file mitkNavigationToolWriter.h.
| typedef itk::Object mitk::NavigationToolWriter::Superclass |
Definition at line 45 of file mitkNavigationToolWriter.h.
| mitk::NavigationToolWriter::NavigationToolWriter | ( | ) | [protected] |
Definition at line 32 of file mitkNavigationToolWriter.cpp.
{
}
| mitk::NavigationToolWriter::~NavigationToolWriter | ( | ) | [protected] |
Definition at line 37 of file mitkNavigationToolWriter.cpp.
{
}
| mitk::DataNode::Pointer mitk::NavigationToolWriter::ConvertToDataNode | ( | mitk::NavigationTool::Pointer | Tool ) | [protected] |
Definition at line 72 of file mitkNavigationToolWriter.cpp.
References mitk::IntProperty::New(), mitk::StringProperty::New(), and mitk::DataNode::New().
{
mitk::DataNode::Pointer thisTool = mitk::DataNode::New();
//Name
thisTool->SetName(Tool->GetDataNode()->GetName().c_str());
//Identifier
thisTool->AddProperty("identifier",mitk::StringProperty::New(Tool->GetIdentifier().c_str()));
//Serial Number
thisTool->AddProperty("serial number",mitk::StringProperty::New(Tool->GetSerialNumber().c_str()));
//Tracking Device
thisTool->AddProperty("tracking device type",mitk::IntProperty::New(Tool->GetTrackingDeviceType()));
//Tool Type
thisTool->AddProperty("tracking tool type",mitk::IntProperty::New(Tool->GetType()));
//Calibration File Name
thisTool->AddProperty("toolfileName",mitk::StringProperty::New(GetFileWithoutPath(Tool->GetCalibrationFile())));
//Surface
thisTool->SetData(Tool->GetDataNode()->GetData());
//Material is not needed, to avoid errors in scene serialization we have to do this:
//thisTool->ReplaceProperty("material",NULL);
return thisTool;
}
| bool mitk::NavigationToolWriter::DoWrite | ( | std::string | FileName, |
| mitk::NavigationTool::Pointer | Tool | ||
| ) |
Writes a navigation tool to a file.
| FileName | The filename (complete, with path, C:.igtTool for example) |
| Tool | The tool which should be written to the file. |
Definition at line 42 of file mitkNavigationToolWriter.cpp.
References mitk::StandardFileLocations::GetInstance(), mitk::StandardFileLocations::GetOptionDirectory(), mitk::SceneIO::New(), and mitk::StandaloneDataStorage::New().
{
//convert whole data to a mitk::DataStorage
mitk::StandaloneDataStorage::Pointer saveStorage = mitk::StandaloneDataStorage::New();
mitk::DataNode::Pointer thisTool = ConvertToDataNode(Tool);
saveStorage->Add(thisTool);
//use SceneSerialization to save the DataStorage
std::string DataStorageFileName = mitk::StandardFileLocations::GetInstance()->GetOptionDirectory() + Poco::Path::separator() + GetFileWithoutPath(FileName) + ".storage";
mitk::SceneIO::Pointer mySceneIO = mitk::SceneIO::New();
mySceneIO->SaveScene(saveStorage->GetAll(),saveStorage,DataStorageFileName);
//now put the DataStorage and the Toolfile in a ZIP-file
std::ofstream file( FileName.c_str(), std::ios::binary | std::ios::out);
if (!file.good())
{
m_ErrorMessage = "Could not open a zip file for writing: '" + FileName + "'";
return false;
}
else
{
Poco::Zip::Compress zipper( file, true );
zipper.addFile(DataStorageFileName,GetFileWithoutPath(DataStorageFileName));
zipper.addFile(Tool->GetCalibrationFile(),GetFileWithoutPath(Tool->GetCalibrationFile()));
zipper.close();
}
return true;
}
| virtual const char* mitk::NavigationToolWriter::GetClassName | ( | ) | const [virtual] |
| virtual std::string mitk::NavigationToolWriter::GetErrorMessage | ( | ) | [virtual] |
| std::string mitk::NavigationToolWriter::GetFileWithoutPath | ( | std::string | FileWithPath ) | [protected] |
Definition at line 96 of file mitkNavigationToolWriter.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::NavigationToolWriter::New | ( | ) | [static] |
friend class mitk::NavigationToolStorageSerializer [friend] |
Definition at line 42 of file mitkNavigationToolWriter.h.
std::string mitk::NavigationToolWriter::m_ErrorMessage [protected] |
Definition at line 62 of file mitkNavigationToolWriter.h.
1.7.2