UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-03)
usTissueModelPolynomial.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  * Author:
29  * Jason Chevrie
30  *
31  *****************************************************************************/
32 
33 #include <visp3/ustk_needle_modeling/usTissueModelPolynomial.h>
34 
36 
38  : m_surface(tissue.m_surface), m_path(tissue.m_path)
39 {
40 }
41 
43 
45 {
46  m_surface = tissue.m_surface;
47  m_path = tissue.m_path;
48 
49  return *this;
50 }
51 
53 
55 
57 
59 
61 
62 bool usTissueModelPolynomial::moveInWorldFrame(const vpHomogeneousMatrix &H)
63 {
65  m_path.move(H);
66 
67  return true;
68 }
69 
70 bool usTissueModelPolynomial::moveInWorldFrame(double x, double y, double z, double tx, double ty, double tz)
71 {
72  return this->moveInWorldFrame(vpHomogeneousMatrix(x, y, z, tx, ty, tz));
73 }
74 
75 bool usTissueModelPolynomial::move(const vpHomogeneousMatrix &H)
76 {
77  vpPoseVector ptu(this->getPose());
78 
79  vpHomogeneousMatrix M(ptu);
80  M = M * H * M.inverse();
82  m_path.move(M);
83 
84  return true;
85 }
86 
87 bool usTissueModelPolynomial::move(double x, double y, double z, double tx, double ty, double tz)
88 {
89  return this->move(vpHomogeneousMatrix(x, y, z, tx, ty, tz));
90 }
91 
92 bool usTissueModelPolynomial::setPose(const vpPoseVector &p)
93 {
94  vpPoseVector ptu(this->getPose());
95 
96  vpHomogeneousMatrix M(vpHomogeneousMatrix(p) * vpHomogeneousMatrix(ptu).inverse());
98  m_path.move(M);
99 
100  return true;
101 }
102 
104 {
105  vpPoseVector ptu = m_surface.getPose();
106 
107  vpColVector p = m_path.getPoint(0);
108  for (int i = 0; i < 3; i++)
109  ptu[i] = p[i];
110 
111  return ptu;
112 }
113 
114 std::ostream &operator<<(std::ostream &s, const usTissueModelPolynomial &tissue)
115 {
116  s << "usTissueModelPolynomial\n";
117  s << tissue.m_surface;
118  s << tissue.m_path;
119 
120  s.flush();
121  return s;
122 }
123 
124 std::istream &operator>>(std::istream &s, usTissueModelPolynomial &tissue)
125 {
126  std::string c;
127  s >> c;
128  if (c != "usTissueModelPolynomial") {
129  vpException e(vpException::ioError, "Stream does not contain usTissueModelPolynomial data");
130  throw e;
131  }
132  s >> tissue.m_surface;
133  s >> tissue.m_path;
134  return s;
135 }
136 
137 std::ostream &operator<<=(std::ostream &s, const usTissueModelPolynomial &tissue)
138 {
139  s.write("usTissueModelPolynomial", 24);
140  s <<= tissue.m_surface;
141  s <<= tissue.m_path;
142 
143  s.flush();
144  return s;
145 }
146 
147 std::istream &operator>>=(std::istream &s, usTissueModelPolynomial &tissue)
148 {
149  char c[24];
150  s.read(c, 24);
151  if (strcmp(c, "usTissueModelPolynomial")) {
152  vpException e(vpException::ioError, "Stream does not contain usTissueModelPolynomial data");
153  throw e;
154  }
155  s >>= tissue.m_surface;
156  s >>= tissue.m_path;
157  return s;
158 }
void moveInWorldFrame(const vpHomogeneousMatrix &H)
vpPoseVector getPose() const
vpColVector getPoint(double parameter) const
void move(const vpHomogeneousMatrix &H)
const usOrientedPlane3D & accessSurface() const
Parameters setters and getters.
usTissueModelPolynomial()
Constructors, destructor.
const usTissueModelPolynomial & operator=(const usTissueModelPolynomial &tissue)
virtual usTissueModelPolynomial * clone() const
bool setPose(const vpPoseVector &p)
bool moveInWorldFrame(const vpHomogeneousMatrix &H)
usOrientedPlane3D m_surface
Tissue parameters.
bool move(const vpHomogeneousMatrix &H)
const usPolynomialCurve3D & accessPath() const