ViSP  2.10.0
vpNurbs.h
1 /****************************************************************************
2  *
3  * $Id: vpNurbs.h 4574 2014-01-09 08:48:51Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * This class implements the Non Uniform Rational B-Spline (NURBS)
36  *
37  * Authors:
38  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 
42 #ifndef vpNurbs_H
43 #define vpNurbs_H
44 
50 #include <visp/vpImagePoint.h>
51 #include <visp/vpMatrix.h>
52 #include <visp/vpMath.h>
53 #include <visp/vpMeSite.h>
54 #include <visp/vpBSpline.h>
55 #include <visp/vpList.h>
56 
57 #include <list>
58 
89 class VISP_EXPORT vpNurbs : public vpBSpline
90 {
91 protected:
92  std::vector<double> weights; //Vector which contains the weights associated to each control Points
93 
94 
95 protected:
96  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);
97  vpMatrix computeCurveDers(double u, unsigned int der);
98 
99 public:
100 
101  vpNurbs();
102  vpNurbs(const vpNurbs &nurbs);
103  virtual ~vpNurbs();
104 
110  inline void get_weights(std::list<double>& list) const {
111  list.clear();
112  for (unsigned int i = 0; i < weights.size(); i++)
113  list.push_back(*(&(weights[0])+i));
114  }
115 
121  inline void set_weights(const std::list<double> &list) {
122  weights.clear();
123  for(std::list<double>::const_iterator it=list.begin(); it!=list.end(); ++it){
124  weights.push_back(*it);
125  }
126  }
127 
128  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);
130 
131  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);
132  vpImagePoint* computeCurveDersPoint(double u, unsigned int der);
133 
134  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);
135  void curveKnotIns(double u, unsigned int s = 0, unsigned int r = 1);
136 
137  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);
138  void refineKnotVectCurve(double* x, unsigned int r);
139 
140  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);
141  unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL);
142 
143  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);
144  void globalCurveInterp(vpList<vpMeSite>& l_crossingPoints);
145  void globalCurveInterp(const std::list<vpImagePoint>& l_crossingPoints);
146  void globalCurveInterp(const std::list<vpMeSite>& l_crossingPoints);
147  void globalCurveInterp();
148 
149  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);
150  void globalCurveApprox(vpList<vpMeSite>& l_crossingPoints, unsigned int n);
151  void globalCurveApprox(const std::list<vpImagePoint>& l_crossingPoints, unsigned int n);
152  void globalCurveApprox(const std::list<vpMeSite>& l_crossingPoints, unsigned int n);
153  void globalCurveApprox(unsigned int n);
154 
155 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
156 
165  vp_deprecated inline vpList<double> get_weights() const {
166  vpList<double> list;
167  for (unsigned int i = 0; i < weights.size(); i++) list.addRight(*(&(weights[0])+i));
168  return list; }
169 
176  vp_deprecated inline void set_weights(vpList<double> &list) {
177  weights.clear();
178  list.front();
179  for (unsigned int i = 0; i < list.nbElements(); i++)
180  {
181  weights.push_back(list.value());
182  list.next();
183  }
184  }
185  vp_deprecated void globalCurveApprox(vpList<vpImagePoint>& l_crossingPoints, unsigned int n);
186  vp_deprecated void globalCurveInterp(vpList<vpImagePoint>& l_crossingPoints);
187 
188 #endif
189 };
190 
191 #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:456
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
unsigned int nbElements(void)
return the number of element in the list
Definition: vpList.h:259
Provide simple list management.
Definition: vpList.h:113
vp_deprecated void set_weights(vpList< double > &list)
Definition: vpNurbs.h:176
void next(void)
position the current element on the next one
Definition: vpList.h:273
void get_weights(std::list< double > &list) const
Definition: vpNurbs.h:110
void front(void)
Position the current element on the first element of the list.
Definition: vpList.h:384
type & value(void)
return the value of the current element
Definition: vpList.h:301
void addRight(const type &el)
add a new element in the list, at the right of the current one
Definition: vpList.h:478
vp_deprecated vpList< double > get_weights() const
Definition: vpNurbs.h:165
Class that provides tools to compute and manipulate a B-Spline curve.
Definition: vpBSpline.h:109
std::vector< double > weights
Definition: vpNurbs.h:92
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:93
void set_weights(const std::list< double > &list)
Definition: vpNurbs.h:121
Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve...
Definition: vpNurbs.h:89
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:387