18 #include <Poco/Zip/Compress.h>
19 #include <Poco/Path.h>
47 m_ErrorMessage =
"Cannot write a navigation tool containing invalid tool data, aborting!";
57 if ( Tool->GetDataNode().IsNotNull()
58 && (Tool->GetDataNode()->GetData()!=NULL)
59 && (Tool->GetDataNode()->GetData()->GetGeometry()!=NULL)
62 geometryBackup = Tool->GetDataNode()->GetData()->GetGeometry()->Clone();
63 Tool->GetDataNode()->GetData()->GetGeometry()->SetIdentity();
65 else {
MITK_WARN <<
"Saving a tool with invalid data node, proceeding but errors might occure!";}
70 saveStorage->Add(thisTool);
75 mySceneIO->SaveScene(saveStorage->GetAll(),saveStorage,DataStorageFileName);
78 std::ofstream file( FileName.c_str(), std::ios::binary | std::ios::out);
81 m_ErrorMessage =
"Could not open a zip file for writing: '" + FileName +
"'";
87 Poco::Zip::Compress zipper( file,
true );
88 zipper.addFile(DataStorageFileName,GetFileWithoutPath(DataStorageFileName));
89 if (Tool->GetCalibrationFile()!=
"none") zipper.addFile(Tool->GetCalibrationFile(),GetFileWithoutPath(Tool->GetCalibrationFile()));
94 std::remove(DataStorageFileName.c_str());
97 if (geometryBackup.IsNotNull()) {Tool->GetDataNode()->GetData()->SetGeometry(geometryBackup);}
106 if (Tool->GetDataNode().IsNull()) thisTool->SetName(
"none");
107 else thisTool->SetName(Tool->GetDataNode()->GetName().c_str());
119 if (Tool->GetDataNode().IsNotNull())
if (Tool->GetDataNode()->GetData()!=NULL) thisTool->SetData(Tool->GetDataNode()->GetData());
122 thisTool->AddProperty(
"ToolRegistrationLandmarks",
mitk::StringProperty::New(ConvertPointSetToString(Tool->GetToolRegistrationLandmarks())));
123 thisTool->AddProperty(
"ToolCalibrationLandmarks",
mitk::StringProperty::New(ConvertPointSetToString(Tool->GetToolCalibrationLandmarks())));
126 if (Tool->IsToolTipSet())
129 thisTool->AddProperty(
"ToolTipOrientation",
mitk::StringProperty::New(ConvertQuaternionToString(Tool->GetToolTipOrientation())));
133 thisTool->ReplaceProperty(
"material",NULL);
141 Poco::Path myFile(FileWithPath.c_str());
142 return myFile.getFileName();
147 std::stringstream returnValue;
149 for ( it = pointSet->GetPointSet()->GetPointData()->Begin();it != pointSet->GetPointSet()->GetPointData()->End();it++ )
152 returnValue << it->Index() <<
";" << ConvertPointToString(thisPoint) <<
"|";
154 return returnValue.str();
159 std::stringstream returnValue;
160 returnValue << point[0] <<
";" << point[1] <<
";" << point[2];
161 return returnValue.str();
166 std::stringstream returnValue;
167 returnValue << quat.x() <<
";" << quat.y() <<
";" << quat.z() <<
";" << quat.r();
168 return returnValue.str();
itk::SmartPointer< Self > Pointer
vnl_quaternion< ScalarType > Quaternion
static std::string CreateTemporaryDirectory(const std::string &templateName="XXXXXX", std::string path=std::string())
DataType::PointDataContainerIterator PointDataIterator