Tulip  4.6.0
Better Visualization Through Research
library/tulip-ogl/include/tulip/GlOpenUniformCubicBSpline.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 GLUNIFORMCUBICBSPLINE_H_
00022 #define GLUNIFORMCUBICBSPLINE_H_
00023 
00024 #include <tulip/AbstractGlCurve.h>
00025 
00026 namespace tlp {
00027 
00028 /**
00029  * @ingroup OpenGL
00030  * @brief A class to draw open uniform cubic B-splines
00031  *
00032  * A B-spline is a convenient form for representing complicated, smooth curves. A cubic uniform B-spline is a
00033  * 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.
00034  * B-splines have local control : parameters of a B-spline only affect a small part of the entire spline.
00035  * A B-spline is qualified as open when it passes through its first and last control points.
00036  *
00037  */
00038 class TLP_GL_SCOPE GlOpenUniformCubicBSpline : public AbstractGlCurve {
00039 
00040 public:
00041 
00042   /**
00043    * @brief Constructor
00044    * @warning Don't use it, see other construstor
00045    */
00046   GlOpenUniformCubicBSpline();
00047 
00048   /**
00049    * @brief GlOpenUniformCubicBSpline constructor
00050    *
00051    * @param controlPoints a vector of control points (size must be greater or equal to 4)
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   GlOpenUniformCubicBSpline(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   ~GlOpenUniformCubicBSpline();
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   void setCurveVertexShaderRenderingSpecificParameters();
00068 
00069   Coord computeCurvePointOnCPU(const std::vector<Coord> &controlPoints, float t);
00070 
00071   void computeCurvePointsOnCPU(const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints, unsigned int nbCurvePoints);
00072 
00073 private:
00074 
00075   unsigned nbKnots;
00076   float stepKnots;
00077 
00078 };
00079 
00080 }
00081 
00082 #endif
 All Classes Files Functions Variables Enumerations Enumerator Properties