Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
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 
52 BEGIN_VISP_NAMESPACE
92 class VISP_EXPORT vpNurbs : public vpBSpline
93 {
94 protected:
96  std::vector<double> weights;
97 
98 protected:
129  static vpMatrix computeCurveDers(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
130  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
131  std::vector<double> &l_weights);
132 
155  vpMatrix computeCurveDers(double u, unsigned int der);
156 
157 public:
164  vpNurbs();
165 
169  vpNurbs(const vpNurbs &nurbs);
170 
171 
178  inline void get_weights(std::list<double> &list) const
179  {
180  list.clear();
181  for (unsigned int i = 0; i < weights.size(); i++)
182  list.push_back(*(&(weights[0]) + i));
183  }
184 
190  inline void set_weights(const std::list<double> &list)
191  {
192  weights.clear();
193  for (std::list<double>::const_iterator it = list.begin(); it != list.end(); ++it) {
194  weights.push_back(*it);
195  }
196  }
197 
214  static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots,
215  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
216 
227 
248  static vpImagePoint *computeCurveDersPoint(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der,
249  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
250  std::vector<double> &l_weights);
251 
265  vpImagePoint *computeCurveDersPoint(double u, unsigned int der);
266 
284  static void curveKnotIns(double l_u, unsigned int l_k, unsigned int l_s, unsigned int l_r, unsigned int l_p,
285  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
286  std::vector<double> &l_weights);
287 
300  void curveKnotIns(double u, unsigned int s = 0, unsigned int r = 1);
301 
316  static void refineKnotVectCurve(double *l_x, unsigned int l_r, unsigned int l_p, std::vector<double> &l_knots,
317  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
318 
329  void refineKnotVectCurve(double *x, unsigned int r);
330 
357  static unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL, unsigned int l_s,
358  unsigned int l_p, std::vector<double> &l_knots,
359  std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights);
360 
382  unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL);
383 
397  static void globalCurveInterp(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p,
398  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
399  std::vector<double> &l_weights);
400 
411  void globalCurveInterp(vpList<vpMeSite> &l_crossingPoints);
412 
423  void globalCurveInterp(const std::list<vpImagePoint> &l_crossingPoints);
424 
435  void globalCurveInterp(const std::list<vpMeSite> &l_crossingPoints);
436 
444  void globalCurveInterp();
445 
463  static void globalCurveApprox(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p, unsigned int l_n,
464  std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints,
465  std::vector<double> &l_weights);
481  void globalCurveApprox(vpList<vpMeSite> &l_crossingPoints, unsigned int n);
482 
497  void globalCurveApprox(const std::list<vpImagePoint> &l_crossingPoints, unsigned int n);
498 
514  void globalCurveApprox(const std::list<vpMeSite> &l_crossingPoints, unsigned int n);
515 
525  void globalCurveApprox(unsigned int n);
526 };
527 END_VISP_NAMESPACE
528 #endif
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:108
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:376
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:446
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:109
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve.
Definition: vpNurbs.h:93
void get_weights(std::list< double > &list) const
Definition: vpNurbs.h:178
std::vector< double > weights
Vector which contains the weights associated to each control Points.
Definition: vpNurbs.h:96
void set_weights(const std::list< double > &list)
Definition: vpNurbs.h:190