43 m_ErrorMessage =
"Cannot write a navigation tool containing invalid tool data, aborting!";
44 MITK_ERROR << m_ErrorMessage;
52 mitk::BaseGeometry::Pointer geometryBackup;
53 if ( Tool->GetDataNode().IsNotNull()
54 && (Tool->GetDataNode()->GetData()!=
nullptr)
55 && (Tool->GetDataNode()->GetData()->GetGeometry()!=
nullptr)
58 geometryBackup = Tool->GetDataNode()->GetData()->GetGeometry()->Clone();
59 Tool->GetDataNode()->GetData()->GetGeometry()->SetIdentity();
61 else {MITK_WARN <<
"Saving a tool with invalid data node, proceeding but errors might occure!";}
64 mitk::StandaloneDataStorage::Pointer saveStorage = mitk::StandaloneDataStorage::New();
65 mitk::DataNode::Pointer thisTool = ConvertToDataNode(Tool);
66 saveStorage->Add(thisTool);
69 std::string DataStorageFileName = mitk::IOUtil::CreateTemporaryDirectory() + Poco::Path::separator() + GetFileWithoutPath(FileName) +
".storage";
70 mitk::SceneIO::Pointer mySceneIO = mitk::SceneIO::New();
71 mySceneIO->SaveScene(saveStorage->GetAll(),saveStorage,DataStorageFileName);
74 std::ofstream file( FileName.c_str(), std::ios::binary | std::ios::out);
77 m_ErrorMessage =
"Could not open a zip file for writing: '" + FileName +
"'";
78 MITK_ERROR << m_ErrorMessage;
83 Poco::Zip::Compress zipper( file,
true );
84 zipper.addFile(DataStorageFileName,GetFileWithoutPath(DataStorageFileName));
85 if (Tool->GetCalibrationFile()!=
"none") zipper.addFile(Tool->GetCalibrationFile(),GetFileWithoutPath(Tool->GetCalibrationFile()));
90 std::remove(DataStorageFileName.c_str());
93 if (geometryBackup.IsNotNull()) {Tool->GetDataNode()->GetData()->SetGeometry(geometryBackup);}
100 mitk::DataNode::Pointer thisTool = Tool->GetDataNode();
102 if (Tool->GetDataNode().IsNull())
104 thisTool = mitk::DataNode::New();
105 thisTool->SetName(
"none");
109 thisTool->AddProperty(
"identifier",mitk::StringProperty::New(Tool->GetIdentifier().c_str()),
nullptr,
true);
111 thisTool->AddProperty(
"serial number",mitk::StringProperty::New(Tool->GetSerialNumber().c_str()),
nullptr,
true);
113 thisTool->AddProperty(
"tracking device type",mitk::StringProperty::New(Tool->GetTrackingDeviceType()),
nullptr,
true);
115 thisTool->AddProperty(
"tracking tool type",mitk::IntProperty::New(Tool->GetType()),
nullptr,
true);
117 thisTool->AddProperty(
"toolfileName",mitk::StringProperty::New(GetFileWithoutPath(Tool->GetCalibrationFile())),
nullptr,
true);
119 thisTool->AddProperty(
"ToolRegistrationLandmarks",mitk::StringProperty::New(ConvertPointSetToString(Tool->GetToolLandmarks())),
nullptr,
true);
120 thisTool->AddProperty(
"ToolCalibrationLandmarks",mitk::StringProperty::New(ConvertPointSetToString(Tool->GetToolControlPoints())),
nullptr,
true);
123 if (Tool->IsToolTipSet())
125 thisTool->AddProperty(
"ToolTipPosition",mitk::StringProperty::New(ConvertPointToString(Tool->GetToolTipPosition())),
nullptr,
true);
126 thisTool->AddProperty(
"ToolAxisOrientation",mitk::StringProperty::New(ConvertQuaternionToString(Tool->GetToolAxisOrientation())),
nullptr,
true);
130 thisTool->RemoveProperty(
"material");
143 std::stringstream returnValue;
144 mitk::PointSet::PointDataIterator it;
145 for ( it = pointSet->GetPointSet()->GetPointData()->Begin();it != pointSet->GetPointSet()->GetPointData()->End();it++ )
147 mitk::Point3D thisPoint = pointSet->GetPoint(it->Index());
148 returnValue << it->Index() <<
";" << ConvertPointToString(thisPoint) <<
"|";
150 return returnValue.str();