Visual Servoing Platform  version 3.4.0
vpBSpline.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * This class implements the B-Spline
33  *
34  * Authors:
35  * Nicolas Melchior
36  *
37  *****************************************************************************/
38 
39 #ifndef vpBSpline_H
40 #define vpBSpline_H
41 
47 #include <visp3/core/vpImagePoint.h>
48 
49 #include <list>
50 #include <vector>
51 #include <visp3/core/vpMatrix.h>
52 
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 
65 typedef struct vpBasisFunction {
66  unsigned int i;
67  unsigned int p;
68  double u;
69  unsigned int k;
70  double value;
71 } vpBasisFunction;
72 #endif
73 
110 class VISP_EXPORT vpBSpline
111 {
112 public /*protected*/:
114  std::vector<vpImagePoint> controlPoints;
116  std::vector<double> knots;
118  unsigned int p;
120  std::vector<vpImagePoint> crossingPoints;
121 
122 public:
123  vpBSpline();
124  vpBSpline(const vpBSpline &bspline);
125  virtual ~vpBSpline();
126 
132  inline unsigned int get_p() const { return p; }
133 
140  inline void get_controlPoints(std::list<vpImagePoint> &list) const
141  {
142  list.clear();
143  for (unsigned int i = 0; i < controlPoints.size(); i++) {
144  list.push_back(*(&(controlPoints[0]) + i));
145  }
146  }
147 
153  inline void get_knots(std::list<double> &list) const
154  {
155  list.clear();
156  for (unsigned int i = 0; i < knots.size(); i++) {
157  list.push_back(*(&(knots[0]) + i));
158  }
159  }
160 
167  inline void get_crossingPoints(std::list<vpImagePoint> &list) const
168  {
169  list.clear();
170  for (unsigned int i = 0; i < crossingPoints.size(); i++) {
171  list.push_back(*(&(crossingPoints[0]) + i));
172  }
173  }
174 
180  inline void set_p(unsigned int degree) { this->p = degree; }
181 
187  inline void set_controlPoints(const std::list<vpImagePoint> &list)
188  {
189  controlPoints.clear();
190  for (std::list<vpImagePoint>::const_iterator it = list.begin(); it != list.end(); ++it) {
191  controlPoints.push_back(*it);
192  }
193  }
194 
200  inline void set_knots(const std::list<double> &list)
201  {
202  knots.clear();
203  for (std::list<double>::const_iterator it = list.begin(); it != list.end(); ++it) {
204  knots.push_back(*it);
205  }
206  }
207 
214  inline void set_crossingPoints(const std::list<vpImagePoint> &list)
215  {
216  crossingPoints.clear();
217  for (std::list<vpImagePoint>::const_iterator it = list.begin(); it != list.end(); ++it) {
218  crossingPoints.push_back(*it);
219  }
220  }
221 
222  static unsigned int findSpan(double l_u, unsigned int l_p, std::vector<double> &l_knots);
223  unsigned int findSpan(double u);
224 
225  static vpBasisFunction *computeBasisFuns(double l_u, unsigned int l_i, unsigned int l_p,
226  std::vector<double> &l_knots);
227  vpBasisFunction *computeBasisFuns(double u);
228 
229  static vpBasisFunction **computeDersBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
230  std::vector<double> &l_knots);
231  vpBasisFunction **computeDersBasisFuns(double u, unsigned int der);
232 
233  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots,
234  std::vector<vpImagePoint> &l_controlPoints);
235  vpImagePoint computeCurvePoint(double u);
236 
237  static vpImagePoint *computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
238  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints);
239  vpImagePoint *computeCurveDers(double u, unsigned int der);
240 };
241 
242 #endif
void get_controlPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:140
void get_crossingPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:167
void set_p(unsigned int degree)
Definition: vpBSpline.h:180
void set_crossingPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:214
unsigned int get_p() const
Definition: vpBSpline.h:132
void set_controlPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:187
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:110
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:87
void get_knots(std::list< double > &list) const
Definition: vpBSpline.h:153
void set_knots(const std::list< double > &list)
Definition: vpBSpline.h:200