UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-11-21)
usImageSettingsXmlParser.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
38 #ifndef __usImageSettingsXmlParser_h_
39 #define __usImageSettingsXmlParser_h_
40 
41 #include <visp3/core/vpConfig.h>
42 
43 #ifdef VISP_HAVE_XML2
44 
45 #include <iostream>
46 #include <string>
47 #include <visp3/core/vpDebug.h>
48 #include <visp3/core/vpIoTools.h>
49 #include <visp3/core/vpXmlParser.h>
50 #include <visp3/io/vpParseArgv.h>
51 #include <visp3/ustk_core/us.h>
52 #include <visp3/ustk_core/usImagePostScan2D.h>
53 #include <visp3/ustk_core/usImagePreScan2D.h>
54 #include <visp3/ustk_core/usMotorSettings.h>
55 #include <visp3/ustk_core/usTransducerSettings.h>
56 
62 class VISP_EXPORT usImageSettingsXmlParser : public vpXmlParser
63 {
64 public:
67  // usImageSettingsXmlParser(usImageSettingsXmlParser& twinParser);
68  usImageSettingsXmlParser &operator=(const usImageSettingsXmlParser &twinparser);
69  virtual ~usImageSettingsXmlParser();
70 
71  typedef enum {
72  CODE_XML_BAD = -1,
91 
96  } vpXmlCodeType;
97 
98  typedef enum { SEQUENCE_OK, SEQUENCE_ERROR } vpXmlCodeSequenceType;
99 
100  // getters
101  double getAxialResolution() const { return m_axialResolution; }
102  double getFrameNumber() const { return m_motorSettings.getFrameNumber(); }
103  std::string getImageFileName() const { return m_imageFileName; }
104  double getHeightResolution() const { return m_heightResolution; }
105  us::ImageType getImageType() const { return m_image_type; }
106  usMotorSettings getMotorSettings() const { return m_motorSettings; }
107  unsigned int getScanLineNumber() const { return m_transducerSettings.getScanLineNumber(); }
108  double getSequenceFrameRate() const { return m_sequence_frame_rate; }
109  int getSequenceStartNumber() const { return m_sequence_start; }
110  int getSequenceStopNumber() const { return m_sequence_stop; }
111  double getSpacingX() const { return m_spacingX; }
112  double getSpacingY() const { return m_spacingY; }
113  double getSpacingZ() const { return m_spacingZ; }
114  double getWidthResolution() const { return m_widthResolution; }
115  usTransducerSettings getTransducerSettings() const { return m_transducerSettings; }
116 
117  bool isImage3D() const { return m_is_3D; }
118  bool isSequence() const { return m_is_sequence; }
119 
120  // Data setters
121  void setFrameNumber(unsigned int frameNumber) { m_motorSettings.setFrameNumber(frameNumber); }
122  void setImageFileName(const std::string &imageFileName);
123  void setImageSettings(double transducerRadius, double scanLinePitch, bool isTransducerConvex, double axialResolution,
124  us::ImageType image_type, int samplingFrequency, int transmitFrequency);
125  void setImageSettings(double transducerRadius, double scanLinePitch, bool isTransducerConvex,
126  unsigned int scanLineNumber, double widthResolution, double heightResolution,
127  int samplingFrequency, int transmitFrequency);
128  void setImageType(us::ImageType image_type) { m_image_type = image_type; }
129  void setMotorSettings(const usMotorSettings &motorSettings);
130  void setScanLineNumber(unsigned int scanLineNumber) { m_transducerSettings.setScanLineNumber(scanLineNumber); }
131  void setSequenceFrameRate(double sequenceFrameRate)
132  {
133  m_sequence_frame_rate = sequenceFrameRate;
134  m_is_sequence = true;
135  }
136  void setSequenceStartNumber(int sequenceStartNumber)
137  {
138  m_sequence_start = sequenceStartNumber;
139  m_is_sequence = true;
140  }
141  void setSequenceStopNumber(int sequenceStopNumber)
142  {
143  m_sequence_stop = sequenceStopNumber;
144  m_is_sequence = true;
145  }
146  void setSequenceType(bool isSequence) { m_is_sequence = isSequence; }
147  void setSpacing(double spacingX, double spacingY, double spacingZ)
148  {
149  m_spacingX = spacingX;
150  m_spacingY = spacingY;
151  m_spacingZ = spacingZ;
152  }
153  void setTransducerSettings(const usTransducerSettings transducerSettings);
154 
155 private:
156  // basic
157  usTransducerSettings m_transducerSettings;
158 
159  // for 2D post scan images
160  double m_widthResolution;
161  double m_heightResolution;
162 
163  // for 3D post scan images
164  double m_spacingX;
165  double m_spacingY;
166  double m_spacingZ;
167 
168  // for rf / pre-scan
169  double m_axialResolution;
170 
171  // for 3D
172  usMotorSettings m_motorSettings;
173 
174  std::string m_imageFileName;
175 
176  // to manage different resolution types
177  us::ImageType m_image_type;
178  bool m_is_3D;
179  // to manage usltrasound images sequences
180  bool m_is_sequence;
181  double m_sequence_frame_rate;
182  std::string m_sequence_name;
183  int m_sequence_start;
184  int m_sequence_stop;
185 
186 protected:
187  void readMainClass(xmlDocPtr doc, xmlNodePtr node);
188  void writeMainClass(xmlNodePtr node);
189 };
190 #endif // __usImageSettingsXmlParser_h_
191 #endif // VISP_HAVE_XML2
Input/output operations between ultrasound image settings and the assiciated xml files.
void setTransducerSettings(const usTransducerSettings transducerSettings)
void setSequenceType(bool isSequence)
void setSpacing(double spacingX, double spacingY, double spacingZ)
unsigned int getScanLineNumber() const
usMotorSettings getMotorSettings() const
void setImageType(us::ImageType image_type)
us::ImageType getImageType() const
void setScanLineNumber(unsigned int scanLineNumber)
usTransducerSettings getTransducerSettings() const
std::string getImageFileName() const
void setSequenceStartNumber(int sequenceStartNumber)
void setFrameNumber(unsigned int frameNumber)
void setSequenceStopNumber(int sequenceStopNumber)
void setSequenceFrameRate(double sequenceFrameRate)
Generic class for 3D ultrasound motor settings associated to the 3D probe used during acquisition.
Generic class for 2D ultrasound data common settings associated to the type of probe transducer used ...
ImageType
Definition: us.h:65