QGIS API Documentation  2.99.0-Master (d55fa22)
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  ***************************************************************************/
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  ***************************************************************************/
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"
28 class QProgressDialog;
32 class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
33 {
34  public:
36  enum PointState {Normal, BreakLine, EndPoint};
39  virtual ~NormVecDecorator();
41  int addPoint( Point3D *p ) override;
43  bool calcNormal( double x, double y, Vector3D *result ) override;
45  bool calcNormalForPoint( double x, double y, int point, Vector3D *result );
47  bool calcPoint( double x, double y, Point3D *result ) override;
49  virtual void eliminateHorizontalTriangles() override;
51  bool estimateFirstDerivative( int pointno );
53  bool estimateFirstDerivatives( QProgressDialog *d = nullptr );
55  Vector3D *getNormal( int n ) const;
57  bool getTriangle( double x, double y, Point3D *p1 SIP_OUT, Vector3D *v1 SIP_OUT, Point3D *p2 SIP_OUT, Vector3D *v2 SIP_OUT, Point3D *p3 SIP_OUT, Vector3D *v3 SIP_OUT );
62  bool getTriangle( double x, double y, Point3D *p1, int *ptn1, Vector3D *v1, PointState *state1, Point3D *p2, int *ptn2, Vector3D *v2, PointState *state2, Point3D *p3, int *ptn3, Vector3D *v3, PointState *state3 ) SIP_SKIP;
64  PointState getState( int pointno ) const;
66  void setTriangleInterpolator( TriangleInterpolator *inter ) override;
68  virtual bool swapEdge( double x, double y ) override;
72  virtual bool saveAsShapefile( const QString &fileName ) const override;
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 };
88 inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) ), mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
89 {
90  alreadyestimated = false;
91 }
94 {
95  alreadyestimated = false;
96 }
99 {
100  mInterpolator = inter;
101 }
103 inline Vector3D *NormVecDecorator::getNormal( int n ) const
104 {
105  if ( mNormVec )
106  {
107  return mNormVec->at( n );
108  }
109  else
110  {
111  QgsDebugMsg( "warning, null pointer" );
112  return nullptr;
113  }
114 }
116 #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
virtual bool saveAsShapefile(const QString &fileName) const =0
Saves the triangulation as a (line) shapefile.
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.
virtual bool calcPoint(double x, double y, Point3D *result) override
Calculates x-, y and z-value of the point on the surface and assigns it to &#39;result&#39;.
Definition: TriDecorator.cc:72
Point3D is a class to represent a three dimensional point.
Definition: Point3D.h:25
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
Definition: Vector3D.h:29
This is an interface for interpolator classes for triangulations.
#define SIP_SKIP
Definition: qgis_sip.h:87
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;.
Definition: TriDecorator.cc:58
static const unsigned int DEFAULT_STORAGE_FOR_NORMALS
Interface for Triangulation classes.
Definition: Triangulation.h:30
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
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...
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:25
bool alreadyestimated
Is true, if the normals already have been estimated.
#define SIP_OUT
Definition: qgis_sip.h:39
virtual int addPoint(Point3D *p) override
Adds a point to the triangulation Ownership is transferred to this class.
Definition: TriDecorator.cc:32
bool getTriangle(double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3) override
Finds out in which triangle the point with coordinates x and y is and assigns the numbers of the vert...
Vector3D * getNormal(int n) const
Returns a pointer to the normal vector for the point with the number n.