Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
ParametricCurves.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef PARAMETRICCURVES_H_
22 #define PARAMETRICCURVES_H_
23 
24 #include <vector>
25 
26 #include <tulip/Coord.h>
27 
28 namespace tlp {
29 
30 /**
31  * Compute Pascal triangle until nth row
32  *
33  * \param n the number of Pascal triangle rows to compute
34  * \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.
35  */
36 TLP_GL_SCOPE void buildPascalTriangle(unsigned int n, std::vector<std::vector<double> > &pascalTriangle);
37 
38 /**
39  * Compute the position of a point 'p' at t (0 <= t <= 1)
40  * along Bézier curve defined by a set of control points
41  *
42  * \param controlPoints a vector of control points
43  * \param t curve parameter value (0 <= t <= 1)
44  */
45 TLP_GL_SCOPE Coord computeBezierPoint(const std::vector<Coord> &controlPoints, const float t);
46 
47 /** Compute a set of points approximating a Bézier curve
48  *
49  * \param controlPoints a vector of control points
50  * \param curvePoints an empty vector to store the computed points
51  * \param nbCurvePoints number of points to generate
52  */
53 TLP_GL_SCOPE void computeBezierPoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const unsigned int nbCurvePoints = 100);
54 
55 
56 /**
57  * Compute the position of a point 'p' at t (0 <= t <= 1)
58  * along Catmull-Rom curve defined by a set of control points.
59  * The features of this type of spline are the following :
60  * -> the spline passes through all of the control points
61  * -> the spline is C1 continuous, meaning that there are no discontinuities in the tangent direction and magnitude
62  * -> 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
63  *
64  * \param controlPoints a vector of control points
65  * \param t curve parameter value (0 <= t <= 1)
66  * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the last and first control point
67  * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization
68  */
69 TLP_GL_SCOPE Coord computeCatmullRomPoint(const std::vector<Coord> &controlPoints, const float t, const bool closedCurve = false, const float alpha = 0.5);
70 
71 /** Compute a set of points approximating a Catmull-Rom curve
72  *
73  * \param controlPoints a vector of control points
74  * \param curvePoints an empty vector to store the computed points
75  * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the last and first control point
76  * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization
77  * \param nbCurvePoints number of points to generate
78  */
79 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);
80 
81 /**
82  * Compute the position of a point 'p' at t (0 <= t <= 1)
83  * along open uniform B-spline curve defined by a set of control points.
84  * An uniform B-spline is a piecewise collection of Bézier curves of the same degree, connected end to end.
85  * The features of this type of spline are the following :
86  * -> the spline is C^2 continuous, meaning there is no discontinuities in curvature
87  * -> the spline has local control : its parameters only affect a small part of the entire spline
88  * A B-spline is qualified as open when it passes through its first and last control points.
89  * \param controlPoints a vector of control points
90  * \param t curve parameter value (0 <= t <= 1)
91  * \param curveDegree the B-spline degree
92  */
93 
94 
95 TLP_GL_SCOPE Coord computeOpenUniformBsplinePoint(const std::vector<Coord> &controlPoints, const float t, const unsigned int curveDegree = 3);
96 
97 /** Compute a set of points approximating an open uniform B-spline curve
98  *
99  * \param controlPoints a vector of control points
100  * \param curvePoints an empty vector to store the computed points
101  * \param curveDegree the B-spline degree
102  * \param nbCurvePoints number of points to generate
103  */
104 TLP_GL_SCOPE void computeOpenUniformBsplinePoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const unsigned int curveDegree = 3, const unsigned int nbCurvePoints = 100);
105 
106 
107 }
108 
109 #endif /* PARAMETRICCURVES_H_ */
110 ///@endcond