QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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, Vector3D *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->getPoint( i );
91  return p;
92  }
93  else
94  {
95  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
96  return nullptr;
97  }
98 }
99 
100 bool TriDecorator::getTriangle( 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->getTriangle( 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::getTriangle( double x, double y, QgsPoint &p1, QgsPoint &p2, QgsPoint &p3 )
115 {
116  if ( mTIN )
117  {
118  bool b = mTIN->getTriangle( 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->getNumberOfPoints() );
133  }
134  else
135  {
136  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
137  return false;
138  }
139 }
140 
141 int TriDecorator::getOppositePoint( int p1, int p2 )
142 {
143  if ( mTIN )
144  {
145  int i = mTIN->getOppositePoint( 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::getSurroundingTriangles( int pointno )
156 {
157  if ( mTIN )
158  {
159  return mTIN->getSurroundingTriangles( pointno );
160  }
161  else
162  {
163  return QList< int >();
164  }
165 }
166 
167 double TriDecorator::getXMax() const
168 {
169  if ( mTIN )
170  {
171  double d = mTIN->getXMax();
172  return d;
173  }
174  else
175  {
176  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
177  return 0;
178  }
179 }
180 
181 double TriDecorator::getXMin() const
182 {
183  if ( mTIN )
184  {
185  double d = mTIN->getXMin();
186  return d;
187  }
188  else
189  {
190  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
191  return 0;
192  }
193 }
194 double TriDecorator::getYMax() const
195 {
196  if ( mTIN )
197  {
198  double d = mTIN->getYMax();
199  return d;
200  }
201  else
202  {
203  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
204  return 0;
205  }
206 }
207 
208 double TriDecorator::getYMin() const
209 {
210  if ( mTIN )
211  {
212  double d = mTIN->getYMin();
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 
234 void TriDecorator::setEdgeColor( int r, int g, int b )
235 {
236  if ( mTIN )
237  {
238  mTIN->setEdgeColor( r, g, b );
239  }
240  else
241  {
242  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
243  }
244 }
245 
246 void TriDecorator::setForcedEdgeColor( int r, int g, int b )
247 {
248  if ( mTIN )
249  {
250  mTIN->setForcedEdgeColor( r, g, b );
251  }
252  else
253  {
254  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
255  }
256 }
257 
258 void TriDecorator::setBreakEdgeColor( int r, int g, int b )
259 {
260  if ( mTIN )
261  {
262  mTIN->setBreakEdgeColor( r, g, b );
263  }
264  else
265  {
266  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
267  }
268 }
269 
271 {
272  if ( mTIN )
273  {
274  mTIN->setTriangleInterpolator( interpolator );
275  }
276  else
277  {
278  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
279  }
280 }
281 
283 {
284  if ( mTIN )
285  {
287  }
288  else
289  {
290  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
291  }
292 }
293 
295 {
296  if ( mTIN )
297  {
299  }
300  else
301  {
302  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
303  }
304 }
305 
306 bool TriDecorator::pointInside( double x, double y )
307 {
308  if ( mTIN )
309  {
310  bool b = mTIN->pointInside( x, y );
311  return b;
312  }
313  else
314  {
315  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
316  return false;
317  }
318 }
319 
320 bool TriDecorator::swapEdge( double x, double y )
321 {
322  if ( mTIN )
323  {
324  bool b = mTIN->swapEdge( x, y );
325  return b;
326  }
327  else
328  {
329  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
330  return false;
331  }
332 }
333 
334 QList<int> *TriDecorator::getPointsAroundEdge( double x, double y )
335 {
336  if ( mTIN )
337  {
338  return mTIN->getPointsAroundEdge( x, y );
339  }
340  else
341  {
342  QgsDebugMsg( QStringLiteral( "warning, null pointer" ) );
343  return nullptr;
344  }
345 }
void setForcedEdgeColor(int r, int g, int b) override
Sets the color of the forced edges.
double getXMin() const override
Returns the smallest x-coordinate value of the bounding box.
virtual bool swapEdge(double x, double y)=0
Reads the content of a taff-file.
virtual void setBreakEdgeColor(int r, int g, int b)=0
Sets the color of the breaklines.
void setTriangleInterpolator(TriangleInterpolator *interpolator) override
Sets an interpolator object.
void setForcedCrossBehavior(Triangulation::ForcedCrossBehavior b) override
Draws the points, edges and the forced lines.
virtual double getYMax() const =0
Returns the largest y-coordinate value of the bounding box.
Triangulation * mTIN
Association with a Triangulation object.
Definition: TriDecorator.h:67
virtual void setEdgeColor(int r, int g, int b)=0
Sets the color of the normal edges.
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
virtual double getXMax() const =0
Returns the largest x-coordinate value of the bounding box.
QList< int > getSurroundingTriangles(int pointno) override
Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise...
bool swapEdge(double x, double y) override
Reads the content of a taff-file.
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)
SourceType
Describes the type of input data.
QList< int > * getPointsAroundEdge(double x, double y) override
Returns a value list with the numbers of the four points, which would be affected by an edge swap...
void ruppertRefinement() override
Adds points to make the triangles better shaped (algorithm of ruppert)
void setEdgeColor(int r, int g, int b) override
Sets the color of the normal edges.
void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping.
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...
double getYMax() const override
Returns the largest y-coordinate value of the bounding box.
double getXMax() const override
Returns the largest x-coordinate value of the bounding box.
virtual QgsPoint * getPoint(int i) const =0
Returns a pointer to the point with number i. Any virtual points must have the number -1...
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
Definition: Vector3D.h:33
This is an interface for interpolator classes for triangulations.
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...
double getYMin() const override
Returns the smallest x-coordinate value of the bounding box.
int getNumberOfPoints() const override
Returns the number of points.
virtual int getNumberOfPoints() const =0
Returns the number of points.
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;.
virtual void setForcedEdgeColor(int r, int g, int b)=0
Sets the color of the forced edges.
virtual bool getTriangle(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...
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
void setBreakEdgeColor(int r, int g, int b) override
Sets the color of the breaklines.
virtual double getXMin() const =0
Returns the smallest x-coordinate value of the bounding box.
void addLine(const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType) override
Adds a line (e.g.
virtual bool calcNormal(double x, double y, Vector3D *result)=0
Calculates the normal at a point on the surface and assigns it to &#39;result&#39;.
virtual QList< int > getSurroundingTriangles(int pointno)=0
Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise...
virtual QList< int > * getPointsAroundEdge(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 setForcedCrossBehavior(Triangulation::ForcedCrossBehavior b)=0
Draws the points, edges and the forced lines.
virtual double getYMin() const =0
Returns the smallest x-coordinate value of the bounding box.
int addPoint(const QgsPoint &p) override
Adds a point to the triangulation.
virtual void addLine(const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
virtual void eliminateHorizontalTriangles()=0
Eliminates the horizontal triangles by swapping.
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 &#39;result&#39;.
int getOppositePoint(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...
QgsPoint * getPoint(int i) const override
Returns a pointer to the point with number i. Any virtual points must have the number -1...
virtual int getOppositePoint(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...
ForcedCrossBehavior
Enumeration describing the behavior, if two forced lines cross.
Definition: Triangulation.h:42
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...
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 &#39;result&#39;.
void performConsistencyTest() override
Performs a consistency check, remove this later.
virtual void setTriangleInterpolator(TriangleInterpolator *interpolator)=0
Sets an interpolator object.