1
/***************************************************************************
2
Bezier3D.h - description
4
copyright : (C) 2004 by Marco Hugentobler
5
email : mhugent@geo.unizh.ch
6
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
20
#include "ParametricLine.h"
22
#include "MathUtils.h"
23
#include "qgslogger.h"
25
/**Class Bezier3D represents a bezier curve, represented by control points. Parameter t is running from 0 to 1. The class is capable to calculate the curve point and the first two derivatives belonging to t.*/
26
class ANALYSIS_EXPORT Bezier3D: public ParametricLine
31
/**Default constructor*/
33
/**Constructor, par is a pointer to the parent, controlpoly a controlpolygon*/
34
Bezier3D( ParametricLine* par, QVector<Point3D*>* controlpoly );
37
/**Do not use this method, since a Bezier curve does not consist of other curves*/
38
virtual void add( ParametricLine* pl );
39
/**Calculates the first derivative and assigns it to v*/
40
virtual void calcFirstDer( float t, Vector3D* v );
41
/**Calculates the second derivative and assigns it to v*/
42
virtual void calcSecDer( float t, Vector3D* v );
43
//virtual Point3D calcPoint(float t);
44
/**Calculates the point on the curve and assigns it to p*/
45
virtual void calcPoint( float t, Point3D* p );
46
/**changes the order of control points*/
47
virtual void changeDirection();
48
//virtual void draw(QPainter* p);
49
//virtual bool intersects(ParametricLine* pal);
50
/**Do not use this method, since a Bezier curve does not consist of other curves*/
51
virtual void remove( int i );
52
/**Returns a control point*/
53
virtual const Point3D* getControlPoint( int number ) const;
54
/**Returns a pointer to the control polygon*/
55
virtual const QVector<Point3D*>* getControlPoly() const;
56
/**Returns the degree of the curve*/
57
virtual int getDegree() const;
58
/**Returns the parent*/
59
virtual ParametricLine* getParent() const;
61
virtual void setParent( ParametricLine* par );
62
/**Sets the control polygon*/
63
virtual void setControlPoly( QVector<Point3D*>* cp );
67
//-----------------------------------------------constructors, destructor and assignment operator------------------------------
69
inline Bezier3D::Bezier3D() : ParametricLine()//default constructor
74
inline Bezier3D::Bezier3D( ParametricLine* parent, QVector<Point3D*>* controlpoly ) : ParametricLine( parent, controlpoly )
76
mDegree = mControlPoly->count() - 1;
79
inline Bezier3D::~Bezier3D()
84
//----------------------------------------------invalid methods add and remove (because of inheritance from ParametricLine)
86
inline void Bezier3D::add( ParametricLine* pl )
88
QgsDebugMsg( "Error!!!!! A Bezier-curve can not be parent of a ParametricLine." );
91
inline void Bezier3D::remove( int i )
93
QgsDebugMsg( "Error!!!!! A Bezier-curve has no Childs to remove." );
96
//-----------------------------------------------setters and getters---------------------------------------------------------------
98
inline const Point3D* Bezier3D::getControlPoint( int number ) const
100
return ( *mControlPoly )[number-1];
103
inline const QVector<Point3D*>* Bezier3D::getControlPoly() const
108
inline int Bezier3D::getDegree() const
113
inline ParametricLine* Bezier3D::getParent() const
118
inline void Bezier3D::setParent( ParametricLine* par )
123
inline void Bezier3D::setControlPoly( QVector<Point3D*>* cp )
126
mDegree = mControlPoly->count() - 1;