Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
GlOpenUniformCubicBSpline.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
20#ifndef GLUNIFORMCUBICBSPLINE_H_
21#define GLUNIFORMCUBICBSPLINE_H_
22
23#include <tulip/AbstractGlCurve.h>
24
25namespace tlp {
26
27/**
28 * @ingroup OpenGL
29 * @brief A class to draw open uniform cubic B-splines
30 *
31 * A B-spline is a convenient form for representing complicated, smooth curves. A cubic uniform
32 * B-spline is a
33 * piecewise collection of cubic Bezier curves, connected end to end. A cubic B-spline is C^2
34 * continuous, meaning there is no discontinuities in curvature.
35 * B-splines have local control : parameters of a B-spline only affect a small part of the entire
36 * spline.
37 * A B-spline is qualified as open when it passes through its first and last control points.
38 *
39 */
40class TLP_GL_SCOPE GlOpenUniformCubicBSpline : public AbstractGlCurve {
41
42public:
43 /**
44 * @brief Constructor
45 * @warning Don't use it, see other construstor
46 */
48
49 /**
50 * @brief GlOpenUniformCubicBSpline constructor
51 *
52 * @param controlPoints a vector of control points (size must be greater or equal to 4)
53 * @param startColor the color at the start of the curve
54 * @param endColor the color at the end of the curve
55 * @param startSize the width at the start of the curve
56 * @param endSize the width at the end of the curve
57 * @param nbCurvePoints the number of curve points to generate
58 */
59 GlOpenUniformCubicBSpline(const std::vector<Coord> &controlPoints, const Color &startColor,
60 const Color &endColor, const float startSize, const float endSize,
61 const unsigned int nbCurvePoints = 200);
62
64
65 void drawCurve(std::vector<Coord> &controlPoints, const Color &startColor, const Color &endColor,
66 const float startSize, const float endSize,
67 const unsigned int nbCurvePoints = 200) override;
68
69protected:
70 void setCurveVertexShaderRenderingSpecificParameters() override;
71
72 Coord computeCurvePointOnCPU(const std::vector<Coord> &controlPoints, float t) override;
73
74 void computeCurvePointsOnCPU(const std::vector<Coord> &controlPoints,
75 std::vector<Coord> &curvePoints,
76 unsigned int nbCurvePoints) override;
77
78private:
79 unsigned nbKnots;
80 float stepKnots;
81};
82} // namespace tlp
83
84#endif
A class to draw open uniform cubic B-splines.
GlOpenUniformCubicBSpline()
Constructor.
GlOpenUniformCubicBSpline(const std::vector< Coord > &controlPoints, const Color &startColor, const Color &endColor, const float startSize, const float endSize, const unsigned int nbCurvePoints=200)
GlOpenUniformCubicBSpline constructor.