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