QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
17 #include <QApplication>
32 for (
int i = 0; i <
mNormVec->count(); i++ )
34 delete ( *mNormVec )[i];
50 if ( pointno == -100 )
62 auto it = list.constBegin();
63 while ( it != list.constEnd() )
98 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
113 int numberofbreaks = 0;
114 int ffirstbp = -1000;
115 int lfirstbp = -1000;
116 bool pointfound =
false;
117 int numberofruns = 0;
130 if ( ( ( vlist.count() ) % 4 ) != 0 )
132 QgsDebugMsg( QStringLiteral(
"warning, wrong number of items in vlist" ) );
136 auto it = vlist.constBegin();
143 if ( numberofruns > limit )
145 QgsDebugMsg( QStringLiteral(
"warning, a probable endless loop is detected" ) );
149 int p1, p2, p3, line;
160 if ( numberofbreaks > 0 )
163 if ( p1 != -1 && p2 != -1 && p3 != -1 )
181 if ( numberofbreaks == 0 )
188 if ( p2 == ffirstbp && p3 == lfirstbp && !firstrun )
192 QgsDebugMsg( QStringLiteral(
"warning: point (x,y) was in no triangle" ) );
199 if ( numberofbreaks > 0 && pointfound )
213 if ( it == vlist.constEnd() )
215 it = vlist.constBegin();
222 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
244 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
251 if ( v1 && v2 && v3 )
275 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
288 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
301 QgsDebugMsg( QStringLiteral(
"warning, number below 0" ) );
307 bool NormVecDecorator::getTriangle(
double x,
double y,
QgsPoint &p1,
int &ptn1,
Vector3D *v1,
PointState *state1,
QgsPoint &p2,
int &ptn2,
Vector3D *v2,
PointState *state2,
QgsPoint &p3,
int &ptn3,
Vector3D *v3,
PointState *state3 )
309 if ( v1 && v2 && v3 && state1 && state2 && state3 )
317 ( *state1 ) = ( *mPointState )[( ptn1 )];
323 ( *state2 ) = ( *mPointState )[( ptn2 )];
329 ( *state3 ) = ( *mPointState )[( ptn3 )];
341 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
358 int numberofbreaks = 0;
360 double currentweight = 0;
383 ( *mNormVec )[pointno]->setX( 0 );
384 ( *mNormVec )[pointno]->setY( 0 );
385 ( *mNormVec )[pointno]->setZ( 0 );
390 if ( ( vlist.count() % 4 ) != 0 )
392 QgsDebugMsg( QStringLiteral(
"warning, wrong number of items in vlist" ) );
396 auto it = vlist.constBegin();
397 while ( it != vlist.constEnd() )
399 int p1, p2, p3, flag;
419 if ( p1 != -1 && p2 != -1 && p3 != -1 )
427 currentweight = 1 / ( dist1 * dist1 * dist2 * dist2 );
431 weights += currentweight;
437 if ( total.
getX() == 0 && total.
getY() == 0 && total.
getZ() == 0 )
443 total.
setX( total.
getX() / weights );
444 total.
setY( total.
getY() / weights );
445 total.
setZ( total.
getZ() / weights );
450 if ( numberofbreaks == 0 )
454 else if ( numberofbreaks == 1 )
476 ( *mNormVec )[pointno]->setX( total.
getX() );
477 ( *mNormVec )[pointno]->setY( total.
getY() );
478 ( *mNormVec )[pointno]->setZ( total.
getZ() );
488 ( *mPointState )[pointno] = status;
497 for (
int i = 0; i < numberPoints; i++ )
501 feedback->
setProgress( 100.0 *
static_cast< double >( i ) / numberPoints );
525 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
533 ( *mPointState )[pointno] = s;
537 QgsDebugMsg( QStringLiteral(
"warning, pointno>0" ) );
552 QList<int>::iterator it;
553 for ( it = list->begin(); it != list->end(); ++it )
568 QgsDebugMsg( QStringLiteral(
"warning, null pointer" ) );
virtual bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const =0
Saves the triangulation features to a feature sink.
void setProgress(double progress)
Sets the current progress for the feedback object.
bool alreadyestimated
Is true, if the normals already have been estimated.
void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping or by insertion of new points. If alreadyestimated is...
void setX(double x)
Sets the x-component of the vector.
bool ANALYSIS_EXPORT pointInsideTriangle(double x, double y, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3)
Returns true, if the point with coordinates x and y is inside (or at the edge) of the triangle p1,...
Point geometry type, with support for z-dimension and m-values.
bool calcNormalForPoint(double x, double y, int point, Vector3D *result)
Calculates the normal of a triangle-point for the point with coordinates x and y. This is needed,...
QgsPoint * getPoint(int i) const override
Returns a pointer to the point with number i. Any virtual points must have the number -1.
void standardise()
Standardises the vector.
Triangulation * mTIN
Association with a Triangulation object.
QVector< PointState > * mPointState
Vector who stores, it a point is not on a breakline, if it is a normal point of the breakline or if i...
QList< int > getSurroundingTriangles(int pointno) override
Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise...
bool calcNormal(double x, double y, Vector3D *result) override
Calculates the normal at a point on the surface and assigns it to 'result'. Returns true in case of s...
void setState(int pointno, PointState s)
Sets the state (BreakLine, Normal, EndPoint) of a point.
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.
double getZ() const
Returns the z-component of the vector.
PointState getState(int pointno) const
Returns the state of the point with the number 'pointno'.
double getY() const
Returns the y-component of the vector.
~NormVecDecorator() override
bool estimateFirstDerivatives(QgsFeedback *feedback=nullptr)
This method adds the functionality of estimating normals at the data points. Return true in the case ...
double distance3D(double x, double y, double z) const
Returns the Cartesian 3D distance between this point and a specified x, y, z coordinate.
virtual QList< int > getSurroundingTriangles(int pointno)=0
Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise...
int getNumberOfPoints() const override
Returns the number of points.
void ANALYSIS_EXPORT normalFromPoints(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, Vector3D *vec)
Calculates the normal vector of the plane through the points p1, p2 and p3 and assigns the result to ...
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
void setY(double y)
Sets the y-component of the vector.
bool swapEdge(double x, double y) override
Swaps the edge which is closest to the point with x and y coordinates (if this is possible) and force...
void setZ(double z)
Sets the z-component of the vector.
int addPoint(const QgsPoint &p) override
Adds a point to the triangulation.
virtual bool calcNormVec(double x, double y, Vector3D *result)=0
Calculates the normal vector and assigns it to vec.
virtual bool calcPoint(double x, double y, QgsPoint &result)=0
Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point.
virtual bool swapEdge(double x, double y)=0
Reads the content of a taff-file.
QVector< Vector3D * > * mNormVec
Vector that stores the normals for the points. If 'estimateFirstDerivatives()' was called and there i...
TriangleInterpolator * mInterpolator
Association with an interpolator object.
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'.
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...
virtual void eliminateHorizontalTriangles()=0
Eliminates the horizontal triangles by swapping.
PointState
Enumeration for the state of a point. Normal means, that the point is not on a BreakLine,...
bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const override
Saves the triangulation features to a feature sink.
double getX() const
Returns the x-component of the vector.
bool getTriangle(double x, double y, QgsPoint &p1, Vector3D *v1, QgsPoint &p2, Vector3D *v2, QgsPoint &p3, Vector3D *v3)
Finds out, in which triangle a point with coordinates x and y is and assigns the triangle points to p...
bool estimateFirstDerivative(int pointno)
Estimates the first derivative a point. Return true in case of success and false otherwise.