/usr/include/visp/vpBSpline.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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | /****************************************************************************
*
* $Id: vpBSpline.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 B-Spline
*
* Authors:
* Nicolas Melchior
*
*****************************************************************************/
#ifndef vpBSpline_H
#define vpBSpline_H
/*!
\file vpBSpline.h
\brief Class that provides tools to compute and manipulate a B-Spline curve.
*/
#include <visp/vpImagePoint.h>
#include <vector>
#include <list>
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
# include <visp/vpList.h>
#endif
#include <visp/vpMatrix.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/*!
Structure that defines a B-Spline basis function \f$ N_{i,p}^k(u) \f$.
- i is the number of the knot interval in which the basis function is computed.
- p is the degree of the B-Spline basis function.
- u is the "point" point of the curve where the basis function is computed.
- k indicates which kth derivative is computed.
- value is the numerical value of \f$ N_{i,p}^k(u) \f$.
*/
typedef struct vpBasisFunction{
unsigned int i;
unsigned int p;
double u;
unsigned int k;
double value;
} vpBasisFunction;
#endif
/*!
\class vpBSpline
\ingroup MathTools
\brief Class that provides tools to compute and manipulate a 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 \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.
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) = \sum_{i=0}^n (N_{i,p}(u)P_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 vpBSpline
{
public/*protected*/:
//!Vector wich contains the control points
std::vector<vpImagePoint> controlPoints;
//! Vector which contain the knots \f$ {u0, ..., um} \f$
std::vector<double> knots;
//! Degree of the B-Spline basis functions.
unsigned int p;
//! Vector wich contains the points used during the interpolation method.
std::vector<vpImagePoint> crossingPoints;
public:
vpBSpline();
vpBSpline(const vpBSpline &bspline);
virtual ~vpBSpline();
/*!
Gets the degree of the B-Spline.
\return the degree of the B-Spline.
*/
inline unsigned int get_p() const {return p;}
/*!
Gets all the control points.
\param list : A std::list containing the coordinates of the control points.
*/
inline void get_controlPoints(std::list<vpImagePoint> &list) const {
list.clear();
for (unsigned int i = 0; i < controlPoints.size(); i++)
list.push_back(*(&(controlPoints[0])+i));
}
/*!
Gets all the knots.
\param list : A std::list containing the value of the knots.
*/
inline void get_knots(std::list<double> &list) const {
list.clear();
for (unsigned int i = 0; i < knots.size(); i++)
list.push_back(*(&(knots[0])+i));
}
/*!
Gets all the crossing points (used in the interpolation method)
\param list : A std::list containing the coordinates of the crossing points.
*/
inline void get_crossingPoints(std::list<vpImagePoint> &list) const {
list.clear();
for (unsigned int i = 0; i < crossingPoints.size(); i++)
list.push_back(*(&(crossingPoints[0])+i));
}
/*!
Sets the degree of the B-Spline.
\param p : the degree of the B-Spline.
*/
inline void set_p(unsigned int p) {this->p = p;}
/*!
Sets all the control points.
\param list : A std::list containing the coordinates of the control points
*/
inline void set_controlPoints(const std::list<vpImagePoint> &list) {
controlPoints.clear();
for(std::list<vpImagePoint>::const_iterator it = list.begin(); it!=list.end(); ++it){
controlPoints.push_back(*it);
}
}
/*!
Sets all the knots.
\param list : A std::list containing the value of the knots.
*/
inline void set_knots(const std::list<double> &list) {
knots.clear();
for(std::list<double>::const_iterator it = list.begin(); it!=list.end(); ++it){
knots.push_back(*it);
}
}
/*!
Sets all the crossing points (used in the interpolation method)
\param list : A std::list containing the coordinates of the crossing points
*/
inline void set_crossingPoints(const std::list<vpImagePoint> &list) {
crossingPoints.clear();
for(std::list<vpImagePoint>::const_iterator it=list.begin(); it!=list.end(); ++it){
crossingPoints.push_back(*it);
}
}
static unsigned int findSpan(double l_u, unsigned int l_p, std::vector<double> &l_knots);
unsigned int findSpan(double u);
static vpBasisFunction* computeBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots);
vpBasisFunction* computeBasisFuns(double u);
static vpBasisFunction** computeDersBasisFuns(double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, std::vector<double> &l_knots);
vpBasisFunction** computeDersBasisFuns(double u, unsigned int der);
static vpImagePoint computeCurvePoint(double l_u, unsigned int l_i, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints);
vpImagePoint computeCurvePoint(double u);
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);
vpImagePoint* computeCurveDers(double u, unsigned int der);
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
/*!
@name Deprecated functions
*/
/*!
\deprecated This method is deprecated. You should use get_controlPoints(std::list<vpImagePoint> &) const instead. \n \n
Gets all the control points.
\return list : A vpList containing the coordinates of the control points
*/
vp_deprecated vpList<vpImagePoint> get_controlPoints() const {
vpList<vpImagePoint> list;
for (unsigned int i = 0; i < controlPoints.size(); i++) list.addRight(*(&(controlPoints[0])+i));
return list; }
/*!
\deprecated This method is deprecated. You should use get_knots(std::list<double> &) const instead. \n \n
Gets all the knots.
\return list : A vpList containing the value of the knots.
*/
vp_deprecated inline vpList<double> get_knots() const {
vpList<double> list;
for (unsigned int i = 0; i < knots.size(); i++) list.addRight(*(&(knots[0])+i));
return list; }
/*!
\deprecated This method is deprecated. You should use get_crossingPoints(std::list<vpImagePoint> &) const instead. \n \n
Gets all the crossing points (used in the interpolation method)
\return list : A vpList containing the coordinates of the crossing points
*/
vp_deprecated inline vpList<vpImagePoint> get_crossingPoints() const {
vpList<vpImagePoint> list;
for (unsigned int i = 0; i < crossingPoints.size(); i++) list.addRight(*(&(crossingPoints[0])+i));
return list; }
/*!
\deprecated This method is deprecated. You should use set_controlPoints(const std::list<vpImagePoint> &) instead. \n \n
Sets all the control points.
\param list : A vpList containing the coordinates of the control points
*/
vp_deprecated inline void set_controlPoints(vpList<vpImagePoint> &list) {
controlPoints.clear();
list.front();
for (unsigned int i = 0; i < list.nbElements(); i++)
{
controlPoints.push_back(list.value());
list.next();
}
}
/*!
\deprecated This method is deprecated. You should use set_knots(const std::list<double> &) instead. \n \n
Sets all the knots.
\param list : A vpList containing the value of the knots.
*/
vp_deprecated inline void set_knots(vpList<double> &list) {
knots.clear();
list.front();
for (unsigned int i = 0; i < list.nbElements(); i++)
{
knots.push_back(list.value());
list.next();
}
}
/*!
\deprecated This method is deprecated. You should use set_crossingPoints(const std::list<vpImagePoint> &) instead. \n \n
Sets all the crossing points (used in the interpolation method)
\param list : A vpList containing the coordinates of the crossing points
*/
vp_deprecated inline void set_crossingPoints(vpList<vpImagePoint> &list) {
crossingPoints.clear();
list.front();
for (unsigned int i = 0; i < list.nbElements(); i++)
{
crossingPoints.push_back(list.value());
list.next();
}
}
#endif
};
#endif
|