44 std::ifstream file(filename.c_str(), std::ios::binary);
47 m_ErrorMessage =
"Cannot open '" + filename +
"' for reading";
51 std::string tempDirectory = m_ToolfilePath + GetFileWithoutPath(filename);
52 Poco::Zip::Decompress unzipper(file, Poco::Path(tempDirectory));
53 unzipper.decompressAllFiles();
56 mitk::SceneIO::Pointer mySceneIO = mitk::SceneIO::New();
57 mitk::DataStorage::Pointer loadedStorage = mySceneIO->LoadScene(tempDirectory + Poco::Path::separator() + GetFileWithoutPath(filename) +
".storage");
59 if (loadedStorage->GetAll()->size() == 0 || loadedStorage.IsNull())
61 m_ErrorMessage =
"Invalid file: cannot parse tool data.";
66 mitk::DataNode::Pointer myNode = loadedStorage->GetAll()->ElementAt(0);
67 mitk::NavigationTool::Pointer returnValue = ConvertDataNodeToNavigationTool(myNode, tempDirectory);
70 std::remove((std::string(tempDirectory + Poco::Path::separator() + GetFileWithoutPath(filename) +
".storage")).c_str());
77 mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New();
80 returnValue->SetDataNode(node);
83 std::string identifier;
84 node->GetStringProperty(
"identifier", identifier);
85 returnValue->SetIdentifier(identifier);
87 node->RemoveProperty(
"identifier");
91 node->GetStringProperty(
"serial number", serial);
92 returnValue->SetSerialNumber(serial);
94 node->RemoveProperty(
"serial number");
98 node->GetStringProperty(
"tracking device type", device_type);
101 if (device_type.size() == 0)
120 node->GetIntProperty(
"tracking device type", device_type_old);
121 switch (device_type_old)
126 case 3:device_type =
"IntuitiveDaVinci";
break;
127 case 4:device_type =
"AscensionMicroBird";
break;
130 case 7:device_type =
"TrackingSystemInvalid";
break;
137 node->RemoveProperty(
"tracking device type");
143 node->GetIntProperty(
"tracking tool type", type);
146 node->RemoveProperty(
"tracking tool type");
149 std::string calibration_filename;
150 node->GetStringProperty(
"toolfileName", calibration_filename);
151 if (calibration_filename ==
"none")
153 returnValue->SetCalibrationFile(
"none");
157 std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
158 returnValue->SetCalibrationFile(calibration_filename_with_path);
161 node->RemoveProperty(
"toolfileName");
164 mitk::PointSet::Pointer ToolRegLandmarks = mitk::PointSet::New();
165 mitk::PointSet::Pointer ToolCalLandmarks = mitk::PointSet::New();
166 std::string RegLandmarksString;
167 std::string CalLandmarksString;
168 node->GetStringProperty(
"ToolRegistrationLandmarks", RegLandmarksString);
169 node->GetStringProperty(
"ToolCalibrationLandmarks", CalLandmarksString);
170 ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
171 ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
172 returnValue->SetToolLandmarks(ToolRegLandmarks);
173 returnValue->SetToolControlPoints(ToolCalLandmarks);
175 node->RemoveProperty(
"ToolRegistrationLandmarks");
176 node->RemoveProperty(
"ToolCalibrationLandmarks");
179 std::string toolTipPositionString;
180 std::string toolTipOrientationString;
181 bool positionSet = node->GetStringProperty(
"ToolTipPosition", toolTipPositionString);
182 bool orientationSet = node->GetStringProperty(
"ToolAxisOrientation", toolTipOrientationString);
184 if (positionSet && orientationSet)
186 returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
187 returnValue->SetToolAxisOrientation(ConvertStringToQuaternion(toolTipOrientationString));
189 else if (positionSet != orientationSet)
191 MITK_WARN <<
"Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
194 node->RemoveProperty(
"ToolTipPosition");
195 node->RemoveProperty(
"ToolAxisOrientation");
208 mitk::PointSet::Pointer returnValue = mitk::PointSet::New();
209 std::string pointSeperator =
"|";
210 std::string valueSeperator =
";";
211 std::vector<std::string> points;
212 split(
string, pointSeperator, points);
213 for (
unsigned int i = 0; i < points.size(); i++)
215 std::vector<std::string> values;
216 split(points.at(i), valueSeperator, values);
217 if (values.size() == 4)
219 double index = atof(values.at(0).c_str());
221 point[0] = atof(values.at(1).c_str());
222 point[1] = atof(values.at(2).c_str());
223 point[2] = atof(values.at(3).c_str());
224 returnValue->SetPoint(index, point);
231 std::string valueSeperator =
";";
232 std::vector<std::string> values;
233 split(
string, valueSeperator, values);
235 if (values.size() == 3)
237 point[0] = atof(values.at(0).c_str());
238 point[1] = atof(values.at(1).c_str());
239 point[2] = atof(values.at(2).c_str());
246 std::string valueSeperator =
";";
247 std::vector<std::string> values;
248 split(
string, valueSeperator, values);
249 mitk::Quaternion quat = mitk::Quaternion(0, 0, 0, 1);
250 if (values.size() == 4)
252 quat = mitk::Quaternion(atof(values.at(0).c_str()),
253 atof(values.at(1).c_str()),
254 atof(values.at(2).c_str()),
255 atof(values.at(3).c_str()));
262 int n = text.length();
265 start = text.find_first_not_of(separators);
266 while ((start >= 0) && (start < n))
268 stop = text.find_first_of(separators, start);
269 if ((stop < 0) || (stop > n)) stop = n;
270 words.push_back(text.substr(start, stop - start));
271 start = text.find_first_not_of(separators, stop + 1);