Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpNurbs.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 Non Uniform Rational B-Spline (NURBS)
32  *
33  * Authors:
34  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 
38 #ifndef vpNurbs_H
39 #define vpNurbs_H
40 
46 #include <visp3/core/vpImagePoint.h>
47 #include <visp3/core/vpMatrix.h>
48 #include <visp3/core/vpMath.h>
49 #include <visp3/me/vpMeSite.h>
50 #include <visp3/core/vpBSpline.h>
51 #include <visp3/core/vpList.h>
52 
53 #include <list>
54 
85 class VISP_EXPORT vpNurbs : public vpBSpline
86 {
87 protected:
88  std::vector<double> weights; //Vector which contains the weights associated to each control Points
89 
90 
91 protected:
92  static vpMatrix 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, std::vector<double> &l_weights);
93  vpMatrix computeCurveDers(double u, unsigned int der);
94 
95 public:
96 
97  vpNurbs();
98  vpNurbs(const vpNurbs &nurbs);
99  virtual ~vpNurbs();
100 
106  inline void get_weights(std::list<double>& list) const {
107  list.clear();
108  for (unsigned int i = 0; i < weights.size(); i++)
109  list.push_back(*(&(weights[0])+i));
110  }
111 
117  inline void set_weights(const std::list<double> &list) {
118  weights.clear();
119  for(std::list<double>::const_iterator it=list.begin(); it!=list.end(); ++it){
120  weights.push_back(*it);
121  }
122  }
123 
124  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
126 
127  static vpImagePoint* computeCurveDersPoint(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, std::vector<double> &l_weights);
128  vpImagePoint* computeCurveDersPoint(double u, unsigned int der);
129 
130  static void curveKnotIns(double l_u, unsigned int l_k, unsigned int l_s, unsigned int l_r, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
131  void curveKnotIns(double u, unsigned int s = 0, unsigned int r = 1);
132 
133  static void refineKnotVectCurve(double* l_x, unsigned int l_r, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
134  void refineKnotVectCurve(double* x, unsigned int r);
135 
136  static unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL, unsigned int l_s, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
137  unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL);
138 
139  static void globalCurveInterp(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
140  void globalCurveInterp(vpList<vpMeSite>& l_crossingPoints);
141  void globalCurveInterp(const std::list<vpImagePoint>& l_crossingPoints);
142  void globalCurveInterp(const std::list<vpMeSite>& l_crossingPoints);
143  void globalCurveInterp();
144 
145  static void globalCurveApprox(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p, unsigned int l_n, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
146  void globalCurveApprox(vpList<vpMeSite>& l_crossingPoints, unsigned int n);
147  void globalCurveApprox(const std::list<vpImagePoint>& l_crossingPoints, unsigned int n);
148  void globalCurveApprox(const std::list<vpMeSite>& l_crossingPoints, unsigned int n);
149  void globalCurveApprox(unsigned int n);
150 };
151 
152 #endif
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)
Definition: vpBSpline.cpp:449
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
Provide simple list management.
Definition: vpList.h:118
void get_weights(std::list< double > &list) const
Definition: vpNurbs.h:106
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:100
std::vector< double > weights
Definition: vpNurbs.h:88
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_weights(const std::list< double > &list)
Definition: vpNurbs.h:117
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve...
Definition: vpNurbs.h:85
static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints)
Definition: vpBSpline.cpp:380