Tulip  4.1.0
Better Visualization Through Research
 All Classes 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 #include <tulip/GlTools.h>
26 
27 namespace tlp {
28 
29 /**
30  * @ingroup OpenGL
31  * @brief A class to draw open uniform cubic B-splines
32  *
33  * A B-spline is a convenient form for representing complicated, smooth curves. A cubic uniform B-spline is a
34  * 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.
35  * B-splines have local control : parameters of a B-spline only affect a small part of the entire spline.
36  * A B-spline is qualified as open when it passes through its first and last control points.
37  *
38  */
39 class TLP_GL_SCOPE GlOpenUniformCubicBSpline : public AbstractGlCurve {
40 
41 public:
42 
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, const Color &endColor,
60  const float startSize, const float endSize, const unsigned int nbCurvePoints = 200);
61 
63 
64  void drawCurve(std::vector<Coord> &controlPoints, const Color &startColor, const Color &endColor, const float startSize, const float endSize, const unsigned int nbCurvePoints=200);
65 
66 protected :
67 
68  void setCurveVertexShaderRenderingSpecificParameters();
69 
70  Coord computeCurvePointOnCPU(const std::vector<Coord> &controlPoints, float t);
71 
72  void computeCurvePointsOnCPU(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, unsigned int nbCurvePoints);
73 
74 private:
75 
76  unsigned nbKnots;
77  float stepKnots;
78 
79 };
80 
81 }
82 
83 #endif