QGIS API Documentation  2.99.0-Master (25b0421)
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 *
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 "qgis.h"
23 #include "TriangleInterpolator.h"
24 #include "MathUtils.h"
25 #include "qgslogger.h"
26 #include "qgis_analysis.h"
27
28 #define SIP_NO_FILE
29
30 class QgsFeedback;
31
37 class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
38 {
39  public:
41  enum PointState {Normal, BreakLine, EndPoint};
44  virtual ~NormVecDecorator();
46  int addPoint( QgsPoint *p ) override;
48  bool calcNormal( double x, double y, Vector3D *result SIP_OUT ) override;
50  bool calcNormalForPoint( double x, double y, int point, Vector3D *result SIP_OUT );
52  bool calcPoint( double x, double y, QgsPoint *result SIP_OUT ) override;
54  virtual void eliminateHorizontalTriangles() override;
56  bool estimateFirstDerivative( int pointno );
58  bool estimateFirstDerivatives( QgsFeedback *feedback = nullptr );
60  Vector3D *getNormal( int n ) const;
62  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 );
64  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 );
66  PointState getState( int pointno ) const;
68  void setTriangleInterpolator( TriangleInterpolator *inter ) override;
70  virtual bool swapEdge( double x, double y ) override;
71
72  virtual bool saveTriangulation( QgsFeatureSink *sink, 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
88 #ifndef SIP_RUN
89
91  : TriDecorator()
92  , mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) )
93  , mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
94 {
96 }
97
99  : TriDecorator( tin )
100  , mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) )
102 {
104 }
105
107 {
108  mInterpolator = inter;
109 }
110
111 inline Vector3D *NormVecDecorator::getNormal( int n ) const
112 {
113  if ( mNormVec )
114  {
115  return mNormVec->at( n );
116  }
117  else
118  {
119  QgsDebugMsg( "warning, null pointer" );
120  return nullptr;
121  }
122 }
123
124 #endif
125
126 #endif
TriangleInterpolator * mInterpolator
Association with an interpolator object.
Decorator class which adds the functionality of estimating normals at the data points.
virtual void setTriangleInterpolator(TriangleInterpolator *interpolator) override
Sets an interpolator object.
#define QgsDebugMsg(str)
Definition: qgslogger.h:37
An interface for objects which accept features via addFeature(s) methods.
virtual bool swapEdge(double x, double y) override
Reads the content of a taff-file.
virtual void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping.
Adds a point to the triangulation Ownership is transferred to this class.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
bool getTriangle(double x, double y, QgsPoint *p1, int *n1, QgsPoint *p2, int *n2, QgsPoint *p3, int *n3) override
Finds out in which triangle the point with coordinates x and y is and assigns the numbers of the vert...
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
Definition: Vector3D.h:33
virtual bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const =0
Saves the triangulation features to a feature sink.
This is an interface for interpolator classes for triangulations.
QVector< Vector3D * > * mNormVec
Vector that stores the normals for the points. If &#39;estimateFirstDerivatives()&#39; was called and there i...
virtual bool calcNormal(double x, double y, Vector3D *result) override
Calculates the normal at a point on the surface and assigns it to &#39;result&#39;.
static const unsigned int DEFAULT_STORAGE_FOR_NORMALS
Interface for Triangulation classes.
Definition: Triangulation.h:38
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
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...
PointState
Enumeration for the state of a point. Normal means, that the point is not on a BreakLine, BreakLine means that the point is on a breakline (but not an end point of it) and EndPoint means, that it is an endpoint of a breakline.
Decorator class for Triangulations (s.
Definition: TriDecorator.h:31