QGIS API Documentation  3.21.0-Master (5b68dc587e)
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]h
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  const 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  const 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  const 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  const 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  const 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  const 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  const 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  const 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  const 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  const 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  const 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  const 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 }
SourceType
Describes the type of input data.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
virtual QgsPoint * point(int i) const =0
Returns a pointer to the point with number i.
virtual bool calcNormal(double x, double y, QgsPoint &result)=0
Calculates the normal at a point on the surface and assigns it to 'result'.
virtual double yMax() const =0
Returns the largest y-coordinate value of the bounding box.
virtual void eliminateHorizontalTriangles()=0
Eliminates the horizontal triangles by swapping.
virtual void performConsistencyTest()=0
Performs a consistency check, remove this later.
virtual void ruppertRefinement()=0
Adds points to make the triangles better shaped (algorithm of ruppert)
virtual int pointsCount() const =0
Returns the number of points.
virtual double xMax() const =0
Returns the largest x-coordinate value of the bounding box.
virtual double yMin() const =0
Returns the smallest x-coordinate value of the bounding box.
virtual QList< int > surroundingTriangles(int pointno)=0
Returns a value list with the information of the triangles surrounding (counterclockwise) a point.
ForcedCrossBehavior
Enumeration describing the behavior, if two forced lines cross.
virtual void addLine(const QgsPointSequence &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
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'.
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...
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
virtual bool swapEdge(double x, double y)=0
Reads the content of a taff-file.
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.
virtual void setTriangleInterpolator(TriangleInterpolator *interpolator)=0
Sets an interpolator object.
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...
virtual double xMin() const =0
Returns the smallest x-coordinate value of the bounding box.
virtual void setForcedCrossBehavior(QgsTriangulation::ForcedCrossBehavior b)=0
Draws the points, edges and the forced lines.
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.
bool swapEdge(double x, double y) override
Reads the content of a taff-file.
QgsPoint * point(int i) const override
Returns a pointer to the point with number i.
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...
void setTriangleInterpolator(TriangleInterpolator *interpolator) override
Sets an interpolator object.
void ruppertRefinement() override
Adds points to make the triangles better shaped (algorithm of ruppert)
double yMin() const override
Returns the smallest x-coordinate value of the bounding box.
void performConsistencyTest() override
Performs a consistency check, remove this later.
double xMax() const override
Returns the largest x-coordinate value of the bounding box.
void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping.
double yMax() const override
Returns the largest y-coordinate value of the bounding box.
int addPoint(const QgsPoint &p) override
Adds a point to the triangulation.
QgsTriangulation * mTIN
Association with a Triangulation object.
Definition: TriDecorator.h:65
void addLine(const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType) override
Adds a line (e.g.
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.
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'.
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.
QList< int > surroundingTriangles(int pointno) override
Returns a value list with the information of the triangles surrounding (counterclockwise) a point.
int pointsCount() const override
Returns the number of points.
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...
bool calcNormal(double x, double y, QgsPoint &result) override
Calculates the normal at a point on the surface and assigns it to 'result'.
void setForcedCrossBehavior(QgsTriangulation::ForcedCrossBehavior b) override
Draws the points, edges and the forced lines.
double xMin() const override
Returns the smallest x-coordinate value of the bounding box.
This is an interface for interpolator classes for triangulations.
#define QgsDebugMsg(str)
Definition: qgslogger.h:38