QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
TriDecorator.cpp
Go to the documentation of this file.
1/***************************************************************************
2 TriDecorator.cpp
3 ----------------
4 copyright : (C) 2004 by Marco Hugentobler
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
19#include "qgslogger.h"
20
21void TriDecorator::addLine( const QVector<QgsPoint> &points, QgsInterpolator::SourceType lineType )
22{
23 if ( mTIN )
24 {
25 mTIN->addLine( points, lineType );
26 }
27 else
28 {
29 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
30 }
31}
32
34{
35 if ( mTIN )
36 {
37 const unsigned int number = mTIN->addPoint( p );
38 return number;
39 }
40 else
41 {
42 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
43 return 0;
44 }
45}
46
48{
49 if ( mTIN )
50 {
51 mTIN->performConsistencyTest();
52 }
53 else
54 {
55 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
56 }
57}
58
59bool TriDecorator::calcNormal( double x, double y, QgsPoint &result )
60{
61 if ( mTIN )
62 {
63 const bool b = mTIN->calcNormal( x, y, result );
64 return b;
65 }
66 else
67 {
68 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
69 return false;
70 }
71}
72
73bool TriDecorator::calcPoint( double x, double y, QgsPoint &result )
74{
75 if ( mTIN )
76 {
77 const bool b = mTIN->calcPoint( x, y, result );
78 return b;
79 }
80 else
81 {
82 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
83 return false;
84 }
85}
86
88{
89 if ( mTIN )
90 {
91 QgsPoint *p = mTIN->point( i );
92 return p;
93 }
94 else
95 {
96 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
97 return nullptr;
98 }
99}
100
101bool TriDecorator::triangleVertices( double x, double y, QgsPoint &p1, int &n1, QgsPoint &p2, int &n2, QgsPoint &p3, int &n3 )
102{
103 if ( mTIN )
104 {
105 const bool b = mTIN->triangleVertices( x, y, p1, n1, p2, n2, p3, n3 );
106 return b;
107 }
108 else
109 {
110 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
111 return false;
112 }
113}
114
115bool TriDecorator::triangleVertices( double x, double y, QgsPoint &p1, QgsPoint &p2, QgsPoint &p3 )
116{
117 if ( mTIN )
118 {
119 const bool b = mTIN->triangleVertices( x, y, p1, p2, p3 );
120 return b;
121 }
122 else
123 {
124 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
125 return false;
126 }
127}
128
130{
131 if ( mTIN )
132 {
133 return ( mTIN->pointsCount() );
134 }
135 else
136 {
137 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
138 return false;
139 }
140}
141
142int TriDecorator::oppositePoint( int p1, int p2 )
143{
144 if ( mTIN )
145 {
146 const int i = mTIN->oppositePoint( p1, p2 );
147 return i;
148 }
149 else
150 {
151 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
152 return 0;
153 }
154}
155
156QList<int> TriDecorator::surroundingTriangles( int pointno )
157{
158 if ( mTIN )
159 {
160 return mTIN->surroundingTriangles( pointno );
161 }
162 else
163 {
164 return QList<int>();
165 }
166}
167
168double TriDecorator::xMax() const
169{
170 if ( mTIN )
171 {
172 const double d = mTIN->xMax();
173 return d;
174 }
175 else
176 {
177 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
178 return 0;
179 }
180}
181
182double TriDecorator::xMin() const
183{
184 if ( mTIN )
185 {
186 const double d = mTIN->xMin();
187 return d;
188 }
189 else
190 {
191 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
192 return 0;
193 }
194}
195double TriDecorator::yMax() const
196{
197 if ( mTIN )
198 {
199 const double d = mTIN->yMax();
200 return d;
201 }
202 else
203 {
204 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
205 return 0;
206 }
207}
208
209double TriDecorator::yMin() const
210{
211 if ( mTIN )
212 {
213 const double d = mTIN->yMin();
214 return d;
215 }
216 else
217 {
218 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
219 return 0;
220 }
221}
222
224{
225 if ( mTIN )
226 {
227 mTIN->setForcedCrossBehavior( b );
228 }
229 else
230 {
231 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
232 }
233}
234
236{
237 if ( mTIN )
238 {
239 mTIN->setTriangleInterpolator( interpolator );
240 }
241 else
242 {
243 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
244 }
245}
246
248{
249 if ( mTIN )
250 {
251 mTIN->eliminateHorizontalTriangles();
252 }
253 else
254 {
255 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
256 }
257}
258
260{
261 if ( mTIN )
262 {
263 mTIN->ruppertRefinement();
264 }
265 else
266 {
267 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
268 }
269}
270
271bool TriDecorator::pointInside( double x, double y )
272{
273 if ( mTIN )
274 {
275 const bool b = mTIN->pointInside( x, y );
276 return b;
277 }
278 else
279 {
280 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
281 return false;
282 }
283}
284
285bool TriDecorator::swapEdge( double x, double y )
286{
287 if ( mTIN )
288 {
289 const bool b = mTIN->swapEdge( x, y );
290 return b;
291 }
292 else
293 {
294 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
295 return false;
296 }
297}
298
299QList<int> TriDecorator::pointsAroundEdge( double x, double y )
300{
301 if ( mTIN )
302 {
303 return mTIN->pointsAroundEdge( x, y );
304 }
305 else
306 {
307 QgsDebugError( QStringLiteral( "warning, null pointer" ) );
308 return QList<int>();
309 }
310}
SourceType
Describes the type of input data.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
ForcedCrossBehavior
Enumeration describing the behavior, if two forced lines cross.
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.
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.
An interface for interpolator classes for triangulations.
#define QgsDebugError(str)
Definition qgslogger.h:57