Visual Servoing Platform  version 3.6.1 under development (2024-03-28)
vpNurbs.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 https://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 
34 #ifndef vpNurbs_H
35 #define vpNurbs_H
36 
43 #include <visp3/core/vpBSpline.h>
44 #include <visp3/core/vpImagePoint.h>
45 #include <visp3/core/vpList.h>
46 #include <visp3/core/vpMath.h>
47 #include <visp3/core/vpMatrix.h>
48 #include <visp3/me/vpMeSite.h>
49 
50 #include <list>
51 
91 class VISP_EXPORT vpNurbs : public vpBSpline
92 {
93 protected:
95  std::vector<double> weights;
96 
97 protected:
128  static vpMatrix computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
129  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
130  std::vector<double> &l_weights);
131 
154  vpMatrix computeCurveDers(double u, unsigned int der);
155 
156 public:
163  vpNurbs();
164 
168  vpNurbs(const vpNurbs &nurbs);
169 
170 
177  inline void get_weights(std::list<double> &list) const
178  {
179  list.clear();
180  for (unsigned int i = 0; i < weights.size(); i++)
181  list.push_back(*(&(weights[0]) + i));
182  }
183 
189  inline void set_weights(const std::list<double> &list)
190  {
191  weights.clear();
192  for (std::list<double>::const_iterator it = list.begin(); it != list.end(); ++it) {
193  weights.push_back(*it);
194  }
195  }
196 
213  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots,
214  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
215 
226 
247  static vpImagePoint *computeCurveDersPoint(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
248  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
249  std::vector<double> &l_weights);
250 
264  vpImagePoint *computeCurveDersPoint(double u, unsigned int der);
265 
283  static void curveKnotIns(double l_u, unsigned int l_k, unsigned int l_s, unsigned int l_r, unsigned int l_p,
284  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
285  std::vector<double> &l_weights);
286 
299  void curveKnotIns(double u, unsigned int s = 0, unsigned int r = 1);
300 
315  static void refineKnotVectCurve(double *l_x, unsigned int l_r, unsigned int l_p, std::vector<double> &l_knots,
316  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
317 
328  void refineKnotVectCurve(double *x, unsigned int r);
329 
356  static unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL, unsigned int l_s,
357  unsigned int l_p, std::vector<double> &l_knots,
358  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
359 
381  unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL);
382 
396  static void globalCurveInterp(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p,
397  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
398  std::vector<double> &l_weights);
399 
410  void globalCurveInterp(vpList<vpMeSite> &l_crossingPoints);
411 
422  void globalCurveInterp(const std::list<vpImagePoint> &l_crossingPoints);
423 
434  void globalCurveInterp(const std::list<vpMeSite> &l_crossingPoints);
435 
443  void globalCurveInterp();
444 
462  static void globalCurveApprox(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p, unsigned int l_n,
463  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
464  std::vector<double> &l_weights);
480  void globalCurveApprox(vpList<vpMeSite> &l_crossingPoints, unsigned int n);
481 
496  void globalCurveApprox(const std::list<vpImagePoint> &l_crossingPoints, unsigned int n);
497 
513  void globalCurveApprox(const std::list<vpMeSite> &l_crossingPoints, unsigned int n);
514 
524  void globalCurveApprox(unsigned int n);
525 };
526 
527 #endif
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:107
static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, const std::vector< double > &l_knots, const std::vector< vpImagePoint > &l_controlPoints)
Definition: vpBSpline.cpp:375
static vpImagePoint * computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, const std::vector< double > &l_knots, const std::vector< vpImagePoint > &l_controlPoints)
Definition: vpBSpline.cpp:445
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
Provide simple list management.
Definition: vpList.h:108
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve.
Definition: vpNurbs.h:92
void get_weights(std::list< double > &list) const
Definition: vpNurbs.h:177
std::vector< double > weights
Vector which contains the weights associated to each control Points.
Definition: vpNurbs.h:95
void set_weights(const std::list< double > &list)
Definition: vpNurbs.h:189