QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
NormVecDecorator.h
Go to the documentation of this file.
1 /***************************************************************************
2  NormVecDecorator.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 NORMVECDECORATOR_H
18 #define NORMVECDECORATOR_H
19 
20 #include "TriDecorator.h"
21 #include "qgis_sip.h"
22 #include "TriangleInterpolator.h"
23 #include "MathUtils.h"
24 #include "qgslogger.h"
25 #include "qgis_analysis.h"
26 
27 #define SIP_NO_FILE
28 
29 class QgsFeedback;
30 
36 class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
37 {
38  public:
40  enum PointState {Normal, BreakLine, EndPoint};
44  ~NormVecDecorator() override;
45  int addPoint( const QgsPoint &p ) override;
47  bool calcNormal( double x, double y, QgsPoint &result SIP_OUT ) override;
49  bool calcNormalForPoint( double x, double y, int pointIndex, Vector3D *result SIP_OUT );
50  bool calcPoint( double x, double y, QgsPoint &result SIP_OUT ) override;
52  void eliminateHorizontalTriangles() override;
54  bool estimateFirstDerivative( int pointno );
56  bool estimateFirstDerivatives( QgsFeedback *feedback = nullptr );
58  Vector3D *getNormal( int n ) const;
60  bool getTriangle( double x, double y, QgsPoint &p1 SIP_OUT, Vector3D *v1 SIP_OUT, QgsPoint &p2 SIP_OUT, Vector3D *v2 SIP_OUT, QgsPoint &p3 SIP_OUT, Vector3D *v3 SIP_OUT ) SIP_PYNAME( getTriangleVertices );
62  bool getTriangle( double x, double y, QgsPoint &p1 SIP_OUT, int &ptn1 SIP_OUT, Vector3D *v1 SIP_OUT, PointState *state1 SIP_OUT, QgsPoint &p2 SIP_OUT, int &ptn2 SIP_OUT, Vector3D *v2 SIP_OUT, PointState *state2 SIP_OUT, QgsPoint &p3 SIP_OUT, int &ptn3 SIP_OUT, Vector3D *v3 SIP_OUT, PointState *state3 SIP_OUT );
64  PointState getState( int pointno ) const;
66  void setTriangleInterpolator( TriangleInterpolator *inter ) override;
68  bool swapEdge( double x, double y ) override;
69 
70  bool saveTriangulation( QgsFeatureSink *sink, QgsFeedback *feedback = nullptr ) const override;
71 
72  QgsMesh triangulationToMesh( QgsFeedback *feedback = nullptr ) const override;
73 
74  protected:
77  static const unsigned int DEFAULT_STORAGE_FOR_NORMALS = 100000;
79  TriangleInterpolator *mInterpolator = nullptr;
81  QVector<Vector3D *> *mNormVec;
83  QVector<PointState> *mPointState;
85  void setState( int pointno, PointState s );
86 
87  private:
88  NormVecDecorator( const NormVecDecorator & ) = delete;
89  NormVecDecorator &operator=( const NormVecDecorator & ) = delete;
90 };
91 
92 #ifndef SIP_RUN
93 
95  : mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) )
96  , mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
97 {
98  alreadyestimated = false;
99 }
100 
102  : TriDecorator( tin )
103  , mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) )
104  , mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
105 {
106  alreadyestimated = false;
107 }
108 
110 {
111  mInterpolator = inter;
112 }
113 
114 inline Vector3D *NormVecDecorator::getNormal( int n ) const
115 {
116  if ( mNormVec )
117  {
118  return mNormVec->at( n );
119  }
120  else
121  {
122  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
123  return nullptr;
124  }
125 }
126 
127 #endif
128 
129 #endif
SIP_PYNAME
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
TriDecorator::eliminateHorizontalTriangles
void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping.
Definition: TriDecorator.cpp:246
TriDecorator
Decorator class for Triangulations (s. Decorator pattern in Gamma et al.).
Definition: TriDecorator.h:31
NormVecDecorator::alreadyestimated
bool alreadyestimated
Is true, if the normals already have been estimated.
Definition: NormVecDecorator.h:76
MathUtils.h
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
TriDecorator::addPoint
int addPoint(const QgsPoint &p) override
Adds a point to the triangulation.
Definition: TriDecorator.cpp:32
TriDecorator::calcNormal
bool calcNormal(double x, double y, QgsPoint &result) override
Calculates the normal at a point on the surface and assigns it to 'result'.
Definition: TriDecorator.cpp:58
QgsTriangulation
Interface for Triangulation classes.
Definition: qgstriangulation.h:41
QgsMesh
Mesh - vertices, edges and faces.
Definition: qgsmeshdataprovider.h:58
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
NormVecDecorator::getNormal
Vector3D * getNormal(int n) const
Returns a pointer to the normal vector for the point with the number n.
Definition: NormVecDecorator.h:114
NormVecDecorator::NormVecDecorator
NormVecDecorator()
Definition: NormVecDecorator.h:94
NormVecDecorator::mPointState
QVector< PointState > * mPointState
Vector who stores, it a point is not on a breakline, if it is a normal point of the breakline or if i...
Definition: NormVecDecorator.h:83
QgsTriangulation::triangulationToMesh
virtual QgsMesh triangulationToMesh(QgsFeedback *feedback=nullptr) const =0
Returns a QgsMesh corresponding to the triangulation.
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgis_sip.h
TriDecorator::setTriangleInterpolator
void setTriangleInterpolator(TriangleInterpolator *interpolator) override
Sets an interpolator object.
Definition: TriDecorator.cpp:234
TriDecorator::calcPoint
bool calcPoint(double x, double y, QgsPoint &result) override
Calculates x-, y and z-value of the point on the surface and assigns it to 'result'.
Definition: TriDecorator.cpp:72
TriDecorator::swapEdge
bool swapEdge(double x, double y) override
Reads the content of a taff-file.
Definition: TriDecorator.cpp:284
NormVecDecorator::mNormVec
QVector< Vector3D * > * mNormVec
Vector that stores the normals for the points. If 'estimateFirstDerivatives()' was called and there i...
Definition: NormVecDecorator.h:81
NormVecDecorator::mInterpolator
TriangleInterpolator * mInterpolator
Association with an interpolator object.
Definition: NormVecDecorator.h:79
TriangleInterpolator.h
NormVecDecorator::setTriangleInterpolator
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
Definition: NormVecDecorator.h:109
qgslogger.h
Vector3D
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values.
Definition: Vector3D.h:35
TriDecorator.h
NormVecDecorator::PointState
PointState
Enumeration for the state of a point. Normal means, that the point is not on a BreakLine,...
Definition: NormVecDecorator.h:40
QgsTriangulation::saveTriangulation
virtual bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const =0
Saves the triangulation features to a feature sink.
QgsFeatureSink
An interface for objects which accept features via addFeature(s) methods.
Definition: qgsfeaturesink.h:33
NormVecDecorator
Decorator class which adds the functionality of estimating normals at the data points.
Definition: NormVecDecorator.h:36
TriangleInterpolator
This is an interface for interpolator classes for triangulations.
Definition: TriangleInterpolator.h:34