18 #include <Poco/Zip/Decompress.h>
19 #include <Poco/Path.h>
48 std::ifstream file(filename.c_str(), std::ios::binary);
51 m_ErrorMessage =
"Cannot open '" + filename +
"' for reading";
55 std::string tempDirectory = m_ToolfilePath + GetFileWithoutPath(filename);
56 Poco::Zip::Decompress unzipper(file, Poco::Path(tempDirectory));
57 unzipper.decompressAllFiles();
61 mitk::DataStorage::Pointer loadedStorage = mySceneIO->LoadScene(tempDirectory + Poco::Path::separator() + GetFileWithoutPath(filename) +
".storage");
63 if (loadedStorage->GetAll()->size() == 0 || loadedStorage.IsNull())
65 m_ErrorMessage =
"Invalid file: cannot parse tool data.";
74 std::remove((std::string(tempDirectory + Poco::Path::separator() + GetFileWithoutPath(filename) +
".storage")).c_str());
85 newNode->SetName(node->GetName());
86 newNode->SetData(node->GetData());
87 returnValue->SetDataNode(newNode);
90 std::string identifier;
91 node->GetStringProperty(
"identifier", identifier);
92 returnValue->SetIdentifier(identifier);
96 node->GetStringProperty(
"serial number", serial);
97 returnValue->SetSerialNumber(serial);
101 node->GetStringProperty(
"tracking device type", device_type);
104 if (device_type.size() == 0)
123 node->GetIntProperty(
"tracking device type", device_type_old);
124 switch (device_type_old)
129 case 3:device_type =
"IntuitiveDaVinci";
break;
130 case 4:device_type =
"AscensionMicroBird";
break;
133 case 7:device_type =
"TrackingSystemInvalid";
break;
140 returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type));
144 node->GetIntProperty(
"tracking tool type", type);
145 returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type));
148 std::string calibration_filename;
149 node->GetStringProperty(
"toolfileName", calibration_filename);
150 if (calibration_filename ==
"none")
152 returnValue->SetCalibrationFile(
"none");
156 std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
157 returnValue->SetCalibrationFile(calibration_filename_with_path);
163 std::string RegLandmarksString;
164 std::string CalLandmarksString;
165 node->GetStringProperty(
"ToolRegistrationLandmarks", RegLandmarksString);
166 node->GetStringProperty(
"ToolCalibrationLandmarks", CalLandmarksString);
167 ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
168 ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
169 returnValue->SetToolRegistrationLandmarks(ToolRegLandmarks);
170 returnValue->SetToolCalibrationLandmarks(ToolCalLandmarks);
173 std::string toolTipPositionString;
174 std::string toolTipOrientationString;
175 bool positionSet = node->GetStringProperty(
"ToolTipPosition", toolTipPositionString);
176 bool orientationSet = node->GetStringProperty(
"ToolTipOrientation", toolTipOrientationString);
178 if (positionSet && orientationSet)
180 returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
181 returnValue->SetToolTipOrientation(ConvertStringToQuaternion(toolTipOrientationString));
183 else if (positionSet != orientationSet)
185 MITK_WARN <<
"Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
193 Poco::Path myFile(FileWithPath.c_str());
194 return myFile.getFileName();
200 std::string pointSeperator =
"|";
201 std::string valueSeperator =
";";
202 std::vector<std::string> points;
203 split(
string, pointSeperator, points);
204 for (
unsigned int i = 0; i < points.size(); i++)
206 std::vector<std::string> values;
207 split(points.at(i), valueSeperator, values);
208 if (values.size() == 4)
210 double index = atof(values.at(0).c_str());
212 point[0] = atof(values.at(1).c_str());
213 point[1] = atof(values.at(2).c_str());
214 point[2] = atof(values.at(3).c_str());
215 returnValue->SetPoint(index, point);
222 std::string valueSeperator =
";";
223 std::vector<std::string> values;
224 split(
string, valueSeperator, values);
226 if (values.size() == 3)
228 point[0] = atof(values.at(0).c_str());
229 point[1] = atof(values.at(1).c_str());
230 point[2] = atof(values.at(2).c_str());
237 std::string valueSeperator =
";";
238 std::vector<std::string> values;
239 split(
string, valueSeperator, values);
241 if (values.size() == 4)
244 atof(values.at(1).c_str()),
245 atof(values.at(2).c_str()),
246 atof(values.at(3).c_str()));
253 int n = text.length();
256 start = text.find_first_not_of(separators);
257 while ((start >= 0) && (start < n))
259 stop = text.find_first_of(separators, start);
260 if ((stop < 0) || (stop > n)) stop = n;
261 words.push_back(text.substr(start, stop - start));
262 start = text.find_first_not_of(separators, stop + 1);
itk::SmartPointer< Self > Pointer
static std::string GetTempPath()
static const std::string filename
vnl_quaternion< ScalarType > Quaternion
std::string TrackingDeviceType
static std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)