Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlBezierCurve.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
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 GLBEZIERCURVE_H_
22 #define GLBEZIERCURVE_H_
23 
24 #include <tulip/AbstractGlCurve.h>
25 
26 namespace tlp {
27 
28 /**
29  * @ingroup OpenGL
30  * @brief A class to draw Bezier curves
31  *
32  * This class allows to draw Bezier curves defined by an arbitrary number of control points.
33  * Bezier curves are named after their inventor, Dr. Pierre Bezier. He was an engineer with the
34  * Renault car company and set out in the early 1960's to develop a curve formulation which would
35  * lend itself to shape design.
36  * Bezier curves are widely used in computer graphics to model smooth curves. A Bezier curve is
37  * completely contained in the convex hull of its control points and passes through its first and
38  * last control points. The curve is also always tangent to the first and last convex hull polygon segments.
39  * In addition, the curve shape tends to follow the polygon shape.
40  *
41  */
42 class TLP_GL_SCOPE GlBezierCurve : public AbstractGlCurve {
43 
44 public:
45 
46  GlBezierCurve();
47 
48  /**
49  * @brief GlBezierCurve constructor
50  *
51  * @param controlPoints a vector of control points (size must be greater or equal to 2)
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  GlBezierCurve(const std::vector<Coord> &controlPoints, const Color &startColor, const Color &endColor,
59  const float &startSize, const float &endSize, const unsigned int nbCurvePoints = 200);
60 
61  ~GlBezierCurve();
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  Coord computeCurvePointOnCPU(const std::vector<Coord> &controlPoints, float t);
68 
69  void computeCurvePointsOnCPU(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, unsigned int nbCurvePoints);
70 
71  std::string genCurveVertexShaderSpecificCode();
72 
73 };
74 
75 }
76 #endif /* GLBEZIERCURVE_H_ */
A class to draw Bezier curves.
Definition: GlBezierCurve.h:42