17#include <mitkLocaleSwitch.h>
22#include <itksys/SystemTools.hxx>
28 std::string ReadStringAttribute(
const tinyxml2::XMLElement* elem,
const char* name)
30 const char* attrib = elem->Attribute(name);
32 return attrib !=
nullptr
40 "MITK USDevice Reader (XML)"), m_Filename(
"")
51 return m_DeviceConfig;
68 MITK_WARN <<
"This method is not implemented. \
69 Please use the method ReadUltrasoundDeviceConfiguration() instead.";
70 std::vector<mitk::BaseData::Pointer> result;
76 MITK_INFO <<
"Try to start reading xml device configuration...";
79 MITK_WARN <<
"Cannot read file - empty filename!";
83 tinyxml2::XMLDocument document;
84 if (tinyxml2::XML_SUCCESS != document.LoadFile(m_Filename.c_str()))
86 MITK_ERROR <<
"Error when opening and reading file :" << m_Filename;
90 tinyxml2::XMLHandle documentHandle(&document);
92 if (ultrasoundDeviceTag ==
nullptr)
94 MITK_ERROR <<
"Error parsing the file :" << m_Filename << std::endl <<
"Wrong xml format structure.";
99 this->ExtractAttributeInformationOfUltrasoundDeviceTag(ultrasoundDeviceTag);
102 if (generalSettingsTag ==
nullptr)
104 MITK_ERROR <<
"Error parsing the GENERALSETTINGS-Tag in the file :" << m_Filename;
109 this->ExtractAttributeInformationOfGeneralSettingsTag(generalSettingsTag);
112 if (probesTag ==
nullptr)
114 MITK_ERROR <<
"Error: PROBES-Tag was not found in the file :" << m_Filename <<
"Therefore, creating default probe.";
116 mitk::USProbe::Pointer ultrasoundProbeDefault = mitk::USProbe::New();
117 ultrasoundProbeDefault->SetName(
"default");
118 ultrasoundProbeDefault->SetDepth(0);
119 m_DeviceConfig.probes.push_back(ultrasoundProbeDefault);
125 probeTag !=
nullptr; probeTag = probeTag->NextSiblingElement())
127 this->ExtractProbe(probeTag);
134 m_Filename = filename;
166 mitk::USProbe::Pointer ultrasoundProbe = mitk::USProbe::New();
168 ultrasoundProbe->SetName(probeName);
171 if (depthsTag !=
nullptr)
174 depthTag !=
nullptr; depthTag = depthTag->NextSiblingElement())
177 mitk::Vector3D spacing;
185 if (spacingTag !=
nullptr)
191 ultrasoundProbe->SetDepthAndSpacing(depth, spacing);
196 MITK_ERROR <<
"Error: DEPTHS-Tag was not found in the file :" << m_Filename
197 <<
"Therefore, creating default depth [0] and spacing [1,1,1] for the probe.";
198 ultrasoundProbe->SetDepth(0);
201 unsigned int croppingTop = 0;
202 unsigned int croppingBottom = 0;
203 unsigned int croppingLeft = 0;
204 unsigned int croppingRight = 0;
207 if (croppingTag !=
nullptr)
215 ultrasoundProbe->SetProbeCropping(croppingTop, croppingBottom, croppingLeft, croppingRight);
216 m_DeviceConfig.probes.push_back(ultrasoundProbe);
void ExtractAttributeInformationOfGeneralSettingsTag(const tinyxml2::XMLElement *element)
Extracts all stored attribute information of the GENERALSETTINGS-Tag.
~USDeviceReaderXML() override
void ExtractAttributeInformationOfUltrasoundDeviceTag(const tinyxml2::XMLElement *element)
Extracts all stored attribute information of the ULTRASOUNDDEVICE-Tag.
void SetFilename(std::string filename)
std::vector< itk::SmartPointer< BaseData > > DoRead() override
USDeviceConfigData & GetUSDeviceConfigData()
void ExtractProbe(const tinyxml2::XMLElement *element)
Extracts all stored information of a single ultrasound probe.
mitk::USDeviceReaderXML * Clone() const override
bool ReadUltrasoundDeviceConfiguration()
static const char * ATTR_RESOLUTIONHEIGHT
static const char * ATTR_DEPTH
static const char * ATTR_TYPE
static const char * ATTR_SOURCEID
static const char * ATTR_BOTTOM
static const char * ATTR_IMAGESTREAMS
static const char * ATTR_X
static const char * ATTR_RESOLUTIONOVERRIDE
static const char * ATTR_OPENCVPORT
static const char * ATTR_FILEVERS
static const char * ATTR_FILEPATH
static const char * ATTR_TOP
static const char * TAG_DEPTH
static const char * TAG_SPACING
static const char * TAG_PROBE
static const char * ATTR_GREYSCALE
static const char * TAG_CROPPING
static const char * ATTR_PORT
static const char * ATTR_SERVER
static const char * ATTR_NAME
static const char * TAG_GENERALSETTINGS
static const char * TAG_PROBES
static const char * TAG_DEPTHS
static const char * TAG_ULTRASOUNDDEVICE
static const char * ATTR_LEFT
static const char * ATTR_RIGHT
static const char * ATTR_RESOLUTIONWIDTH
static const char * ATTR_Y
static const char * ATTR_HOST