UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-11-21)
usMotorSettings.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/usMotorSettings.h>
44 
45 // ustk includes
46 
51  : m_motorRadius(0.0), m_framePitch(0.0), m_frameNumberIsSet(false), m_motorType(LinearMotor)
52 {
53 }
54 
63 usMotorSettings::usMotorSettings(double motorRadius, double framePitch, unsigned int frameNumber,
64  const usMotorType &motorType)
65  : m_motorRadius(motorRadius), m_framePitch(framePitch), m_frameNumber(frameNumber), m_frameNumberIsSet(true),
66  m_motorType(motorType)
67 {
68 }
69 
75  : m_motorRadius(other.getMotorRadius()), m_framePitch(other.getFramePitch()), m_frameNumber(other.getFrameNumber()),
76  m_frameNumberIsSet(other.frameNumberIsSet()), m_motorType(other.getMotorType())
77 {
78 }
79 
84 
90 {
91  m_motorRadius = other.getMotorRadius();
92  m_framePitch = other.getFramePitch();
93  m_frameNumber = other.getFrameNumber();
94  m_frameNumberIsSet = other.frameNumberIsSet();
95  m_motorType = other.getMotorType();
96  return *this;
97 }
98 
105 {
106  return (this->getFramePitch() == other.getFramePitch() && this->getFrameNumber() == other.getFrameNumber() &&
107  this->frameNumberIsSet() == other.frameNumberIsSet() && this->getMotorRadius() == other.getMotorRadius() &&
108  this->getMotorType() == other.getMotorType());
109 }
110 
116 bool usMotorSettings::operator!=(const usMotorSettings &other) { return !operator==(other); }
117 
121 VISP_EXPORT std::ostream &operator<<(std::ostream &out, const usMotorSettings &other)
122 {
123  return out << "motor radius : " << other.getMotorRadius() << std::endl
124  << "frame angle : " << other.getFramePitch() << std::endl
125  << "frame number : " << other.getFrameNumber() << std::endl
126  << "motor type : " << other.getMotorType() << std::endl;
127 }
128 
129 // probe settings getters/setters
130 
135 void usMotorSettings::setMotorRadius(double motorRadius) { m_motorRadius = motorRadius; }
136 
141 double usMotorSettings::getMotorRadius() const { return m_motorRadius; }
142 
147 void usMotorSettings::setFramePitch(double framePitch) { m_framePitch = framePitch; }
148 
153 double usMotorSettings::getFramePitch() const { return m_framePitch; }
154 
159 unsigned int usMotorSettings::getFrameNumber() const { return m_frameNumber; }
160 
167 {
168  m_motorType = motorType;
169  if (motorType == LinearMotor) {
170  setMotorRadius(0.0);
171  }
172 }
173 
179 
184 void usMotorSettings::setMotorSettings(const usMotorSettings &other) { *this = other; }
185 
190 void usMotorSettings::setFrameNumber(unsigned int frameNumber)
191 {
192  m_frameNumber = frameNumber;
193  m_frameNumberIsSet = true;
194 }
195 
200 bool usMotorSettings::frameNumberIsSet() const { return m_frameNumberIsSet; }
201 
207 {
208  if (!m_frameNumberIsSet)
209  throw vpException(vpException::notInitialized, "The frame number is not set, cannot determine the field of view");
210  return m_framePitch * (double)(m_frameNumber - 1);
211 }
212 
226 void usMotorSettings::setMotorFieldOfView(double motorFieldOfView)
227 {
228  if (!m_frameNumberIsSet)
229  throw vpException(vpException::notInitialized,
230  "The frame number is not set, cannot determine the pitch from the field of view");
231  m_framePitch = motorFieldOfView / (double)(m_frameNumber - 1);
232 }
233 
235 {
236  usMotorSettings ret = *this;
237  return ret;
238 }
Generic class for 3D ultrasound motor settings associated to the 3D probe used during acquisition.
usMotorSettings & operator=(const usMotorSettings &other)
bool operator==(const usMotorSettings &other)
void setMotorSettings(const usMotorSettings &other)
unsigned int getFrameNumber() const
virtual ~usMotorSettings()
double getMotorRadius() const
void setMotorType(const usMotorType &motorType)
void setMotorRadius(double motorRadius)
double getFramePitch() const
void setFrameNumber(unsigned int frameNumber)
usMotorSettings getMotorSettings() const
void setMotorFieldOfView(double motorFieldOfView)
bool operator!=(const usMotorSettings &other)
double getMotorFieldOfView() const
usMotorType getMotorType() const
bool frameNumberIsSet() const
void setFramePitch(double framePitch)