UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-03)
usBSpline3D.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  * Author:
29  * Jason Chevrie
30  *
31  *****************************************************************************/
32 
33 #ifndef usBSpline3D_h
34 #define usBSpline3D_h
35 
36 #include <vector>
37 
38 #include <visp3/core/vpColVector.h>
39 #include <visp3/core/vpHomogeneousMatrix.h>
40 
41 #include <visp3/ustk_core/usPolynomialCurve3D.h>
42 
43 class VISP_EXPORT usBSpline3D
44 {
45 protected:
47 
48  std::vector<usPolynomialCurve3D> m_spline;
49 
50 public:
52 
53  usBSpline3D();
54  usBSpline3D(const usBSpline3D &spline);
55  virtual ~usBSpline3D();
56  const usBSpline3D &operator=(const usBSpline3D &spline);
57 
58  virtual usBSpline3D *clone() const; // Polymorph copy method
59 
61 
62  int getNbSegments() const;
63  double getParametricLength() const;
64  double getLength(int nbSubSeg = 50) const;
65 
67 
68  void addSegment(const usPolynomialCurve3D &seg);
69  void insertSegment(int i, const usPolynomialCurve3D &seg);
70  void setSegment(int i, const usPolynomialCurve3D &poly);
71  void removeLastSegment();
72  void removeSegment(int i);
73  void removeSegments(int i, int j);
74  void clear();
75 
76  void defineFromPoints(const std::vector<vpColVector> &points, const std::vector<double> &lengths, int order = 3);
77 
78  const usPolynomialCurve3D &accessSegment(int i) const;
79  const usPolynomialCurve3D &accessLastSegment() const;
80  usPolynomialCurve3D &accessSegment(int i);
81  usPolynomialCurve3D &accessLastSegment();
82  usBSpline3D getSubSpline(double a, double b) const;
83 
85 
86  bool move(const vpHomogeneousMatrix &H);
87  bool move(double x, double y, double z, double tx, double ty, double tz);
88 
90 
92 
93  vpColVector getPoint(double param) const;
94  vpColVector getTangent(double param) const;
95  double getDistanceFromPoint(const vpColVector &point, double start = 0, double stop = -1,
96  double threshold = 1e-5) const;
97  bool getParametersFromLength(double l, int &index, double &param) const;
98 
100 
101  double getCurvatureFromShape(double start, double end, vpColVector &center3D, vpColVector &direction3D) const;
102 
104 
106  friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usBSpline3D &spline);
107  friend VISP_EXPORT std::istream &operator>>(std::istream &s, usBSpline3D &spline);
109  friend VISP_EXPORT std::ostream &operator<<=(std::ostream &s, const usBSpline3D &spline);
110  friend VISP_EXPORT std::istream &operator>>=(std::istream &s, usBSpline3D &spline);
111 };
112 
113 VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usBSpline3D &spline);
114 VISP_EXPORT std::istream &operator>>(std::istream &s, usBSpline3D &spline);
115 
116 VISP_EXPORT std::ostream &operator<<=(std::ostream &s, const usBSpline3D &spline);
117 VISP_EXPORT std::istream &operator>>=(std::istream &s, usBSpline3D &spline);
118 
119 #endif // usBSpline3D_h
std::vector< usPolynomialCurve3D > m_spline
Polynomials container.
Definition: usBSpline3D.h:48