Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
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 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 http://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  * Authors:
34  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 
38 #ifndef vpBSpline_H
39 #define vpBSpline_H
40 
46 #include <visp3/core/vpImagePoint.h>
47 
48 #include <vector>
49 #include <list>
50 #include <visp3/core/vpMatrix.h>
51 
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 
63 typedef struct vpBasisFunction{
64  unsigned int i;
65  unsigned int p;
66  double u;
67  unsigned int k;
68  double value;
69 } vpBasisFunction;
70 #endif
71 
100 class VISP_EXPORT vpBSpline
101 {
102  public/*protected*/:
104  std::vector<vpImagePoint> controlPoints;
106  std::vector<double> knots;
108  unsigned int p;
110  std::vector<vpImagePoint> crossingPoints;
111 
112  public:
113 
114  vpBSpline();
115  vpBSpline(const vpBSpline &bspline);
116  virtual ~vpBSpline();
117 
123  inline unsigned int get_p() const {return p;}
124 
130  inline void get_controlPoints(std::list<vpImagePoint> &list) const {
131  list.clear();
132  for (unsigned int i = 0; i < controlPoints.size(); i++)
133  list.push_back(*(&(controlPoints[0])+i));
134  }
135 
141  inline void get_knots(std::list<double> &list) const {
142  list.clear();
143  for (unsigned int i = 0; i < knots.size(); i++)
144  list.push_back(*(&(knots[0])+i));
145  }
146 
152  inline void get_crossingPoints(std::list<vpImagePoint> &list) const {
153  list.clear();
154  for (unsigned int i = 0; i < crossingPoints.size(); i++)
155  list.push_back(*(&(crossingPoints[0])+i));
156  }
157 
158 
164  inline void set_p(unsigned int degree) {this->p = degree;}
165 
166 
172  inline void set_controlPoints(const std::list<vpImagePoint> &list) {
173  controlPoints.clear();
174  for(std::list<vpImagePoint>::const_iterator it = list.begin(); it!=list.end(); ++it){
175  controlPoints.push_back(*it);
176  }
177  }
178 
184  inline void set_knots(const std::list<double> &list) {
185  knots.clear();
186  for(std::list<double>::const_iterator it = list.begin(); it!=list.end(); ++it){
187  knots.push_back(*it);
188  }
189  }
190 
196  inline void set_crossingPoints(const std::list<vpImagePoint> &list) {
197  crossingPoints.clear();
198  for(std::list<vpImagePoint>::const_iterator it=list.begin(); it!=list.end(); ++it){
199  crossingPoints.push_back(*it);
200  }
201  }
202 
203  static unsigned int findSpan(double l_u, unsigned int l_p, std::vector<double> &l_knots);
204  unsigned int findSpan(double u);
205 
206  static vpBasisFunction* computeBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots);
207  vpBasisFunction* computeBasisFuns(double u);
208 
209  static vpBasisFunction** computeDersBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, std::vector<double> &l_knots);
210  vpBasisFunction** computeDersBasisFuns(double u, unsigned int der);
211 
212  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints);
213  vpImagePoint computeCurvePoint(double u);
214 
215  static vpImagePoint* computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints);
216  vpImagePoint* computeCurveDers(double u, unsigned int der);
217 };
218 
219 #endif
void get_controlPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:130
void get_crossingPoints(std::list< vpImagePoint > &list) const
Definition: vpBSpline.h:152
void set_p(unsigned int degree)
Definition: vpBSpline.h:164
void set_crossingPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:196
unsigned int get_p() const
Definition: vpBSpline.h:123
void set_controlPoints(const std::list< vpImagePoint > &list)
Definition: vpBSpline.h:172
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:100
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
void get_knots(std::list< double > &list) const
Definition: vpBSpline.h:141
void set_knots(const std::list< double > &list)
Definition: vpBSpline.h:184