Visual Servoing Platform  version 3.6.1 under development (2024-03-18)
vpBSpline.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 ViSP 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  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * This class implements the B-Spline
32  */
33 
34 #ifndef vpBSpline_H
35 #define vpBSpline_H
36 
42 #include <visp3/core/vpImagePoint.h>
43 
44 #include <list>
45 #include <vector>
46 #include <visp3/core/vpMatrix.h>
47 
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49 
60 typedef struct vpBasisFunction {
61  unsigned int i;
62  unsigned int p;
63  double u;
64  unsigned int k;
65  double value;
66 } vpBasisFunction;
67 #endif
68 
105 class VISP_EXPORT vpBSpline
106 {
107  public /*protected*/:
109  std::vector<vpImagePoint> controlPoints;
111  std::vector<double> knots;
113  unsigned int p;
115  std::vector<vpImagePoint> crossingPoints;
116 
117 public:
118  vpBSpline();
119  vpBSpline(const vpBSpline &bspline);
120  virtual ~vpBSpline();
121 
127  inline unsigned int get_p() const { return p; }
128 
135  inline void get_controlPoints(std::list<vpImagePoint> &list) const
136  {
137  list.clear();
138  for (unsigned int i = 0; i < controlPoints.size(); i++) {
139  list.push_back(*(&(controlPoints[0]) + i));
140  }
141  }
142 
148  inline void get_knots(std::list<double> &list) const
149  {
150  list.clear();
151  for (unsigned int i = 0; i < knots.size(); i++) {
152  list.push_back(*(&(knots[0]) + i));
153  }
154  }
155 
162  inline void get_crossingPoints(std::list<vpImagePoint> &list) const
163  {
164  list.clear();
165  for (unsigned int i = 0; i < crossingPoints.size(); i++) {
166  list.push_back(*(&(crossingPoints[0]) + i));
167  }
168  }
169 
175  inline void set_p(unsigned int degree) { this->p = degree; }
176 
182  inline void set_controlPoints(const std::list<vpImagePoint> &list)
183  {
184  controlPoints.clear();
185  for (std::list<vpImagePoint>::const_iterator it = list.begin(); it != list.end(); ++it) {
186  controlPoints.push_back(*it);
187  }
188  }
189 
195  inline void set_knots(const std::list<double> &list)
196  {
197  knots.clear();
198  for (std::list<double>::const_iterator it = list.begin(); it != list.end(); ++it) {
199  knots.push_back(*it);
200  }
201  }
202 
209  inline void set_crossingPoints(const std::list<vpImagePoint> &list)
210  {
211  crossingPoints.clear();
212  for (std::list<vpImagePoint>::const_iterator it = list.begin(); it != list.end(); ++it) {
213  crossingPoints.push_back(*it);
214  }
215  }
216 
217  static unsigned int findSpan(double l_u, unsigned int l_p, std::vector<double> &l_knots);
218  unsigned int findSpan(double u);
219 
220  static vpBasisFunction *computeBasisFuns(double l_u, unsigned int l_i, unsigned int l_p,
221  std::vector<double> &l_knots);
222  vpBasisFunction *computeBasisFuns(double u);
223 
224  static vpBasisFunction **computeDersBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
225  std::vector<double> &l_knots);
226  vpBasisFunction **computeDersBasisFuns(double u, unsigned int der);
227 
228  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots,
229  std::vector<vpImagePoint> &l_controlPoints);
230  vpImagePoint computeCurvePoint(double u);
231 
232  static vpImagePoint *computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
233  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints);
234  vpImagePoint *computeCurveDers(double u, unsigned int der);
235 };
236 
237 #endif
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:106
void get_controlPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:135
void set_p(unsigned int degree)
Definition: vpBSpline.h:175
void set_crossingPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:209
unsigned int get_p() const
Definition: vpBSpline.h:127
void get_crossingPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:162
void set_controlPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:182
void get_knots(std::list< double > &list) const
Definition: vpBSpline.h:148
void set_knots(const std::list< double > &list)
Definition: vpBSpline.h:195
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82