QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
TriDecorator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  TriDecorator.cpp
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 #include "TriDecorator.h"
18 #include "qgslogger.h"
19 
20 void TriDecorator::addLine( const QVector<QgsPoint> &points, QgsInterpolator::SourceType lineType )
21 {
22  if ( mTIN )
23  {
24  mTIN->addLine( points, lineType );
25  }
26  else
27  {
28  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
29  }
30 }
31 
33 {
34  if ( mTIN )
35  {
36  unsigned int number = mTIN->addPoint( p );
37  return number;
38  }
39  else
40  {
41  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
42  return 0;
43  }
44 }
45 
47 {
48  if ( mTIN )
49  {
51  }
52  else
53  {
54  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
55  }
56 }
57 
58 bool TriDecorator::calcNormal( double x, double y, QgsPoint &result )
59 {
60  if ( mTIN )
61  {
62  bool b = mTIN->calcNormal( x, y, result );
63  return b;
64  }
65  else
66  {
67  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
68  return false;
69  }
70 }
71 
72 bool TriDecorator::calcPoint( double x, double y, QgsPoint &result )
73 {
74  if ( mTIN )
75  {
76  bool b = mTIN->calcPoint( x, y, result );
77  return b;
78  }
79  else
80  {
81  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
82  return false;
83  }
84 }
85 
87 {
88  if ( mTIN )
89  {
90  QgsPoint *p = mTIN->point( i );
91  return p;
92  }
93  else
94  {
95  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
96  return nullptr;
97  }
98 }
99 
100 bool TriDecorator::triangleVertices( double x, double y, QgsPoint &p1, int &n1, QgsPoint &p2, int &n2, QgsPoint &p3, int &n3 )
101 {
102  if ( mTIN )
103  {
104  bool b = mTIN->triangleVertices( x, y, p1, n1, p2, n2, p3, n3 );
105  return b;
106  }
107  else
108  {
109  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
110  return false;
111  }
112 }
113 
114 bool TriDecorator::triangleVertices( double x, double y, QgsPoint &p1, QgsPoint &p2, QgsPoint &p3 )
115 {
116  if ( mTIN )
117  {
118  bool b = mTIN->triangleVertices( x, y, p1, p2, p3 );
119  return b;
120  }
121  else
122  {
123  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
124  return false;
125  }
126 }
127 
129 {
130  if ( mTIN )
131  {
132  return ( mTIN->pointsCount() );
133  }
134  else
135  {
136  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
137  return false;
138  }
139 }
140 
141 int TriDecorator::oppositePoint( int p1, int p2 )
142 {
143  if ( mTIN )
144  {
145  int i = mTIN->oppositePoint( p1, p2 );
146  return i;
147  }
148  else
149  {
150  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
151  return 0;
152  }
153 }
154 
155 QList<int> TriDecorator::surroundingTriangles( int pointno )
156 {
157  if ( mTIN )
158  {
159  return mTIN->surroundingTriangles( pointno );
160  }
161  else
162  {
163  return QList< int >();
164  }
165 }
166 
167 double TriDecorator::xMax() const
168 {
169  if ( mTIN )
170  {
171  double d = mTIN->xMax();
172  return d;
173  }
174  else
175  {
176  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
177  return 0;
178  }
179 }
180 
181 double TriDecorator::xMin() const
182 {
183  if ( mTIN )
184  {
185  double d = mTIN->xMin();
186  return d;
187  }
188  else
189  {
190  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
191  return 0;
192  }
193 }
194 double TriDecorator::yMax() const
195 {
196  if ( mTIN )
197  {
198  double d = mTIN->yMax();
199  return d;
200  }
201  else
202  {
203  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
204  return 0;
205  }
206 }
207 
208 double TriDecorator::yMin() const
209 {
210  if ( mTIN )
211  {
212  double d = mTIN->yMin();
213  return d;
214  }
215  else
216  {
217  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
218  return 0;
219  }
220 }
221 
223 {
224  if ( mTIN )
225  {
227  }
228  else
229  {
230  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
231  }
232 }
233 
235 {
236  if ( mTIN )
237  {
238  mTIN->setTriangleInterpolator( interpolator );
239  }
240  else
241  {
242  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
243  }
244 }
245 
247 {
248  if ( mTIN )
249  {
251  }
252  else
253  {
254  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
255  }
256 }
257 
259 {
260  if ( mTIN )
261  {
263  }
264  else
265  {
266  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
267  }
268 }
269 
270 bool TriDecorator::pointInside( double x, double y )
271 {
272  if ( mTIN )
273  {
274  bool b = mTIN->pointInside( x, y );
275  return b;
276  }
277  else
278  {
279  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
280  return false;
281  }
282 }
283 
284 bool TriDecorator::swapEdge( double x, double y )
285 {
286  if ( mTIN )
287  {
288  bool b = mTIN->swapEdge( x, y );
289  return b;
290  }
291  else
292  {
293  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
294  return false;
295  }
296 }
297 
298 QList<int> TriDecorator::pointsAroundEdge( double x, double y )
299 {
300  if ( mTIN )
301  {
302  return mTIN->pointsAroundEdge( x, y );
303  }
304  else
305  {
306  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
307  return QList<int>();
308  }
309 }
TriDecorator::yMax
double yMax() const override
Returns the largest y-coordinate value of the bounding box.
Definition: TriDecorator.cpp:194
TriDecorator::eliminateHorizontalTriangles
void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping.
Definition: TriDecorator.cpp:246
TriDecorator::xMin
double xMin() const override
Returns the smallest x-coordinate value of the bounding box.
Definition: TriDecorator.cpp:181
QgsTriangulation::oppositePoint
virtual int oppositePoint(int p1, int p2)=0
Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedg...
QgsTriangulation::ruppertRefinement
virtual void ruppertRefinement()=0
Adds points to make the triangles better shaped (algorithm of ruppert)
QgsTriangulation::point
virtual QgsPoint * point(int i) const =0
Returns a pointer to the point with number i.
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
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
TriDecorator::yMin
double yMin() const override
Returns the smallest x-coordinate value of the bounding box.
Definition: TriDecorator.cpp:208
TriDecorator::pointsCount
int pointsCount() const override
Returns the number of points.
Definition: TriDecorator.cpp:128
QgsTriangulation::ForcedCrossBehavior
ForcedCrossBehavior
Enumeration describing the behavior, if two forced lines cross.
Definition: qgstriangulation.h:46
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsTriangulation::performConsistencyTest
virtual void performConsistencyTest()=0
Performs a consistency check, remove this later.
TriDecorator::pointsAroundEdge
QList< int > pointsAroundEdge(double x, double y) override
Returns a value list with the numbers of the four points, which would be affected by an edge swap.
Definition: TriDecorator.cpp:298
QgsTriangulation::setTriangleInterpolator
virtual void setTriangleInterpolator(TriangleInterpolator *interpolator)=0
Sets an interpolator object.
QgsTriangulation::swapEdge
virtual bool swapEdge(double x, double y)=0
Reads the content of a taff-file.
QgsTriangulation::calcPoint
virtual bool calcPoint(double x, double y, QgsPoint &result)=0
Calculates x-, y and z-value of the point on the surface and assigns it to 'result'.
TriDecorator::pointInside
bool pointInside(double x, double y) override
Returns true, if the point with coordinates x and y is inside the convex hull and false otherwise.
Definition: TriDecorator.cpp:270
QgsTriangulation::addPoint
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
QgsTriangulation::xMin
virtual double xMin() const =0
Returns the smallest x-coordinate value of the bounding box.
QgsTriangulation::eliminateHorizontalTriangles
virtual void eliminateHorizontalTriangles()=0
Eliminates the horizontal triangles by swapping.
QgsTriangulation::pointsAroundEdge
virtual QList< int > pointsAroundEdge(double x, double y)=0
Returns a value list with the numbers of the four points, which would be affected by an edge swap.
TriDecorator::setTriangleInterpolator
void setTriangleInterpolator(TriangleInterpolator *interpolator) override
Sets an interpolator object.
Definition: TriDecorator.cpp:234
TriDecorator::addLine
void addLine(const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType) override
Adds a line (e.g.
Definition: TriDecorator.cpp:20
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::triangleVertices
bool triangleVertices(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...
Definition: TriDecorator.cpp:100
QgsInterpolator::SourceType
SourceType
Describes the type of input data.
Definition: qgsinterpolator.h:72
QgsTriangulation::triangleVertices
virtual bool triangleVertices(double x, double y, QgsPoint &p1, int &n1, QgsPoint &p2, int &n2, QgsPoint &p3, int &n3)=0
Finds out in which triangle the point with coordinates x and y is and assigns the numbers of the vert...
QgsTriangulation::yMax
virtual double yMax() const =0
Returns the largest y-coordinate value of the bounding box.
QgsTriangulation::surroundingTriangles
virtual QList< int > surroundingTriangles(int pointno)=0
Returns a value list with the information of the triangles surrounding (counterclockwise) a point.
TriDecorator::swapEdge
bool swapEdge(double x, double y) override
Reads the content of a taff-file.
Definition: TriDecorator.cpp:284
QgsTriangulation::yMin
virtual double yMin() const =0
Returns the smallest x-coordinate value of the bounding box.
TriDecorator::ruppertRefinement
void ruppertRefinement() override
Adds points to make the triangles better shaped (algorithm of ruppert)
Definition: TriDecorator.cpp:258
TriDecorator::point
QgsPoint * point(int i) const override
Returns a pointer to the point with number i.
Definition: TriDecorator.cpp:86
TriDecorator::oppositePoint
int oppositePoint(int p1, int p2) override
Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedg...
Definition: TriDecorator.cpp:141
TriDecorator::surroundingTriangles
QList< int > surroundingTriangles(int pointno) override
Returns a value list with the information of the triangles surrounding (counterclockwise) a point.
Definition: TriDecorator.cpp:155
QgsTriangulation::addLine
virtual void addLine(const QgsPointSequence &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
TriDecorator::mTIN
QgsTriangulation * mTIN
Association with a Triangulation object.
Definition: TriDecorator.h:65
QgsTriangulation::xMax
virtual double xMax() const =0
Returns the largest x-coordinate value of the bounding box.
TriDecorator::setForcedCrossBehavior
void setForcedCrossBehavior(QgsTriangulation::ForcedCrossBehavior b) override
Draws the points, edges and the forced lines.
Definition: TriDecorator.cpp:222
qgslogger.h
QgsTriangulation::calcNormal
virtual bool calcNormal(double x, double y, QgsPoint &result)=0
Calculates the normal at a point on the surface and assigns it to 'result'.
TriDecorator.h
TriDecorator::performConsistencyTest
void performConsistencyTest() override
Performs a consistency check, remove this later.
Definition: TriDecorator.cpp:46
QgsTriangulation::setForcedCrossBehavior
virtual void setForcedCrossBehavior(QgsTriangulation::ForcedCrossBehavior b)=0
Draws the points, edges and the forced lines.
QgsTriangulation::pointInside
virtual bool pointInside(double x, double y)=0
Returns true, if the point with coordinates x and y is inside the convex hull and false otherwise.
TriangleInterpolator
This is an interface for interpolator classes for triangulations.
Definition: TriangleInterpolator.h:35
QgsTriangulation::pointsCount
virtual int pointsCount() const =0
Returns the number of points.
TriDecorator::xMax
double xMax() const override
Returns the largest x-coordinate value of the bounding box.
Definition: TriDecorator.cpp:167