/usr/include/visp/vpNurbs.h is in libvisp-dev 2.8.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | /****************************************************************************
*
* $Id: vpNurbs.h 4056 2013-01-05 13:04:42Z fspindle $
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact INRIA about acquiring a ViSP Professional
* Edition License.
*
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
*
* This software was developed at:
* INRIA Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
* http://www.irisa.fr/lagadic
*
* If you have questions regarding the use of this file, please contact
* INRIA at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* Description:
* This class implements the Non Uniform Rational B-Spline (NURBS)
*
* Authors:
* Nicolas Melchior
*
*****************************************************************************/
#ifndef vpNurbs_H
#define vpNurbs_H
/*!
\file vpNurbs.h
\brief Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve.
*/
#include <visp/vpImagePoint.h>
#include <visp/vpMatrix.h>
#include <visp/vpMath.h>
#include <visp/vpMeSite.h>
#include <visp/vpBSpline.h>
#include <visp/vpList.h>
#include <list>
/*!
\class vpNurbs
\ingroup MathTools
\brief Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve.
The different parameters are :
- The knot vector \f$ U = {u_0, ... , u_m} \f$ where the knots \f$ u_i, i = 0, ...,m \f$ are real number such as \f$ u_i < u_{i+1} i = 0, ...,m \f$.
To define a curve, the knot vector is such as : \f$ U = {a , ... , a, u_{p+1} , ... , u_{m-p-1} , b , ... , b} \f$ where \f$ a \f$ and \f$ b \f$ are real numbers and p is the degree of the B-Spline basis functions.
- The B-Spline basis functions \f$ N_{i,p} \f$ defined as :
\f[ N_{i,0}(u) = \left\{\begin{array}{cc}
1 & \mbox{if } u_i \leq u_{i+1} \\ 0 & else
\end{array}\right.\f]
\f[ N_{i,p}(u) = \frac{u-u_i}{u_{i+p}-u_i}N_{i,p-1}(u)+\frac{u_{i+p+1}-u}{u_{i+p+1}-u_{i+1}}N_{i+1,p-1}(u)\f]
where \f$ i = 0 , ... , m-1 \f$ and p is the degree of the B-Spline basis functions.
- The control points \f$ {P_i} \f$ which are defined by the coordinates \f$ (i,j) \f$ of a point in an image.
- The weight \f$ {w_i} \f$ associated to each control points.The wheights value is upper than 0.
It is possible to compute the coordinates of a point corresponding to the knots \f$ u \f$ (\f$ u \in [u_0,u_m]\f$) thanks to the formula :
\f[ C(u) = \frac{\sum_{i=0}^n (N_{i,p}(u)w_iP_i)}{\sum_{i=0}^n (N_{i,p}(u)w_i)}\f]
You can find much more information about the B-Splines and the implementation of all the methods in the Nurbs Book.
*/
class VISP_EXPORT vpNurbs : public vpBSpline
{
protected:
std::vector<double> weights; //Vector which contains the weights associated to each control Points
protected:
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);
vpMatrix computeCurveDers(double u, unsigned int der);
public:
vpNurbs();
vpNurbs(const vpNurbs &nurbs);
virtual ~vpNurbs();
/*!
Gets all the weights relative to the control points.
\return list : A std::list containing weights relative to the control points.
*/
inline void get_weights(std::list<double>& list) const {
list.clear();
for (unsigned int i = 0; i < weights.size(); i++)
list.push_back(*(&(weights[0])+i));
}
/*!
Sets all the knots.
\param list : A std::list containing the value of the knots.
*/
inline void set_weights(const std::list<double> &list) {
weights.clear();
for(std::list<double>::const_iterator it=list.begin(); it!=list.end(); ++it){
weights.push_back(*it);
}
}
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);
vpImagePoint computeCurvePoint(double u);
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);
vpImagePoint* computeCurveDersPoint(double u, unsigned int der);
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);
void curveKnotIns(double u, unsigned int s = 0, unsigned int r = 1);
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);
void refineKnotVectCurve(double* x, unsigned int r);
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);
unsigned int removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, double l_TOL);
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);
void globalCurveInterp(vpList<vpMeSite>& l_crossingPoints);
void globalCurveInterp(const std::list<vpImagePoint>& l_crossingPoints);
void globalCurveInterp(const std::list<vpMeSite>& l_crossingPoints);
void globalCurveInterp();
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);
void globalCurveApprox(vpList<vpMeSite>& l_crossingPoints, unsigned int n);
void globalCurveApprox(const std::list<vpImagePoint>& l_crossingPoints, unsigned int n);
void globalCurveApprox(const std::list<vpMeSite>& l_crossingPoints, unsigned int n);
void globalCurveApprox(unsigned int n);
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
/*!
@name Deprecated functions
*/
/*!
\deprecated This method is deprecated. You should use get_weights(std::list<double> &) const instead. \n \n
Gets all the weights relative to the control points.
\return list : A list containing weights relative to the control points.
*/
vp_deprecated inline vpList<double> get_weights() const {
vpList<double> list;
for (unsigned int i = 0; i < weights.size(); i++) list.addRight(*(&(weights[0])+i));
return list; }
/*!
\deprecated This method is deprecated. You should use set_weights(const std::list<double>&) instead.\n \n
Sets all the knots.
\param list : A list containing the value of the knots.
*/
vp_deprecated inline void set_weights(vpList<double> &list) {
weights.clear();
list.front();
for (unsigned int i = 0; i < list.nbElements(); i++)
{
weights.push_back(list.value());
list.next();
}
}
vp_deprecated void globalCurveApprox(vpList<vpImagePoint>& l_crossingPoints, unsigned int n);
vp_deprecated void globalCurveInterp(vpList<vpImagePoint>& l_crossingPoints);
#endif
};
#endif
|