Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
ParametricCurves.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
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
29namespace tlp {
30
31/**
32 * Compute the position of a point 'p' at t (0 <= t <= 1)
33 * along Bezier curve defined by a set of control points
34 *
35 * \param controlPoints a vector of control points
36 * \param t curve parameter value (0 <= t <= 1)
37 */
38TLP_SCOPE Coord computeBezierPoint(const std::vector<Coord> &controlPoints, const float t);
39
40/** Compute a set of points approximating a Bézier curve
41 *
42 * \param controlPoints a vector of control points
43 * \param curvePoints an empty vector to store the computed points
44 * \param nbCurvePoints number of points to generate
45 */
46TLP_SCOPE void computeBezierPoints(const std::vector<Coord> &controlPoints,
47 std::vector<Coord> &curvePoints,
48 const unsigned int nbCurvePoints = 100);
49
50/**
51 * Compute the position of a point 'p' at t (0 <= t <= 1)
52 * along Catmull-Rom curve defined by a set of control points.
53 * The features of this type of spline are the following :
54 * -> the spline passes through all of the control points
55 * -> the spline is C1 continuous, meaning that there are no discontinuities in the tangent
56 * direction and magnitude
57 * -> the spline is not C2 continuous. The second derivative is linearly interpolated within
58 * each segment, causing the curvature to vary linearly over the length of the segment
59 *
60 * \param controlPoints a vector of control points
61 * \param t curve parameter value (0 <= t <= 1)
62 * \param closedCurve if true, the curve will be closed, meaning a Bézier segment will connect the
63 * last and first control point
64 * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform
65 * parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length
66 * parameterization
67 */
68TLP_SCOPE Coord computeCatmullRomPoint(const std::vector<Coord> &controlPoints, const float t,
69 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
76 * last and first control point
77 * \param alpha curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform
78 * parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length
79 * parameterization
80 * \param nbCurvePoints number of points to generate
81 */
82TLP_SCOPE void computeCatmullRomPoints(const std::vector<Coord> &controlPoints,
83 std::vector<Coord> &curvePoints,
84 const bool closedCurve = false,
85 const unsigned int nbCurvePoints = 100,
86 const float alpha = 0.5);
87
88/**
89 * Compute the position of a point 'p' at t (0 <= t <= 1)
90 * along open uniform B-spline curve defined by a set of control points.
91 * An uniform B-spline is a piecewise collection of Bézier curves of the same degree, connected end
92 * to end.
93 * The features of this type of spline are the following :
94 * -> the spline is C^2 continuous, meaning there is no discontinuities in curvature
95 * -> the spline has local control : its parameters only affect a small part of the entire
96 * spline
97 * A B-spline is qualified as open when it passes through its first and last control points.
98 * \param controlPoints a vector of control points
99 * \param t curve parameter value (0 <= t <= 1)
100 * \param curveDegree the B-spline degree
101 */
102
103TLP_SCOPE Coord computeOpenUniformBsplinePoint(const std::vector<Coord> &controlPoints,
104 const float t, const unsigned int curveDegree = 3);
105
106/** Compute a set of points approximating an open uniform B-spline curve
107 *
108 * \param controlPoints a vector of control points
109 * \param curvePoints an empty vector to store the computed points
110 * \param curveDegree the B-spline degree
111 * \param nbCurvePoints number of points to generate
112 */
113TLP_SCOPE void computeOpenUniformBsplinePoints(const std::vector<Coord> &controlPoints,
114 std::vector<Coord> &curvePoints,
115 const unsigned int curveDegree = 3,
116 const unsigned int nbCurvePoints = 100);
117} // namespace tlp
118
119#endif /* PARAMETRICCURVES_H_ */
120///@endcond