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