38 #include <visp3/ustk_core/usImageSettingsXmlParser.h>
45 : m_transducerSettings(
usTransducerSettings()), m_spacingX(0.0), m_spacingY(0.0), m_spacingZ(0.0),
46 m_motorSettings(
usMotorSettings()), m_imageFileName(std::string(
"")), m_image_type(
us::UNKNOWN), m_is_3D(false),
116 for (xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) {
117 if (dataNode->type == XML_ELEMENT_NODE) {
118 std::map<std::string, int>::iterator iter_data = this->nodeMap.find((
char *)dataNode->name);
119 if (iter_data != nodeMap.end()) {
120 switch (iter_data->second) {
122 value = xmlReadStringChild(doc, dataNode);
123 if (strcmp(value.c_str(),
"postscan") == 0) {
125 }
else if (strcmp(value.c_str(),
"prescan") == 0) {
127 }
else if (strcmp(value.c_str(),
"rf") == 0) {
130 throw(vpException(vpException::fatalError, std::string(
"unknown image type in xml file")));
134 this->m_axialResolution = xmlReadDoubleChild(doc, dataNode);
136 throw(vpException(vpException::fatalError,
137 std::string(
"Trying to assign an axial resolution to a post-scan image !")));
141 throw(vpException(vpException::fatalError,
142 std::string(
"Trying to assign an height resolution to a pre-scan image !")));
143 }
else if (this->m_is_3D) {
145 vpException::fatalError,
146 std::string(
"Trying to assign an height resolution to a 3D image ! Use spacing_y instead.")));
148 this->m_heightResolution = xmlReadDoubleChild(doc, dataNode);
152 throw(vpException(vpException::fatalError,
153 std::string(
"Trying to assign an width resolution to a pre-scan image !")));
154 }
else if (this->m_is_3D) {
156 vpException::fatalError,
157 std::string(
"Trying to assign an height resolution to a 3D image ! Use spacing_x instead.")));
159 this->m_widthResolution = xmlReadDoubleChild(doc, dataNode);
164 vpException(vpException::fatalError, std::string(
"Trying to assign a spacing to a pre-scan image !")));
165 }
else if (!this->m_is_3D) {
167 vpException::fatalError,
168 std::string(
"Trying to assign a spacing to a 2D image ! Use height/width resolutions instead.")));
170 this->m_widthResolution = xmlReadDoubleChild(doc, dataNode);
175 vpException(vpException::fatalError, std::string(
"Trying to assign a spacing to a pre-scan image !")));
176 }
else if (!this->m_is_3D) {
178 vpException::fatalError,
179 std::string(
"Trying to assign an spacing to a 2D image ! Use height/width resolutions instead.")));
181 this->m_widthResolution = xmlReadDoubleChild(doc, dataNode);
186 vpException(vpException::fatalError, std::string(
"Trying to assign a spacing to a pre-scan image !")));
187 }
else if (!this->m_is_3D) {
189 vpException::fatalError,
190 std::string(
"Trying to assign an spacing to a 2D image ! Use height/width resolutions instead.")));
192 this->m_widthResolution = xmlReadDoubleChild(doc, dataNode);
196 throw(vpException(vpException::fatalError,
197 std::string(
"Trying to assign a scan line number to a pre-scan image (for pre-scan "
198 "images scan line number is the image width) !")));
203 this->m_transducerSettings.
setScanLinePitch(xmlReadDoubleChild(doc, dataNode));
204 this->m_transducerSettings.
setScanLinePitch(xmlReadDoubleChild(doc, dataNode));
221 this->m_motorSettings.
setFramePitch(xmlReadDoubleChild(doc, dataNode));
224 this->m_motorSettings.
setMotorRadius(xmlReadDoubleChild(doc, dataNode));
227 value = xmlReadStringChild(doc, dataNode);
228 if (strcmp(value.c_str(),
"linear_motor") == 0) {
230 }
else if (strcmp(value.c_str(),
"tilting_motor") == 0) {
232 }
else if (strcmp(value.c_str(),
"rotational_motor") == 0) {
235 throw(vpException(vpException::fatalError, std::string(
"unknown image type in xml file")));
239 this->m_imageFileName = xmlReadStringChild(doc, dataNode);
242 this->m_sequence_frame_rate = xmlReadDoubleChild(doc, dataNode);
243 this->m_is_sequence =
true;
246 this->m_sequence_start = xmlReadIntChild(doc, dataNode);
247 this->m_is_sequence =
true;
250 this->m_sequence_stop = xmlReadIntChild(doc, dataNode);
251 this->m_is_sequence =
true;
254 vpTRACE(
"unknown tag in readConfigNode : %d, %s", iter_data->second, (iter_data->first).c_str());
268 std::string imageFileName = m_imageFileName;
269 xmlWriteStringChild(node,
"image_file_name", imageFileName);
271 xmlWriteStringChild(node,
"image_type", std::string(
"rf"));
272 xmlWriteDoubleChild(node,
"scanline_pitch", m_transducerSettings.
getScanLinePitch());
274 xmlWriteBoolChild(node,
"is_probe_convex", m_transducerSettings.
isTransducerConvex());
275 xmlWriteDoubleChild(node,
"axial_resolution", m_axialResolution);
280 xmlWriteStringChild(node,
"image_type", std::string(
"prescan"));
281 xmlWriteDoubleChild(node,
"scanline_pitch", m_transducerSettings.
getScanLinePitch());
283 xmlWriteBoolChild(node,
"is_probe_convex", m_transducerSettings.
isTransducerConvex());
284 xmlWriteDoubleChild(node,
"axial_resolution", m_axialResolution);
288 xmlWriteStringChild(node,
"image_type", std::string(
"postscan"));
289 xmlWriteDoubleChild(node,
"scanline_pitch", m_transducerSettings.
getScanLinePitch());
291 xmlWriteBoolChild(node,
"is_probe_convex", m_transducerSettings.
isTransducerConvex());
292 xmlWriteIntChild(node,
"scanline_number", m_transducerSettings.
getScanLineNumber());
296 xmlWriteIntChild(node,
"frame_number", m_motorSettings.
getFrameNumber());
297 xmlWriteDoubleChild(node,
"spacing_x", m_spacingX);
298 xmlWriteDoubleChild(node,
"spacing_y", m_spacingY);
299 xmlWriteDoubleChild(node,
"spacing_z", m_spacingZ);
301 xmlWriteDoubleChild(node,
"height_resolution", m_heightResolution);
302 xmlWriteDoubleChild(node,
"width_resolution", m_widthResolution);
306 xmlWriteDoubleChild(node,
"frame_pitch", m_motorSettings.
getFramePitch());
307 xmlWriteDoubleChild(node,
"motor_radius", m_motorSettings.
getMotorRadius());
309 xmlWriteStringChild(node,
"motor_type", std::string(
"linear_motor"));
311 xmlWriteStringChild(node,
"motor_type", std::string(
"tilting_motor"));
313 xmlWriteStringChild(node,
"motor_type", std::string(
"rotational_motor"));
317 std::cout <<
"writing sequence parameters" << std::endl;
319 xmlWriteDoubleChild(node,
"sequence_frame_rate", this->m_sequence_frame_rate);
320 xmlWriteIntChild(node,
"sequence_start_number", this->m_sequence_start);
321 xmlWriteIntChild(node,
"sequence_stop_number", this->m_sequence_stop);
336 double axialResolution,
us::ImageType image_type,
int samplingFrequency,
337 int transmitFrequency)
345 m_axialResolution = axialResolution;
346 m_image_type = image_type;
348 throw(vpException(vpException::fatalError,
"trying to write axial resolution in a image not rf nor pre-scan !"));
364 unsigned int scanLineNumber,
double widthResolution,
365 double heightResolution,
int samplingFrequency,
int transmitFrequency)
373 m_heightResolution = widthResolution;
374 m_widthResolution = heightResolution;
385 m_motorSettings = motorSettings;
Input/output operations between ultrasound image settings and the assiciated xml files.
double getSpacingX() const
void setMotorSettings(const usMotorSettings &motorSettings)
usImageSettingsXmlParser & operator=(const usImageSettingsXmlParser &twinparser)
double getWidthResolution() const
usMotorSettings getMotorSettings() const
double getSpacingY() const
void setImageFileName(const std::string &imageFileName)
us::ImageType getImageType() const
usImageSettingsXmlParser()
usTransducerSettings getTransducerSettings() const
void setImageSettings(double transducerRadius, double scanLinePitch, bool isTransducerConvex, double axialResolution, us::ImageType image_type, int samplingFrequency, int transmitFrequency)
std::string getImageFileName() const
virtual ~usImageSettingsXmlParser()
@ CODE_XML_HEIGHT_RESOLUTION
@ CODE_XML_SAMPLING_FREQUENCY
@ CODE_XML_SCANLINE_NUMBER
@ CODE_XML_SCANLINE_PITCH
@ CODE_XML_WIDTH_RESOLUTION
@ CODE_XML_TRANSDUCER_RADIUS
@ CODE_XML_SEQUENCE_FRAME_RATE
@ CODE_XML_AXIAL_RESOLUTION
@ CODE_XML_SEQUENCE_LAST_IMAGE_NUMBER
@ CODE_XML_IS_TRANSDUCER_CONVEX
@ CODE_XML_ASSOCIATED_IMAGE_FILE_NAME
@ CODE_XML_TRANSMIT_FREQUENCY
@ CODE_XML_SEQUENCE_FIRST_IMAGE_NUMBER
double getHeightResolution() const
double getAxialResolution() const
void writeMainClass(xmlNodePtr node)
double getSpacingZ() const
void readMainClass(xmlDocPtr doc, xmlNodePtr node)
Generic class for 3D ultrasound motor settings associated to the 3D probe used during acquisition.
unsigned int getFrameNumber() const
double getMotorRadius() const
void setMotorType(const usMotorType &motorType)
void setMotorRadius(double motorRadius)
double getFramePitch() const
usMotorType getMotorType() const
void setFramePitch(double framePitch)
Generic class for 2D ultrasound data common settings associated to the type of probe transducer used ...
void setTransducerConvexity(const bool isTransducerConvex)
int getTransmitFrequency() const
void setScanLinePitch(const double scanLinePitch)
void setTransmitFrequency(const int transmitFrequency)
double getScanLinePitch() const
void setSamplingFrequency(const int samplingFrequency)
void setTransducerRadius(const double transducerRadius)
bool isTransducerConvex() const
double getTransducerRadius() const
int getSamplingFrequency() const
unsigned int getScanLineNumber() const
void setScanLineNumber(unsigned int scanLineNumber)