Visual Servoing Platform  version 3.1.0
vpBSpline.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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 
152  inline void get_knots(std::list<double> &list) const
153  {
154  list.clear();
155  for (unsigned int i = 0; i < knots.size(); i++)
156  list.push_back(*(&(knots[0]) + i));
157  }
158 
165  inline void get_crossingPoints(std::list<vpImagePoint> &list) const
166  {
167  list.clear();
168  for (unsigned int i = 0; i < crossingPoints.size(); i++)
169  list.push_back(*(&(crossingPoints[0]) + i));
170  }
171 
177  inline void set_p(unsigned int degree) { this->p = degree; }
178 
184  inline void set_controlPoints(const std::list<vpImagePoint> &list)
185  {
186  controlPoints.clear();
187  for (std::list<vpImagePoint>::const_iterator it = list.begin(); it != list.end(); ++it) {
188  controlPoints.push_back(*it);
189  }
190  }
191 
197  inline void set_knots(const std::list<double> &list)
198  {
199  knots.clear();
200  for (std::list<double>::const_iterator it = list.begin(); it != list.end(); ++it) {
201  knots.push_back(*it);
202  }
203  }
204 
211  inline void set_crossingPoints(const std::list<vpImagePoint> &list)
212  {
213  crossingPoints.clear();
214  for (std::list<vpImagePoint>::const_iterator it = list.begin(); it != list.end(); ++it) {
215  crossingPoints.push_back(*it);
216  }
217  }
218 
219  static unsigned int findSpan(double l_u, unsigned int l_p, std::vector<double> &l_knots);
220  unsigned int findSpan(double u);
221 
222  static vpBasisFunction *computeBasisFuns(double l_u, unsigned int l_i, unsigned int l_p,
223  std::vector<double> &l_knots);
224  vpBasisFunction *computeBasisFuns(double u);
225 
226  static vpBasisFunction **computeDersBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
227  std::vector<double> &l_knots);
228  vpBasisFunction **computeDersBasisFuns(double u, unsigned int der);
229 
230  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots,
231  std::vector<vpImagePoint> &l_controlPoints);
232  vpImagePoint computeCurvePoint(double u);
233 
234  static vpImagePoint *computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
235  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints);
236  vpImagePoint *computeCurveDers(double u, unsigned int der);
237 };
238 
239 #endif
void get_crossingPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:165
unsigned int get_p() const
Definition: vpBSpline.h:132
void get_controlPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:140
void set_p(unsigned int degree)
Definition: vpBSpline.h:177
void set_crossingPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:211
void set_controlPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:184
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:88
void set_knots(const std::list< double > &list)
Definition: vpBSpline.h:197
void get_knots(std::list< double > &list) const
Definition: vpBSpline.h:152