Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

glbeziercurve.h

00001 /***************************************************************************
00002                           glbeziercurve.h  -  description
00003                              -------------------
00004     begin                : Thu Jul 3 2003
00005     copyright            : (C) 2003 by Jacques Gasselin de Richebourg
00006     email                : jacquesgasselin@hotmail.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU Lesser General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GLBEZIERCURVE_H
00019 #define GLBEZIERCURVE_H
00020 
00021 #include <vector>
00022 
00023 #include "glgeometricobject.h"
00024 #include "referencecounted.h"
00025 
00034 namespace GLScene
00035 {
00036    
00037    class BernsteinPolynomial
00038    {
00039       static std::vector< std::vector<GLuint> > pascalsTriangle;
00040      
00041       public:
00042       BernsteinPolynomial(unsigned);
00043       ~BernsteinPolynomial();
00044 
00045       void setOrder(unsigned);
00046       const float get(const unsigned, const unsigned, const float);
00047 
00048       TEST_FUNC( void unitTest() );
00049    
00050       protected:
00051       void extendPascal(GLuint);
00052 
00053       inline const unsigned getCoeff(const GLuint order, const GLuint choice)
00054       {  return pascalsTriangle[order][choice]; }
00055    };
00056    
00064    class GLBezierCurve: public GLGeometricObject
00065    {
00066       GLuint nOfCPs;
00067       GLuint sampleFreq;
00068       std::vector<GLVector> cpoints;
00069       GLuint levelOfDetail;
00070    
00071       public:
00072 
00073       SML_TAG(bcurve)
00074    
00075       GLBezierCurve();
00076       ~GLBezierCurve();
00077 
00078       GLuint getSize() const;
00079       void setLOD(const GLuint);
00080       void addControlPoint(const GLVector&);
00081       const GLVector getControlPoint(unsigned) const;
00082 
00083       /* virtual GLVector getVectorToFurthestPoint(const GLVector& fromPoint)
00084       { return getPosition() - fromPoint; };
00085       virtual GLVector getVectorToNearestPoint(const GLVector& fromPoint)
00086       { return getPosition() - fromPoint; };*/
00087 
00088       virtual bool intersection( GLGeometricObject* obj ) { return obj->intersection((GLBezierCurve*)this); };
00089       virtual bool intersection( GLBezierCurve*  ) { return false; };
00090       virtual bool inclusion( GLGeometricObject*  ) { return false;};
00091 
00092       void compileVertexArray() { };
00093       void render( );
00094       void renderForSelection(GLuint&);
00095 
00096       const GLVector pointAt(const GLfloat) const;
00097       const GLVector tangentAt(const GLfloat) const;
00098    };
00099 
00100 };
00101 #endif

Generated on Wed Feb 4 23:11:33 2004 by doxygen 1.3.3