Tulip  4.3.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/tulipconf.h>
27 #include <tulip/Coord.h>
28 
29 namespace tlp {
30 
31 /**
32  * Compute Pascal triangle until nth row
33  *
34  * \param n the number of Pascal triangle rows to compute
35  * \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.
36  */
37 TLP_GL_SCOPE void buildPascalTriangle(unsigned int n, std::vector<std::vector<double> > &pascalTriangle);
38 
39 /**
40  * Compute the position of a point 'p' at t (0 <= t <= 1)
41  * along Bezier curve defined by a set of control points
42  *
43  * \param controlPoints a vector of control points
44  * \param t curve parameter value (0 <= t <= 1)
45  */
46 TLP_GL_SCOPE Coord computeBezierPoint(const std::vector<Coord> &controlPoints, const float t);
47 
48 /** Compute a set of points approximating a Bézier curve
49  *
50  * \param controlPoints a vector of control points
51  * \param curvePoints an empty vector to store the computed points
52  * \param nbCurvePoints number of points to generate
53  */
54 TLP_GL_SCOPE void computeBezierPoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const unsigned int nbCurvePoints = 100);
55 
56 
57 /**
58  * Compute the position of a point 'p' at t (0 <= t <= 1)
59  * along Catmull-Rom curve defined by a set of control points.
60  * The features of this type of spline are the following :
61  * -> the spline passes through all of the control points
62  * -> the spline is C1 continuous, meaning that there are no discontinuities in the tangent direction and magnitude
63  * -> 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
64  *
65  * \param controlPoints a vector of control points
66  * \param t curve parameter value (0 <= t <= 1)
67  * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the last and first control point
68  * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization
69  */
70 TLP_GL_SCOPE Coord computeCatmullRomPoint(const std::vector<Coord> &controlPoints, const float t, const bool closedCurve = false, const float alpha = 0.5);
71 
72 /** Compute a set of points approximating a Catmull-Rom curve
73  *
74  * \param controlPoints a vector of control points
75  * \param curvePoints an empty vector to store the computed points
76  * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the last and first control point
77  * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization
78  * \param nbCurvePoints number of points to generate
79  */
80 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);
81 
82 /**
83  * Compute the position of a point 'p' at t (0 <= t <= 1)
84  * along open uniform B-spline curve defined by a set of control points.
85  * An uniform B-spline is a piecewise collection of Bézier curves of the same degree, connected end to end.
86  * The features of this type of spline are the following :
87  * -> the spline is C^2 continuous, meaning there is no discontinuities in curvature
88  * -> the spline has local control : its parameters only affect a small part of the entire spline
89  * A B-spline is qualified as open when it passes through its first and last control points.
90  * \param controlPoints a vector of control points
91  * \param t curve parameter value (0 <= t <= 1)
92  * \param curveDegree the B-spline degree
93  */
94 
95 
96 TLP_GL_SCOPE Coord computeOpenUniformBsplinePoint(const std::vector<Coord> &controlPoints, const float t, const unsigned int curveDegree = 3);
97 
98 /** Compute a set of points approximating an open uniform B-spline curve
99  *
100  * \param controlPoints a vector of control points
101  * \param curvePoints an empty vector to store the computed points
102  * \param curveDegree the B-spline degree
103  * \param nbCurvePoints number of points to generate
104  */
105 TLP_GL_SCOPE void computeOpenUniformBsplinePoints(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, const unsigned int curveDegree = 3, const unsigned int nbCurvePoints = 100);
106 
107 
108 }
109 
110 #endif /* PARAMETRICCURVES_H_ */
111 ///@endcond