UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usTransducerSettings.cpp
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  * Pierre Chatelain
30  * Marc Pouliquen
31  *
32  *****************************************************************************/
33 
39 // std includes
40 #include <iostream>
41 
42 // visp includes
43 #include <visp3/ustk_core/usTransducerSettings.h>
44 
45 // ustk includes
46 
51  : m_transducerRadius(0.0f), m_scanLinePitch(0.0f), m_scanLineNumber(0), m_isTransducerConvex(true),
52  m_scanLineNumberIsSet(false), m_transmitFrequency(0), m_samplingFrequency(0)
53 {
54 }
55 
69 usTransducerSettings::usTransducerSettings(double transducerRadius, double scanLinePitch, unsigned int scanLineNumber,
70  bool transducerConvex, double depth, int transmitFrequency,
71  int samplingFrequency)
72  : m_transducerRadius(transducerRadius), m_scanLinePitch(scanLinePitch), m_scanLineNumber(scanLineNumber),
73  m_isTransducerConvex(transducerConvex), m_depth(depth), m_scanLineNumberIsSet(true),
74  m_transmitFrequency(transmitFrequency), m_samplingFrequency(samplingFrequency)
75 {
76 }
77 
83 
88 
94 {
95  m_transducerRadius = other.getTransducerRadius();
96  m_scanLinePitch = other.getScanLinePitch();
97  m_scanLineNumber = other.getScanLineNumber();
98  m_isTransducerConvex = other.isTransducerConvex();
99  m_scanLineNumberIsSet = other.scanLineNumberIsSet();
100  m_depth = other.getDepth();
101  m_samplingFrequency = other.getSamplingFrequency();
102  m_transmitFrequency = other.getTransmitFrequency();
103 
104  return *this;
105 }
106 
112 {
113  return (this->getTransducerRadius() == other.getTransducerRadius() &&
114  this->getScanLinePitch() == other.getScanLinePitch() &&
115  this->getScanLineNumber() == other.getScanLineNumber() &&
116  this->isTransducerConvex() == other.isTransducerConvex() &&
117  this->getSamplingFrequency() == other.getSamplingFrequency() &&
118  this->getTransmitFrequency() == other.getTransmitFrequency());
119 }
120 
126 
135 VISP_EXPORT std::ostream &operator<<(std::ostream &out, const usTransducerSettings &other)
136 {
137  out << "transducer radius: " << other.getTransducerRadius() << std::endl;
138  if (other.isTransducerConvex())
139  out << "scan line pitch angle: " << other.getScanLinePitch() << std::endl;
140  else
141  out << "scan line pitch distance: " << other.getScanLinePitch() << std::endl;
142  out << "scan line number : " << other.getScanLineNumber() << std::endl
143  << "convex probe used: " << other.isTransducerConvex() << std::endl
144  << "depth : " << other.getDepth() << std::endl
145  << "sampling frequency " << other.getSamplingFrequency() << std::endl
146  << "transmit frequency " << other.getTransmitFrequency() << std::endl;
147  return out;
148 }
149 
150 // Image settings getters/setters
151 
157 void usTransducerSettings::setTransducerRadius(const double transducerRadius) { m_transducerRadius = transducerRadius; }
158 
163 double usTransducerSettings::getTransducerRadius() const { return m_transducerRadius; }
164 
171 void usTransducerSettings::setScanLinePitch(const double scanLinePitch) { m_scanLinePitch = scanLinePitch; }
172 
182 double usTransducerSettings::getScanLinePitch() const { return m_scanLinePitch; }
183 
189 void usTransducerSettings::setTransducerConvexity(const bool isTransducerConvex)
190 {
191  m_isTransducerConvex = isTransducerConvex;
192  if (!isTransducerConvex) {
193  m_transducerRadius = 0.0;
194  }
195 }
196 
201 bool usTransducerSettings::isTransducerConvex() const { return m_isTransducerConvex; }
202 
211 
216 unsigned int usTransducerSettings::getScanLineNumber() const { return m_scanLineNumber; }
217 
222 void usTransducerSettings::setScanLineNumber(unsigned int scanLineNumber)
223 {
224  m_scanLineNumberIsSet = true;
225  m_scanLineNumber = scanLineNumber;
226 }
227 
232 std::string usTransducerSettings::getProbeName() const { return m_probeName; }
233 
238 void usTransducerSettings::setProbeName(std::string probeName) { m_probeName = probeName; }
239 
245 {
246  if (!m_scanLineNumberIsSet)
247  throw vpException(vpException::notInitialized,
248  "The scan line number is not set, cannot determine the field of view");
249  return m_scanLinePitch * (double)(m_scanLineNumber - 1);
250 }
251 
265 void usTransducerSettings::setFieldOfView(double fieldOfView)
266 {
267  if (!m_scanLineNumberIsSet)
268  throw vpException(vpException::notInitialized,
269  "The scan line number is not set, cannot determine the pitch from the field of view");
270  m_scanLinePitch = fieldOfView / (double)(m_scanLineNumber - 1);
271 }
272 
277 bool usTransducerSettings::scanLineNumberIsSet() const { return m_scanLineNumberIsSet; }
278 
283 void usTransducerSettings::setDepth(double depth) { m_depth = depth; }
284 
289 double usTransducerSettings::getDepth() const { return m_depth; }
290 
296 {
297  usTransducerSettings ret = *this;
298  return ret;
299 }
300 
305 int usTransducerSettings::getSamplingFrequency() const { return m_samplingFrequency; }
306 
311 int usTransducerSettings::getTransmitFrequency() const { return m_transmitFrequency; }
312 
317 void usTransducerSettings::setSamplingFrequency(const int samplingFrequency)
318 {
319  m_samplingFrequency = samplingFrequency;
320 }
321 
326 void usTransducerSettings::setTransmitFrequency(const int transmitFrequency)
327 {
328  m_transmitFrequency = transmitFrequency;
329 }
Generic class for 2D ultrasound data common settings associated to the type of probe transducer used ...
usTransducerSettings getTransducerSettings() const
usTransducerSettings & operator=(const usTransducerSettings &other)
void setFieldOfView(double fieldOfView)
void setTransducerConvexity(const bool isTransducerConvex)
bool operator!=(usTransducerSettings const &other)
void setDepth(double depth)
void setScanLinePitch(const double scanLinePitch)
std::string getProbeName() const
void setTransmitFrequency(const int transmitFrequency)
void setProbeName(std::string probeName)
void setSamplingFrequency(const int samplingFrequency)
bool operator==(usTransducerSettings const &other)
void setTransducerRadius(const double transducerRadius)
double getTransducerRadius() const
void setTransducerSettings(const usTransducerSettings &other)
unsigned int getScanLineNumber() const
void setScanLineNumber(unsigned int scanLineNumber)