QGIS API Documentation  2.99.0-Master (dc72e14)
Bezier3D.h
Go to the documentation of this file.
1 /***************************************************************************
2  Bezier3D.h - description
3  -------------------
4  copyright : (C) 2004 by Marco Hugentobler
5  email : [email protected]
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 "qgslogger.h"
22 #include "qgis_analysis.h"
23 
24 #define SIP_NO_FILE
25 
30 class ANALYSIS_EXPORT Bezier3D: public ParametricLine
31 {
32  protected:
33 
34  public:
36  Bezier3D();
38  Bezier3D( ParametricLine *par, QVector<QgsPoint *> *controlpoly );
39 
40  virtual ~Bezier3D();
42  virtual void add( ParametricLine *pl SIP_TRANSFER ) override;
44  virtual void calcFirstDer( float t, Vector3D *v SIP_OUT ) override;
46  virtual void calcSecDer( float t, Vector3D *v SIP_OUT ) override;
47  //virtual QgsPoint calcPoint(float t);
49  virtual void calcPoint( float t, QgsPoint *p SIP_OUT ) override;
51  virtual void changeDirection() override;
52  //virtual void draw(QPainter* p);
53  //virtual bool intersects(ParametricLine* pal);
55  virtual void remove( int i ) override;
57  virtual const QgsPoint *getControlPoint( int number ) const override;
59  virtual const QVector<QgsPoint *> *getControlPoly() const override;
61  virtual int getDegree() const override;
63  virtual ParametricLine *getParent() const override;
65  virtual void setParent( ParametricLine *par ) override;
67  virtual void setControlPoly( QVector<QgsPoint *> *cp ) override;
68 
69 };
70 
71 #ifndef SIP_RUN
72 
73 //-----------------------------------------------constructors, destructor and assignment operator------------------------------
74 
75 inline Bezier3D::Bezier3D() : ParametricLine()//default constructor
76 {
77 
78 }
79 
80 inline Bezier3D::Bezier3D( ParametricLine *parent, QVector<QgsPoint *> *controlpoly ) : ParametricLine( parent, controlpoly )
81 {
82  mDegree = mControlPoly->count() - 1;
83 }
84 
86 {
87 
88 }
89 
90 //----------------------------------------------invalid methods add and remove (because of inheritance from ParametricLine)
91 
92 inline void Bezier3D::add( ParametricLine *pl )
93 {
94  Q_UNUSED( pl );
95  QgsDebugMsg( "Error!!!!! A Bezier-curve can not be parent of a ParametricLine." );
96 }
97 
98 inline void Bezier3D::remove( int i )
99 {
100  Q_UNUSED( i );
101  QgsDebugMsg( "Error!!!!! A Bezier-curve has no children to remove." );
102 }
103 
104 //-----------------------------------------------setters and getters---------------------------------------------------------------
105 
106 inline const QgsPoint *Bezier3D::getControlPoint( int number ) const
107 {
108  return ( *mControlPoly )[number - 1];
109 }
110 
111 inline const QVector<QgsPoint *> *Bezier3D::getControlPoly() const
112 {
113  return mControlPoly;
114 }
115 
116 inline int Bezier3D::getDegree() const
117 {
118  return mDegree;
119 }
120 
122 {
123  return mParent;
124 }
125 
127 {
128  mParent = par;
129 }
130 
131 inline void Bezier3D::setControlPoly( QVector<QgsPoint *> *cp )
132 {
133  mControlPoly = cp;
134  mDegree = mControlPoly->count() - 1;
135 }
136 
137 #endif
138 
139 #endif
140 
virtual ParametricLine * getParent() const =0
virtual void setParent(ParametricLine *par) override
Sets the parent.
Definition: Bezier3D.h:126
QVector< QgsPoint * > * mControlPoly
MControlPoly stores the points of the control polygon.
virtual void add(ParametricLine *pl) override
Do not use this method, since a Bezier curve does not consist of other curves.
Definition: Bezier3D.h:92
#define QgsDebugMsg(str)
Definition: qgslogger.h:37
Class Bezier3D represents a bezier curve, represented by control points.
Definition: Bezier3D.h:30
virtual void calcFirstDer(float t, Vector3D *v)=0
virtual void calcSecDer(float t, Vector3D *v)=0
virtual const QgsPoint * getControlPoint(int number) const override
Returns a control point.
Definition: Bezier3D.h:106
virtual void calcPoint(float t, QgsPoint *p)=0
virtual void setParent(ParametricLine *paral)=0
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
Definition: Vector3D.h:32
virtual void changeDirection()=0
virtual int getDegree() const override
Returns the degree of the curve.
Definition: Bezier3D.h:116
int mDegree
Degree of the parametric Line.
virtual ParametricLine * getParent() const override
Returns the parent.
Definition: Bezier3D.h:121
virtual void setControlPoly(QVector< QgsPoint *> *cp) override
Sets the control polygon.
Definition: Bezier3D.h:131
virtual void add(ParametricLine *pl)=0
ParametricLine * mParent
Pointer to the parent object. If there isn&#39;t one, mParent is 0.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual int getDegree() const =0
ParametricLine is an Interface for parametric lines.
virtual const QVector< QgsPoint * > * getControlPoly() const =0
virtual ~Bezier3D()
Definition: Bezier3D.h:85
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:36
virtual const QgsPoint * getControlPoint(int number) const =0
virtual const QVector< QgsPoint * > * getControlPoly() const override
Returns a pointer to the control polygon.
Definition: Bezier3D.h:111
Bezier3D()
Default constructor.
Definition: Bezier3D.h:75
virtual void remove(int i) override
Do not use this method, since a Bezier curve does not consist of other curves.
Definition: Bezier3D.h:98
#define SIP_OUT
Definition: qgis_sip.h:51
virtual void setControlPoly(QVector< QgsPoint *> *cp)=0