Tulip  4.6.0
Better Visualization Through Research
library/tulip-ogl/include/tulip/GlBezierCurve.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 
00020 
00021 #ifndef GLBEZIERCURVE_H_
00022 #define GLBEZIERCURVE_H_
00023 
00024 #include <tulip/AbstractGlCurve.h>
00025 
00026 namespace tlp {
00027 
00028 /**
00029  * @ingroup OpenGL
00030  * @brief A class to draw Bezier curves
00031  *
00032  * This class allows to draw Bezier curves defined by an arbitrary number of control points.
00033  * Bezier curves are named after their inventor, Dr. Pierre Bezier. He was an engineer with the
00034  * Renault car company and set out in the early 1960's to develop a curve formulation which would
00035  * lend itself to shape design.
00036  * Bezier curves are widely used in computer graphics to model smooth curves. A Bezier curve is
00037  * completely contained in the convex hull of its control points and passes through its first and
00038  * last control points. The curve is also always tangent to the first and last convex hull polygon segments.
00039  * In addition, the curve shape tends to follow the polygon shape.
00040  *
00041  */
00042 class TLP_GL_SCOPE GlBezierCurve : public AbstractGlCurve {
00043 
00044 public:
00045 
00046   GlBezierCurve();
00047 
00048   /**
00049    * @brief GlBezierCurve constructor
00050    *
00051    * @param controlPoints a vector of control points (size must be greater or equal to 2)
00052    * @param startColor the color at the start of the curve
00053    * @param endColor the color at the end of the curve
00054    * @param startSize the width at the start of the curve
00055    * @param endSize the width at the end of the curve
00056    * @param nbCurvePoints the number of curve points to generate
00057    */
00058   GlBezierCurve(const std::vector<Coord> &controlPoints, const Color &startColor, const Color &endColor,
00059                 const float &startSize, const float &endSize, const unsigned int nbCurvePoints = 200);
00060 
00061   ~GlBezierCurve();
00062 
00063   void drawCurve(std::vector<Coord> &controlPoints, const Color &startColor, const Color &endColor, const float startSize, const float endSize, const unsigned int nbCurvePoints=200);
00064 
00065 protected :
00066 
00067   Coord computeCurvePointOnCPU(const std::vector<Coord> &controlPoints, float t);
00068 
00069   void computeCurvePointsOnCPU(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, unsigned int nbCurvePoints);
00070 
00071   std::string genCurveVertexShaderSpecificCode();
00072 
00073 };
00074 
00075 }
00076 #endif /* GLBEZIERCURVE_H_ */
 All Classes Files Functions Variables Enumerations Enumerator Properties