Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpNurbs.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 Non Uniform Rational B-Spline (NURBS)
33  *
34  * Authors:
35  * Nicolas Melchior
36  *
37  *****************************************************************************/
38 
39 #ifndef vpNurbs_H
40 #define vpNurbs_H
41 
48 #include <visp3/core/vpBSpline.h>
49 #include <visp3/core/vpImagePoint.h>
50 #include <visp3/core/vpList.h>
51 #include <visp3/core/vpMath.h>
52 #include <visp3/core/vpMatrix.h>
53 #include <visp3/me/vpMeSite.h>
54 
55 #include <list>
56 
97 class VISP_EXPORT vpNurbs : public vpBSpline
98 {
99 protected:
100  std::vector<double> weights; // Vector which contains the weights associated
101  // to each control Points
102 
103 protected:
104  static vpMatrix computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
105  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
106  std::vector<double> &l_weights);
107  vpMatrix computeCurveDers(double u, unsigned int der);
108 
109 public:
110  vpNurbs();
111  vpNurbs(const vpNurbs &nurbs);
112  virtual ~vpNurbs();
113 
120  inline void get_weights(std::list<double> &list) const
121  {
122  list.clear();
123  for (unsigned int i = 0; i < weights.size(); i++)
124  list.push_back(*(&(weights[0]) + i));
125  }
126 
132  inline void set_weights(const std::list<double> &list)
133  {
134  weights.clear();
135  for (std::list<double>::const_iterator it = list.begin(); it != list.end(); ++it) {
136  weights.push_back(*it);
137  }
138  }
139 
140  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots,
141  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
143 
144  static vpImagePoint *computeCurveDersPoint(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
145  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
146  std::vector<double> &l_weights);
147  vpImagePoint *computeCurveDersPoint(double u, unsigned int der);
148 
149  static void curveKnotIns(double l_u, unsigned int l_k, unsigned int l_s, unsigned int l_r, unsigned int l_p,
150  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
151  std::vector<double> &l_weights);
152  void curveKnotIns(double u, unsigned int s = 0, unsigned int r = 1);
153 
154  static void refineKnotVectCurve(double *l_x, unsigned int l_r, unsigned int l_p, std::vector<double> &l_knots,
155  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
156  void refineKnotVectCurve(double *x, unsigned int r);
157 
158  static unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL, unsigned int l_s,
159  unsigned int l_p, std::vector<double> &l_knots,
160  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
161  unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL);
162 
163  static void globalCurveInterp(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p,
164  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
165  std::vector<double> &l_weights);
166  void globalCurveInterp(vpList<vpMeSite> &l_crossingPoints);
167  void globalCurveInterp(const std::list<vpImagePoint> &l_crossingPoints);
168  void globalCurveInterp(const std::list<vpMeSite> &l_crossingPoints);
169  void globalCurveInterp();
170 
171  static void globalCurveApprox(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p, unsigned int l_n,
172  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
173  std::vector<double> &l_weights);
174  void globalCurveApprox(vpList<vpMeSite> &l_crossingPoints, unsigned int n);
175  void globalCurveApprox(const std::list<vpImagePoint> &l_crossingPoints, unsigned int n);
176  void globalCurveApprox(const std::list<vpMeSite> &l_crossingPoints, unsigned int n);
177  void globalCurveApprox(unsigned int n);
178 };
179 
180 #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:451
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:153
Provide simple list management.
Definition: vpList.h:113
void get_weights(std::list< double > &list) const
Definition: vpNurbs.h:120
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:110
std::vector< double > weights
Definition: vpNurbs.h:100
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:87
void set_weights(const std::list< double > &list)
Definition: vpNurbs.h:132
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve...
Definition: vpNurbs.h:97
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:381