00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00084
00085
00086
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