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