24 #include <itksys/SystemTools.hxx>
30 "MITK NavigationDataSet Writer (XML)")
50 std::ostream* out = GetOutputStream();
53 out =
new std::ofstream( GetOutputLocation().c_str() );
59 StreamHeader(out, data);
60 StreamData(out, data);
70 stream->precision(10);
76 *stream <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" << std::endl;
79 *stream <<
" " <<
"<Data ToolCount=\"" << data->GetNumberOfTools() <<
"\" version=\"1.0\">" << std::endl;
86 for (
auto it = data->Begin(); it != data->End(); it++)
88 for (std::size_t toolIndex = 0; toolIndex < it->size(); toolIndex++)
91 auto elem =
new TiXmlElement(
"ND");
93 elem->SetDoubleAttribute(
"Time", nd->GetIGTTimeStamp());
95 elem->SetDoubleAttribute(
"Tool", toolIndex);
96 elem->SetDoubleAttribute(
"X", nd->GetPosition()[0]);
97 elem->SetDoubleAttribute(
"Y", nd->GetPosition()[1]);
98 elem->SetDoubleAttribute(
"Z", nd->GetPosition()[2]);
100 elem->SetDoubleAttribute(
"QX", nd->GetOrientation()[0]);
101 elem->SetDoubleAttribute(
"QY", nd->GetOrientation()[1]);
102 elem->SetDoubleAttribute(
"QZ", nd->GetOrientation()[2]);
103 elem->SetDoubleAttribute(
"QR", nd->GetOrientation()[3]);
105 elem->SetDoubleAttribute(
"C00", nd->GetCovErrorMatrix()[0][0]);
106 elem->SetDoubleAttribute(
"C01", nd->GetCovErrorMatrix()[0][1]);
107 elem->SetDoubleAttribute(
"C02", nd->GetCovErrorMatrix()[0][2]);
108 elem->SetDoubleAttribute(
"C03", nd->GetCovErrorMatrix()[0][3]);
109 elem->SetDoubleAttribute(
"C04", nd->GetCovErrorMatrix()[0][4]);
110 elem->SetDoubleAttribute(
"C05", nd->GetCovErrorMatrix()[0][5]);
111 elem->SetDoubleAttribute(
"C10", nd->GetCovErrorMatrix()[1][0]);
112 elem->SetDoubleAttribute(
"C11", nd->GetCovErrorMatrix()[1][1]);
113 elem->SetDoubleAttribute(
"C12", nd->GetCovErrorMatrix()[1][2]);
114 elem->SetDoubleAttribute(
"C13", nd->GetCovErrorMatrix()[1][3]);
115 elem->SetDoubleAttribute(
"C14", nd->GetCovErrorMatrix()[1][4]);
116 elem->SetDoubleAttribute(
"C15", nd->GetCovErrorMatrix()[1][5]);
118 if (nd->IsDataValid())
119 elem->SetAttribute(
"Valid",1);
121 elem->SetAttribute(
"Valid",0);
123 if (nd->GetHasOrientation())
124 elem->SetAttribute(
"hO",1);
126 elem->SetAttribute(
"hO",0);
128 if (nd->GetHasPosition())
129 elem->SetAttribute(
"hP",1);
131 elem->SetAttribute(
"hP",0);
133 *stream <<
" " << *elem << std::endl;
142 *stream <<
"</Data>" << std::endl;
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
virtual void StreamData(std::ostream *stream, mitk::NavigationDataSet::ConstPointer data)
virtual mitk::NavigationDataSetWriterXML * Clone() const override
Convenience class to temporarily change the current locale.
static const char * GetStaticNameOfClass()
Data structure which stores streams of mitk::NavigationData for multiple tools.
virtual void Write() override
Write the base data to the specified location or output stream.
virtual void StreamFooter(std::ostream *stream)
us::ServiceRegistration< IFileWriter > RegisterService(us::ModuleContext *context=us::GetModuleContext())
NavigationDataSetWriterXML()
virtual ~NavigationDataSetWriterXML()
Base class for writing mitk::BaseData objects to files or streams.
virtual void StreamHeader(std::ostream *stream, mitk::NavigationDataSet::ConstPointer data)