~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/analysis/interpolation/Bezier3D.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          Bezier3D.h  -  description
 
3
                             -------------------
 
4
    copyright            : (C) 2004 by Marco Hugentobler
 
5
    email                : mhugent@geo.unizh.ch
 
6
 ***************************************************************************/
 
7
 
 
8
/***************************************************************************
 
9
 *                                                                         *
 
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.                                   *
 
14
 *                                                                         *
 
15
 ***************************************************************************/
 
16
 
 
17
#ifndef BEZIER3D_H
 
18
#define BEZIER3D_H
 
19
 
 
20
#include "ParametricLine.h"
 
21
#include "Vector3D.h"
 
22
#include "MathUtils.h"
 
23
#include "qgslogger.h"
 
24
 
 
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
 
27
{
 
28
  protected:
 
29
 
 
30
  public:
 
31
    /**Default constructor*/
 
32
    Bezier3D();
 
33
    /**Constructor, par is a pointer to the parent, controlpoly a controlpolygon*/
 
34
    Bezier3D( ParametricLine* par, QVector<Point3D*>* controlpoly );
 
35
    /**Destructor*/
 
36
    virtual ~Bezier3D();
 
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;
 
60
    /** Sets the parent*/
 
61
    virtual void setParent( ParametricLine* par );
 
62
    /**Sets the control polygon*/
 
63
    virtual void setControlPoly( QVector<Point3D*>* cp );
 
64
 
 
65
};
 
66
 
 
67
//-----------------------------------------------constructors, destructor and assignment operator------------------------------
 
68
 
 
69
inline Bezier3D::Bezier3D() : ParametricLine()//default constructor
 
70
{
 
71
 
 
72
}
 
73
 
 
74
inline Bezier3D::Bezier3D( ParametricLine* parent, QVector<Point3D*>* controlpoly ) : ParametricLine( parent, controlpoly )
 
75
{
 
76
  mDegree = mControlPoly->count() - 1;
 
77
}
 
78
 
 
79
inline Bezier3D::~Bezier3D()
 
80
{
 
81
 
 
82
}
 
83
 
 
84
//----------------------------------------------invalid methods add and remove (because of inheritance from ParametricLine)
 
85
 
 
86
inline void Bezier3D::add( ParametricLine* pl )
 
87
{
 
88
  QgsDebugMsg( "Error!!!!! A Bezier-curve can not be parent of a ParametricLine." );
 
89
}
 
90
 
 
91
inline void Bezier3D::remove( int i )
 
92
{
 
93
  QgsDebugMsg( "Error!!!!! A Bezier-curve has no Childs to remove." );
 
94
}
 
95
 
 
96
//-----------------------------------------------setters and getters---------------------------------------------------------------
 
97
 
 
98
inline const Point3D* Bezier3D::getControlPoint( int number ) const
 
99
{
 
100
  return ( *mControlPoly )[number-1];
 
101
}
 
102
 
 
103
inline const QVector<Point3D*>* Bezier3D::getControlPoly() const
 
104
{
 
105
  return mControlPoly;
 
106
}
 
107
 
 
108
inline int Bezier3D::getDegree() const
 
109
{
 
110
  return mDegree;
 
111
}
 
112
 
 
113
inline ParametricLine* Bezier3D::getParent() const
 
114
{
 
115
  return mParent;
 
116
}
 
117
 
 
118
inline void Bezier3D::setParent( ParametricLine* par )
 
119
{
 
120
  mParent = par;
 
121
}
 
122
 
 
123
inline void Bezier3D::setControlPoly( QVector<Point3D*>* cp )
 
124
{
 
125
  mControlPoly = cp;
 
126
  mDegree = mControlPoly->count() - 1;
 
127
}
 
128
 
 
129
#endif
 
130