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" ) );
TriangleInterpolator * mInterpolator
Association with an interpolator object.
void setX(double x)
Sets the x-component of the vector.
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...
virtual bool swapEdge(double x, double y)=0
Reads the content of a taff-file.
Triangulation * mTIN
Association with a Triangulation 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'.
QList< int > getSurroundingTriangles(int pointno) override
Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise...
void standardise()
Standardises the vector.
void setProgress(double progress)
Sets the current progress for the feedback object.
void setState(int pointno, PointState s)
Sets the state (BreakLine, Normal, EndPoint) of a point.
An interface for objects which accept features via addFeature(s) methods.
PointState getState(int pointno) const
Returns the state of the point with the number 'pointno'.
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...
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.
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...
double getZ() const
Returns the z-component of the vector.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
int addPoint(const QgsPoint &p) override
Adds a point to the triangulation.
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
virtual bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const =0
Saves the triangulation features to a feature sink.
void setZ(double z)
Sets the z-component of the vector.
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...
QVector< Vector3D * > * mNormVec
Vector that stores the normals for the points. If 'estimateFirstDerivatives()' was called and there i...
int getNumberOfPoints() const override
Returns the number of points.
Point geometry type, with support for z-dimension and m-values.
bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const override
Saves the triangulation features to a feature sink.
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...
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 int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
PointState
Enumeration for the state of a point. Normal means, that the point is not on a BreakLine, BreakLine means that the point is on a breakline (but not an end point of it) and EndPoint means, that it is an endpoint of a breakline.
bool alreadyestimated
Is true, if the normals already have been estimated.
double getY() const
Returns the y-component of the vector.
void setY(double y)
Sets the y-component of the vector.
virtual QList< int > getSurroundingTriangles(int pointno)=0
Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise...
virtual bool calcNormVec(double x, double y, Vector3D *result)=0
Calculates the normal vector and assigns it to vec.
void eliminateHorizontalTriangles() override
Eliminates the horizontal triangles by swapping or by insertion of new points. If alreadyestimated is...
~NormVecDecorator() override
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...
double getX() const
Returns the x-component of the vector.
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 void eliminateHorizontalTriangles()=0
Eliminates the horizontal triangles by swapping.
QgsPoint * getPoint(int i) const override
Returns a pointer to the point with number i. Any virtual points must have the number -1...
bool estimateFirstDerivatives(QgsFeedback *feedback=nullptr)
This method adds the functionality of estimating normals at the data points. Return true in the case ...
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...
double distance3D(double x, double y, double z) const
Returns the 3D distance between this point and a specified x, y, z coordinate.