22 #include <itksys/SystemTools.hxx> 28 "MITK USDevice Reader (XML)"), m_Filename(
"")
39 return m_DeviceConfig;
56 MITK_WARN <<
"This method is not implemented. \ 57 Please use the method ReadUltrasoundDeviceConfiguration() instead.";
58 std::vector<mitk::BaseData::Pointer> result;
64 MITK_INFO <<
"Try to start reading xml device configuration...";
67 MITK_WARN <<
"Cannot read file - empty filename!";
71 TiXmlDocument document(m_Filename);
72 if (!document.LoadFile())
74 MITK_ERROR <<
"Error when opening and reading file :" << m_Filename;
78 TiXmlHandle documentHandle(&document);
79 TiXmlElement* ultrasoundDeviceTag = documentHandle.FirstChildElement(
TAG_ULTRASOUNDDEVICE).ToElement();
80 if (ultrasoundDeviceTag ==
nullptr)
82 MITK_ERROR <<
"Error parsing the file :" << m_Filename << std::endl <<
"Wrong xml format structure.";
90 if (generalSettingsTag ==
nullptr)
92 MITK_ERROR <<
"Error parsing the GENERALSETTINGS-Tag in the file :" << m_Filename;
100 if (probesTag ==
nullptr)
102 MITK_ERROR <<
"Error: PROBES-Tag was not found in the file :" << m_Filename <<
"Therefore, creating default probe.";
105 ultrasoundProbeDefault->SetName(
"default");
106 ultrasoundProbeDefault->SetDepth(0);
107 m_DeviceConfig.
probes.push_back(ultrasoundProbeDefault);
112 for (TiXmlElement* probeTag = probesTag->FirstChildElement(
TAG_PROBE);
113 probeTag !=
nullptr; probeTag = probeTag->NextSiblingElement())
122 m_Filename = filename;
131 ultrasoundTag->QueryStringAttribute(
ATTR_MODEL, &m_DeviceConfig.
model);
134 ultrasoundTag->QueryStringAttribute(
ATTR_HOST, &m_DeviceConfig.
host);
135 ultrasoundTag->QueryIntAttribute(
ATTR_PORT, &m_DeviceConfig.
port);
153 std::string probeName;
154 probeTag->QueryStringAttribute(
ATTR_NAME, &probeName);
155 ultrasoundProbe->SetName(probeName);
157 TiXmlElement* depthsTag = probeTag->FirstChildElement(
TAG_DEPTHS);
158 if (depthsTag !=
nullptr)
160 for (TiXmlElement* depthTag = depthsTag->FirstChildElement(
TAG_DEPTH);
161 depthTag !=
nullptr; depthTag = depthTag->NextSiblingElement())
169 depthTag->QueryIntAttribute(
ATTR_DEPTH, &depth);
171 TiXmlElement* spacingTag = depthTag->FirstChildElement(
TAG_SPACING);
172 if (spacingTag !=
nullptr)
174 spacingTag->QueryDoubleAttribute(
ATTR_X, &spacing[0]);
175 spacingTag->QueryDoubleAttribute(
ATTR_Y, &spacing[1]);
178 ultrasoundProbe->SetDepthAndSpacing(depth, spacing);
183 MITK_ERROR <<
"Error: DEPTHS-Tag was not found in the file :" << m_Filename
184 <<
"Therefore, creating default depth [0] and spacing [1,1,1] for the probe.";
185 ultrasoundProbe->SetDepth(0);
188 unsigned int croppingTop = 0;
189 unsigned int croppingBottom = 0;
190 unsigned int croppingLeft = 0;
191 unsigned int croppingRight = 0;
193 TiXmlElement* croppingTag = probeTag->FirstChildElement(
TAG_CROPPING);
194 if (croppingTag !=
nullptr)
196 croppingTag->QueryUnsignedAttribute(
ATTR_TOP, &croppingTop);
197 croppingTag->QueryUnsignedAttribute(
ATTR_BOTTOM, &croppingBottom);
198 croppingTag->QueryUnsignedAttribute(
ATTR_LEFT, &croppingLeft);
199 croppingTag->QueryUnsignedAttribute(
ATTR_RIGHT, &croppingRight);
202 ultrasoundProbe->SetProbeCropping(croppingTop, croppingBottom, croppingLeft, croppingRight);
203 m_DeviceConfig.
probes.push_back(ultrasoundProbe);
static const char * TAG_CROPPING
static const char * TAG_DEPTH
static const char * ATTR_OPENCVPORT
static const char * ATTR_SERVER
mitk::USDeviceReaderXML * Clone() const override
static const char * TAG_PROBE
USDeviceConfigData & GetUSDeviceConfigData()
static const char * ATTR_RIGHT
DataCollection - Class to facilitate loading/accessing structured data.
static const char * ATTR_GREYSCALE
static const char * ATTR_RESOLUTIONWIDTH
std::string filepathVideoSource
std::vector< mitk::USProbe::Pointer > probes
static const char * ATTR_TOP
static const char * ATTR_DEPTH
static const char * ATTR_Y
std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
bool useResolutionOverride
bool ReadUltrasoundDeviceConfiguration()
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
void ExtractAttributeInformationOfGeneralSettingsTag(TiXmlElement *element)
Extracts all stored attribute information of the GENERALSETTINGS-Tag.
static const char * ATTR_LEFT
static const char * ATTR_COMMENT
void ExtractProbe(TiXmlElement *element)
Extracts all stored information of a single ultrasound probe.
static const char * ATTR_X
static const char * ATTR_TYPE
void SetFilename(std::string filename)
static const char * ATTR_IMAGESTREAMS
static const char * ATTR_PORT
~USDeviceReaderXML() override
void ExtractAttributeInformationOfUltrasoundDeviceTag(TiXmlElement *element)
Extracts all stored attribute information of the ULTRASOUNDDEVICE-Tag.
static const char * ATTR_FILEVERS
Base class for creating mitk::BaseData objects from files or streams.
static const char * ATTR_FILEPATH
static const char * ATTR_RESOLUTIONHEIGHT
static const char * ATTR_MODEL
static const char * ATTR_BOTTOM
static const char * TAG_ULTRASOUNDDEVICE
static const char * TAG_SPACING
static const char * ATTR_NAME
static const char * ATTR_HOST
static const char * TAG_GENERALSETTINGS
static const char * ATTR_RESOLUTIONOVERRIDE
static const char * ATTR_MANUFACTURER
static const char * TAG_PROBES
static const char * TAG_DEPTHS
static const char * ATTR_SOURCEID