UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-17)
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  {
73  CODE_XML_BAD = -1,
92 
97  } vpXmlCodeType;
98 
99  typedef enum { SEQUENCE_OK, SEQUENCE_ERROR } vpXmlCodeSequenceType;
100 
101  // getters
102  double getAxialResolution() const { return m_axialResolution; }
103  double getFrameNumber() const { return m_motorSettings.getFrameNumber(); }
104  std::string getImageFileName() const { return m_imageFileName; }
105  double getHeightResolution() const { return m_heightResolution; }
106  us::ImageType getImageType() const { return m_image_type; }
107  usMotorSettings getMotorSettings() const { return m_motorSettings; }
108  unsigned int getScanLineNumber() const { return m_transducerSettings.getScanLineNumber(); }
109  double getSequenceFrameRate() const { return m_sequence_frame_rate; }
110  int getSequenceStartNumber() const { return m_sequence_start; }
111  int getSequenceStopNumber() const { return m_sequence_stop; }
112  double getSpacingX() const { return m_spacingX; }
113  double getSpacingY() const { return m_spacingY; }
114  double getSpacingZ() const { return m_spacingZ; }
115  double getWidthResolution() const { return m_widthResolution; }
116  usTransducerSettings getTransducerSettings() const { return m_transducerSettings; }
117 
118  bool isImage3D() const { return m_is_3D; }
119  bool isSequence() const { return m_is_sequence; }
120 
121  // Data setters
122  void setFrameNumber(unsigned int frameNumber) { m_motorSettings.setFrameNumber(frameNumber); }
123  void setImageFileName(const std::string &imageFileName);
124  void setImageSettings(double transducerRadius, double scanLinePitch, bool isTransducerConvex, double axialResolution,
125  us::ImageType image_type, int samplingFrequency, int transmitFrequency);
126  void setImageSettings(double transducerRadius, double scanLinePitch, bool isTransducerConvex,
127  unsigned int scanLineNumber, double widthResolution, double heightResolution,
128  int samplingFrequency, int transmitFrequency);
129  void setImageType(us::ImageType image_type) { m_image_type = image_type; }
130  void setMotorSettings(const usMotorSettings &motorSettings);
131  void setScanLineNumber(unsigned int scanLineNumber) { m_transducerSettings.setScanLineNumber(scanLineNumber); }
132  void setSequenceFrameRate(double sequenceFrameRate)
133  {
134  m_sequence_frame_rate = sequenceFrameRate;
135  m_is_sequence = true;
136  }
137  void setSequenceStartNumber(int sequenceStartNumber)
138  {
139  m_sequence_start = sequenceStartNumber;
140  m_is_sequence = true;
141  }
142  void setSequenceStopNumber(int sequenceStopNumber)
143  {
144  m_sequence_stop = sequenceStopNumber;
145  m_is_sequence = true;
146  }
147  void setSequenceType(bool isSequence) { m_is_sequence = isSequence; }
148  void setSpacing(double spacingX, double spacingY, double spacingZ)
149  {
150  m_spacingX = spacingX;
151  m_spacingY = spacingY;
152  m_spacingZ = spacingZ;
153  }
154  void setTransducerSettings(const usTransducerSettings transducerSettings);
155 
156 private:
157  // basic
158  usTransducerSettings m_transducerSettings;
159 
160  // for 2D post scan images
161  double m_widthResolution;
162  double m_heightResolution;
163 
164  // for 3D post scan images
165  double m_spacingX;
166  double m_spacingY;
167  double m_spacingZ;
168 
169  // for rf / pre-scan
170  double m_axialResolution;
171 
172  // for 3D
173  usMotorSettings m_motorSettings;
174 
175  std::string m_imageFileName;
176 
177  // to manage different resolution types
178  us::ImageType m_image_type;
179  bool m_is_3D;
180  // to manage usltrasound images sequences
181  bool m_is_sequence;
182  double m_sequence_frame_rate;
183  std::string m_sequence_name;
184  int m_sequence_start;
185  int m_sequence_stop;
186 
187 protected:
188  void readMainClass(xmlDocPtr doc, xmlNodePtr node);
189  void writeMainClass(xmlNodePtr node);
190 };
191 #endif // __usImageSettingsXmlParser_h_
192 #endif // VISP_HAVE_XML2
Input/output operations between ultrasound image settings and the associated 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