![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef PARAMETRICCURVES_H_ 00022 #define PARAMETRICCURVES_H_ 00023 00024 #include <vector> 00025 00026 #include <tulip/tulipconf.h> 00027 #include <tulip/Coord.h> 00028 00029 namespace tlp { 00030 00031 /** 00032 * Compute Pascal triangle until nth row 00033 * 00034 * \param n the number of Pascal triangle rows to compute 00035 * \param pascalTriangle a vector of vector of double to store the result. If that vector already contains m Pascal triangle rows and n > m, the first m row are not recomputed and the vector is expanded to store the new rows. 00036 */ 00037 TLP_GL_SCOPE void buildPascalTriangle(unsigned int n, std::vector<std::vector<double> > &pascalTriangle); 00038 00039 /** 00040 * Compute the position of a point 'p' at t (0 <= t <= 1) 00041 * along Bezier curve defined by a set of control points 00042 * 00043 * \param controlPoints a vector of control points 00044 * \param t curve parameter value (0 <= t <= 1) 00045 */ 00046 TLP_GL_SCOPE Coord computeBezierPoint(const std::vector<Coord> &controlPoints, const float t); 00047 00048 /** Compute a set of points approximating a Bézier curve 00049 * 00050 * \param controlPoints a vector of control points 00051 * \param curvePoints an empty vector to store the computed points 00052 * \param nbCurvePoints number of points to generate 00053 */ 00054 TLP_GL_SCOPE void computeBezierPoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const unsigned int nbCurvePoints = 100); 00055 00056 00057 /** 00058 * Compute the position of a point 'p' at t (0 <= t <= 1) 00059 * along Catmull-Rom curve defined by a set of control points. 00060 * The features of this type of spline are the following : 00061 * -> the spline passes through all of the control points 00062 * -> the spline is C1 continuous, meaning that there are no discontinuities in the tangent direction and magnitude 00063 * -> the spline is not C2 continuous. The second derivative is linearly interpolated within each segment, causing the curvature to vary linearly over the length of the segment 00064 * 00065 * \param controlPoints a vector of control points 00066 * \param t curve parameter value (0 <= t <= 1) 00067 * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the last and first control point 00068 * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization 00069 */ 00070 TLP_GL_SCOPE Coord computeCatmullRomPoint(const std::vector<Coord> &controlPoints, const float t, const bool closedCurve = false, const float alpha = 0.5); 00071 00072 /** Compute a set of points approximating a Catmull-Rom curve 00073 * 00074 * \param controlPoints a vector of control points 00075 * \param curvePoints an empty vector to store the computed points 00076 * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the last and first control point 00077 * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization 00078 * \param nbCurvePoints number of points to generate 00079 */ 00080 TLP_GL_SCOPE void computeCatmullRomPoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const bool closedCurve = false, const unsigned int nbCurvePoints = 100, const float alpha = 0.5); 00081 00082 /** 00083 * Compute the position of a point 'p' at t (0 <= t <= 1) 00084 * along open uniform B-spline curve defined by a set of control points. 00085 * An uniform B-spline is a piecewise collection of Bézier curves of the same degree, connected end to end. 00086 * The features of this type of spline are the following : 00087 * -> the spline is C^2 continuous, meaning there is no discontinuities in curvature 00088 * -> the spline has local control : its parameters only affect a small part of the entire spline 00089 * A B-spline is qualified as open when it passes through its first and last control points. 00090 * \param controlPoints a vector of control points 00091 * \param t curve parameter value (0 <= t <= 1) 00092 * \param curveDegree the B-spline degree 00093 */ 00094 00095 00096 TLP_GL_SCOPE Coord computeOpenUniformBsplinePoint(const std::vector<Coord> &controlPoints, const float t, const unsigned int curveDegree = 3); 00097 00098 /** Compute a set of points approximating an open uniform B-spline curve 00099 * 00100 * \param controlPoints a vector of control points 00101 * \param curvePoints an empty vector to store the computed points 00102 * \param curveDegree the B-spline degree 00103 * \param nbCurvePoints number of points to generate 00104 */ 00105 TLP_GL_SCOPE void computeOpenUniformBsplinePoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const unsigned int curveDegree = 3, const unsigned int nbCurvePoints = 100); 00106 00107 00108 } 00109 00110 #endif /* PARAMETRICCURVES_H_ */ 00111 ///@endcond