mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
run astyle on src/*
This commit is contained in:
parent
dccf8c9e13
commit
2e7de50b42
@ -19,7 +19,7 @@
|
||||
#include "Vector3D.h"
|
||||
#include "MathUtils.h"
|
||||
|
||||
void Bezier3D::calcFirstDer( float t, Vector3D* v )
|
||||
void Bezier3D::calcFirstDer( float t, Vector3D *v )
|
||||
{
|
||||
if ( v && mControlPoly )
|
||||
{
|
||||
@ -35,13 +35,13 @@ void Bezier3D::calcFirstDer( float t, Vector3D* v )
|
||||
for ( int n = 1; n <= int( mControlPoly->count() - 1 ); n++ )
|
||||
{
|
||||
double bernst = MathUtils::calcBernsteinPoly( mControlPoly->count() - 2, n - 1, t );
|
||||
v->setX( v->getX() + (( *mControlPoly )[n]->getX() - ( *mControlPoly )[n-1]->getX() )*bernst );
|
||||
v->setY( v->getY() + (( *mControlPoly )[n]->getY() - ( *mControlPoly )[n-1]->getY() )*bernst );
|
||||
v->setZ( v->getZ() + (( *mControlPoly )[n]->getZ() - ( *mControlPoly )[n-1]->getZ() )*bernst );
|
||||
v->setX( v->getX() + ( ( *mControlPoly )[n]->getX() - ( *mControlPoly )[n - 1]->getX() )*bernst );
|
||||
v->setY( v->getY() + ( ( *mControlPoly )[n]->getY() - ( *mControlPoly )[n - 1]->getY() )*bernst );
|
||||
v->setZ( v->getZ() + ( ( *mControlPoly )[n]->getZ() - ( *mControlPoly )[n - 1]->getZ() )*bernst );
|
||||
}
|
||||
v->setX( v->getX()*( mControlPoly->count() - 1 ) );
|
||||
v->setY( v->getY()*( mControlPoly->count() - 1 ) );
|
||||
v->setZ( v->getZ()*( mControlPoly->count() - 1 ) );
|
||||
v->setX( v->getX() * ( mControlPoly->count() - 1 ) );
|
||||
v->setY( v->getY() * ( mControlPoly->count() - 1 ) );
|
||||
v->setZ( v->getZ() * ( mControlPoly->count() - 1 ) );
|
||||
}
|
||||
|
||||
else
|
||||
@ -50,7 +50,7 @@ void Bezier3D::calcFirstDer( float t, Vector3D* v )
|
||||
}
|
||||
}
|
||||
|
||||
void Bezier3D::calcPoint( float t, Point3D* p )
|
||||
void Bezier3D::calcPoint( float t, Point3D *p )
|
||||
{
|
||||
|
||||
if ( p && mControlPoly )
|
||||
@ -62,9 +62,9 @@ void Bezier3D::calcPoint( float t, Point3D* p )
|
||||
for ( int n = 1; n <= int( mControlPoly->count() ); n++ )
|
||||
{
|
||||
double bernst = MathUtils::calcBernsteinPoly( mControlPoly->count() - 1, n - 1, t );
|
||||
p->setX( p->getX() + ( *mControlPoly )[n-1]->getX()*bernst );
|
||||
p->setY( p->getY() + ( *mControlPoly )[n-1]->getY()*bernst );
|
||||
p->setZ( p->getZ() + ( *mControlPoly )[n-1]->getZ()*bernst );
|
||||
p->setX( p->getX() + ( *mControlPoly )[n - 1]->getX()*bernst );
|
||||
p->setY( p->getY() + ( *mControlPoly )[n - 1]->getY()*bernst );
|
||||
p->setZ( p->getZ() + ( *mControlPoly )[n - 1]->getZ()*bernst );
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ void Bezier3D::calcPoint( float t, Point3D* p )
|
||||
}
|
||||
}
|
||||
|
||||
void Bezier3D::calcSecDer( float t, Vector3D* v )
|
||||
void Bezier3D::calcSecDer( float t, Vector3D *v )
|
||||
{
|
||||
if ( v && mControlPoly )
|
||||
{
|
||||
@ -91,9 +91,9 @@ void Bezier3D::calcSecDer( float t, Vector3D* v )
|
||||
for ( int n = 1; n <= int( nodes - 2 ); n++ )
|
||||
{
|
||||
double bernst = MathUtils::calcBernsteinPoly( nodes - 3, n - 1, t );
|
||||
v->setX( v->getX() + (( *mControlPoly )[n+1]->getX() - 2*( *mControlPoly )[n]->getX() + ( *mControlPoly )[n-1]->getX() )*bernst );
|
||||
v->setY( v->getY() + (( *mControlPoly )[n+1]->getY() - 2*( *mControlPoly )[n]->getY() + ( *mControlPoly )[n-1]->getY() )*bernst );
|
||||
v->setZ( v->getZ() + (( *mControlPoly )[n+1]->getZ() - 2*( *mControlPoly )[n]->getZ() + ( *mControlPoly )[n-1]->getZ() )*bernst );
|
||||
v->setX( v->getX() + ( ( *mControlPoly )[n + 1]->getX() - 2 * ( *mControlPoly )[n]->getX() + ( *mControlPoly )[n - 1]->getX() )*bernst );
|
||||
v->setY( v->getY() + ( ( *mControlPoly )[n + 1]->getY() - 2 * ( *mControlPoly )[n]->getY() + ( *mControlPoly )[n - 1]->getY() )*bernst );
|
||||
v->setZ( v->getZ() + ( ( *mControlPoly )[n + 1]->getZ() - 2 * ( *mControlPoly )[n]->getZ() + ( *mControlPoly )[n - 1]->getZ() )*bernst );
|
||||
}
|
||||
v->setX( v->getX()*MathUtils::faculty( nodes - 1 ) / MathUtils::faculty( nodes - 3 ) );
|
||||
v->setY( v->getY()*MathUtils::faculty( nodes - 1 ) / MathUtils::faculty( nodes - 3 ) );
|
||||
@ -111,7 +111,7 @@ void Bezier3D::changeDirection()//does this work correctly? more testing is need
|
||||
{
|
||||
if ( mControlPoly )
|
||||
{
|
||||
Point3D** pointer = new Point3D*[mControlPoly->count()];//create an array to temporarily store pointer to the control points
|
||||
Point3D **pointer = new Point3D*[mControlPoly->count()];//create an array to temporarily store pointer to the control points
|
||||
for ( int i = 0; i < mControlPoly->count(); i++ )//store the points
|
||||
{
|
||||
pointer[i] = ( *mControlPoly )[i];
|
||||
@ -119,7 +119,7 @@ void Bezier3D::changeDirection()//does this work correctly? more testing is need
|
||||
|
||||
for ( int i = 0; i < mControlPoly->count(); i++ )
|
||||
{
|
||||
mControlPoly->insert( i, pointer[( mControlPoly->count()-1 )-i] );
|
||||
mControlPoly->insert( i, pointer[( mControlPoly->count() - 1 ) - i] );
|
||||
}
|
||||
delete [] pointer;
|
||||
}
|
||||
|
@ -31,18 +31,18 @@ class ANALYSIS_EXPORT Bezier3D: public ParametricLine
|
||||
//! Default constructor
|
||||
Bezier3D();
|
||||
//! Constructor, par is a pointer to the parent, controlpoly a controlpolygon
|
||||
Bezier3D( ParametricLine* par, QVector<Point3D*>* controlpoly );
|
||||
Bezier3D( ParametricLine *par, QVector<Point3D *> *controlpoly );
|
||||
|
||||
virtual ~Bezier3D();
|
||||
//! Do not use this method, since a Bezier curve does not consist of other curves
|
||||
virtual void add( ParametricLine *pl ) override;
|
||||
//! Calculates the first derivative and assigns it to v
|
||||
virtual void calcFirstDer( float t, Vector3D* v ) override;
|
||||
virtual void calcFirstDer( float t, Vector3D *v ) override;
|
||||
//! Calculates the second derivative and assigns it to v
|
||||
virtual void calcSecDer( float t, Vector3D* v ) override;
|
||||
virtual void calcSecDer( float t, Vector3D *v ) override;
|
||||
//virtual Point3D calcPoint(float t);
|
||||
//! Calculates the point on the curve and assigns it to p
|
||||
virtual void calcPoint( float t, Point3D* p ) override;
|
||||
virtual void calcPoint( float t, Point3D *p ) override;
|
||||
//! Changes the order of control points
|
||||
virtual void changeDirection() override;
|
||||
//virtual void draw(QPainter* p);
|
||||
@ -50,17 +50,17 @@ class ANALYSIS_EXPORT Bezier3D: public ParametricLine
|
||||
//! Do not use this method, since a Bezier curve does not consist of other curves
|
||||
virtual void remove( int i ) override;
|
||||
//! Returns a control point
|
||||
virtual const Point3D* getControlPoint( int number ) const override;
|
||||
virtual const Point3D *getControlPoint( int number ) const override;
|
||||
//! Returns a pointer to the control polygon
|
||||
virtual const QVector<Point3D*>* getControlPoly() const override;
|
||||
virtual const QVector<Point3D *> *getControlPoly() const override;
|
||||
//! Returns the degree of the curve
|
||||
virtual int getDegree() const override;
|
||||
//! Returns the parent
|
||||
virtual ParametricLine* getParent() const override;
|
||||
virtual ParametricLine *getParent() const override;
|
||||
//! Sets the parent
|
||||
virtual void setParent( ParametricLine* par ) override;
|
||||
virtual void setParent( ParametricLine *par ) override;
|
||||
//! Sets the control polygon
|
||||
virtual void setControlPoly( QVector<Point3D*>* cp ) override;
|
||||
virtual void setControlPoly( QVector<Point3D *> *cp ) override;
|
||||
|
||||
};
|
||||
|
||||
@ -71,7 +71,7 @@ inline Bezier3D::Bezier3D() : ParametricLine()//default constructor
|
||||
|
||||
}
|
||||
|
||||
inline Bezier3D::Bezier3D( ParametricLine* parent, QVector<Point3D*>* controlpoly ) : ParametricLine( parent, controlpoly )
|
||||
inline Bezier3D::Bezier3D( ParametricLine *parent, QVector<Point3D *> *controlpoly ) : ParametricLine( parent, controlpoly )
|
||||
{
|
||||
mDegree = mControlPoly->count() - 1;
|
||||
}
|
||||
@ -97,12 +97,12 @@ inline void Bezier3D::remove( int i )
|
||||
|
||||
//-----------------------------------------------setters and getters---------------------------------------------------------------
|
||||
|
||||
inline const Point3D* Bezier3D::getControlPoint( int number ) const
|
||||
inline const Point3D *Bezier3D::getControlPoint( int number ) const
|
||||
{
|
||||
return ( *mControlPoly )[number-1];
|
||||
return ( *mControlPoly )[number - 1];
|
||||
}
|
||||
|
||||
inline const QVector<Point3D*>* Bezier3D::getControlPoly() const
|
||||
inline const QVector<Point3D *> *Bezier3D::getControlPoly() const
|
||||
{
|
||||
return mControlPoly;
|
||||
}
|
||||
@ -112,17 +112,17 @@ inline int Bezier3D::getDegree() const
|
||||
return mDegree;
|
||||
}
|
||||
|
||||
inline ParametricLine* Bezier3D::getParent() const
|
||||
inline ParametricLine *Bezier3D::getParent() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
inline void Bezier3D::setParent( ParametricLine* par )
|
||||
inline void Bezier3D::setParent( ParametricLine *par )
|
||||
{
|
||||
mParent = par;
|
||||
}
|
||||
|
||||
inline void Bezier3D::setControlPoly( QVector<Point3D*>* cp )
|
||||
inline void Bezier3D::setControlPoly( QVector<Point3D *> *cp )
|
||||
{
|
||||
mControlPoly = cp;
|
||||
mDegree = mControlPoly->count() - 1;
|
||||
|
@ -21,27 +21,27 @@
|
||||
#include <qmath.h>
|
||||
|
||||
CloughTocherInterpolator::CloughTocherInterpolator()
|
||||
: mTIN( nullptr )
|
||||
, mEdgeTolerance( 0.00001 )
|
||||
, der1X( 0.0 )
|
||||
, der1Y( 0.0 )
|
||||
, der2X( 0.0 )
|
||||
, der2Y( 0.0 )
|
||||
, der3X( 0.0 )
|
||||
, der3Y( 0.0 )
|
||||
: mTIN( nullptr )
|
||||
, mEdgeTolerance( 0.00001 )
|
||||
, der1X( 0.0 )
|
||||
, der1Y( 0.0 )
|
||||
, der2X( 0.0 )
|
||||
, der2Y( 0.0 )
|
||||
, der3X( 0.0 )
|
||||
, der3Y( 0.0 )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CloughTocherInterpolator::CloughTocherInterpolator( NormVecDecorator* tin )
|
||||
: mTIN( tin )
|
||||
, mEdgeTolerance( 0.00001 )
|
||||
, der1X( 0.0 )
|
||||
, der1Y( 0.0 )
|
||||
, der2X( 0.0 )
|
||||
, der2Y( 0.0 )
|
||||
, der3X( 0.0 )
|
||||
, der3Y( 0.0 )
|
||||
CloughTocherInterpolator::CloughTocherInterpolator( NormVecDecorator *tin )
|
||||
: mTIN( tin )
|
||||
, mEdgeTolerance( 0.00001 )
|
||||
, der1X( 0.0 )
|
||||
, der1Y( 0.0 )
|
||||
, der2X( 0.0 )
|
||||
, der2Y( 0.0 )
|
||||
, der3X( 0.0 )
|
||||
, der3Y( 0.0 )
|
||||
{
|
||||
|
||||
}
|
||||
@ -51,7 +51,7 @@ CloughTocherInterpolator::~CloughTocherInterpolator()
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
void CloughTocherInterpolator::setTriangulation( NormVecDecorator* tin )
|
||||
void CloughTocherInterpolator::setTriangulation( NormVecDecorator *tin )
|
||||
{
|
||||
mTIN = tin;
|
||||
}
|
||||
@ -68,7 +68,7 @@ double CloughTocherInterpolator::calcBernsteinPoly( int n, int i, int j, int k,
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CloughTocherInterpolator::calcNormVec( double x, double y, Vector3D* result )
|
||||
bool CloughTocherInterpolator::calcNormVec( double x, double y, Vector3D *result )
|
||||
{
|
||||
if ( result )
|
||||
{
|
||||
@ -87,9 +87,9 @@ bool CloughTocherInterpolator::calcNormVec( double x, double y, Vector3D* result
|
||||
double zv = cp1.getZ() * calcBernsteinPoly( 2, 2, 0, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp2.getZ() * calcBernsteinPoly( 2, 1, 1, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + point2.getZ() * calcBernsteinPoly( 2, 0, 2, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp4.getZ() * calcBernsteinPoly( 2, 1, 0, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp5.getZ() * calcBernsteinPoly( 2, 0, 1, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp8.getZ() * calcBernsteinPoly( 2, 0, 0, 2, barycoord.getX(), barycoord.getY(), barycoord.getZ() );
|
||||
double zw = cp3.getZ() * calcBernsteinPoly( 2, 2, 0, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp4.getZ() * calcBernsteinPoly( 2, 1, 1, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp5.getZ() * calcBernsteinPoly( 2, 0, 2, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp7.getZ() * calcBernsteinPoly( 2, 1, 0, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp8.getZ() * calcBernsteinPoly( 2, 0, 1, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp10.getZ() * calcBernsteinPoly( 2, 0, 0, 2, barycoord.getX(), barycoord.getY(), barycoord.getZ() );
|
||||
MathUtils::BarycentricToXY( barycoord.getX() + 1, barycoord.getY() - 1, barycoord.getZ(), &point1, &point2, &cp10, &endpointUXY );
|
||||
endpointUXY.setZ( 3*( zu - zv ) );
|
||||
endpointUXY.setZ( 3 * ( zu - zv ) );
|
||||
MathUtils::BarycentricToXY( barycoord.getX(), barycoord.getY() + 1, barycoord.getZ() - 1, &point1, &point2, &cp10, &endpointVXY );
|
||||
endpointVXY.setZ( 3*( zv - zw ) );
|
||||
endpointVXY.setZ( 3 * ( zv - zw ) );
|
||||
Vector3D v1( endpointUXY.getX() - x, endpointUXY.getY() - y, endpointUXY.getZ() );
|
||||
Vector3D v2( endpointVXY.getX() - x, endpointVXY.getY() - y, endpointVXY.getZ() );
|
||||
result->setX( v1.getY()*v2.getZ() - v1.getZ()*v2.getY() );
|
||||
@ -106,9 +106,9 @@ bool CloughTocherInterpolator::calcNormVec( double x, double y, Vector3D* result
|
||||
double zv = cp9.getZ() * calcBernsteinPoly( 2, 2, 0, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp16.getZ() * calcBernsteinPoly( 2, 1, 1, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + point3.getZ() * calcBernsteinPoly( 2, 0, 2, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp13.getZ() * calcBernsteinPoly( 2, 1, 0, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp15.getZ() * calcBernsteinPoly( 2, 0, 1, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp12.getZ() * calcBernsteinPoly( 2, 0, 0, 2, barycoord.getX(), barycoord.getY(), barycoord.getZ() );
|
||||
double zw = cp5.getZ() * calcBernsteinPoly( 2, 2, 0, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp13.getZ() * calcBernsteinPoly( 2, 1, 1, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp15.getZ() * calcBernsteinPoly( 2, 0, 2, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp8.getZ() * calcBernsteinPoly( 2, 1, 0, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp12.getZ() * calcBernsteinPoly( 2, 0, 1, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp10.getZ() * calcBernsteinPoly( 2, 0, 0, 2, barycoord.getX(), barycoord.getY(), barycoord.getZ() );
|
||||
MathUtils::BarycentricToXY( barycoord.getX() + 1, barycoord.getY() - 1, barycoord.getZ(), &point2, &point3, &cp10, &endpointUXY );
|
||||
endpointUXY.setZ( 3*( zu - zv ) );
|
||||
endpointUXY.setZ( 3 * ( zu - zv ) );
|
||||
MathUtils::BarycentricToXY( barycoord.getX(), barycoord.getY() + 1, barycoord.getZ() - 1, &point2, &point3, &cp10, &endpointVXY );
|
||||
endpointVXY.setZ( 3*( zv - zw ) );
|
||||
endpointVXY.setZ( 3 * ( zv - zw ) );
|
||||
Vector3D v1( endpointUXY.getX() - x, endpointUXY.getY() - y, endpointUXY.getZ() );
|
||||
Vector3D v2( endpointVXY.getX() - x, endpointVXY.getY() - y, endpointVXY.getZ() );
|
||||
result->setX( v1.getY()*v2.getZ() - v1.getZ()*v2.getY() );
|
||||
@ -126,9 +126,9 @@ bool CloughTocherInterpolator::calcNormVec( double x, double y, Vector3D* result
|
||||
double zv = cp14.getZ() * calcBernsteinPoly( 2, 2, 0, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp6.getZ() * calcBernsteinPoly( 2, 1, 1, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + point1.getZ() * calcBernsteinPoly( 2, 0, 2, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp11.getZ() * calcBernsteinPoly( 2, 1, 0, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp3.getZ() * calcBernsteinPoly( 2, 0, 1, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp7.getZ() * calcBernsteinPoly( 2, 0, 0, 2, barycoord.getX(), barycoord.getY(), barycoord.getZ() );
|
||||
double zw = cp15.getZ() * calcBernsteinPoly( 2, 2, 0, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp11.getZ() * calcBernsteinPoly( 2, 1, 1, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp3.getZ() * calcBernsteinPoly( 2, 0, 2, 0, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp12.getZ() * calcBernsteinPoly( 2, 1, 0, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp7.getZ() * calcBernsteinPoly( 2, 0, 1, 1, barycoord.getX(), barycoord.getY(), barycoord.getZ() ) + cp10.getZ() * calcBernsteinPoly( 2, 0, 0, 2, barycoord.getX(), barycoord.getY(), barycoord.getZ() );
|
||||
MathUtils::BarycentricToXY( barycoord.getX() + 1, barycoord.getY() - 1, barycoord.getZ(), &point3, &point1, &cp10, &endpointUXY );
|
||||
endpointUXY.setZ( 3*( zu - zv ) );
|
||||
endpointUXY.setZ( 3 * ( zu - zv ) );
|
||||
MathUtils::BarycentricToXY( barycoord.getX(), barycoord.getY() + 1, barycoord.getZ() - 1, &point3, &point1, &cp10, &endpointVXY );
|
||||
endpointVXY.setZ( 3*( zv - zw ) );
|
||||
endpointVXY.setZ( 3 * ( zv - zw ) );
|
||||
Vector3D v1( endpointUXY.getX() - x, endpointUXY.getY() - y, endpointUXY.getZ() );
|
||||
Vector3D v2( endpointVXY.getX() - x, endpointVXY.getY() - y, endpointVXY.getZ() );
|
||||
result->setX( v1.getY()*v2.getZ() - v1.getZ()*v2.getY() );
|
||||
@ -178,7 +178,7 @@ bool CloughTocherInterpolator::calcNormVec( double x, double y, Vector3D* result
|
||||
}
|
||||
}
|
||||
|
||||
bool CloughTocherInterpolator::calcPoint( double x, double y, Point3D* result )
|
||||
bool CloughTocherInterpolator::calcPoint( double x, double y, Point3D *result )
|
||||
{
|
||||
if ( result )
|
||||
{
|
||||
@ -305,8 +305,8 @@ void CloughTocherInterpolator::init( double x, double y )//version, which has th
|
||||
cp6.setZ( point1.getZ() + ( cp6.getX() - point1.getX() )*der1X + ( cp6.getY() - point1.getY() )*der1Y );
|
||||
|
||||
//set x- and y-coordinates of the central point
|
||||
cp10.setX(( point1.getX() + point2.getX() + point3.getX() ) / 3 );
|
||||
cp10.setY(( point1.getY() + point2.getY() + point3.getY() ) / 3 );
|
||||
cp10.setX( ( point1.getX() + point2.getX() + point3.getX() ) / 3 );
|
||||
cp10.setY( ( point1.getY() + point2.getY() + point3.getY() ) / 3 );
|
||||
|
||||
//set the derivatives of the points to new values if they are on a breakline
|
||||
if ( state1 == NormVecDecorator::BreakLine )
|
||||
@ -386,68 +386,68 @@ void CloughTocherInterpolator::init( double x, double y )//version, which has th
|
||||
cp15.setZ( point3.getZ() + ( cp15.getX() - point3.getX() )*der3X + ( cp15.getY() - point3.getY() )*der3Y );
|
||||
|
||||
|
||||
cp4.setX(( point1.getX() + cp10.getX() + point2.getX() ) / 3 );
|
||||
cp4.setY(( point1.getY() + cp10.getY() + point2.getY() ) / 3 );
|
||||
cp4.setX( ( point1.getX() + cp10.getX() + point2.getX() ) / 3 );
|
||||
cp4.setY( ( point1.getY() + cp10.getY() + point2.getY() ) / 3 );
|
||||
|
||||
Point3D midpoint3(( cp1.getX() + cp2.getX() ) / 2, ( cp1.getY() + cp2.getY() ) / 2, ( cp1.getZ() + cp2.getZ() ) / 2 );
|
||||
Point3D midpoint3( ( cp1.getX() + cp2.getX() ) / 2, ( cp1.getY() + cp2.getY() ) / 2, ( cp1.getZ() + cp2.getZ() ) / 2 );
|
||||
Vector3D cp1cp2( cp2.getX() - cp1.getX(), cp2.getY() - cp1.getY(), cp2.getZ() - cp1.getZ() );
|
||||
Vector3D odir3( 0, 0, 0 );//direction orthogonal to the line from point1 to point2
|
||||
if (( point2.getY() - point1.getY() ) != 0 )//avoid division through zero
|
||||
if ( ( point2.getY() - point1.getY() ) != 0 ) //avoid division through zero
|
||||
{
|
||||
odir3.setX( 1 );
|
||||
odir3.setY( -( point2.getX() - point1.getX() ) / ( point2.getY() - point1.getY() ) );
|
||||
odir3.setZ(( der1X + der2X ) / 2 + ( der1Y + der2Y ) / 2*odir3.getY() );//take the linear interpolated cross-derivative
|
||||
odir3.setZ( ( der1X + der2X ) / 2 + ( der1Y + der2Y ) / 2 * odir3.getY() ); //take the linear interpolated cross-derivative
|
||||
}
|
||||
else
|
||||
{
|
||||
odir3.setY( 1 );
|
||||
odir3.setX( -( point2.getY() - point1.getY() ) / ( point2.getX() - point1.getX() ) );
|
||||
odir3.setZ(( der1X + der2X ) / 2*odir3.getX() + ( der1Y + der2Y ) / 2 );
|
||||
odir3.setZ( ( der1X + der2X ) / 2 * odir3.getX() + ( der1Y + der2Y ) / 2 );
|
||||
}
|
||||
Vector3D midpoint3cp4( 0, 0, 0 );
|
||||
MathUtils::derVec( &cp1cp2, &odir3, &midpoint3cp4, cp4.getX() - midpoint3.getX(), cp4.getY() - midpoint3.getY() );
|
||||
cp4.setZ( midpoint3.getZ() + midpoint3cp4.getZ() );
|
||||
|
||||
cp13.setX(( point2.getX() + cp10.getX() + point3.getX() ) / 3 );
|
||||
cp13.setY(( point2.getY() + cp10.getY() + point3.getY() ) / 3 );
|
||||
cp13.setX( ( point2.getX() + cp10.getX() + point3.getX() ) / 3 );
|
||||
cp13.setY( ( point2.getY() + cp10.getY() + point3.getY() ) / 3 );
|
||||
//find the point in the middle of the bezier curve between point2 and point3
|
||||
Point3D midpoint1(( cp9.getX() + cp16.getX() ) / 2, ( cp9.getY() + cp16.getY() ) / 2, ( cp9.getZ() + cp16.getZ() ) / 2 );
|
||||
Point3D midpoint1( ( cp9.getX() + cp16.getX() ) / 2, ( cp9.getY() + cp16.getY() ) / 2, ( cp9.getZ() + cp16.getZ() ) / 2 );
|
||||
Vector3D cp9cp16( cp16.getX() - cp9.getX(), cp16.getY() - cp9.getY(), cp16.getZ() - cp9.getZ() );
|
||||
Vector3D odir1( 0, 0, 0 );//direction orthogonal to the line from point2 to point3
|
||||
if (( point3.getY() - point2.getY() ) != 0 )//avoid division through zero
|
||||
if ( ( point3.getY() - point2.getY() ) != 0 ) //avoid division through zero
|
||||
{
|
||||
odir1.setX( 1 );
|
||||
odir1.setY( -( point3.getX() - point2.getX() ) / ( point3.getY() - point2.getY() ) );
|
||||
odir1.setZ(( der2X + der3X ) / 2 + ( der2Y + der3Y ) / 2*odir1.getY() );//take the linear interpolated cross-derivative
|
||||
odir1.setZ( ( der2X + der3X ) / 2 + ( der2Y + der3Y ) / 2 * odir1.getY() ); //take the linear interpolated cross-derivative
|
||||
}
|
||||
else
|
||||
{
|
||||
odir1.setY( 1 );
|
||||
odir1.setX( -( point3.getY() - point2.getY() ) / ( point3.getX() - point2.getX() ) );
|
||||
odir1.setZ(( der2X + der3X ) / 2*odir1.getX() + ( der2Y + der3Y ) / 2 );
|
||||
odir1.setZ( ( der2X + der3X ) / 2 * odir1.getX() + ( der2Y + der3Y ) / 2 );
|
||||
}
|
||||
Vector3D midpoint1cp13( 0, 0, 0 );
|
||||
MathUtils::derVec( &cp9cp16, &odir1, &midpoint1cp13, cp13.getX() - midpoint1.getX(), cp13.getY() - midpoint1.getY() );
|
||||
cp13.setZ( midpoint1.getZ() + midpoint1cp13.getZ() );
|
||||
|
||||
|
||||
cp11.setX(( point3.getX() + cp10.getX() + point1.getX() ) / 3 );
|
||||
cp11.setY(( point3.getY() + cp10.getY() + point1.getY() ) / 3 );
|
||||
cp11.setX( ( point3.getX() + cp10.getX() + point1.getX() ) / 3 );
|
||||
cp11.setY( ( point3.getY() + cp10.getY() + point1.getY() ) / 3 );
|
||||
//find the point in the middle of the bezier curve between point3 and point2
|
||||
Point3D midpoint2(( cp14.getX() + cp6.getX() ) / 2, ( cp14.getY() + cp6.getY() ) / 2, ( cp14.getZ() + cp6.getZ() ) / 2 );
|
||||
Point3D midpoint2( ( cp14.getX() + cp6.getX() ) / 2, ( cp14.getY() + cp6.getY() ) / 2, ( cp14.getZ() + cp6.getZ() ) / 2 );
|
||||
Vector3D cp14cp6( cp6.getX() - cp14.getX(), cp6.getY() - cp14.getY(), cp6.getZ() - cp14.getZ() );
|
||||
Vector3D odir2( 0, 0, 0 );//direction orthogonal to the line from point 1 to point3
|
||||
if (( point3.getY() - point1.getY() ) != 0 )//avoid division through zero
|
||||
if ( ( point3.getY() - point1.getY() ) != 0 ) //avoid division through zero
|
||||
{
|
||||
odir2.setX( 1 );
|
||||
odir2.setY( -( point3.getX() - point1.getX() ) / ( point3.getY() - point1.getY() ) );
|
||||
odir2.setZ(( der3X + der1X ) / 2 + ( der3Y + der1Y ) / 2*odir2.getY() );//take the linear interpolated cross-derivative
|
||||
odir2.setZ( ( der3X + der1X ) / 2 + ( der3Y + der1Y ) / 2 * odir2.getY() ); //take the linear interpolated cross-derivative
|
||||
}
|
||||
else
|
||||
{
|
||||
odir2.setY( 1 );
|
||||
odir2.setX( -( point3.getY() - point1.getY() ) / ( point3.getX() - point1.getX() ) );
|
||||
odir2.setZ(( der3X + der1X ) / 2*odir2.getX() + ( der3Y + der1Y ) / 2 );
|
||||
odir2.setZ( ( der3X + der1X ) / 2 * odir2.getX() + ( der3Y + der1Y ) / 2 );
|
||||
}
|
||||
Vector3D midpoint2cp11( 0, 0, 0 );
|
||||
MathUtils::derVec( &cp14cp6, &odir2, &midpoint2cp11, cp11.getX() - midpoint2.getX(), cp11.getY() - midpoint2.getY() );
|
||||
@ -551,8 +551,8 @@ void CloughTocherInterpolator::init( double x, double y )//version which has uni
|
||||
cp6.setZ( point1.getZ() + ( cp6.getX() - point1.getX() )*der1X + ( cp6.getY() - point1.getY() )*der1Y );
|
||||
|
||||
//set x- and y-coordinates of the central point
|
||||
cp10.setX(( point1.getX() + point2.getX() + point3.getX() ) / 3 );
|
||||
cp10.setY(( point1.getY() + point2.getY() + point3.getY() ) / 3 );
|
||||
cp10.setX( ( point1.getX() + point2.getX() + point3.getX() ) / 3 );
|
||||
cp10.setY( ( point1.getY() + point2.getY() + point3.getY() ) / 3 );
|
||||
|
||||
//do the necessary adjustments in case of breaklines--------------------------------------------------------------------
|
||||
|
||||
@ -570,11 +570,11 @@ void CloughTocherInterpolator::init( double x, double y )//version which has uni
|
||||
tmpy = -tmp.getY() / tmp.getZ();
|
||||
if ( state3 == NormVecDecorator::Normal )
|
||||
{
|
||||
cp6.setZ( point1.getZ() + (( point3.getX() - point1.getX() ) / 3 )*tmpx + (( point3.getY() - point1.getY() ) / 3 )*tmpy );
|
||||
cp6.setZ( point1.getZ() + ( ( point3.getX() - point1.getX() ) / 3 )*tmpx + ( ( point3.getY() - point1.getY() ) / 3 )*tmpy );
|
||||
}
|
||||
if ( state2 == NormVecDecorator::Normal )
|
||||
{
|
||||
cp1.setZ( point1.getZ() + (( point2.getX() - point1.getX() ) / 3 )*tmpx + (( point2.getY() - point1.getY() ) / 3 )*tmpy );
|
||||
cp1.setZ( point1.getZ() + ( ( point2.getX() - point1.getX() ) / 3 )*tmpx + ( ( point2.getY() - point1.getY() ) / 3 )*tmpy );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,11 +587,11 @@ void CloughTocherInterpolator::init( double x, double y )//version which has uni
|
||||
tmpy = -tmp.getY() / tmp.getZ();
|
||||
if ( state1 == NormVecDecorator::Normal )
|
||||
{
|
||||
cp2.setZ( point2.getZ() + (( point1.getX() - point2.getX() ) / 3 )*tmpx + (( point1.getY() - point2.getY() ) / 3 )*tmpy );
|
||||
cp2.setZ( point2.getZ() + ( ( point1.getX() - point2.getX() ) / 3 )*tmpx + ( ( point1.getY() - point2.getY() ) / 3 )*tmpy );
|
||||
}
|
||||
if ( state3 == NormVecDecorator::Normal )
|
||||
{
|
||||
cp9.setZ( point2.getZ() + (( point3.getX() - point2.getX() ) / 3 )*tmpx + (( point3.getY() - point2.getY() ) / 3 )*tmpy );
|
||||
cp9.setZ( point2.getZ() + ( ( point3.getX() - point2.getX() ) / 3 )*tmpx + ( ( point3.getY() - point2.getY() ) / 3 )*tmpy );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -604,11 +604,11 @@ void CloughTocherInterpolator::init( double x, double y )//version which has uni
|
||||
tmpy = -tmp.getY() / tmp.getZ();
|
||||
if ( state1 == NormVecDecorator::Normal )
|
||||
{
|
||||
cp14.setZ( point3.getZ() + (( point1.getX() - point3.getX() ) / 3 )*tmpx + (( point1.getY() - point3.getY() ) / 3 )*tmpy );
|
||||
cp14.setZ( point3.getZ() + ( ( point1.getX() - point3.getX() ) / 3 )*tmpx + ( ( point1.getY() - point3.getY() ) / 3 )*tmpy );
|
||||
}
|
||||
if ( state2 == NormVecDecorator::Normal )
|
||||
{
|
||||
cp16.setZ( point3.getZ() + (( point2.getX() - point3.getX() ) / 3 )*tmpx + (( point2.getY() - point3.getY() ) / 3 )*tmpy );
|
||||
cp16.setZ( point3.getZ() + ( ( point2.getX() - point3.getX() ) / 3 )*tmpx + ( ( point2.getY() - point3.getY() ) / 3 )*tmpy );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -656,68 +656,68 @@ void CloughTocherInterpolator::init( double x, double y )//version which has uni
|
||||
cp15.setZ( point3.getZ() + ( cp15.getX() - point3.getX() )*der3X + ( cp15.getY() - point3.getY() )*der3Y );
|
||||
|
||||
|
||||
cp4.setX(( point1.getX() + cp10.getX() + point2.getX() ) / 3 );
|
||||
cp4.setY(( point1.getY() + cp10.getY() + point2.getY() ) / 3 );
|
||||
cp4.setX( ( point1.getX() + cp10.getX() + point2.getX() ) / 3 );
|
||||
cp4.setY( ( point1.getY() + cp10.getY() + point2.getY() ) / 3 );
|
||||
|
||||
Point3D midpoint3(( cp1.getX() + cp2.getX() ) / 2, ( cp1.getY() + cp2.getY() ) / 2, ( cp1.getZ() + cp2.getZ() ) / 2 );
|
||||
Point3D midpoint3( ( cp1.getX() + cp2.getX() ) / 2, ( cp1.getY() + cp2.getY() ) / 2, ( cp1.getZ() + cp2.getZ() ) / 2 );
|
||||
Vector3D cp1cp2( cp2.getX() - cp1.getX(), cp2.getY() - cp1.getY(), cp2.getZ() - cp1.getZ() );
|
||||
Vector3D odir3( 0, 0, 0 );//direction orthogonal to the line from point1 to point2
|
||||
if (( point2.getY() - point1.getY() ) != 0 )//avoid division through zero
|
||||
if ( ( point2.getY() - point1.getY() ) != 0 ) //avoid division through zero
|
||||
{
|
||||
odir3.setX( 1 );
|
||||
odir3.setY( -( point2.getX() - point1.getX() ) / ( point2.getY() - point1.getY() ) );
|
||||
odir3.setZ(( der1X + der2X ) / 2 + ( der1Y + der2Y ) / 2*odir3.getY() );//take the linear interpolated cross-derivative
|
||||
odir3.setZ( ( der1X + der2X ) / 2 + ( der1Y + der2Y ) / 2 * odir3.getY() ); //take the linear interpolated cross-derivative
|
||||
}
|
||||
else
|
||||
{
|
||||
odir3.setY( 1 );
|
||||
odir3.setX( -( point2.getY() - point1.getY() ) / ( point2.getX() - point1.getX() ) );
|
||||
odir3.setZ(( der1X + der2X ) / 2*odir3.getX() + ( der1Y + der2Y ) / 2 );
|
||||
odir3.setZ( ( der1X + der2X ) / 2 * odir3.getX() + ( der1Y + der2Y ) / 2 );
|
||||
}
|
||||
Vector3D midpoint3cp4( 0, 0, 0 );
|
||||
MathUtils::derVec( &cp1cp2, &odir3, &midpoint3cp4, cp4.getX() - midpoint3.getX(), cp4.getY() - midpoint3.getY() );
|
||||
cp4.setZ( midpoint3.getZ() + midpoint3cp4.getZ() );
|
||||
|
||||
cp13.setX(( point2.getX() + cp10.getX() + point3.getX() ) / 3 );
|
||||
cp13.setY(( point2.getY() + cp10.getY() + point3.getY() ) / 3 );
|
||||
cp13.setX( ( point2.getX() + cp10.getX() + point3.getX() ) / 3 );
|
||||
cp13.setY( ( point2.getY() + cp10.getY() + point3.getY() ) / 3 );
|
||||
//find the point in the middle of the bezier curve between point2 and point3
|
||||
Point3D midpoint1(( cp9.getX() + cp16.getX() ) / 2, ( cp9.getY() + cp16.getY() ) / 2, ( cp9.getZ() + cp16.getZ() ) / 2 );
|
||||
Point3D midpoint1( ( cp9.getX() + cp16.getX() ) / 2, ( cp9.getY() + cp16.getY() ) / 2, ( cp9.getZ() + cp16.getZ() ) / 2 );
|
||||
Vector3D cp9cp16( cp16.getX() - cp9.getX(), cp16.getY() - cp9.getY(), cp16.getZ() - cp9.getZ() );
|
||||
Vector3D odir1( 0, 0, 0 );//direction orthogonal to the line from point2 to point3
|
||||
if (( point3.getY() - point2.getY() ) != 0 )//avoid division through zero
|
||||
if ( ( point3.getY() - point2.getY() ) != 0 ) //avoid division through zero
|
||||
{
|
||||
odir1.setX( 1 );
|
||||
odir1.setY( -( point3.getX() - point2.getX() ) / ( point3.getY() - point2.getY() ) );
|
||||
odir1.setZ(( der2X + der3X ) / 2 + ( der2Y + der3Y ) / 2*odir1.getY() );//take the linear interpolated cross-derivative
|
||||
odir1.setZ( ( der2X + der3X ) / 2 + ( der2Y + der3Y ) / 2 * odir1.getY() ); //take the linear interpolated cross-derivative
|
||||
}
|
||||
else
|
||||
{
|
||||
odir1.setY( 1 );
|
||||
odir1.setX( -( point3.getY() - point2.getY() ) / ( point3.getX() - point2.getX() ) );
|
||||
odir1.setZ(( der2X + der3X ) / 2*odir1.getX() + ( der2Y + der3Y ) / 2 );
|
||||
odir1.setZ( ( der2X + der3X ) / 2 * odir1.getX() + ( der2Y + der3Y ) / 2 );
|
||||
}
|
||||
Vector3D midpoint1cp13( 0, 0, 0 );
|
||||
MathUtils::derVec( &cp9cp16, &odir1, &midpoint1cp13, cp13.getX() - midpoint1.getX(), cp13.getY() - midpoint1.getY() );
|
||||
cp13.setZ( midpoint1.getZ() + midpoint1cp13.getZ() );
|
||||
|
||||
|
||||
cp11.setX(( point3.getX() + cp10.getX() + point1.getX() ) / 3 );
|
||||
cp11.setY(( point3.getY() + cp10.getY() + point1.getY() ) / 3 );
|
||||
cp11.setX( ( point3.getX() + cp10.getX() + point1.getX() ) / 3 );
|
||||
cp11.setY( ( point3.getY() + cp10.getY() + point1.getY() ) / 3 );
|
||||
//find the point in the middle of the bezier curve between point3 and point2
|
||||
Point3D midpoint2(( cp14.getX() + cp6.getX() ) / 2, ( cp14.getY() + cp6.getY() ) / 2, ( cp14.getZ() + cp6.getZ() ) / 2 );
|
||||
Point3D midpoint2( ( cp14.getX() + cp6.getX() ) / 2, ( cp14.getY() + cp6.getY() ) / 2, ( cp14.getZ() + cp6.getZ() ) / 2 );
|
||||
Vector3D cp14cp6( cp6.getX() - cp14.getX(), cp6.getY() - cp14.getY(), cp6.getZ() - cp14.getZ() );
|
||||
Vector3D odir2( 0, 0, 0 );//direction orthogonal to the line from point 1 to point3
|
||||
if (( point3.getY() - point1.getY() ) != 0 )//avoid division through zero
|
||||
if ( ( point3.getY() - point1.getY() ) != 0 ) //avoid division through zero
|
||||
{
|
||||
odir2.setX( 1 );
|
||||
odir2.setY( -( point3.getX() - point1.getX() ) / ( point3.getY() - point1.getY() ) );
|
||||
odir2.setZ(( der3X + der1X ) / 2 + ( der3Y + der1Y ) / 2*odir2.getY() );//take the linear interpolated cross-derivative
|
||||
odir2.setZ( ( der3X + der1X ) / 2 + ( der3Y + der1Y ) / 2 * odir2.getY() ); //take the linear interpolated cross-derivative
|
||||
}
|
||||
else
|
||||
{
|
||||
odir2.setY( 1 );
|
||||
odir2.setX( -( point3.getY() - point1.getY() ) / ( point3.getX() - point1.getX() ) );
|
||||
odir2.setZ(( der3X + der1X ) / 2*odir2.getX() + ( der3Y + der1Y ) / 2 );
|
||||
odir2.setZ( ( der3X + der1X ) / 2 * odir2.getX() + ( der3Y + der1Y ) / 2 );
|
||||
}
|
||||
Vector3D midpoint2cp11( 0, 0, 0 );
|
||||
MathUtils::derVec( &cp14cp6, &odir2, &midpoint2cp11, cp11.getX() - midpoint2.getX(), cp11.getY() - midpoint2.getY() );
|
||||
|
@ -29,7 +29,7 @@ class ANALYSIS_EXPORT CloughTocherInterpolator : public TriangleInterpolator
|
||||
{
|
||||
protected:
|
||||
//! Association with a triangulation object
|
||||
NormVecDecorator* mTIN = nullptr;
|
||||
NormVecDecorator *mTIN = nullptr;
|
||||
//! Tolerance of the barycentric coordinates at the borders of the triangles (to prevent errors because of very small negativ baricentric coordinates)
|
||||
double mEdgeTolerance;
|
||||
//! First point of the triangle in x-,y-,z-coordinates
|
||||
@ -81,13 +81,13 @@ class ANALYSIS_EXPORT CloughTocherInterpolator : public TriangleInterpolator
|
||||
//! Standard constructor
|
||||
CloughTocherInterpolator();
|
||||
//! Constructor with a pointer to the triangulation as argument
|
||||
CloughTocherInterpolator( NormVecDecorator* tin );
|
||||
CloughTocherInterpolator( NormVecDecorator *tin );
|
||||
virtual ~CloughTocherInterpolator();
|
||||
//! Calculates the normal vector and assigns it to vec (not implemented at the moment)
|
||||
virtual bool calcNormVec( double x, double y, Vector3D* result ) override;
|
||||
virtual bool calcNormVec( double x, double y, Vector3D *result ) override;
|
||||
//! Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point
|
||||
virtual bool calcPoint( double x, double y, Point3D* result ) override;
|
||||
virtual void setTriangulation( NormVecDecorator* tin );
|
||||
virtual bool calcPoint( double x, double y, Point3D *result ) override;
|
||||
virtual void setTriangulation( NormVecDecorator *tin );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -66,7 +66,7 @@ void DualEdgeTriangulation::performConsistencyTest()
|
||||
QgsDebugMsg( "consistency test finished" );
|
||||
}
|
||||
|
||||
void DualEdgeTriangulation::addLine( Line3D* line, bool breakline )
|
||||
void DualEdgeTriangulation::addLine( Line3D *line, bool breakline )
|
||||
{
|
||||
int actpoint = -10;//number of the last point, which has been inserted from the line
|
||||
int currentpoint = -10;//number of the point, which is currently inserted from the line
|
||||
@ -109,7 +109,7 @@ void DualEdgeTriangulation::addLine( Line3D* line, bool breakline )
|
||||
delete line;
|
||||
}
|
||||
|
||||
int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
int DualEdgeTriangulation::addPoint( Point3D *p )
|
||||
{
|
||||
if ( p )
|
||||
{
|
||||
@ -126,20 +126,20 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
|
||||
else//update bounding box else
|
||||
{
|
||||
if (( *p ).getX() < xMin )
|
||||
if ( ( *p ).getX() < xMin )
|
||||
{
|
||||
xMin = ( *p ).getX();
|
||||
}
|
||||
else if (( *p ).getX() > xMax )
|
||||
else if ( ( *p ).getX() > xMax )
|
||||
{
|
||||
xMax = ( *p ).getX();
|
||||
}
|
||||
|
||||
if (( *p ).getY() < yMin )
|
||||
if ( ( *p ).getY() < yMin )
|
||||
{
|
||||
yMin = ( *p ).getY();
|
||||
}
|
||||
else if (( *p ).getY() > yMax )
|
||||
else if ( ( *p ).getY() > yMax )
|
||||
{
|
||||
yMax = ( *p ).getY();
|
||||
}
|
||||
@ -152,9 +152,9 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
if ( mPointVector.count() == 1 )//insert the first point into the triangulation
|
||||
{
|
||||
unsigned int zedge = insertEdge( -10, -10, -1, false, false );//edge pointing from p to the virtual point
|
||||
unsigned int fedge = insertEdge(( int )zedge, ( int )zedge, 0, false, false );//edge pointing from the virtual point to p
|
||||
( mHalfEdge.at( zedge ) )->setDual(( int )fedge );
|
||||
( mHalfEdge.at( zedge ) )->setNext(( int )fedge );
|
||||
unsigned int fedge = insertEdge( ( int )zedge, ( int )zedge, 0, false, false ); //edge pointing from the virtual point to p
|
||||
( mHalfEdge.at( zedge ) )->setDual( ( int )fedge );
|
||||
( mHalfEdge.at( zedge ) )->setNext( ( int )fedge );
|
||||
|
||||
}
|
||||
|
||||
@ -164,22 +164,22 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
if ( p->getX() == mPointVector[0]->getX() && p->getY() == mPointVector[0]->getY() )
|
||||
{
|
||||
QgsDebugMsg( "second point is the same as the first point, it thus has not been inserted" );
|
||||
Point3D* p = mPointVector[1];
|
||||
Point3D *p = mPointVector[1];
|
||||
mPointVector.remove( 1 );
|
||||
delete p;
|
||||
return -100;
|
||||
}
|
||||
|
||||
unsigned int sedge = insertEdge( -10, -10, 1, false, false );//edge pointing from point 0 to point 1
|
||||
unsigned int tedge = insertEdge(( int )sedge, 0, 0, false, false );//edge pointing from point 1 to point 0
|
||||
unsigned int tedge = insertEdge( ( int )sedge, 0, 0, false, false ); //edge pointing from point 1 to point 0
|
||||
unsigned int foedge = insertEdge( -10, 4, 1, false, false );//edge pointing from the virtual point to point 1
|
||||
unsigned int fiedge = insertEdge(( int )foedge, 1, -1, false, false );//edge pointing from point 2 to the virtual point
|
||||
mHalfEdge.at( sedge )->setDual(( int )tedge );
|
||||
mHalfEdge.at( sedge )->setNext(( int )fiedge );
|
||||
mHalfEdge.at( foedge )->setDual(( int )fiedge );
|
||||
mHalfEdge.at( foedge )->setNext(( int )tedge );
|
||||
mHalfEdge.at( 0 )->setNext(( int )foedge );
|
||||
mHalfEdge.at( 1 )->setNext(( int )sedge );
|
||||
unsigned int fiedge = insertEdge( ( int )foedge, 1, -1, false, false ); //edge pointing from point 2 to the virtual point
|
||||
mHalfEdge.at( sedge )->setDual( ( int )tedge );
|
||||
mHalfEdge.at( sedge )->setNext( ( int )fiedge );
|
||||
mHalfEdge.at( foedge )->setDual( ( int )fiedge );
|
||||
mHalfEdge.at( foedge )->setNext( ( int )tedge );
|
||||
mHalfEdge.at( 0 )->setNext( ( int )foedge );
|
||||
mHalfEdge.at( 1 )->setNext( ( int )sedge );
|
||||
|
||||
mEdgeInside = 3;
|
||||
}
|
||||
@ -192,38 +192,38 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
{
|
||||
//insert six new edges
|
||||
unsigned int edgea = insertEdge( -10, -10, 2, false, false );//edge pointing from point1 to point2
|
||||
unsigned int edgeb = insertEdge(( int )edgea, 5, 1, false, false );//edge pointing from point2 to point1
|
||||
unsigned int edgeb = insertEdge( ( int )edgea, 5, 1, false, false ); //edge pointing from point2 to point1
|
||||
unsigned int edgec = insertEdge( -10, ( int )edgeb, 2, false, false );//edge pointing from the virtual point to p2
|
||||
unsigned int edged = insertEdge( -10, 2, 0, false, false );//edge pointing from point2 to point0
|
||||
unsigned int edgee = insertEdge(( int )edged, -10, 2, false, false );//edge pointing from point0 to point2
|
||||
unsigned int edgef = insertEdge(( int )edgec, 1, -1, false, false );//edge pointing from point2 to the virtual point
|
||||
mHalfEdge.at( edgea )->setDual(( int )edgeb );
|
||||
mHalfEdge.at( edgea )->setNext(( int )edged );
|
||||
mHalfEdge.at( edgec )->setDual(( int )edgef );
|
||||
mHalfEdge.at( edged )->setDual(( int )edgee );
|
||||
mHalfEdge.at( edgee )->setNext(( int )edgef );
|
||||
mHalfEdge.at( 5 )->setNext(( int )edgec );
|
||||
mHalfEdge.at( 1 )->setNext(( int )edgee );
|
||||
mHalfEdge.at( 2 )->setNext(( int )edgea );
|
||||
unsigned int edgee = insertEdge( ( int )edged, -10, 2, false, false ); //edge pointing from point0 to point2
|
||||
unsigned int edgef = insertEdge( ( int )edgec, 1, -1, false, false ); //edge pointing from point2 to the virtual point
|
||||
mHalfEdge.at( edgea )->setDual( ( int )edgeb );
|
||||
mHalfEdge.at( edgea )->setNext( ( int )edged );
|
||||
mHalfEdge.at( edgec )->setDual( ( int )edgef );
|
||||
mHalfEdge.at( edged )->setDual( ( int )edgee );
|
||||
mHalfEdge.at( edgee )->setNext( ( int )edgef );
|
||||
mHalfEdge.at( 5 )->setNext( ( int )edgec );
|
||||
mHalfEdge.at( 1 )->setNext( ( int )edgee );
|
||||
mHalfEdge.at( 2 )->setNext( ( int )edgea );
|
||||
}
|
||||
|
||||
else if ( number > leftOfTresh )//p is on the right side
|
||||
{
|
||||
//insert six new edges
|
||||
unsigned int edgea = insertEdge( -10, -10, 2, false, false );//edge pointing from p0 to p2
|
||||
unsigned int edgeb = insertEdge(( int )edgea, 0, 0, false, false );//edge pointing from p2 to p0
|
||||
unsigned int edgeb = insertEdge( ( int )edgea, 0, 0, false, false ); //edge pointing from p2 to p0
|
||||
unsigned int edgec = insertEdge( -10, ( int )edgeb, 2, false, false );//edge pointing from the virtual point to p2
|
||||
unsigned int edged = insertEdge( -10, 3, 1, false, false );//edge pointing from p2 to p1
|
||||
unsigned int edgee = insertEdge(( int )edged, -10, 2, false, false );//edge pointing from p1 to p2
|
||||
unsigned int edgef = insertEdge(( int )edgec, 4, -1, false, false );//edge pointing from p2 to the virtual point
|
||||
mHalfEdge.at( edgea )->setDual(( int )edgeb );
|
||||
mHalfEdge.at( edgea )->setNext(( int )edged );
|
||||
mHalfEdge.at( edgec )->setDual(( int )edgef );
|
||||
mHalfEdge.at( edged )->setDual(( int )edgee );
|
||||
mHalfEdge.at( edgee )->setNext(( int )edgef );
|
||||
mHalfEdge.at( 0 )->setNext(( int )edgec );
|
||||
mHalfEdge.at( 4 )->setNext(( int )edgee );
|
||||
mHalfEdge.at( 3 )->setNext(( int )edgea );
|
||||
unsigned int edgee = insertEdge( ( int )edged, -10, 2, false, false ); //edge pointing from p1 to p2
|
||||
unsigned int edgef = insertEdge( ( int )edgec, 4, -1, false, false ); //edge pointing from p2 to the virtual point
|
||||
mHalfEdge.at( edgea )->setDual( ( int )edgeb );
|
||||
mHalfEdge.at( edgea )->setNext( ( int )edged );
|
||||
mHalfEdge.at( edgec )->setDual( ( int )edgef );
|
||||
mHalfEdge.at( edged )->setDual( ( int )edgee );
|
||||
mHalfEdge.at( edgee )->setNext( ( int )edgef );
|
||||
mHalfEdge.at( 0 )->setNext( ( int )edgec );
|
||||
mHalfEdge.at( 4 )->setNext( ( int )edgee );
|
||||
mHalfEdge.at( 3 )->setNext( ( int )edgea );
|
||||
}
|
||||
|
||||
else//p is in a line with p0 and p1
|
||||
@ -270,7 +270,7 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
|
||||
|
||||
//find ccwedge and replace the virtual point with the new point when necessary
|
||||
while ( MathUtils::leftOf( mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getPoint()], mPointVector[mPointVector.count()-1], mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->getNext()]->getPoint()] ) < ( -leftOfTresh ) )
|
||||
while ( MathUtils::leftOf( mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getPoint()], mPointVector[mPointVector.count() - 1], mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->getNext()]->getPoint()] ) < ( -leftOfTresh ) )
|
||||
{
|
||||
//set the point number of the necessary edge to the actual point instead of the virtual point
|
||||
mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[ccwedge]->getNext()]->getNext()]->getDual()]->setPoint( mPointVector.count() - 1 );
|
||||
@ -317,20 +317,20 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
|
||||
//insert 6 new HalfEdges for the connections to the vertices of the triangle
|
||||
unsigned int edge1 = insertEdge( -10, nextnumber, mHalfEdge[number]->getPoint(), false, false );
|
||||
unsigned int edge2 = insertEdge(( int )edge1, -10, mPointVector.count() - 1, false, false );
|
||||
unsigned int edge2 = insertEdge( ( int )edge1, -10, mPointVector.count() - 1, false, false );
|
||||
unsigned int edge3 = insertEdge( -10, nextnextnumber, mHalfEdge[nextnumber]->getPoint(), false, false );
|
||||
unsigned int edge4 = insertEdge(( int )edge3, ( int )edge1, mPointVector.count() - 1, false, false );
|
||||
unsigned int edge4 = insertEdge( ( int )edge3, ( int )edge1, mPointVector.count() - 1, false, false );
|
||||
unsigned int edge5 = insertEdge( -10, number, mHalfEdge[nextnextnumber]->getPoint(), false, false );
|
||||
unsigned int edge6 = insertEdge(( int )edge5, ( int )edge3, mPointVector.count() - 1, false, false );
|
||||
unsigned int edge6 = insertEdge( ( int )edge5, ( int )edge3, mPointVector.count() - 1, false, false );
|
||||
|
||||
|
||||
mHalfEdge.at( edge1 )->setDual(( int )edge2 );
|
||||
mHalfEdge.at( edge2 )->setNext(( int )edge5 );
|
||||
mHalfEdge.at( edge3 )->setDual(( int )edge4 );
|
||||
mHalfEdge.at( edge5 )->setDual(( int )edge6 );
|
||||
mHalfEdge.at( number )->setNext(( int )edge2 );
|
||||
mHalfEdge.at( nextnumber )->setNext(( int )edge4 );
|
||||
mHalfEdge.at( nextnextnumber )->setNext(( int )edge6 );
|
||||
mHalfEdge.at( edge1 )->setDual( ( int )edge2 );
|
||||
mHalfEdge.at( edge2 )->setNext( ( int )edge5 );
|
||||
mHalfEdge.at( edge3 )->setDual( ( int )edge4 );
|
||||
mHalfEdge.at( edge5 )->setDual( ( int )edge6 );
|
||||
mHalfEdge.at( number )->setNext( ( int )edge2 );
|
||||
mHalfEdge.at( nextnumber )->setNext( ( int )edge4 );
|
||||
mHalfEdge.at( nextnextnumber )->setNext( ( int )edge6 );
|
||||
|
||||
//check, if there are swaps necessary
|
||||
checkSwap( number, 0 );
|
||||
@ -377,7 +377,7 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
else if ( number == -100 || number == -5 )//this means unknown problems or a numerical error occurred in 'baseEdgeOfTriangle'
|
||||
{
|
||||
// QgsDebugMsg("point has not been inserted because of unknown problems");
|
||||
Point3D* p = mPointVector[mPointVector.count()-1];
|
||||
Point3D *p = mPointVector[mPointVector.count() - 1];
|
||||
mPointVector.remove( mPointVector.count() - 1 );
|
||||
delete p;
|
||||
return -100;
|
||||
@ -385,8 +385,8 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
|
||||
else if ( number == -25 )//this means that the point has already been inserted in the triangulation
|
||||
{
|
||||
//Take the higher z-Value in case of two equal points
|
||||
Point3D* newPoint = mPointVector[mPointVector.count()-1];
|
||||
Point3D* existingPoint = mPointVector[mTwiceInsPoint];
|
||||
Point3D *newPoint = mPointVector[mPointVector.count() - 1];
|
||||
Point3D *existingPoint = mPointVector[mTwiceInsPoint];
|
||||
existingPoint->setZ( qMax( newPoint->getZ(), existingPoint->getZ() ) );
|
||||
|
||||
mPointVector.remove( mPointVector.count() - 1 );
|
||||
@ -476,7 +476,7 @@ int DualEdgeTriangulation::baseEdgeOfPoint( int point )
|
||||
}
|
||||
}
|
||||
|
||||
int DualEdgeTriangulation::baseEdgeOfTriangle( Point3D* point )
|
||||
int DualEdgeTriangulation::baseEdgeOfTriangle( Point3D *point )
|
||||
{
|
||||
unsigned int actedge = mEdgeInside;//start with an edge which does not point to the virtual point (usually number 3)
|
||||
int counter = 0;//number of consecutive successful left-of-tests
|
||||
@ -653,12 +653,12 @@ int DualEdgeTriangulation::baseEdgeOfTriangle( Point3D* point )
|
||||
return -100;//this means a bug happened
|
||||
}
|
||||
|
||||
bool DualEdgeTriangulation::calcNormal( double x, double y, Vector3D* result )
|
||||
bool DualEdgeTriangulation::calcNormal( double x, double y, Vector3D *result )
|
||||
{
|
||||
if ( result && mTriangleInterpolator )
|
||||
{
|
||||
if ( !mTriangleInterpolator->calcNormVec( x, y, result ) )
|
||||
{return false;}
|
||||
{return false;}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -668,12 +668,12 @@ bool DualEdgeTriangulation::calcNormal( double x, double y, Vector3D* result )
|
||||
}
|
||||
}
|
||||
|
||||
bool DualEdgeTriangulation::calcPoint( double x, double y, Point3D* result )
|
||||
bool DualEdgeTriangulation::calcPoint( double x, double y, Point3D *result )
|
||||
{
|
||||
if ( result && mTriangleInterpolator )
|
||||
{
|
||||
if ( !mTriangleInterpolator->calcPoint( x, y, result ) )
|
||||
{return false;}
|
||||
{return false;}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -687,10 +687,10 @@ bool DualEdgeTriangulation::checkSwap( unsigned int edge, unsigned int recursive
|
||||
{
|
||||
if ( swapPossible( edge ) )
|
||||
{
|
||||
Point3D* pta = mPointVector[mHalfEdge[edge]->getPoint()];
|
||||
Point3D* ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
|
||||
Point3D* ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
|
||||
Point3D* ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
|
||||
Point3D *pta = mPointVector[mHalfEdge[edge]->getPoint()];
|
||||
Point3D *ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
|
||||
Point3D *ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
|
||||
Point3D *ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
|
||||
if ( MathUtils::inCircle( ptd, pta, ptb, ptc ) && recursiveDeep < 100 )//empty circle criterion violated
|
||||
{
|
||||
doSwap( edge, recursiveDeep );//swap the edge (recursive)
|
||||
@ -742,7 +742,7 @@ void DualEdgeTriangulation::doSwap( unsigned int edge, unsigned int recursiveDee
|
||||
}
|
||||
|
||||
#if 0
|
||||
void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height ) const
|
||||
void DualEdgeTriangulation::draw( QPainter *p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height ) const
|
||||
{
|
||||
//if mPointVector is empty, there is nothing to do
|
||||
if ( mPointVector.isEmpty() )
|
||||
@ -752,8 +752,8 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
|
||||
p->setPen( mEdgeColor );
|
||||
|
||||
bool* control = new bool[mHalfEdge.count()];//controllarray that no edge is painted twice
|
||||
bool* control2 = new bool[mHalfEdge.count()];//controllarray for the flat triangles
|
||||
bool *control = new bool[mHalfEdge.count()];//controllarray that no edge is painted twice
|
||||
bool *control2 = new bool[mHalfEdge.count()];//controllarray for the flat triangles
|
||||
|
||||
for ( unsigned int i = 0; i <= mHalfEdge.count() - 1; i++ )
|
||||
{
|
||||
@ -761,13 +761,13 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
control2[i] = false;
|
||||
}
|
||||
|
||||
if ((( xupright - xlowleft ) / width ) > (( yupright - ylowleft ) / height ) )
|
||||
if ( ( ( xupright - xlowleft ) / width ) > ( ( yupright - ylowleft ) / height ) )
|
||||
{
|
||||
double lowerborder = -( height * ( xupright - xlowleft ) / width - yupright );//real world coordinates of the lower widget border. This is useful to know because of the HalfEdge bounding box test
|
||||
for ( unsigned int i = 0; i < mHalfEdge.count() - 1; i++ )
|
||||
{
|
||||
if ( mHalfEdge[i]->getPoint() == -1 || mHalfEdge[mHalfEdge[i]->getDual()]->getPoint() == -1 )
|
||||
{continue;}
|
||||
{continue;}
|
||||
|
||||
//check, if the edge belongs to a flat triangle, remove this later
|
||||
if ( !control2[i] )
|
||||
@ -796,7 +796,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
}//end of the section, which has to be removed later
|
||||
|
||||
if ( control[i] )//check, if edge has already been drawn
|
||||
{continue;}
|
||||
{continue;}
|
||||
|
||||
//draw the edge;
|
||||
if ( halfEdgeBBoxTest( i, xlowleft, lowerborder, xupright, yupright ) )//only draw the halfedge if its bounding box intersects the painted area
|
||||
@ -811,7 +811,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
}
|
||||
|
||||
|
||||
p->drawLine(( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( xupright - xlowleft )*width, ( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getY() ) / ( xupright - xlowleft )*width );
|
||||
p->drawLine( ( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( xupright - xlowleft )*width, ( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getX() - xlowleft ) / ( xupright - xlowleft )*width, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getY() ) / ( xupright - xlowleft )*width );
|
||||
|
||||
if ( mHalfEdge[i]->getForced() )
|
||||
{
|
||||
@ -830,7 +830,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
for ( unsigned int i = 0; i < mHalfEdge.count() - 1; i++ )
|
||||
{
|
||||
if ( mHalfEdge[i]->getPoint() == -1 || mHalfEdge[mHalfEdge[i]->getDual()]->getPoint() == -1 )
|
||||
{continue;}
|
||||
{continue;}
|
||||
|
||||
//check, if the edge belongs to a flat triangle, remove this section later
|
||||
if ( !control2[i] )
|
||||
@ -860,7 +860,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
|
||||
|
||||
if ( control[i] )//check, if edge has already been drawn
|
||||
{continue;}
|
||||
{continue;}
|
||||
|
||||
//draw the edge
|
||||
if ( halfEdgeBBoxTest( i, xlowleft, ylowleft, rightborder, yupright ) )//only draw the edge if its bounding box intersects with the painted area
|
||||
@ -874,7 +874,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
|
||||
p->setPen( mForcedEdgeColor );
|
||||
}
|
||||
|
||||
p->drawLine(( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( yupright - ylowleft )*height, ( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getY() ) / ( yupright - ylowleft )*height );
|
||||
p->drawLine( ( mPointVector[mHalfEdge[i]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[i]->getPoint()]->getY() ) / ( yupright - ylowleft )*height, ( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getX() - xlowleft ) / ( yupright - ylowleft )*height, ( yupright - mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()]->getY() ) / ( yupright - ylowleft )*height );
|
||||
|
||||
if ( mHalfEdge[i]->getForced() )
|
||||
{
|
||||
@ -926,7 +926,7 @@ int DualEdgeTriangulation::getOppositePoint( int p1, int p2 )
|
||||
|
||||
}
|
||||
|
||||
QList<int>* DualEdgeTriangulation::getSurroundingTriangles( int pointno )
|
||||
QList<int> *DualEdgeTriangulation::getSurroundingTriangles( int pointno )
|
||||
{
|
||||
int firstedge = baseEdgeOfPoint( pointno );
|
||||
|
||||
@ -935,7 +935,7 @@ QList<int>* DualEdgeTriangulation::getSurroundingTriangles( int pointno )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<int>* vlist = new QList<int>();//create the value list on the heap
|
||||
QList<int> *vlist = new QList<int>();//create the value list on the heap
|
||||
|
||||
int actedge = firstedge;
|
||||
int edge, nextedge, nextnextedge;
|
||||
@ -963,7 +963,7 @@ QList<int>* DualEdgeTriangulation::getSurroundingTriangles( int pointno )
|
||||
|
||||
}
|
||||
|
||||
bool DualEdgeTriangulation::getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 )
|
||||
bool DualEdgeTriangulation::getTriangle( double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3 )
|
||||
{
|
||||
if ( mPointVector.size() < 3 )
|
||||
{
|
||||
@ -1081,7 +1081,7 @@ bool DualEdgeTriangulation::getTriangle( double x, double y, Point3D* p1, int* n
|
||||
}
|
||||
}
|
||||
|
||||
bool DualEdgeTriangulation::getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 )
|
||||
bool DualEdgeTriangulation::getTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 )
|
||||
{
|
||||
if ( mPointVector.size() < 3 )
|
||||
{
|
||||
@ -1192,7 +1192,7 @@ bool DualEdgeTriangulation::getTriangle( double x, double y, Point3D* p1, Point3
|
||||
|
||||
unsigned int DualEdgeTriangulation::insertEdge( int dual, int next, int point, bool mbreak, bool forced )
|
||||
{
|
||||
HalfEdge* edge = new HalfEdge( dual, next, point, mbreak, forced );
|
||||
HalfEdge *edge = new HalfEdge( dual, next, point, mbreak, forced );
|
||||
mHalfEdge.append( edge );
|
||||
return mHalfEdge.count() - 1;
|
||||
|
||||
@ -1249,7 +1249,7 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
}
|
||||
|
||||
//test, if the forced segment is a multiple of actedge and if the direction is the same
|
||||
else if ( /*lines are parallel*/( mPointVector[p2]->getY() - mPointVector[p1]->getY() ) / ( mPointVector[mHalfEdge[actedge]->getPoint()]->getY() - mPointVector[p1]->getY() ) == ( mPointVector[p2]->getX() - mPointVector[p1]->getX() ) / ( mPointVector[mHalfEdge[actedge]->getPoint()]->getX() - mPointVector[p1]->getX() ) && (( mPointVector[p2]->getY() - mPointVector[p1]->getY() ) >= 0 ) == (( mPointVector[mHalfEdge[actedge]->getPoint()]->getY() - mPointVector[p1]->getY() ) > 0 ) && (( mPointVector[p2]->getX() - mPointVector[p1]->getX() ) >= 0 ) == (( mPointVector[mHalfEdge[actedge]->getPoint()]->getX() - mPointVector[p1]->getX() ) > 0 ) )
|
||||
else if ( /*lines are parallel*/( mPointVector[p2]->getY() - mPointVector[p1]->getY() ) / ( mPointVector[mHalfEdge[actedge]->getPoint()]->getY() - mPointVector[p1]->getY() ) == ( mPointVector[p2]->getX() - mPointVector[p1]->getX() ) / ( mPointVector[mHalfEdge[actedge]->getPoint()]->getX() - mPointVector[p1]->getX() ) && ( ( mPointVector[p2]->getY() - mPointVector[p1]->getY() ) >= 0 ) == ( ( mPointVector[mHalfEdge[actedge]->getPoint()]->getY() - mPointVector[p1]->getY() ) > 0 ) && ( ( mPointVector[p2]->getX() - mPointVector[p1]->getX() ) >= 0 ) == ( ( mPointVector[mHalfEdge[actedge]->getPoint()]->getX() - mPointVector[p1]->getX() ) > 0 ) )
|
||||
{
|
||||
//mark actedge and Dual(actedge) as forced, reset p1 and start the method from the beginning
|
||||
mHalfEdge[actedge]->setForced( true );
|
||||
@ -1275,8 +1275,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
p3 = mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getDual()]->getPoint();
|
||||
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
|
||||
double dista = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double distb = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
double dista = sqrt( ( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double distb = sqrt( ( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
if ( dista <= distb )
|
||||
{
|
||||
insertForcedSegment( p1, p3, breakline );
|
||||
@ -1297,8 +1297,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
p3 = mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getNext()]->getDual()]->getPoint();
|
||||
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
|
||||
double distpart = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
double disttot = sqrt(( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
|
||||
double distpart = sqrt( ( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
double disttot = sqrt( ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
|
||||
float frac = distpart / disttot;
|
||||
|
||||
if ( frac == 0 || frac == 1 )//just in case MathUtils::lineIntersection does not work as expected
|
||||
@ -1363,8 +1363,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
p3 = mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
|
||||
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
|
||||
double dista = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double distb = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
double dista = sqrt( ( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double distb = sqrt( ( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
if ( dista <= distb )
|
||||
{
|
||||
insertForcedSegment( p1, p3, breakline );
|
||||
@ -1385,8 +1385,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
p3 = mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
|
||||
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
|
||||
double distpart = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double disttot = sqrt(( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
|
||||
double distpart = sqrt( ( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double disttot = sqrt( ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
|
||||
float frac = distpart / disttot;
|
||||
if ( frac == 0 || frac == 1 )
|
||||
{
|
||||
@ -1410,8 +1410,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
p3 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getPoint();
|
||||
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
|
||||
double dista = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double distb = sqrt(( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
double dista = sqrt( ( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double distb = sqrt( ( crosspoint.getX() - mPointVector[p4]->getX() ) * ( crosspoint.getX() - mPointVector[p4]->getX() ) + ( crosspoint.getY() - mPointVector[p4]->getY() ) * ( crosspoint.getY() - mPointVector[p4]->getY() ) );
|
||||
if ( dista <= distb )
|
||||
{
|
||||
insertForcedSegment( p1, p3, breakline );
|
||||
@ -1432,8 +1432,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
p3 = mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[crossedEdges.last()]->getDual()]->getNext()]->getNext()]->getPoint();
|
||||
MathUtils::lineIntersection( mPointVector[p1], mPointVector[p2], mPointVector[p3], mPointVector[p4], &crosspoint );
|
||||
double distpart = sqrt(( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double disttot = sqrt(( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
|
||||
double distpart = sqrt( ( crosspoint.getX() - mPointVector[p3]->getX() ) * ( crosspoint.getX() - mPointVector[p3]->getX() ) + ( crosspoint.getY() - mPointVector[p3]->getY() ) * ( crosspoint.getY() - mPointVector[p3]->getY() ) );
|
||||
double disttot = sqrt( ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) * ( mPointVector[p3]->getX() - mPointVector[p4]->getX() ) + ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) * ( mPointVector[p3]->getY() - mPointVector[p4]->getY() ) );
|
||||
float frac = distpart / disttot;
|
||||
if ( frac == 0 || frac == 1 )
|
||||
{
|
||||
@ -1500,7 +1500,7 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
leftPolygon.append( theedge );
|
||||
}
|
||||
if ( leftiter == crossedEdges.constBegin() )
|
||||
{break;}
|
||||
{break;}
|
||||
--leftiter;
|
||||
}
|
||||
|
||||
@ -1533,7 +1533,7 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
leftiter += 2;
|
||||
for ( ; leftiter != leftPolygon.constEnd(); ++leftiter )
|
||||
{
|
||||
mHalfEdge[actedgel]->setNext(( *leftiter ) );
|
||||
mHalfEdge[actedgel]->setNext( ( *leftiter ) );
|
||||
actedgel = ( *leftiter );
|
||||
}
|
||||
|
||||
@ -1543,16 +1543,16 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
rightiter += 2;
|
||||
for ( ; rightiter != rightPolygon.constEnd(); ++rightiter )
|
||||
{
|
||||
mHalfEdge[actedger]->setNext(( *rightiter ) );
|
||||
mHalfEdge[actedger]->setNext( ( *rightiter ) );
|
||||
actedger = ( *( rightiter ) );
|
||||
}
|
||||
|
||||
|
||||
//setNext and setPoint for the forced edge because this would disturb the building of 'leftpoly' and 'rightpoly' otherwise
|
||||
mHalfEdge[leftPolygon.first()]->setNext(( *( ++( leftiter = leftPolygon.begin() ) ) ) );
|
||||
mHalfEdge[leftPolygon.first()]->setNext( ( *( ++( leftiter = leftPolygon.begin() ) ) ) );
|
||||
mHalfEdge[leftPolygon.first()]->setPoint( p2 );
|
||||
mHalfEdge[leftPolygon.last()]->setNext( firstedge );
|
||||
mHalfEdge[rightPolygon.first()]->setNext(( *( ++( rightiter = rightPolygon.begin() ) ) ) );
|
||||
mHalfEdge[rightPolygon.first()]->setNext( ( *( ++( rightiter = rightPolygon.begin() ) ) ) );
|
||||
mHalfEdge[rightPolygon.first()]->setPoint( p1 );
|
||||
mHalfEdge[rightPolygon.last()]->setNext( dualfirstedge );
|
||||
|
||||
@ -1562,7 +1562,7 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
|
||||
//optimisation of the new edges
|
||||
for ( iter = crossedEdges.begin(); iter != crossedEdges.end(); ++iter )
|
||||
{
|
||||
checkSwap(( *( iter ) ), 0 );
|
||||
checkSwap( ( *( iter ) ), 0 );
|
||||
}
|
||||
|
||||
return leftPolygon.first();
|
||||
@ -1588,7 +1588,7 @@ void DualEdgeTriangulation::setBreakEdgeColor( int r, int g, int b )
|
||||
mBreakEdgeColor.setRgb( r, g, b );
|
||||
}
|
||||
|
||||
void DualEdgeTriangulation::setTriangleInterpolator( TriangleInterpolator* interpolator )
|
||||
void DualEdgeTriangulation::setTriangleInterpolator( TriangleInterpolator *interpolator )
|
||||
{
|
||||
mTriangleInterpolator = interpolator;
|
||||
}
|
||||
@ -1601,7 +1601,7 @@ void DualEdgeTriangulation::eliminateHorizontalTriangles()
|
||||
while ( true )
|
||||
{
|
||||
bool swapped = false;//flag which allows exiting the loop
|
||||
bool* control = new bool[mHalfEdge.count()];//controlarray
|
||||
bool *control = new bool[mHalfEdge.count()];//controlarray
|
||||
|
||||
for ( int i = 0; i <= mHalfEdge.count() - 1; i++ )
|
||||
{
|
||||
@ -1643,19 +1643,19 @@ void DualEdgeTriangulation::eliminateHorizontalTriangles()
|
||||
if ( el1 == el2 && el2 == el3 )//we found a horizonal triangle
|
||||
{
|
||||
//swap edges if it is possible, if it would remove the horizontal triangle and if the minimum angle generated by the swap is high enough
|
||||
if ( swapPossible(( uint )e1 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e1]->getDual()]->getNext()]->getPoint()]->getZ() != el1 && swapMinAngle( e1 ) > minangle )
|
||||
if ( swapPossible( ( uint )e1 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e1]->getDual()]->getNext()]->getPoint()]->getZ() != el1 && swapMinAngle( e1 ) > minangle )
|
||||
{
|
||||
doOnlySwap(( uint )e1 );
|
||||
doOnlySwap( ( uint )e1 );
|
||||
swapped = true;
|
||||
}
|
||||
else if ( swapPossible(( uint )e2 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e2]->getDual()]->getNext()]->getPoint()]->getZ() != el2 && swapMinAngle( e2 ) > minangle )
|
||||
else if ( swapPossible( ( uint )e2 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e2]->getDual()]->getNext()]->getPoint()]->getZ() != el2 && swapMinAngle( e2 ) > minangle )
|
||||
{
|
||||
doOnlySwap(( uint )e2 );
|
||||
doOnlySwap( ( uint )e2 );
|
||||
swapped = true;
|
||||
}
|
||||
else if ( swapPossible(( uint )e3 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e3]->getDual()]->getNext()]->getPoint()]->getZ() != el3 && swapMinAngle( e3 ) > minangle )
|
||||
else if ( swapPossible( ( uint )e3 ) && mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[e3]->getDual()]->getNext()]->getPoint()]->getZ() != el3 && swapMinAngle( e3 ) > minangle )
|
||||
{
|
||||
doOnlySwap(( uint )e3 );
|
||||
doOnlySwap( ( uint )e3 );
|
||||
swapped = true;
|
||||
}
|
||||
control[e1] = true;
|
||||
@ -1708,7 +1708,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
|
||||
if ( mHalfEdge[next]->getPoint() != -1 && ( mHalfEdge[i]->getForced() || mHalfEdge[mHalfEdge[mHalfEdge[i]->getDual()]->getNext()]->getPoint() == -1 ) )//check for encroached points on forced segments and segments on the inner side of the convex hull, but don't consider edges on the outer side of the convex hull
|
||||
{
|
||||
if ( !(( mHalfEdge[next]->getForced() || edgeOnConvexHull( next ) ) || ( mHalfEdge[nextnext]->getForced() || edgeOnConvexHull( nextnext ) ) ) )//don't consider triangles where all three edges are forced edges or hull edges
|
||||
if ( !( ( mHalfEdge[next]->getForced() || edgeOnConvexHull( next ) ) || ( mHalfEdge[nextnext]->getForced() || edgeOnConvexHull( nextnext ) ) ) ) //don't consider triangles where all three edges are forced edges or hull edges
|
||||
{
|
||||
//test for encroachment
|
||||
while ( MathUtils::inDiametral( mPointVector[mHalfEdge[mHalfEdge[i]->getDual()]->getPoint()], mPointVector[mHalfEdge[i]->getPoint()], mPointVector[mHalfEdge[next]->getPoint()] ) )
|
||||
@ -1741,7 +1741,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
bool twoforcededges;//flag to decide, if edges should be added to the maps. Do not add them if true
|
||||
|
||||
|
||||
if (( mHalfEdge[i]->getForced() || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
|
||||
if ( ( mHalfEdge[i]->getForced() || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
|
||||
{
|
||||
twoforcededges = true;
|
||||
}
|
||||
@ -1858,7 +1858,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
//don't put the edges on the maps if two segments are forced or on a hull
|
||||
bool twoforcededges1, twoforcededges2, twoforcededges3;//flag to indicate, if angle1, angle2 and angle3 are between forced edges or hull edges
|
||||
|
||||
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
|
||||
if ( ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
|
||||
{
|
||||
twoforcededges1 = true;
|
||||
}
|
||||
@ -1867,7 +1867,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
twoforcededges1 = false;
|
||||
}
|
||||
|
||||
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
|
||||
if ( ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
|
||||
{
|
||||
twoforcededges2 = true;
|
||||
}
|
||||
@ -1876,7 +1876,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
twoforcededges2 = false;
|
||||
}
|
||||
|
||||
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
|
||||
if ( ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
|
||||
{
|
||||
twoforcededges3 = true;
|
||||
}
|
||||
@ -2028,7 +2028,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
|
||||
for ( QSet<int>::iterator it = influenceedges.begin(); it != influenceedges.end(); ++it )
|
||||
{
|
||||
if (( mHalfEdge[*it]->getForced() || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
|
||||
if ( ( mHalfEdge[*it]->getForced() || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
|
||||
{
|
||||
//split segment
|
||||
QgsDebugMsg( "segment split" );
|
||||
@ -2067,7 +2067,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
|
||||
|
||||
|
||||
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
|
||||
if ( ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
|
||||
{
|
||||
twoforcededges1 = true;
|
||||
}
|
||||
@ -2076,7 +2076,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
twoforcededges1 = false;
|
||||
}
|
||||
|
||||
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
|
||||
if ( ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
|
||||
{
|
||||
twoforcededges2 = true;
|
||||
}
|
||||
@ -2085,7 +2085,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
twoforcededges2 = false;
|
||||
}
|
||||
|
||||
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
|
||||
if ( ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
|
||||
{
|
||||
twoforcededges3 = true;
|
||||
}
|
||||
@ -2205,7 +2205,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
|
||||
/*******otherwise, try to add the circumcenter to the triangulation************************************************************************************************/
|
||||
|
||||
Point3D* p = new Point3D();
|
||||
Point3D *p = new Point3D();
|
||||
mDecorator->calcPoint( circumcenter.getX(), circumcenter.getY(), p );
|
||||
int pointno = mDecorator->addPoint( p );
|
||||
|
||||
@ -2280,7 +2280,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
//todo: put all three edges on the dontexamine list if two edges are forced or convex hull edges
|
||||
bool twoforcededges1, twoforcededges2, twoforcededges3;
|
||||
|
||||
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
|
||||
if ( ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
|
||||
{
|
||||
twoforcededges1 = true;
|
||||
}
|
||||
@ -2289,7 +2289,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
twoforcededges1 = false;
|
||||
}
|
||||
|
||||
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
|
||||
if ( ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
|
||||
{
|
||||
twoforcededges2 = true;
|
||||
}
|
||||
@ -2298,7 +2298,7 @@ void DualEdgeTriangulation::ruppertRefinement()
|
||||
twoforcededges2 = false;
|
||||
}
|
||||
|
||||
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
|
||||
if ( ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
|
||||
{
|
||||
twoforcededges3 = true;
|
||||
}
|
||||
@ -2435,10 +2435,10 @@ bool DualEdgeTriangulation::swapPossible( unsigned int edge )
|
||||
return false;
|
||||
}
|
||||
//then, test, if the edge is in the middle of a not convex quad
|
||||
Point3D* pta = mPointVector[mHalfEdge[edge]->getPoint()];
|
||||
Point3D* ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
|
||||
Point3D* ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
|
||||
Point3D* ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
|
||||
Point3D *pta = mPointVector[mHalfEdge[edge]->getPoint()];
|
||||
Point3D *ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
|
||||
Point3D *ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
|
||||
Point3D *ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
|
||||
if ( MathUtils::leftOf( ptc, pta, ptb ) > leftOfTresh )
|
||||
{
|
||||
return false;
|
||||
@ -2458,7 +2458,7 @@ bool DualEdgeTriangulation::swapPossible( unsigned int edge )
|
||||
return true;
|
||||
}
|
||||
|
||||
void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* free, int mainedge )
|
||||
void DualEdgeTriangulation::triangulatePolygon( QList<int> *poly, QList<int> *free, int mainedge )
|
||||
{
|
||||
if ( poly && free )
|
||||
{
|
||||
@ -2491,7 +2491,7 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
|
||||
int insertb = mHalfEdge[inserta]->getDual();
|
||||
free->pop_front();
|
||||
|
||||
mHalfEdge[inserta]->setNext(( poly->at( 1 ) ) );
|
||||
mHalfEdge[inserta]->setNext( ( poly->at( 1 ) ) );
|
||||
mHalfEdge[inserta]->setPoint( mHalfEdge[mainedge]->getPoint() );
|
||||
mHalfEdge[insertb]->setNext( nextdistedge );
|
||||
mHalfEdge[insertb]->setPoint( mHalfEdge[distedge]->getPoint() );
|
||||
@ -2501,7 +2501,7 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
|
||||
QList<int> polya;
|
||||
for ( iterator = ( ++( poly->constBegin() ) ); ( *iterator ) != nextdistedge; ++iterator )
|
||||
{
|
||||
polya.append(( *iterator ) );
|
||||
polya.append( ( *iterator ) );
|
||||
}
|
||||
polya.prepend( inserta );
|
||||
|
||||
@ -2522,7 +2522,7 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
|
||||
int insertb = mHalfEdge[inserta]->getDual();
|
||||
free->pop_front();
|
||||
|
||||
mHalfEdge[inserta]->setNext(( poly->at( 2 ) ) );
|
||||
mHalfEdge[inserta]->setNext( ( poly->at( 2 ) ) );
|
||||
mHalfEdge[inserta]->setPoint( mHalfEdge[distedge]->getPoint() );
|
||||
mHalfEdge[insertb]->setNext( mainedge );
|
||||
mHalfEdge[insertb]->setPoint( mHalfEdge[mHalfEdge[mainedge]->getDual()]->getPoint() );
|
||||
@ -2534,7 +2534,7 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
|
||||
iterator += 2;
|
||||
while ( iterator != poly->constEnd() )
|
||||
{
|
||||
polya.append(( *iterator ) );
|
||||
polya.append( ( *iterator ) );
|
||||
++iterator;
|
||||
}
|
||||
polya.prepend( inserta );
|
||||
@ -2552,7 +2552,7 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
|
||||
int insertd = mHalfEdge[insertc]->getDual();
|
||||
free->pop_front();
|
||||
|
||||
mHalfEdge[inserta]->setNext(( poly->at( 1 ) ) );
|
||||
mHalfEdge[inserta]->setNext( ( poly->at( 1 ) ) );
|
||||
mHalfEdge[inserta]->setPoint( mHalfEdge[mainedge]->getPoint() );
|
||||
mHalfEdge[insertb]->setNext( insertd );
|
||||
mHalfEdge[insertb]->setPoint( mHalfEdge[distedge]->getPoint() );
|
||||
@ -2571,14 +2571,14 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
|
||||
|
||||
for ( iterator = ++( poly->constBegin() ); ( *iterator ) != nextdistedge; ++iterator )
|
||||
{
|
||||
polya.append(( *iterator ) );
|
||||
polya.append( ( *iterator ) );
|
||||
}
|
||||
polya.prepend( inserta );
|
||||
|
||||
|
||||
while ( iterator != poly->constEnd() )
|
||||
{
|
||||
polyb.append(( *iterator ) );
|
||||
polyb.append( ( *iterator ) );
|
||||
++iterator;
|
||||
}
|
||||
polyb.prepend( insertc );
|
||||
@ -2719,7 +2719,7 @@ bool DualEdgeTriangulation::readFromTAFF( QString filename )
|
||||
|
||||
|
||||
//import all the DualEdges
|
||||
QProgressBar* edgebar = new QProgressBar();//use a progress dialog so that it is not boring for the user
|
||||
QProgressBar *edgebar = new QProgressBar();//use a progress dialog so that it is not boring for the user
|
||||
edgebar->setCaption( "Reading edges..." );
|
||||
edgebar->setTotalSteps( numberofhalfedges / 2 );
|
||||
edgebar->setMinimumWidth( 400 );
|
||||
@ -2783,14 +2783,14 @@ bool DualEdgeTriangulation::readFromTAFF( QString filename )
|
||||
break2 = true;
|
||||
}
|
||||
|
||||
HalfEdge* hf1 = new HalfEdge();
|
||||
HalfEdge *hf1 = new HalfEdge();
|
||||
hf1->setDual( nr2 );
|
||||
hf1->setNext( next1 );
|
||||
hf1->setPoint( point1 );
|
||||
hf1->setBreak( break1 );
|
||||
hf1->setForced( forced1 );
|
||||
|
||||
HalfEdge* hf2 = new HalfEdge();
|
||||
HalfEdge *hf2 = new HalfEdge();
|
||||
hf2->setDual( nr1 );
|
||||
hf2->setNext( next2 );
|
||||
hf2->setPoint( point2 );
|
||||
@ -2840,7 +2840,7 @@ bool DualEdgeTriangulation::readFromTAFF( QString filename )
|
||||
textstream >> buff;
|
||||
}
|
||||
|
||||
QProgressBar* pointbar = new QProgressBar();
|
||||
QProgressBar *pointbar = new QProgressBar();
|
||||
pointbar->setCaption( "Reading points..." );
|
||||
pointbar->setTotalSteps( numberofpoints );
|
||||
pointbar->setMinimumWidth( 400 );
|
||||
@ -2860,7 +2860,7 @@ bool DualEdgeTriangulation::readFromTAFF( QString filename )
|
||||
textstream >> y;
|
||||
textstream >> z;
|
||||
|
||||
Point3D* p = new Point3D( x, y, z );
|
||||
Point3D *p = new Point3D( x, y, z );
|
||||
|
||||
// QgsDebugMsg( QString( "inserting point %1" ).arg( i ) );
|
||||
mPointVector.insert( i, p );
|
||||
@ -2919,7 +2919,7 @@ bool DualEdgeTriangulation::saveToTAFF( QString filename ) const
|
||||
outstream << "PANO 1" << std::endl << std::flush;
|
||||
outstream << "DATA ";
|
||||
|
||||
bool* cont = new bool[mHalfEdge.count()];
|
||||
bool *cont = new bool[mHalfEdge.count()];
|
||||
for ( unsigned int i = 0; i <= mHalfEdge.count() - 1; i++ )
|
||||
{
|
||||
cont[i] = false;
|
||||
@ -2951,7 +2951,7 @@ bool DualEdgeTriangulation::saveToTAFF( QString filename ) const
|
||||
|
||||
for ( int i = 0; i < getNumberOfPoints(); i++ )
|
||||
{
|
||||
Point3D* p = mPointVector[i];
|
||||
Point3D *p = mPointVector[i];
|
||||
outstream << p->getX() << " " << p->getY() << " " << p->getZ() << " ";
|
||||
}
|
||||
outstream << std::endl << std::flush;
|
||||
@ -2968,9 +2968,9 @@ bool DualEdgeTriangulation::swapEdge( double x, double y )
|
||||
if ( edge1 >= 0 )
|
||||
{
|
||||
int edge2, edge3;
|
||||
Point3D* point1 = nullptr;
|
||||
Point3D* point2 = nullptr;
|
||||
Point3D* point3 = nullptr;
|
||||
Point3D *point1 = nullptr;
|
||||
Point3D *point2 = nullptr;
|
||||
Point3D *point3 = nullptr;
|
||||
edge2 = mHalfEdge[edge1]->getNext();
|
||||
edge3 = mHalfEdge[edge2]->getNext();
|
||||
point1 = getPoint( mHalfEdge[edge1]->getPoint() );
|
||||
@ -3022,7 +3022,7 @@ bool DualEdgeTriangulation::swapEdge( double x, double y )
|
||||
}
|
||||
}
|
||||
|
||||
QList<int>* DualEdgeTriangulation::getPointsAroundEdge( double x, double y )
|
||||
QList<int> *DualEdgeTriangulation::getPointsAroundEdge( double x, double y )
|
||||
{
|
||||
Point3D p( x, y, 0 );
|
||||
int p1, p2, p3, p4;
|
||||
@ -3030,9 +3030,9 @@ QList<int>* DualEdgeTriangulation::getPointsAroundEdge( double x, double y )
|
||||
if ( edge1 >= 0 )
|
||||
{
|
||||
int edge2, edge3;
|
||||
Point3D* point1 = nullptr;
|
||||
Point3D* point2 = nullptr;
|
||||
Point3D* point3 = nullptr;
|
||||
Point3D *point1 = nullptr;
|
||||
Point3D *point2 = nullptr;
|
||||
Point3D *point3 = nullptr;
|
||||
edge2 = mHalfEdge[edge1]->getNext();
|
||||
edge3 = mHalfEdge[edge2]->getNext();
|
||||
point1 = getPoint( mHalfEdge[edge1]->getPoint() );
|
||||
@ -3065,7 +3065,7 @@ QList<int>* DualEdgeTriangulation::getPointsAroundEdge( double x, double y )
|
||||
p3 = mHalfEdge[mHalfEdge[edge3]->getDual()]->getPoint();
|
||||
p4 = mHalfEdge[mHalfEdge[mHalfEdge[edge3]->getDual()]->getNext()]->getPoint();
|
||||
}
|
||||
QList<int>* list = new QList<int>();
|
||||
QList<int> *list = new QList<int>();
|
||||
list->append( p1 );
|
||||
list->append( p2 );
|
||||
list->append( p3 );
|
||||
@ -3085,7 +3085,7 @@ QList<int>* DualEdgeTriangulation::getPointsAroundEdge( double x, double y )
|
||||
}
|
||||
}
|
||||
|
||||
bool DualEdgeTriangulation::saveAsShapefile( const QString& fileName ) const
|
||||
bool DualEdgeTriangulation::saveAsShapefile( const QString &fileName ) const
|
||||
{
|
||||
QString shapeFileName = fileName;
|
||||
|
||||
@ -3127,14 +3127,14 @@ bool DualEdgeTriangulation::saveAsShapefile( const QString& fileName ) const
|
||||
|
||||
for ( int i = 0; i < mHalfEdge.size(); ++i )
|
||||
{
|
||||
HalfEdge* currentEdge = mHalfEdge[i];
|
||||
HalfEdge *currentEdge = mHalfEdge[i];
|
||||
if ( currentEdge->getPoint() != -1 && mHalfEdge[currentEdge->getDual()]->getPoint() != -1 && !alreadyVisitedEdges[currentEdge->getDual()] )
|
||||
{
|
||||
QgsFeature edgeLineFeature;
|
||||
|
||||
//geometry
|
||||
Point3D* p1 = mPointVector[currentEdge->getPoint()];
|
||||
Point3D* p2 = mPointVector[mHalfEdge[currentEdge->getDual()]->getPoint()];
|
||||
Point3D *p1 = mPointVector[currentEdge->getPoint()];
|
||||
Point3D *p2 = mPointVector[mHalfEdge[currentEdge->getDual()]->getPoint()];
|
||||
QgsPolyline lineGeom;
|
||||
lineGeom.push_back( QgsPoint( p1->getX(), p1->getY() ) );
|
||||
lineGeom.push_back( QgsPoint( p2->getX(), p2->getY() ) );
|
||||
@ -3168,10 +3168,10 @@ bool DualEdgeTriangulation::saveAsShapefile( const QString& fileName ) const
|
||||
|
||||
double DualEdgeTriangulation::swapMinAngle( int edge ) const
|
||||
{
|
||||
Point3D* p1 = getPoint( mHalfEdge[edge]->getPoint() );
|
||||
Point3D* p2 = getPoint( mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint() );
|
||||
Point3D* p3 = getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() );
|
||||
Point3D* p4 = getPoint( mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint() );
|
||||
Point3D *p1 = getPoint( mHalfEdge[edge]->getPoint() );
|
||||
Point3D *p2 = getPoint( mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint() );
|
||||
Point3D *p3 = getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() );
|
||||
Point3D *p4 = getPoint( mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint() );
|
||||
|
||||
//search for the minimum angle (it is important, which directions the lines have!)
|
||||
double minangle;
|
||||
@ -3215,7 +3215,7 @@ int DualEdgeTriangulation::splitHalfEdge( int edge, float position )
|
||||
}
|
||||
|
||||
//create the new point on the heap
|
||||
Point3D* p = new Point3D( mPointVector[mHalfEdge[edge]->getPoint()]->getX()*position + mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()]->getX()*( 1 - position ), mPointVector[mHalfEdge[edge]->getPoint()]->getY()*position + mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()]->getY()*( 1 - position ), 0 );
|
||||
Point3D *p = new Point3D( mPointVector[mHalfEdge[edge]->getPoint()]->getX()*position + mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()]->getX() * ( 1 - position ), mPointVector[mHalfEdge[edge]->getPoint()]->getY()*position + mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()]->getY() * ( 1 - position ), 0 );
|
||||
|
||||
//calculate the z-value of the point to insert
|
||||
Point3D zvaluepoint;
|
||||
@ -3266,7 +3266,7 @@ bool DualEdgeTriangulation::edgeOnConvexHull( int edge )
|
||||
return ( mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint() == -1 || mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint() == -1 );
|
||||
}
|
||||
|
||||
void DualEdgeTriangulation::evaluateInfluenceRegion( Point3D* point, int edge, QSet<int> &set )
|
||||
void DualEdgeTriangulation::evaluateInfluenceRegion( Point3D *point, int edge, QSet<int> &set )
|
||||
{
|
||||
if ( set.find( edge ) == set.end() )
|
||||
{
|
||||
|
@ -39,32 +39,32 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
{
|
||||
public:
|
||||
DualEdgeTriangulation();
|
||||
DualEdgeTriangulation( int nop, Triangulation* decorator );
|
||||
DualEdgeTriangulation( int nop, Triangulation *decorator );
|
||||
virtual ~DualEdgeTriangulation();
|
||||
void setDecorator( Triangulation* d ) {mDecorator = d;}
|
||||
void setDecorator( Triangulation *d ) {mDecorator = d;}
|
||||
//! Adds a line (e.g. a break-, structure- or an isoline) to the triangulation. The class takes ownership of the line object and its points
|
||||
void addLine( Line3D* line, bool breakline ) override;
|
||||
void addLine( Line3D *line, bool breakline ) override;
|
||||
//! Adds a point to the triangulation and returns the number of this point in case of success or -100 in case of failure
|
||||
int addPoint( Point3D* p ) override;
|
||||
int addPoint( Point3D *p ) override;
|
||||
//! Performs a consistency check, remove this later
|
||||
virtual void performConsistencyTest() override;
|
||||
//! Calculates the normal at a point on the surface
|
||||
virtual bool calcNormal( double x, double y, Vector3D* result ) override;
|
||||
virtual bool calcNormal( double x, double y, Vector3D *result ) override;
|
||||
//! Calculates x-, y and z-value of the point on the surface
|
||||
virtual bool calcPoint( double x, double y, Point3D* result ) override;
|
||||
virtual bool calcPoint( double x, double y, Point3D *result ) override;
|
||||
//! Draws the points, edges and the forced lines
|
||||
//virtual void draw(QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height) const;
|
||||
//! Returns a pointer to the point with number i
|
||||
virtual Point3D* getPoint( unsigned int i ) const override;
|
||||
virtual Point3D *getPoint( unsigned int i ) const override;
|
||||
//! Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge)
|
||||
int getOppositePoint( int p1, int p2 ) override;
|
||||
//! Finds out, in which triangle the point with coordinates x and y is and assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'
|
||||
//! @note not available in python bindings
|
||||
virtual bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 ) override;
|
||||
virtual bool getTriangle( double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3 ) override;
|
||||
//! Finds out, in which triangle the point with coordinates x and y is and assigns addresses to the points at the vertices to 'p1', 'p2' and 'p3
|
||||
virtual bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 ) override;
|
||||
virtual bool getTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 ) override;
|
||||
//! Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point. Four integer values describe a triangle, the first three are the number of the half edges of the triangle and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise. The value list has to be deleted by the code which called the method
|
||||
QList<int>* getSurroundingTriangles( int pointno ) override;
|
||||
QList<int> *getSurroundingTriangles( int pointno ) override;
|
||||
//! Returns the largest x-coordinate value of the bounding box
|
||||
virtual double getXMax() const override { return xMax; }
|
||||
//! Returns the smallest x-coordinate value of the bounding box
|
||||
@ -84,7 +84,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Sets the color of the breaklines
|
||||
virtual void setBreakEdgeColor( int r, int g, int b ) override;
|
||||
//! Sets an interpolator object
|
||||
void setTriangleInterpolator( TriangleInterpolator* interpolator ) override;
|
||||
void setTriangleInterpolator( TriangleInterpolator *interpolator ) override;
|
||||
//! Eliminates the horizontal triangles by swapping or by insertion of new points
|
||||
void eliminateHorizontalTriangles() override;
|
||||
//! Adds points to make the triangles better shaped (algorithm of ruppert)
|
||||
@ -98,11 +98,11 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Swaps the edge which is closest to the point with x and y coordinates (if this is possible)
|
||||
virtual bool swapEdge( double x, double y ) override;
|
||||
//! Returns a value list with the numbers of the four points, which would be affected by an edge swap. This function is e.g. needed by NormVecDecorator to know the points, for which the normals have to be recalculated. The returned ValueList has to be deleted by the code which calls the method
|
||||
virtual QList<int>* getPointsAroundEdge( double x, double y ) override;
|
||||
virtual QList<int> *getPointsAroundEdge( double x, double y ) override;
|
||||
|
||||
/** Saves the triangulation as a (line) shapefile
|
||||
@return true in case of success*/
|
||||
virtual bool saveAsShapefile( const QString& fileName ) const override;
|
||||
virtual bool saveAsShapefile( const QString &fileName ) const override;
|
||||
|
||||
protected:
|
||||
//! X-coordinate of the upper right corner of the bounding box
|
||||
@ -116,13 +116,13 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Default value for the number of storable points at the beginning
|
||||
static const unsigned int DEFAULT_STORAGE_FOR_POINTS = 100000;
|
||||
//! Stores pointers to all points in the triangulations (including the points contained in the lines)
|
||||
QVector<Point3D*> mPointVector;
|
||||
QVector<Point3D *> mPointVector;
|
||||
//! Default value for the number of storable HalfEdges at the beginning
|
||||
static const unsigned int DEFAULT_STORAGE_FOR_HALF_EDGES = 300006;
|
||||
//! Stores pointers to the HalfEdges
|
||||
QVector<HalfEdge*> mHalfEdge;
|
||||
QVector<HalfEdge *> mHalfEdge;
|
||||
//! Association to an interpolator object
|
||||
TriangleInterpolator* mTriangleInterpolator = nullptr;
|
||||
TriangleInterpolator *mTriangleInterpolator = nullptr;
|
||||
//! Member to store the behavior in case of crossing forced segments
|
||||
Triangulation::ForcedCrossBehavior mForcedCrossBehavior;
|
||||
//! Color to paint the normal edges
|
||||
@ -132,7 +132,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Color to paint the breaklines
|
||||
QColor mBreakEdgeColor;
|
||||
//! Pointer to the decorator using this triangulation. It it is used directly, mDecorator equals this
|
||||
Triangulation* mDecorator = nullptr;
|
||||
Triangulation *mDecorator = nullptr;
|
||||
//! Inserts an edge and makes sure, everything is ok with the storage of the edge. The number of the HalfEdge is returned
|
||||
unsigned int insertEdge( int dual, int next, int point, bool mbreak, bool forced );
|
||||
//! Inserts a forced segment between the points with the numbers p1 and p2 into the triangulation and returns the number of a HalfEdge belonging to this forced edge or -100 in case of failure
|
||||
@ -144,7 +144,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Returns the number of an edge which points to the point with number 'point' or -1 if there is an error
|
||||
int baseEdgeOfPoint( int point );
|
||||
//! Returns the number of a HalfEdge from a triangle in which 'point' is in. If the number -10 is returned, this means, that 'point' is outside the convex hull. If -5 is returned, then numerical problems with the leftOfTest occurred (and the value of the possible edge is stored in the variable 'mUnstableEdge'. -20 means, that the inserted point is exactly on an edge (the number is stored in the variable 'mEdgeWithPoint'). -25 means, that the point is already in the triangulation (the number of the point is stored in the member 'mTwiceInsPoint'. If -100 is returned, this means that something else went wrong
|
||||
int baseEdgeOfTriangle( Point3D* point );
|
||||
int baseEdgeOfTriangle( Point3D *point );
|
||||
//! Checks, if 'edge' has to be swapped because of the empty circle criterion. If so, doSwap(...) is called.
|
||||
bool checkSwap( unsigned int edge, unsigned int recursiveDeep );
|
||||
//! Swaps 'edge' and test recursively for other swaps (delaunay criterion)
|
||||
@ -164,7 +164,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Returns true, if it is possible to swap an edge, otherwise false(concave quad or edge on (or outside) the convex hull)
|
||||
bool swapPossible( unsigned int edge );
|
||||
//! Divides a polygon in a triangle and two polygons and calls itself recursively for these two polygons. 'poly' is a pointer to a list with the numbers of the edges of the polygon, 'free' is a pointer to a list of free halfedges, and 'mainedge' is the number of the edge, towards which the new triangle is inserted. Mainedge has to be the same as poly->begin(), otherwise the recursion does not work
|
||||
void triangulatePolygon( QList<int>* poly, QList<int>* free, int mainedge );
|
||||
void triangulatePolygon( QList<int> *poly, QList<int> *free, int mainedge );
|
||||
//! Tests, if the bounding box of the halfedge with index i intersects the specified bounding box. The main purpose for this method is the drawing of the triangulation
|
||||
bool halfEdgeBBoxTest( int edge, double xlowleft, double ylowleft, double xupright, double yupright ) const;
|
||||
//! Calculates the minimum angle, which would be present, if the specified halfedge would be swapped
|
||||
@ -174,46 +174,46 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
|
||||
//! Returns true, if a half edge is on the convex hull and false otherwise
|
||||
bool edgeOnConvexHull( int edge );
|
||||
//! Function needed for the ruppert algorithm. Tests, if point is in the circle through both endpoints of edge and the endpoint of edge->dual->next->point. If so, the function calls itself recursively for edge->next and edge->next->next. Stops, if it finds a forced edge or a convex hull edge
|
||||
void evaluateInfluenceRegion( Point3D* point, int edge, QSet<int> &set );
|
||||
void evaluateInfluenceRegion( Point3D *point, int edge, QSet<int> &set );
|
||||
};
|
||||
|
||||
inline DualEdgeTriangulation::DualEdgeTriangulation()
|
||||
: xMax( 0 )
|
||||
, xMin( 0 )
|
||||
, yMax( 0 )
|
||||
, yMin( 0 )
|
||||
, mTriangleInterpolator( nullptr )
|
||||
, mForcedCrossBehavior( Triangulation::DeleteFirst )
|
||||
, mEdgeColor( 0, 255, 0 )
|
||||
, mForcedEdgeColor( 0, 0, 255 )
|
||||
, mBreakEdgeColor( 100, 100, 0 )
|
||||
, mDecorator( this )
|
||||
, mEdgeInside( 0 )
|
||||
, mEdgeOutside( 0 )
|
||||
, mEdgeWithPoint( 0 )
|
||||
, mUnstableEdge( 0 )
|
||||
, mTwiceInsPoint( 0 )
|
||||
: xMax( 0 )
|
||||
, xMin( 0 )
|
||||
, yMax( 0 )
|
||||
, yMin( 0 )
|
||||
, mTriangleInterpolator( nullptr )
|
||||
, mForcedCrossBehavior( Triangulation::DeleteFirst )
|
||||
, mEdgeColor( 0, 255, 0 )
|
||||
, mForcedEdgeColor( 0, 0, 255 )
|
||||
, mBreakEdgeColor( 100, 100, 0 )
|
||||
, mDecorator( this )
|
||||
, mEdgeInside( 0 )
|
||||
, mEdgeOutside( 0 )
|
||||
, mEdgeWithPoint( 0 )
|
||||
, mUnstableEdge( 0 )
|
||||
, mTwiceInsPoint( 0 )
|
||||
{
|
||||
mPointVector.reserve( DEFAULT_STORAGE_FOR_POINTS );
|
||||
mHalfEdge.reserve( DEFAULT_STORAGE_FOR_HALF_EDGES );
|
||||
}
|
||||
|
||||
inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* decorator )
|
||||
: xMax( 0 )
|
||||
, xMin( 0 )
|
||||
, yMax( 0 )
|
||||
, yMin( 0 )
|
||||
, mTriangleInterpolator( nullptr )
|
||||
, mForcedCrossBehavior( Triangulation::DeleteFirst )
|
||||
, mEdgeColor( 0, 255, 0 )
|
||||
, mForcedEdgeColor( 0, 0, 255 )
|
||||
, mBreakEdgeColor( 100, 100, 0 )
|
||||
, mDecorator( decorator ? decorator : this )
|
||||
, mEdgeInside( 0 )
|
||||
, mEdgeOutside( 0 )
|
||||
, mEdgeWithPoint( 0 )
|
||||
, mUnstableEdge( 0 )
|
||||
, mTwiceInsPoint( 0 )
|
||||
inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation *decorator )
|
||||
: xMax( 0 )
|
||||
, xMin( 0 )
|
||||
, yMax( 0 )
|
||||
, yMin( 0 )
|
||||
, mTriangleInterpolator( nullptr )
|
||||
, mForcedCrossBehavior( Triangulation::DeleteFirst )
|
||||
, mEdgeColor( 0, 255, 0 )
|
||||
, mForcedEdgeColor( 0, 0, 255 )
|
||||
, mBreakEdgeColor( 100, 100, 0 )
|
||||
, mDecorator( decorator ? decorator : this )
|
||||
, mEdgeInside( 0 )
|
||||
, mEdgeOutside( 0 )
|
||||
, mEdgeWithPoint( 0 )
|
||||
, mUnstableEdge( 0 )
|
||||
, mTwiceInsPoint( 0 )
|
||||
{
|
||||
mPointVector.reserve( nop );
|
||||
mHalfEdge.reserve( nop );
|
||||
@ -224,7 +224,7 @@ inline int DualEdgeTriangulation::getNumberOfPoints() const
|
||||
return mPointVector.count();
|
||||
}
|
||||
|
||||
inline Point3D* DualEdgeTriangulation::getPoint( unsigned int i ) const
|
||||
inline Point3D *DualEdgeTriangulation::getPoint( unsigned int i ) const
|
||||
{
|
||||
return mPointVector.at( i );
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "LinTriangleInterpolator.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
bool LinTriangleInterpolator::calcFirstDerX( double x, double y, Vector3D* vec )
|
||||
bool LinTriangleInterpolator::calcFirstDerX( double x, double y, Vector3D *vec )
|
||||
{
|
||||
|
||||
if ( vec && mTIN )
|
||||
@ -33,7 +33,7 @@ bool LinTriangleInterpolator::calcFirstDerX( double x, double y, Vector3D* vec )
|
||||
|
||||
vec->setX( 1.0 );
|
||||
vec->setY( 0.0 );
|
||||
vec->setZ(( pt1.getZ()*( pt2.getY() - pt3.getY() ) + pt2.getZ()*( pt3.getY() - pt1.getY() ) + pt3.getZ()*( pt1.getY() - pt2.getY() ) ) / (( pt1.getX() - pt2.getX() )*( pt2.getY() - pt3.getY() ) - ( pt2.getX() - pt3.getX() )*( pt1.getY() - pt2.getY() ) ) );
|
||||
vec->setZ( ( pt1.getZ() * ( pt2.getY() - pt3.getY() ) + pt2.getZ() * ( pt3.getY() - pt1.getY() ) + pt3.getZ() * ( pt1.getY() - pt2.getY() ) ) / ( ( pt1.getX() - pt2.getX() ) * ( pt2.getY() - pt3.getY() ) - ( pt2.getX() - pt3.getX() ) * ( pt1.getY() - pt2.getY() ) ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ bool LinTriangleInterpolator::calcFirstDerX( double x, double y, Vector3D* vec )
|
||||
}
|
||||
}
|
||||
|
||||
bool LinTriangleInterpolator::calcFirstDerY( double x, double y, Vector3D* vec )
|
||||
bool LinTriangleInterpolator::calcFirstDerY( double x, double y, Vector3D *vec )
|
||||
{
|
||||
if ( vec && mTIN )
|
||||
{
|
||||
@ -59,7 +59,7 @@ bool LinTriangleInterpolator::calcFirstDerY( double x, double y, Vector3D* vec )
|
||||
|
||||
vec->setX( 0 );
|
||||
vec->setY( 1.0 );
|
||||
vec->setZ(( pt1.getZ()*( pt2.getX() - pt3.getX() ) + pt2.getZ()*( pt3.getX() - pt1.getX() ) + pt3.getZ()*( pt1.getX() - pt2.getX() ) ) / (( pt1.getY() - pt2.getY() )*( pt2.getX() - pt3.getX() ) - ( pt2.getY() - pt3.getY() )*( pt1.getX() - pt2.getX() ) ) );
|
||||
vec->setZ( ( pt1.getZ() * ( pt2.getX() - pt3.getX() ) + pt2.getZ() * ( pt3.getX() - pt1.getX() ) + pt3.getZ() * ( pt1.getX() - pt2.getX() ) ) / ( ( pt1.getY() - pt2.getY() ) * ( pt2.getX() - pt3.getX() ) - ( pt2.getY() - pt3.getY() ) * ( pt1.getX() - pt2.getX() ) ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ bool LinTriangleInterpolator::calcFirstDerY( double x, double y, Vector3D* vec )
|
||||
}
|
||||
}
|
||||
|
||||
bool LinTriangleInterpolator::calcNormVec( double x, double y, Vector3D* vec )
|
||||
bool LinTriangleInterpolator::calcNormVec( double x, double y, Vector3D *vec )
|
||||
{
|
||||
//calculate vector product of the two derivative vectors in x- and y-direction and set the length to 1
|
||||
if ( vec && mTIN )
|
||||
@ -78,9 +78,9 @@ bool LinTriangleInterpolator::calcNormVec( double x, double y, Vector3D* vec )
|
||||
Vector3D vec1;
|
||||
Vector3D vec2;
|
||||
if ( !calcFirstDerX( x, y, &vec1 ) )
|
||||
{return false;}
|
||||
{return false;}
|
||||
if ( !calcFirstDerY( x, y, &vec2 ) )
|
||||
{return false;}
|
||||
{return false;}
|
||||
Vector3D vec3( vec1.getY()*vec2.getZ() - vec1.getZ()*vec2.getY(), vec1.getZ()*vec2.getX() - vec1.getX()*vec2.getZ(), vec1.getX()*vec2.getY() - vec1.getY()*vec2.getX() );//calculate vector product
|
||||
double absvec3 = sqrt( vec3.getX() * vec3.getX() + vec3.getY() * vec3.getY() + vec3.getZ() * vec3.getZ() );//length of vec3
|
||||
vec->setX( vec3.getX() / absvec3 );//standardize vec3 and assign it to vec
|
||||
@ -98,7 +98,7 @@ bool LinTriangleInterpolator::calcNormVec( double x, double y, Vector3D* vec )
|
||||
}
|
||||
|
||||
|
||||
bool LinTriangleInterpolator::calcPoint( double x, double y, Point3D* point )
|
||||
bool LinTriangleInterpolator::calcPoint( double x, double y, Point3D *point )
|
||||
{
|
||||
if ( point && mTIN )
|
||||
{
|
||||
@ -111,13 +111,13 @@ bool LinTriangleInterpolator::calcPoint( double x, double y, Point3D* point )
|
||||
return false;//point is outside the convex hull or numerical problems
|
||||
}
|
||||
|
||||
double a = ( pt1.getZ() * ( pt2.getY() - pt3.getY() ) + pt2.getZ() * ( pt3.getY() - pt1.getY() ) + pt3.getZ() * ( pt1.getY() - pt2.getY() ) ) / (( pt1.getX() - pt2.getX() ) * ( pt2.getY() - pt3.getY() ) - ( pt2.getX() - pt3.getX() ) * ( pt1.getY() - pt2.getY() ) );
|
||||
double b = ( pt1.getZ() * ( pt2.getX() - pt3.getX() ) + pt2.getZ() * ( pt3.getX() - pt1.getX() ) + pt3.getZ() * ( pt1.getX() - pt2.getX() ) ) / (( pt1.getY() - pt2.getY() ) * ( pt2.getX() - pt3.getX() ) - ( pt2.getY() - pt3.getY() ) * ( pt1.getX() - pt2.getX() ) );
|
||||
double a = ( pt1.getZ() * ( pt2.getY() - pt3.getY() ) + pt2.getZ() * ( pt3.getY() - pt1.getY() ) + pt3.getZ() * ( pt1.getY() - pt2.getY() ) ) / ( ( pt1.getX() - pt2.getX() ) * ( pt2.getY() - pt3.getY() ) - ( pt2.getX() - pt3.getX() ) * ( pt1.getY() - pt2.getY() ) );
|
||||
double b = ( pt1.getZ() * ( pt2.getX() - pt3.getX() ) + pt2.getZ() * ( pt3.getX() - pt1.getX() ) + pt3.getZ() * ( pt1.getX() - pt2.getX() ) ) / ( ( pt1.getY() - pt2.getY() ) * ( pt2.getX() - pt3.getX() ) - ( pt2.getY() - pt3.getY() ) * ( pt1.getX() - pt2.getX() ) );
|
||||
double c = pt1.getZ() - a * pt1.getX() - b * pt1.getY();
|
||||
|
||||
point->setX( x );
|
||||
point->setY( y );
|
||||
point->setZ( a*x + b*y + c );
|
||||
point->setZ( a * x + b * y + c );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -29,33 +29,33 @@ class ANALYSIS_EXPORT LinTriangleInterpolator : public TriangleInterpolator
|
||||
//! Default constructor
|
||||
LinTriangleInterpolator();
|
||||
//! Constructor with reference to a DualEdgeTriangulation object
|
||||
LinTriangleInterpolator( DualEdgeTriangulation* tin );
|
||||
LinTriangleInterpolator( DualEdgeTriangulation *tin );
|
||||
virtual ~LinTriangleInterpolator();
|
||||
//! Calculates the normal vector and assigns it to vec
|
||||
virtual bool calcNormVec( double x, double y, Vector3D* result ) override;
|
||||
virtual bool calcNormVec( double x, double y, Vector3D *result ) override;
|
||||
//! Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point
|
||||
virtual bool calcPoint( double x, double y, Point3D* result ) override;
|
||||
virtual bool calcPoint( double x, double y, Point3D *result ) override;
|
||||
//! Returns a pointer to the current Triangulation object
|
||||
virtual DualEdgeTriangulation* getTriangulation() const;
|
||||
virtual DualEdgeTriangulation *getTriangulation() const;
|
||||
//! Sets a Triangulation
|
||||
virtual void setTriangulation( DualEdgeTriangulation* tin );
|
||||
virtual void setTriangulation( DualEdgeTriangulation *tin );
|
||||
|
||||
|
||||
protected:
|
||||
DualEdgeTriangulation* mTIN = nullptr;
|
||||
DualEdgeTriangulation *mTIN = nullptr;
|
||||
//! Calculates the first derivative with respect to x for a linear surface and assigns it to vec
|
||||
virtual bool calcFirstDerX( double x, double y, Vector3D* result );
|
||||
virtual bool calcFirstDerX( double x, double y, Vector3D *result );
|
||||
//! Calculates the first derivative with respect to y for a linear surface and assigns it to vec
|
||||
virtual bool calcFirstDerY( double x, double y, Vector3D* result );
|
||||
virtual bool calcFirstDerY( double x, double y, Vector3D *result );
|
||||
};
|
||||
|
||||
inline LinTriangleInterpolator::LinTriangleInterpolator()
|
||||
: mTIN( nullptr )
|
||||
: mTIN( nullptr )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline LinTriangleInterpolator::LinTriangleInterpolator( DualEdgeTriangulation* tin ): mTIN( tin )
|
||||
inline LinTriangleInterpolator::LinTriangleInterpolator( DualEdgeTriangulation *tin ): mTIN( tin )
|
||||
{
|
||||
|
||||
}
|
||||
@ -65,12 +65,12 @@ inline LinTriangleInterpolator::~LinTriangleInterpolator()
|
||||
|
||||
}
|
||||
|
||||
inline DualEdgeTriangulation* LinTriangleInterpolator::getTriangulation() const
|
||||
inline DualEdgeTriangulation *LinTriangleInterpolator::getTriangulation() const
|
||||
{
|
||||
return mTIN;
|
||||
}
|
||||
|
||||
inline void LinTriangleInterpolator::setTriangulation( DualEdgeTriangulation* tin )
|
||||
inline void LinTriangleInterpolator::setTriangulation( DualEdgeTriangulation *tin )
|
||||
{
|
||||
mTIN = tin;
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ bool Line3D::empty() const
|
||||
return ( head->getNext() == z );
|
||||
}
|
||||
|
||||
void Line3D::insertPoint( Point3D* p )
|
||||
void Line3D::insertPoint( Point3D *p )
|
||||
{
|
||||
if ( currentNode != z )//we can't insert a node behind the z-node
|
||||
{
|
||||
//create a new Node after the current Node
|
||||
Node* thenode = new Node();
|
||||
Node *thenode = new Node();
|
||||
thenode->setPoint( p );
|
||||
thenode->setNext( currentNode->getNext() );
|
||||
currentNode->setNext( thenode );
|
||||
@ -64,7 +64,7 @@ void Line3D::insertPoint( Point3D* p )
|
||||
|
||||
void Line3D::removePoint()
|
||||
{
|
||||
Node* x = currentNode->getNext();
|
||||
Node *x = currentNode->getNext();
|
||||
if ( x != z )//don't remove the end node of the list
|
||||
{
|
||||
currentNode->setNext( x->getNext() );
|
||||
|
@ -26,13 +26,13 @@ class ANALYSIS_EXPORT Line3D
|
||||
{
|
||||
private:
|
||||
//! Copy constructor, declared private to not use it
|
||||
Line3D( const Line3D& );
|
||||
Line3D( const Line3D & );
|
||||
//! Assignment operator, declared private to not use it
|
||||
Line3D& operator=( const Line3D& );
|
||||
Line3D &operator=( const Line3D & );
|
||||
protected:
|
||||
Node* head = nullptr;
|
||||
Node* z = nullptr;
|
||||
Node* currentNode = nullptr;
|
||||
Node *head = nullptr;
|
||||
Node *z = nullptr;
|
||||
Node *currentNode = nullptr;
|
||||
unsigned int size;
|
||||
unsigned int current;
|
||||
|
||||
@ -42,11 +42,11 @@ class ANALYSIS_EXPORT Line3D
|
||||
//! Returns true, if the Line contains no Point3D, otherwise false
|
||||
bool empty() const;
|
||||
//! Inserts a node behind the current position and sets the current position to this new node
|
||||
void insertPoint( Point3D* p );
|
||||
void insertPoint( Point3D *p );
|
||||
//! Removes the point behind the current position
|
||||
void removePoint();
|
||||
//! Gets the point at the current position
|
||||
Point3D* getPoint() const;
|
||||
Point3D *getPoint() const;
|
||||
//! Returns the current position
|
||||
unsigned int getCurrent() const;
|
||||
//! Returns the size of the line (the numbero of inserted Nodes without 'head' and 'z'
|
||||
@ -57,12 +57,12 @@ class ANALYSIS_EXPORT Line3D
|
||||
void goToNext();
|
||||
};
|
||||
|
||||
inline Line3D::Line3D( const Line3D& )
|
||||
inline Line3D::Line3D( const Line3D & )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline Line3D& Line3D::operator=( const Line3D& )
|
||||
inline Line3D &Line3D::operator=( const Line3D & )
|
||||
{
|
||||
return ( *this );
|
||||
}
|
||||
@ -72,7 +72,7 @@ inline unsigned int Line3D::getCurrent() const
|
||||
return current;
|
||||
}
|
||||
|
||||
inline Point3D* Line3D::getPoint() const
|
||||
inline Point3D *Line3D::getPoint() const
|
||||
{
|
||||
return ( currentNode->getPoint() );
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
bool MathUtils::calcBarycentricCoordinates( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result )
|
||||
bool MathUtils::calcBarycentricCoordinates( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result )
|
||||
{
|
||||
if ( p1 && p2 && p3 && result )
|
||||
{
|
||||
@ -50,7 +50,7 @@ bool MathUtils::calcBarycentricCoordinates( double x, double y, Point3D* p1, Poi
|
||||
}
|
||||
}
|
||||
|
||||
bool MathUtils::BarycentricToXY( double u, double v, double w, Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result )//this is wrong at the moment. Furthermore, the case, where the denominators are 0 have to be treated (two ways of calculating px and py)
|
||||
bool MathUtils::BarycentricToXY( double u, double v, double w, Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result )//this is wrong at the moment. Furthermore, the case, where the denominators are 0 have to be treated (two ways of calculating px and py)
|
||||
{
|
||||
Q_UNUSED( w );
|
||||
|
||||
@ -65,11 +65,11 @@ bool MathUtils::BarycentricToXY( double u, double v, double w, Point3D* p1, Poin
|
||||
return false;
|
||||
}
|
||||
|
||||
double denominator = (( p2->getY() - p3->getY() ) * ( p1->getX() - p3->getX() ) - ( p3->getY() - p1->getY() ) * ( p3->getX() - p2->getX() ) );
|
||||
double denominator = ( ( p2->getY() - p3->getY() ) * ( p1->getX() - p3->getX() ) - ( p3->getY() - p1->getY() ) * ( p3->getX() - p2->getX() ) );
|
||||
if ( denominator != 0 )//drop out py in the two equations
|
||||
{
|
||||
px = ( 2 * u * area * ( p1->getX() - p3->getX() ) - 2 * v * area * ( p3->getX() - p2->getX() ) - p2->getX() * p3->getY() * ( p1->getX() - p3->getX() ) + p3->getX() * p1->getY() * ( p3->getX() - p2->getX() ) + p3->getX() * p2->getY() * ( p1->getX() - p3->getX() ) - p1->getX() * p3->getY() * ( p3->getX() - p2->getX() ) ) / denominator;
|
||||
if (( p3->getX() - p2->getX() ) != 0 )
|
||||
if ( ( p3->getX() - p2->getX() ) != 0 )
|
||||
{
|
||||
py = ( 2 * u * area - px * ( p2->getY() - p3->getY() ) - p2->getX() * p3->getY() + p3->getX() * p2->getY() ) / ( p3->getX() - p2->getX() );
|
||||
}
|
||||
@ -80,8 +80,8 @@ bool MathUtils::BarycentricToXY( double u, double v, double w, Point3D* p1, Poin
|
||||
}
|
||||
else//dorp out px in the two equations(maybe this possibility occurs only, if p1, p2 and p3 are coplanar
|
||||
{
|
||||
py = ( 2 * u * area * ( p3->getY() - p1->getY() ) - 2 * v * area * ( p2->getY() - p3->getY() ) - p2->getX() * p3->getY() * ( p3->getY() - p1->getY() ) + p3->getX() * p1->getY() * ( p2->getY() - p3->getY() ) + p3->getX() * p2->getY() * ( p3->getY() - p1->getY() ) - p1->getX() * p3->getY() * ( p2->getY() - p3->getY() ) ) / (( p3->getX() - p2->getX() ) * ( p3->getY() - p1->getY() ) - ( p1->getX() - p3->getX() ) * ( p2->getY() - p3->getY() ) );
|
||||
if (( p2->getY() - p3->getY() ) != 0 )
|
||||
py = ( 2 * u * area * ( p3->getY() - p1->getY() ) - 2 * v * area * ( p2->getY() - p3->getY() ) - p2->getX() * p3->getY() * ( p3->getY() - p1->getY() ) + p3->getX() * p1->getY() * ( p2->getY() - p3->getY() ) + p3->getX() * p2->getY() * ( p3->getY() - p1->getY() ) - p1->getX() * p3->getY() * ( p2->getY() - p3->getY() ) ) / ( ( p3->getX() - p2->getX() ) * ( p3->getY() - p1->getY() ) - ( p1->getX() - p3->getX() ) * ( p2->getY() - p3->getY() ) );
|
||||
if ( ( p2->getY() - p3->getY() ) != 0 )
|
||||
{
|
||||
px = ( 2 * u * area - py * ( p3->getX() - p2->getX() ) - p2->getX() * p3->getY() + p3->getX() * p2->getY() ) / ( p2->getY() - p3->getY() );
|
||||
}
|
||||
@ -108,24 +108,24 @@ double MathUtils::calcBernsteinPoly( int n, int i, double t )
|
||||
return 0;
|
||||
}
|
||||
|
||||
return lower( n, i )*qPow( t, i )*qPow(( 1 - t ), ( n - i ) );
|
||||
return lower( n, i ) * qPow( t, i ) * qPow( ( 1 - t ), ( n - i ) );
|
||||
}
|
||||
|
||||
double MathUtils::cFDerBernsteinPoly( int n, int i, double t )
|
||||
{
|
||||
return n*( calcBernsteinPoly( n - 1, i - 1, t ) - calcBernsteinPoly( n - 1, i, t ) );
|
||||
return n * ( calcBernsteinPoly( n - 1, i - 1, t ) - calcBernsteinPoly( n - 1, i, t ) );
|
||||
}
|
||||
|
||||
bool MathUtils::circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result )//version using the property that the distances from p1, p2, p3 to the circumcenter have to be equal. Possibly there is a bug
|
||||
bool MathUtils::circumcenter( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result )//version using the property that the distances from p1, p2, p3 to the circumcenter have to be equal. Possibly there is a bug
|
||||
{
|
||||
if ( p1 && p2 && p3 && result )
|
||||
{
|
||||
double distp1p2 = sqrt(( p1->getX() - p2->getX() ) * ( p1->getX() - p2->getX() ) + ( p1->getY() - p2->getY() ) * ( p1->getY() - p2->getY() ) );
|
||||
double distp2p3 = sqrt(( p2->getX() - p3->getX() ) * ( p2->getX() - p3->getX() ) + ( p2->getY() - p3->getY() ) * ( p2->getY() - p3->getY() ) );
|
||||
double distp1p2 = sqrt( ( p1->getX() - p2->getX() ) * ( p1->getX() - p2->getX() ) + ( p1->getY() - p2->getY() ) * ( p1->getY() - p2->getY() ) );
|
||||
double distp2p3 = sqrt( ( p2->getX() - p3->getX() ) * ( p2->getX() - p3->getX() ) + ( p2->getY() - p3->getY() ) * ( p2->getY() - p3->getY() ) );
|
||||
if ( distp1p2 > distp2p3 )
|
||||
{
|
||||
//swap p1 and p3 to avoid round-off errors
|
||||
Point3D* temp = p1;
|
||||
Point3D *temp = p1;
|
||||
p1 = p3;
|
||||
p3 = temp;
|
||||
}
|
||||
@ -138,14 +138,14 @@ bool MathUtils::circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* re
|
||||
}
|
||||
else
|
||||
{
|
||||
result->setX( 0.5*( p1->getX()*p1->getX()*p2->getY() - p1->getX()*p1->getX()*p3->getY() - p3->getX()*p3->getX()*p2->getY() - p1->getY()*p2->getX()*p2->getX() - p1->getY()*p1->getY()*p3->getY() - p3->getY()*p3->getY()*p2->getY() + p1->getY()*p1->getY()*p2->getY() + p3->getY()*p2->getX()*p2->getX() - p1->getY()*p2->getY()*p2->getY() + p1->getY()*p3->getY()*p3->getY() + p1->getY()*p3->getX()*p3->getX() + p3->getY()*p2->getY()*p2->getY() ) / denominator );
|
||||
result->setY( -0.5*( p3->getX()*p2->getX()*p2->getX() + p2->getX()*p1->getY()*p1->getY() + p3->getX()*p2->getY()*p2->getY() - p3->getX()*p1->getX()*p1->getX() + p1->getX()*p3->getY()*p3->getY() - p3->getX()*p1->getY()*p1->getY() - p1->getX()*p2->getX()*p2->getX() - p2->getX()*p3->getY()*p3->getY() - p1->getX()*p2->getY()*p2->getY() - p2->getX()*p3->getX()*p3->getX() + p1->getX()*p3->getX()*p3->getX() + p2->getX()*p1->getX()*p1->getX() ) / denominator );
|
||||
result->setX( 0.5 * ( p1->getX()*p1->getX()*p2->getY() - p1->getX()*p1->getX()*p3->getY() - p3->getX()*p3->getX()*p2->getY() - p1->getY()*p2->getX()*p2->getX() - p1->getY()*p1->getY()*p3->getY() - p3->getY()*p3->getY()*p2->getY() + p1->getY()*p1->getY()*p2->getY() + p3->getY()*p2->getX()*p2->getX() - p1->getY()*p2->getY()*p2->getY() + p1->getY()*p3->getY()*p3->getY() + p1->getY()*p3->getX()*p3->getX() + p3->getY()*p2->getY()*p2->getY() ) / denominator );
|
||||
result->setY( -0.5 * ( p3->getX()*p2->getX()*p2->getX() + p2->getX()*p1->getY()*p1->getY() + p3->getX()*p2->getY()*p2->getY() - p3->getX()*p1->getX()*p1->getX() + p1->getX()*p3->getY()*p3->getY() - p3->getX()*p1->getY()*p1->getY() - p1->getX()*p2->getX()*p2->getX() - p2->getX()*p3->getY()*p3->getY() - p1->getX()*p2->getY()*p2->getY() - p2->getX()*p3->getX()*p3->getX() + p1->getX()*p3->getX()*p3->getX() + p2->getX()*p1->getX()*p1->getX() ) / denominator );
|
||||
|
||||
#if 0
|
||||
//debugging: test, if the distances from p1, p2, p3 to result are equal
|
||||
double dist1 = sqrt(( p1->getX() - result->getX() ) * ( p1->getX() - result->getX() ) + ( p1->getY() - result->getY() ) * ( p1->getY() - result->getY() ) );
|
||||
double dist2 = sqrt(( p2->getX() - result->getX() ) * ( p2->getX() - result->getX() ) + ( p2->getY() - result->getY() ) * ( p2->getY() - result->getY() ) );
|
||||
double dist3 = sqrt(( p3->getX() - result->getX() ) * ( p3->getX() - result->getX() ) + ( p3->getY() - result->getY() ) * ( p3->getY() - result->getY() ) );
|
||||
double dist1 = sqrt( ( p1->getX() - result->getX() ) * ( p1->getX() - result->getX() ) + ( p1->getY() - result->getY() ) * ( p1->getY() - result->getY() ) );
|
||||
double dist2 = sqrt( ( p2->getX() - result->getX() ) * ( p2->getX() - result->getX() ) + ( p2->getY() - result->getY() ) * ( p2->getY() - result->getY() ) );
|
||||
double dist3 = sqrt( ( p3->getX() - result->getX() ) * ( p3->getX() - result->getX() ) + ( p3->getY() - result->getY() ) * ( p3->getY() - result->getY() ) );
|
||||
|
||||
if ( dist1 - dist2 > 1 || dist2 - dist1 > 1 || dist1 - dist3 > 1 || dist3 - dist1 > 1 )
|
||||
{
|
||||
@ -164,12 +164,12 @@ bool MathUtils::circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* re
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool MathUtils::circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result )//version imitating the geometric construction
|
||||
bool MathUtils::circumcenter( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result )//version imitating the geometric construction
|
||||
{
|
||||
if ( p1 && p2 && p3 && result )
|
||||
{
|
||||
Point3D midpoint12(( p1->getX() + p2->getX() ) / 2, ( p1->getY() + p2->getY() ) / 2, 0 );
|
||||
Point3D midpoint23(( p2->getX() + p3->getX() ) / 2, ( p2->getY() + p3->getY() ) / 2, 0 );
|
||||
Point3D midpoint12( ( p1->getX() + p2->getX() ) / 2, ( p1->getY() + p2->getY() ) / 2, 0 );
|
||||
Point3D midpoint23( ( p2->getX() + p3->getX() ) / 2, ( p2->getY() + p3->getY() ) / 2, 0 );
|
||||
Vector3D v12( p2->getX() - p1->getX(), p2->getY() - p1->getY(), 0 );
|
||||
Vector3D v23( p3->getX() - p2->getX(), p3->getY() - p2->getY(), 0 );
|
||||
Vector3D n12;
|
||||
@ -181,9 +181,9 @@ bool MathUtils::circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* re
|
||||
MathUtils::lineIntersection( &midpoint12, &helppoint1, &midpoint23, &helppoint2, result );
|
||||
|
||||
//debugging: test, if the distances from p1, p2, p3 to result are equal
|
||||
double dist1 = sqrt(( p1->getX() - result->getX() ) * ( p1->getX() - result->getX() ) + ( p1->getY() - result->getY() ) * ( p1->getY() - result->getY() ) );
|
||||
double dist2 = sqrt(( p2->getX() - result->getX() ) * ( p2->getX() - result->getX() ) + ( p2->getY() - result->getY() ) * ( p2->getY() - result->getY() ) );
|
||||
double dist3 = sqrt(( p3->getX() - result->getX() ) * ( p3->getX() - result->getX() ) + ( p3->getY() - result->getY() ) * ( p3->getY() - result->getY() ) );
|
||||
double dist1 = sqrt( ( p1->getX() - result->getX() ) * ( p1->getX() - result->getX() ) + ( p1->getY() - result->getY() ) * ( p1->getY() - result->getY() ) );
|
||||
double dist2 = sqrt( ( p2->getX() - result->getX() ) * ( p2->getX() - result->getX() ) + ( p2->getY() - result->getY() ) * ( p2->getY() - result->getY() ) );
|
||||
double dist3 = sqrt( ( p3->getX() - result->getX() ) * ( p3->getX() - result->getX() ) + ( p3->getY() - result->getY() ) * ( p3->getY() - result->getY() ) );
|
||||
|
||||
if ( dist1 - dist2 > 1 || dist2 - dist1 > 1 || dist1 - dist3 > 1 || dist3 - dist1 > 1 )
|
||||
{
|
||||
@ -201,7 +201,7 @@ bool MathUtils::circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* re
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
double MathUtils::distPointFromLine( Point3D* thepoint, Point3D* p1, Point3D* p2 )
|
||||
double MathUtils::distPointFromLine( Point3D *thepoint, Point3D *p1, Point3D *p2 )
|
||||
{
|
||||
if ( thepoint && p1 && p2 )
|
||||
{
|
||||
@ -211,7 +211,7 @@ double MathUtils::distPointFromLine( Point3D* thepoint, Point3D* p1, Point3D* p2
|
||||
double a = normal.getX();
|
||||
double b = normal.getY();
|
||||
double c = -( normal.getX() * p2->getX() + normal.getY() * p2->getY() );
|
||||
double distance = qAbs(( a * thepoint->getX() + b * thepoint->getY() + c ) / ( sqrt( a * a + b * b ) ) );
|
||||
double distance = qAbs( ( a * thepoint->getX() + b * thepoint->getY() + c ) / ( sqrt( a * a + b * b ) ) );
|
||||
return distance;
|
||||
}
|
||||
else
|
||||
@ -232,7 +232,7 @@ int MathUtils::faculty( int n )
|
||||
int result = n;
|
||||
|
||||
if ( n == 0 || n == 1 )
|
||||
{return 1;}//faculty of 0 is 1!
|
||||
{return 1;}//faculty of 0 is 1!
|
||||
|
||||
for ( i = n - 1; i >= 2; i-- )
|
||||
{
|
||||
@ -241,7 +241,7 @@ int MathUtils::faculty( int n )
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3 )
|
||||
bool MathUtils::inCircle( Point3D *testp, Point3D *p1, Point3D *p2, Point3D *p3 )
|
||||
{
|
||||
double tolerance = 0.0001;//if the amount of aValue is below this, testp is approximately on the circle and we have to define another criterion to tell, if it is inside or outside.
|
||||
|
||||
@ -268,9 +268,9 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
|
||||
py -= ymin;
|
||||
|
||||
double aValue = ( ax * ax + ay * ay ) * triArea( p2, p3, testp );
|
||||
aValue = aValue - (( bx * bx + by * by ) * triArea( p1, p3, testp ) );
|
||||
aValue = aValue + (( cx * cx + cy * cy ) * triArea( p1, p2, testp ) );
|
||||
aValue = aValue - (( px * px + py * py ) * triArea( p1, p2, p3 ) );
|
||||
aValue = aValue - ( ( bx * bx + by * by ) * triArea( p1, p3, testp ) );
|
||||
aValue = aValue + ( ( cx * cx + cy * cy ) * triArea( p1, p2, testp ) );
|
||||
aValue = aValue - ( ( px * px + py * py ) * triArea( p1, p2, p3 ) );
|
||||
|
||||
return aValue > tolerance;
|
||||
}
|
||||
@ -281,19 +281,19 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
|
||||
}
|
||||
}
|
||||
|
||||
bool MathUtils::inDiametral( Point3D* p1, Point3D* p2, Point3D* point )
|
||||
bool MathUtils::inDiametral( Point3D *p1, Point3D *p2, Point3D *point )
|
||||
{
|
||||
return angle( p1, point, p2, point ) > 90;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool MathUtils::inDiametral( Point3D* p1, Point3D* p2, Point3D* point )
|
||||
bool MathUtils::inDiametral( Point3D *p1, Point3D *p2, Point3D *point )
|
||||
{
|
||||
if ( p1 && p2 && point )
|
||||
{
|
||||
Vector3D p1p2( p2->getX() - p1->getX(), p2->getY() - p1->getY(), 0 );
|
||||
Vector3D orthogonalvec;//vector orthogonal to p1p2 (length radius)
|
||||
Point3D midpoint(( p1->getX() + p2->getX() ) / 2, ( p1->getY() + p2->getY() ) / 2, 0 );
|
||||
Point3D midpoint( ( p1->getX() + p2->getX() ) / 2, ( p1->getY() + p2->getY() ) / 2, 0 );
|
||||
double radius = p1p2.getLength() / 2;
|
||||
normalLeft( &p1p2, &orthogonalvec, radius );
|
||||
Point3D p3( midpoint.getX() + orthogonalvec.getX(), midpoint.getY() + orthogonalvec.getY(), 0 );
|
||||
@ -307,7 +307,7 @@ bool MathUtils::inDiametral( Point3D* p1, Point3D* p2, Point3D* point )
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
double MathUtils::leftOf( Point3D* thepoint, Point3D* p1, Point3D* p2 )
|
||||
double MathUtils::leftOf( Point3D *thepoint, Point3D *p1, Point3D *p2 )
|
||||
{
|
||||
if ( thepoint && p1 && p2 )
|
||||
{
|
||||
@ -316,7 +316,7 @@ double MathUtils::leftOf( Point3D* thepoint, Point3D* p1, Point3D* p2 )
|
||||
double f2 = p2->getY() - p1->getY();
|
||||
double f3 = thepoint->getY() - p1->getY();
|
||||
double f4 = p2->getX() - p1->getX();
|
||||
return f1*f2 - f3*f4;
|
||||
return f1 * f2 - f3 * f4;
|
||||
//return thepoint->getX()-p1->getX())*(p2->getY()-p1->getY())-(thepoint->getY()-p1->getY())*(p2->getX()-p1->getX();//calculating the vectorproduct
|
||||
}
|
||||
else
|
||||
@ -326,19 +326,19 @@ double MathUtils::leftOf( Point3D* thepoint, Point3D* p1, Point3D* p2 )
|
||||
}
|
||||
}
|
||||
|
||||
bool MathUtils::lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* p4 )
|
||||
bool MathUtils::lineIntersection( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4 )
|
||||
{
|
||||
if ( p1 && p2 && p3 && p4 )
|
||||
{
|
||||
double t1, t2;
|
||||
Vector3D p1p2( p2->getX() - p1->getX(), p2->getY() - p1->getY(), 0 );
|
||||
Vector3D p3p4( p4->getX() - p3->getX(), p4->getY() - p3->getY(), 0 );
|
||||
if (( p3p4.getX()*p1p2.getY() - p3p4.getY()*p1p2.getX() ) != 0 && p1p2.getX() != 0 )//avoid division through zero
|
||||
if ( ( p3p4.getX()*p1p2.getY() - p3p4.getY()*p1p2.getX() ) != 0 && p1p2.getX() != 0 ) //avoid division through zero
|
||||
{
|
||||
t2 = ( p1->getX() * p1p2.getY() - p1->getY() * p1p2.getX() + p3->getY() * p1p2.getX() - p3->getX() * p1p2.getY() ) / ( p3p4.getX() * p1p2.getY() - p3p4.getY() * p1p2.getX() );
|
||||
t1 = ( p3->getX() - p1->getX() + t2 * p3p4.getX() ) / p1p2.getX();
|
||||
}
|
||||
else if (( p1p2.getX()*p3p4.getY() - p1p2.getY()*p3p4.getX() ) != 0 && p3p4.getX() != 0 )
|
||||
else if ( ( p1p2.getX()*p3p4.getY() - p1p2.getY()*p3p4.getX() ) != 0 && p3p4.getX() != 0 )
|
||||
{
|
||||
t1 = ( p3->getX() * p3p4.getY() - p3->getY() * p3p4.getX() - p1->getX() * p3p4.getY() + p1->getY() * p3p4.getX() ) / ( p1p2.getX() * p3p4.getY() - p1p2.getY() * p3p4.getX() );
|
||||
t2 = ( p1->getX() + t1 * p1p2.getX() - p3->getX() ) / p3p4.getX();
|
||||
@ -348,9 +348,9 @@ bool MathUtils::lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( t1 > 0 && t1<1 && t2>0 && t2 < 1 )
|
||||
if ( t1 > 0 && t1 < 1 && t2 > 0 && t2 < 1 )
|
||||
{
|
||||
if (( *p1 ) == ( *p3 ) || ( *p1 ) == ( *p4 ) || ( *p2 ) == ( *p3 ) || ( *p2 ) == ( *p4 ) )//the lines touch each other, so they do not cross
|
||||
if ( ( *p1 ) == ( *p3 ) || ( *p1 ) == ( *p4 ) || ( *p2 ) == ( *p3 ) || ( *p2 ) == ( *p4 ) ) //the lines touch each other, so they do not cross
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -369,19 +369,19 @@ bool MathUtils::lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D
|
||||
}
|
||||
}
|
||||
|
||||
bool MathUtils::lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* p4, Point3D* intersection_point )
|
||||
bool MathUtils::lineIntersection( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4, Point3D *intersection_point )
|
||||
{
|
||||
if ( p1 && p2 && p3 && p4 )
|
||||
{
|
||||
double t1, t2;
|
||||
Vector3D p1p2( p2->getX() - p1->getX(), p2->getY() - p1->getY(), 0 );
|
||||
Vector3D p3p4( p4->getX() - p3->getX(), p4->getY() - p3->getY(), 0 );
|
||||
if (( p3p4.getX()*p1p2.getY() - p3p4.getY()*p1p2.getX() ) != 0 && p1p2.getX() != 0 )//avoid division through zero
|
||||
if ( ( p3p4.getX()*p1p2.getY() - p3p4.getY()*p1p2.getX() ) != 0 && p1p2.getX() != 0 ) //avoid division through zero
|
||||
{
|
||||
t2 = ( p1->getX() * p1p2.getY() - p1->getY() * p1p2.getX() + p3->getY() * p1p2.getX() - p3->getX() * p1p2.getY() ) / ( p3p4.getX() * p1p2.getY() - p3p4.getY() * p1p2.getX() );
|
||||
t1 = ( p3->getX() - p1->getX() + t2 * p3p4.getX() ) / p1p2.getX();
|
||||
}
|
||||
else if (( p1p2.getX()*p3p4.getY() - p1p2.getY()*p3p4.getX() ) != 0 && p3p4.getX() != 0 )
|
||||
else if ( ( p1p2.getX()*p3p4.getY() - p1p2.getY()*p3p4.getX() ) != 0 && p3p4.getX() != 0 )
|
||||
{
|
||||
t1 = ( p3->getX() * p3p4.getY() - p3->getY() * p3p4.getX() - p1->getX() * p3p4.getY() + p1->getY() * p3p4.getX() ) / ( p1p2.getX() * p3p4.getY() - p1p2.getY() * p3p4.getX() );
|
||||
t2 = ( p1->getX() + t1 * p1p2.getX() - p3->getX() ) / p3p4.getX();
|
||||
@ -394,9 +394,9 @@ bool MathUtils::lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( t1 > 0 && t1<1 && t2>0 && t2 < 1 )
|
||||
if ( t1 > 0 && t1 < 1 && t2 > 0 && t2 < 1 )
|
||||
{
|
||||
if (( *p1 ) == ( *p3 ) || ( *p1 ) == ( *p4 ) || ( *p2 ) == ( *p3 ) || ( *p2 ) == ( *p4 ) )//the lines touch each other, so they do not cross
|
||||
if ( ( *p1 ) == ( *p3 ) || ( *p1 ) == ( *p4 ) || ( *p2 ) == ( *p3 ) || ( *p2 ) == ( *p4 ) ) //the lines touch each other, so they do not cross
|
||||
{
|
||||
intersection_point->setX( 0 );
|
||||
intersection_point->setY( 0 );
|
||||
@ -404,8 +404,8 @@ bool MathUtils::lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D
|
||||
return false;
|
||||
}
|
||||
//calculate the intersection point
|
||||
intersection_point->setX( p1->getX()*( 1 - t1 ) + p2->getX()*t1 );
|
||||
intersection_point->setY( p1->getY()*( 1 - t1 ) + p2->getY()*t1 );
|
||||
intersection_point->setX( p1->getX() * ( 1 - t1 ) + p2->getX()*t1 );
|
||||
intersection_point->setY( p1->getY() * ( 1 - t1 ) + p2->getY()*t1 );
|
||||
intersection_point->setZ( 0 );
|
||||
return true;
|
||||
}
|
||||
@ -426,7 +426,7 @@ int MathUtils::lower( int n, int i )
|
||||
{
|
||||
if ( i >= 0 && i <= n )
|
||||
{
|
||||
return faculty( n ) / ( faculty( i )*faculty( n - i ) );
|
||||
return faculty( n ) / ( faculty( i ) * faculty( n - i ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -472,7 +472,7 @@ double MathUtils::power( double a, int b )
|
||||
return 1;
|
||||
}
|
||||
double tmp = a;
|
||||
for ( int i = 2; i <= qAbs(( double )b ); i++ )
|
||||
for ( int i = 2; i <= qAbs( ( double )b ); i++ )
|
||||
{
|
||||
|
||||
a *= tmp;
|
||||
@ -487,12 +487,12 @@ double MathUtils::power( double a, int b )
|
||||
}
|
||||
}
|
||||
|
||||
double MathUtils::triArea( Point3D* pa, Point3D* pb, Point3D* pc )
|
||||
double MathUtils::triArea( Point3D *pa, Point3D *pb, Point3D *pc )
|
||||
{
|
||||
if ( pa && pb && pc )
|
||||
{
|
||||
double deter = ( pa->getX() * pb->getY() + pb->getX() * pc->getY() + pc->getX() * pa->getY() - pa->getX() * pc->getY() - pb->getX() * pa->getY() - pc->getX() * pb->getY() );
|
||||
return 0.5*deter;
|
||||
return 0.5 * deter;
|
||||
}
|
||||
else//null pointer
|
||||
{
|
||||
@ -515,12 +515,12 @@ double MathUtils::calcCubicHermitePoly( int n, int i, double t )
|
||||
|
||||
if ( n == 3 && i == 1 )
|
||||
{
|
||||
return ( calcBernsteinPoly( 3, 1, t )*0.33333333 );
|
||||
return ( calcBernsteinPoly( 3, 1, t ) * 0.33333333 );
|
||||
}
|
||||
|
||||
if ( n == 3 && i == 2 )
|
||||
{
|
||||
return ( calcBernsteinPoly( 3, 2, t )* -0.33333333 );
|
||||
return ( calcBernsteinPoly( 3, 2, t ) * -0.33333333 );
|
||||
}
|
||||
|
||||
if ( n == 3 && i == 3 )
|
||||
@ -573,7 +573,7 @@ double MathUtils::cFDerCubicHermitePoly( int n, int i, double t )
|
||||
}
|
||||
}
|
||||
|
||||
bool MathUtils::derVec( const Vector3D* v1, const Vector3D* v2, Vector3D* result, double x, double y )
|
||||
bool MathUtils::derVec( const Vector3D *v1, const Vector3D *v2, Vector3D *result, double x, double y )
|
||||
{
|
||||
if ( v1 && v2 && result )//no null pointers
|
||||
{
|
||||
@ -581,14 +581,14 @@ bool MathUtils::derVec( const Vector3D* v1, const Vector3D* v2, Vector3D* result
|
||||
double v = ( x * v1->getY() - y * v1->getX() ) / ( v2->getX() * v1->getY() - v2->getY() * v1->getX() );
|
||||
result->setX( x );
|
||||
result->setY( y );
|
||||
result->setZ( u*v1->getZ() + v*v2->getZ() );
|
||||
result->setZ( u * v1->getZ() + v * v2->getZ() );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathUtils::normalLeft( Vector3D* v1, Vector3D* result, double length )
|
||||
bool MathUtils::normalLeft( Vector3D *v1, Vector3D *result, double length )
|
||||
{
|
||||
if ( v1 && result )//we don't like null pointers
|
||||
{
|
||||
@ -620,8 +620,8 @@ bool MathUtils::normalLeft( Vector3D* v1, Vector3D* result, double length )
|
||||
return false;
|
||||
}
|
||||
|
||||
result->setX(( -b + sqrt( d ) ) / ( 2*a ) );//take one of the two solutions of the quadratic equation
|
||||
result->setY(( -result->getX()*v1->getX() ) / v1->getY() );
|
||||
result->setX( ( -b + sqrt( d ) ) / ( 2 * a ) ); //take one of the two solutions of the quadratic equation
|
||||
result->setY( ( -result->getX()*v1->getX() ) / v1->getY() );
|
||||
|
||||
Point3D point1( 0, 0, 0 );
|
||||
Point3D point2( v1->getX(), v1->getY(), 0 );
|
||||
@ -644,7 +644,7 @@ bool MathUtils::normalLeft( Vector3D* v1, Vector3D* result, double length )
|
||||
|
||||
|
||||
|
||||
bool MathUtils::normalRight( Vector3D* v1, Vector3D* result, double length )
|
||||
bool MathUtils::normalRight( Vector3D *v1, Vector3D *result, double length )
|
||||
{
|
||||
if ( v1 && result )//we don't like null pointers
|
||||
{
|
||||
@ -677,14 +677,14 @@ bool MathUtils::normalRight( Vector3D* v1, Vector3D* result, double length )
|
||||
return false;
|
||||
}
|
||||
|
||||
result->setX(( -b + sqrt( d ) ) / ( 2*a ) );//take one of the two solutions of the quadratic equation
|
||||
result->setY(( -result->getX()*v1->getX() ) / v1->getY() );
|
||||
result->setX( ( -b + sqrt( d ) ) / ( 2 * a ) ); //take one of the two solutions of the quadratic equation
|
||||
result->setY( ( -result->getX()*v1->getX() ) / v1->getY() );
|
||||
|
||||
Point3D point1( 0, 0, 0 );
|
||||
Point3D point2( v1->getX(), v1->getY(), 0 );
|
||||
Point3D point3( result->getX(), result->getY(), 0 );
|
||||
|
||||
if (( leftOf( &point1, &point2, &point3 ) < 0 ) )//if we took the solution on the right side, change the sign of the components of the result
|
||||
if ( ( leftOf( &point1, &point2, &point3 ) < 0 ) ) //if we took the solution on the right side, change the sign of the components of the result
|
||||
{
|
||||
result->setX( -result->getX() );
|
||||
result->setY( -result->getY() );
|
||||
@ -700,7 +700,7 @@ bool MathUtils::normalRight( Vector3D* v1, Vector3D* result, double length )
|
||||
}
|
||||
|
||||
|
||||
void MathUtils::normalFromPoints( Point3D* p1, Point3D* p2, Point3D* p3, Vector3D* vec )
|
||||
void MathUtils::normalFromPoints( Point3D *p1, Point3D *p2, Point3D *p3, Vector3D *vec )
|
||||
{
|
||||
if ( p1 && p2 && p3 && vec )//no null pointers
|
||||
{
|
||||
@ -711,18 +711,18 @@ void MathUtils::normalFromPoints( Point3D* p1, Point3D* p2, Point3D* p3, Vector3
|
||||
double by = p3->getY() - p1->getY();
|
||||
double bz = p3->getZ() - p1->getZ();
|
||||
|
||||
vec->setX( ay*bz - az*by );
|
||||
vec->setY( az*bx - ax*bz );
|
||||
vec->setZ( ax*by - ay*bx );
|
||||
vec->setX( ay * bz - az * by );
|
||||
vec->setY( az * bx - ax * bz );
|
||||
vec->setZ( ax * by - ay * bx );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double MathUtils::crossVec( Point3D* first, Vector3D* vec1, Point3D* second, Vector3D* vec2 )
|
||||
double MathUtils::crossVec( Point3D *first, Vector3D *vec1, Point3D *second, Vector3D *vec2 )
|
||||
{
|
||||
if ( first && vec1 && second && vec2 )
|
||||
{
|
||||
if (( vec2->getX()*vec1->getY() - vec2->getY()*vec1->getX() ) != 0 )
|
||||
if ( ( vec2->getX()*vec1->getY() - vec2->getY()*vec1->getX() ) != 0 )
|
||||
{
|
||||
/*cout << "first: " << first->getX() << "//" << first->getY() << "//" << first->getZ() << endl << flush;
|
||||
cout << "vec1: " << vec1->getX() << "//" << vec1->getY() << "//" << vec1->getZ() << endl << flush;
|
||||
@ -730,7 +730,7 @@ double MathUtils::crossVec( Point3D* first, Vector3D* vec1, Point3D* second, Vec
|
||||
cout << "vec2: " << vec2->getX() << "//" << vec2->getY() << "//" << vec2->getZ() << endl << flush;
|
||||
cout << "t2: " << ((first->getX()*vec1->getY()-first->getY()*vec1->getX()-second->getX()*vec1->getY()+second->getY()*vec1->getX())/(vec2->getX()*vec1->getY()-vec2->getY()*vec1->getX())) << endl << flush;*/
|
||||
|
||||
return (( first->getX()*vec1->getY() - first->getY()*vec1->getX() - second->getX()*vec1->getY() + second->getY()*vec1->getX() ) / ( vec2->getX()*vec1->getY() - vec2->getY()*vec1->getX() ) );
|
||||
return ( ( first->getX() * vec1->getY() - first->getY() * vec1->getX() - second->getX() * vec1->getY() + second->getY() * vec1->getX() ) / ( vec2->getX() * vec1->getY() - vec2->getY() * vec1->getX() ) );
|
||||
|
||||
}
|
||||
else//if a division by zero would occur
|
||||
@ -748,7 +748,7 @@ double MathUtils::crossVec( Point3D* first, Vector3D* vec1, Point3D* second, Vec
|
||||
}
|
||||
}
|
||||
|
||||
bool MathUtils::pointInsideTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 )
|
||||
bool MathUtils::pointInsideTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 )
|
||||
{
|
||||
Point3D thepoint( x, y, 0 );
|
||||
if ( MathUtils::leftOf( &thepoint, p1, p2 ) > 0 )
|
||||
@ -766,7 +766,7 @@ bool MathUtils::pointInsideTriangle( double x, double y, Point3D* p1, Point3D* p
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MathUtils::normalMinDistance( Vector3D* tangent, Vector3D* target, Vector3D* result )
|
||||
bool MathUtils::normalMinDistance( Vector3D *tangent, Vector3D *target, Vector3D *result )
|
||||
{
|
||||
if ( tangent && target && result )
|
||||
{
|
||||
@ -811,8 +811,8 @@ bool MathUtils::normalMinDistance( Vector3D* tangent, Vector3D* target, Vector3D
|
||||
zg1 = -sqrt( zgalpha1 ) * ( yt * yw * zt - yt * yt * zw + xw * zt * xt - xt * xt * zw );
|
||||
zg2 = sqrt( zgalpha1 ) * ( yt * yw * zt - yt * yt * zw + xw * zt * xt - xt * xt * zw );
|
||||
|
||||
double distance1 = sqrt(( xw - xg1 ) * ( xw - xg1 ) + ( yw - yg1 ) * ( yw - yg1 ) + ( zw - zg1 ) * ( zw - zg1 ) );
|
||||
double distance2 = sqrt(( xw - xg2 ) * ( xw - xg2 ) + ( yw - yg2 ) * ( yw - yg2 ) + ( zw - zg2 ) * ( zw - zg2 ) );
|
||||
double distance1 = sqrt( ( xw - xg1 ) * ( xw - xg1 ) + ( yw - yg1 ) * ( yw - yg1 ) + ( zw - zg1 ) * ( zw - zg1 ) );
|
||||
double distance2 = sqrt( ( xw - xg2 ) * ( xw - xg2 ) + ( yw - yg2 ) * ( yw - yg2 ) + ( zw - zg2 ) * ( zw - zg2 ) );
|
||||
|
||||
if ( distance1 <= distance2 )//find out, which solution is the maximum and which the minimum
|
||||
{
|
||||
@ -837,12 +837,12 @@ bool MathUtils::normalMinDistance( Vector3D* tangent, Vector3D* target, Vector3D
|
||||
}
|
||||
|
||||
|
||||
double MathUtils::planeTest( Point3D* test, Point3D* pt1, Point3D* pt2, Point3D* pt3 )
|
||||
double MathUtils::planeTest( Point3D *test, Point3D *pt1, Point3D *pt2, Point3D *pt3 )
|
||||
{
|
||||
if ( test && pt1 && pt2 && pt3 )
|
||||
{
|
||||
double a = ( pt1->getZ() * ( pt2->getY() - pt3->getY() ) + pt2->getZ() * ( pt3->getY() - pt1->getY() ) + pt3->getZ() * ( pt1->getY() - pt2->getY() ) ) / (( pt1->getX() - pt2->getX() ) * ( pt2->getY() - pt3->getY() ) - ( pt2->getX() - pt3->getX() ) * ( pt1->getY() - pt2->getY() ) );
|
||||
double b = ( pt1->getZ() * ( pt2->getX() - pt3->getX() ) + pt2->getZ() * ( pt3->getX() - pt1->getX() ) + pt3->getZ() * ( pt1->getX() - pt2->getX() ) ) / (( pt1->getY() - pt2->getY() ) * ( pt2->getX() - pt3->getX() ) - ( pt2->getY() - pt3->getY() ) * ( pt1->getX() - pt2->getX() ) );
|
||||
double a = ( pt1->getZ() * ( pt2->getY() - pt3->getY() ) + pt2->getZ() * ( pt3->getY() - pt1->getY() ) + pt3->getZ() * ( pt1->getY() - pt2->getY() ) ) / ( ( pt1->getX() - pt2->getX() ) * ( pt2->getY() - pt3->getY() ) - ( pt2->getX() - pt3->getX() ) * ( pt1->getY() - pt2->getY() ) );
|
||||
double b = ( pt1->getZ() * ( pt2->getX() - pt3->getX() ) + pt2->getZ() * ( pt3->getX() - pt1->getX() ) + pt3->getZ() * ( pt1->getX() - pt2->getX() ) ) / ( ( pt1->getY() - pt2->getY() ) * ( pt2->getX() - pt3->getX() ) - ( pt2->getY() - pt3->getY() ) * ( pt1->getX() - pt2->getX() ) );
|
||||
double c = pt1->getZ() - a * pt1->getX() - b * pt1->getY();
|
||||
double zpredicted = test->getX() * a + test->getY() * b + c;
|
||||
return ( test->getZ() - zpredicted );
|
||||
@ -854,13 +854,13 @@ double MathUtils::planeTest( Point3D* test, Point3D* pt1, Point3D* pt2, Point3D*
|
||||
}
|
||||
}
|
||||
|
||||
double MathUtils::angle( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* p4 )
|
||||
double MathUtils::angle( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4 )
|
||||
{
|
||||
if ( p1 && p2 && p3 && p4 )
|
||||
{
|
||||
Vector3D v1( p2->getX() - p1->getX(), p2->getY() - p1->getY(), 0 );
|
||||
Vector3D v2( p4->getX() - p3->getX(), p4->getY() - p3->getY(), 0 );
|
||||
double value = acos(( v1.getX() * v2.getX() + v1.getY() * v2.getY() ) / ( v1.getLength() * v2.getLength() ) ) * 180 / M_PI;
|
||||
double value = acos( ( v1.getX() * v2.getX() + v1.getY() * v2.getY() ) / ( v1.getLength() * v2.getLength() ) ) * 180 / M_PI;
|
||||
return value;
|
||||
}
|
||||
else
|
||||
|
@ -26,8 +26,8 @@ class Vector3D;
|
||||
namespace MathUtils
|
||||
{
|
||||
//! Calculates the barycentric coordinates of a point (x,y) with respect to p1, p2, p3 and stores the three barycentric coordinates in 'result'. Thus the u-coordinate is stored in result::x, the v-coordinate in result::y and the w-coordinate in result::z. Attention: p1, p2 and p3 have to be ordered counterclockwise
|
||||
bool ANALYSIS_EXPORT calcBarycentricCoordinates( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result );
|
||||
bool ANALYSIS_EXPORT BarycentricToXY( double u, double v, double w, Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result );
|
||||
bool ANALYSIS_EXPORT calcBarycentricCoordinates( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result );
|
||||
bool ANALYSIS_EXPORT BarycentricToXY( double u, double v, double w, Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result );
|
||||
//! Calculates the value of a Bernstein polynomial
|
||||
double ANALYSIS_EXPORT calcBernsteinPoly( int n, int i, double t );
|
||||
//! Calculates the first derivative of a Bernstein polynomial with respect to the parameter t
|
||||
@ -37,21 +37,21 @@ namespace MathUtils
|
||||
//! Calculates the first derivative of a cubic Hermite polynomial with respect to the parameter t
|
||||
double ANALYSIS_EXPORT cFDerCubicHermitePoly( int n, int i, double t );
|
||||
//! Calculates the center of the circle passing through p1, p2 and p3. Returns true in case of success and false otherwise (e.g. all three points on a line)
|
||||
bool ANALYSIS_EXPORT circumcenter( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* result );
|
||||
bool ANALYSIS_EXPORT circumcenter( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result );
|
||||
//! Calculates the (2 dimensional) distance from 'thepoint' to the line defined by p1 and p2
|
||||
double ANALYSIS_EXPORT distPointFromLine( Point3D* thepoint, Point3D* p1, Point3D* p2 );
|
||||
double ANALYSIS_EXPORT distPointFromLine( Point3D *thepoint, Point3D *p1, Point3D *p2 );
|
||||
//! Faculty function
|
||||
int ANALYSIS_EXPORT faculty( int n );
|
||||
//! Tests, whether 'testp' is inside the circle through 'p1', 'p2' and 'p3'
|
||||
bool ANALYSIS_EXPORT inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3 );
|
||||
bool ANALYSIS_EXPORT inCircle( Point3D *testp, Point3D *p1, Point3D *p2, Point3D *p3 );
|
||||
//! Tests, whether 'point' is inside the diametral circle through 'p1' and 'p2'
|
||||
bool ANALYSIS_EXPORT inDiametral( Point3D* p1, Point3D* p2, Point3D* point );
|
||||
bool ANALYSIS_EXPORT inDiametral( Point3D *p1, Point3D *p2, Point3D *point );
|
||||
//! Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negativ values mean left and positiv values right. There may be numerical instabilities, so a threshold may be useful
|
||||
double ANALYSIS_EXPORT leftOf( Point3D* thepoint, Point3D* p1, Point3D* p2 );
|
||||
double ANALYSIS_EXPORT leftOf( Point3D *thepoint, Point3D *p1, Point3D *p2 );
|
||||
//! Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect. If the lines have an endpoint in common, false is returned
|
||||
bool ANALYSIS_EXPORT lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* p4 );
|
||||
bool ANALYSIS_EXPORT lineIntersection( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4 );
|
||||
//! Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect. If the lines have an endpoint in common, false is returned. The intersecting point is stored in 'intersection_point.
|
||||
bool ANALYSIS_EXPORT lineIntersection( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* p4, Point3D* intersection_point );
|
||||
bool ANALYSIS_EXPORT lineIntersection( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4, Point3D *intersection_point );
|
||||
//! Lower function
|
||||
int ANALYSIS_EXPORT lower( int n, int i );
|
||||
//! Returns the maximum of two doubles or the first argument if both are equal
|
||||
@ -61,25 +61,25 @@ namespace MathUtils
|
||||
//! Power function for integer coefficients
|
||||
double ANALYSIS_EXPORT power( double a, int b );//calculates a power b
|
||||
//! Returns the area of a triangle. If the points are ordered counterclockwise, the value will be positiv. If they are ordered clockwise, the value will be negativ
|
||||
double ANALYSIS_EXPORT triArea( Point3D* pa, Point3D* pb, Point3D* pc );
|
||||
double ANALYSIS_EXPORT triArea( Point3D *pa, Point3D *pb, Point3D *pc );
|
||||
//! Calculates the z-component of a vector with coordinates 'x' and 'y'which is in the same tangent plane as the tangent vectors 'v1' and 'v2'. The result is assigned to 'result'
|
||||
bool ANALYSIS_EXPORT derVec( const Vector3D* v1, const Vector3D* v2, Vector3D* result, double x, double y );
|
||||
bool ANALYSIS_EXPORT derVec( const Vector3D *v1, const Vector3D *v2, Vector3D *result, double x, double y );
|
||||
//! Calculates the intersection of the two vectors vec1 and vec2, which start at first(vec1) and second(vec2) end. The return value is t2(multiplication of v2 with t2 and adding to 'second' results the intersection point)
|
||||
double ANALYSIS_EXPORT crossVec( Point3D* first, Vector3D* vec1, Point3D* second, Vector3D* vec2 );
|
||||
double ANALYSIS_EXPORT crossVec( Point3D *first, Vector3D *vec1, Point3D *second, Vector3D *vec2 );
|
||||
//! Assigns the vector 'result', which is normal to the vector 'v1', on the left side of v1 and has length 'length'. This method works only with two dimensions.
|
||||
bool ANALYSIS_EXPORT normalLeft( Vector3D* v1, Vector3D* result, double length );
|
||||
bool ANALYSIS_EXPORT normalLeft( Vector3D *v1, Vector3D *result, double length );
|
||||
//! Assigns the vector 'result', which is normal to the vector 'v1', on the right side of v1 and has length 'length'. The calculation is only in two dimensions
|
||||
bool ANALYSIS_EXPORT normalRight( Vector3D* v1, Vector3D* result, double length );
|
||||
bool ANALYSIS_EXPORT normalRight( Vector3D *v1, Vector3D *result, double length );
|
||||
//! Calculates the normal vector of the plane through the points p1, p2 and p3 and assigns the result to vec. If the points are ordered counterclockwise, the normal will have a positive z-coordinate;
|
||||
void ANALYSIS_EXPORT normalFromPoints( Point3D* p1, Point3D* p2, Point3D* p3, Vector3D* vec );
|
||||
void ANALYSIS_EXPORT normalFromPoints( Point3D *p1, Point3D *p2, Point3D *p3, Vector3D *vec );
|
||||
//! Returns true, if the point with coordinates x and y is inside (or at the edge) of the triangle p1,p2,p3 and false, if it is outside. p1, p2 and p3 have to be ordered counterclockwise
|
||||
bool ANALYSIS_EXPORT pointInsideTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 );
|
||||
bool ANALYSIS_EXPORT pointInsideTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 );
|
||||
//! Calculates a Vector orthogonal to 'tangent' with length 1 and closest possible to result. Returns true in case of success and false otherwise
|
||||
bool ANALYSIS_EXPORT normalMinDistance( Vector3D* tangent, Vector3D* target, Vector3D* result );
|
||||
bool ANALYSIS_EXPORT normalMinDistance( Vector3D *tangent, Vector3D *target, Vector3D *result );
|
||||
//! Tests, if 'test' is in the same plane as 'p1', 'p2' and 'p3' and returns the z-difference from the plane to 'test
|
||||
double ANALYSIS_EXPORT planeTest( Point3D* test, Point3D* pt1, Point3D* pt2, Point3D* pt3 );
|
||||
double ANALYSIS_EXPORT planeTest( Point3D *test, Point3D *pt1, Point3D *pt2, Point3D *pt3 );
|
||||
//! Calculates the angle between two segments (in 2 dimension, z-values are ignored)
|
||||
double ANALYSIS_EXPORT angle( Point3D* p1, Point3D* p2, Point3D* p3, Point3D* p4 );
|
||||
double ANALYSIS_EXPORT angle( Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
Node::Node( const Node& n )
|
||||
Node::Node( const Node &n )
|
||||
{
|
||||
if ( n.getPoint() )
|
||||
{
|
||||
Point3D* point = new Point3D( n.getPoint()->getX(), n.getPoint()->getY(), n.getPoint()->getZ() );
|
||||
Point3D *point = new Point3D( n.getPoint()->getX(), n.getPoint()->getY(), n.getPoint()->getZ() );
|
||||
mPoint = point;
|
||||
}
|
||||
else
|
||||
@ -32,9 +32,9 @@ Node::Node( const Node& n )
|
||||
}
|
||||
|
||||
|
||||
Node& Node::operator=( const Node & n )
|
||||
Node &Node::operator=( const Node &n )
|
||||
{
|
||||
Point3D* tmp = mPoint;
|
||||
Point3D *tmp = mPoint;
|
||||
|
||||
if ( n.getPoint() )//mPoint of n is not a null pointer
|
||||
{
|
||||
|
@ -26,27 +26,27 @@ class ANALYSIS_EXPORT Node
|
||||
{
|
||||
protected:
|
||||
//! Pointer to the Point3D object associated with the node
|
||||
Point3D* mPoint = nullptr;
|
||||
Point3D *mPoint = nullptr;
|
||||
//! Pointer to the next Node in the linked list
|
||||
Node* mNext = nullptr;
|
||||
Node *mNext = nullptr;
|
||||
public:
|
||||
Node();
|
||||
Node( const Node& n );
|
||||
Node( const Node &n );
|
||||
~Node();
|
||||
Node& operator=( const Node& n );
|
||||
Node &operator=( const Node &n );
|
||||
//! Returns a pointer to the next element in the linked list
|
||||
Node* getNext() const;
|
||||
Node *getNext() const;
|
||||
//! Returns a pointer to the Point3D object associated with the node
|
||||
Point3D* getPoint() const;
|
||||
Point3D *getPoint() const;
|
||||
//! Sets the pointer to the next node
|
||||
void setNext( Node* n );
|
||||
void setNext( Node *n );
|
||||
//! Sets a new pointer to an associated Point3D object
|
||||
void setPoint( Point3D* p );
|
||||
void setPoint( Point3D *p );
|
||||
};
|
||||
|
||||
inline Node::Node()
|
||||
: mPoint( nullptr )
|
||||
, mNext( nullptr )
|
||||
: mPoint( nullptr )
|
||||
, mNext( nullptr )
|
||||
{
|
||||
|
||||
}
|
||||
@ -56,22 +56,22 @@ inline Node::~Node()
|
||||
delete mPoint;
|
||||
}
|
||||
|
||||
inline Node* Node::getNext() const
|
||||
inline Node *Node::getNext() const
|
||||
{
|
||||
return mNext;
|
||||
}
|
||||
|
||||
inline Point3D* Node::getPoint() const
|
||||
inline Point3D *Node::getPoint() const
|
||||
{
|
||||
return mPoint;
|
||||
}
|
||||
|
||||
inline void Node::setNext( Node* n )
|
||||
inline void Node::setNext( Node *n )
|
||||
{
|
||||
mNext = n;
|
||||
}
|
||||
|
||||
inline void Node::setPoint( Point3D* p )
|
||||
inline void Node::setPoint( Point3D *p )
|
||||
{
|
||||
mPoint = p;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ NormVecDecorator::~NormVecDecorator()
|
||||
{
|
||||
for ( int i = 0; i < mNormVec->count(); i++ )
|
||||
{
|
||||
delete( *mNormVec )[i];
|
||||
delete ( *mNormVec )[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ NormVecDecorator::~NormVecDecorator()
|
||||
}
|
||||
}
|
||||
|
||||
int NormVecDecorator::addPoint( Point3D* p )
|
||||
int NormVecDecorator::addPoint( Point3D *p )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -57,7 +57,7 @@ int NormVecDecorator::addPoint( Point3D* p )
|
||||
{
|
||||
estimateFirstDerivative( pointno );
|
||||
//update also the neighbours of the new point
|
||||
QList<int>* list = mTIN->getSurroundingTriangles( pointno );
|
||||
QList<int> *list = mTIN->getSurroundingTriangles( pointno );
|
||||
QList<int>::iterator it = list->begin();//iterate through the list and analize it
|
||||
while ( it != list->end() )
|
||||
{
|
||||
@ -80,7 +80,7 @@ int NormVecDecorator::addPoint( Point3D* p )
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool NormVecDecorator::calcNormal( double x, double y, Vector3D* result )
|
||||
bool NormVecDecorator::calcNormal( double x, double y, Vector3D *result )
|
||||
{
|
||||
if ( !alreadyestimated )
|
||||
{
|
||||
@ -100,7 +100,7 @@ bool NormVecDecorator::calcNormal( double x, double y, Vector3D* result )
|
||||
}
|
||||
}
|
||||
|
||||
bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector3D* result )
|
||||
bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector3D *result )
|
||||
{
|
||||
if ( !alreadyestimated )
|
||||
{
|
||||
@ -121,14 +121,14 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
|
||||
result->setY( 0 );
|
||||
result->setZ( 0 );
|
||||
|
||||
QList<int>* vlist = getSurroundingTriangles( point );//get the value list
|
||||
QList<int> *vlist = getSurroundingTriangles( point );//get the value list
|
||||
|
||||
if ( !vlist )//an error occurred in 'getSurroundingTriangles'
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((( vlist->count() ) % 4 ) != 0 )//number of items in vlist has to be a multiple of 4
|
||||
if ( ( ( vlist->count() ) % 4 ) != 0 ) //number of items in vlist has to be a multiple of 4
|
||||
{
|
||||
QgsDebugMsg( "warning, wrong number of items in vlist" );
|
||||
return false;
|
||||
@ -212,7 +212,7 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
|
||||
|
||||
++it;
|
||||
if ( it == vlist->end() )//restart at the beginning of the loop
|
||||
{it = vlist->begin();}
|
||||
{it = vlist->begin();}
|
||||
|
||||
|
||||
}
|
||||
@ -231,7 +231,7 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
|
||||
|
||||
}
|
||||
|
||||
bool NormVecDecorator::calcPoint( double x, double y, Point3D* result )
|
||||
bool NormVecDecorator::calcPoint( double x, double y, Point3D *result )
|
||||
{
|
||||
|
||||
if ( !alreadyestimated )
|
||||
@ -252,29 +252,29 @@ bool NormVecDecorator::calcPoint( double x, double y, Point3D* result )
|
||||
}
|
||||
}
|
||||
|
||||
bool NormVecDecorator::getTriangle( double x, double y, Point3D* p1, Vector3D* v1, Point3D* p2, Vector3D* v2, Point3D* p3, Vector3D* v3 )
|
||||
bool NormVecDecorator::getTriangle( double x, double y, Point3D *p1, Vector3D *v1, Point3D *p2, Vector3D *v2, Point3D *p3, Vector3D *v3 )
|
||||
{
|
||||
if ( p1 && p2 && p3 && v1 && v2 && v3 )
|
||||
{
|
||||
int* nr1 = new int();
|
||||
int* nr2 = new int();
|
||||
int* nr3 = new int();
|
||||
int *nr1 = new int();
|
||||
int *nr2 = new int();
|
||||
int *nr3 = new int();
|
||||
|
||||
if ( TriDecorator::getTriangle( x, y, p1, nr1, p2, nr2, p3, nr3 ) )//everything allright
|
||||
{
|
||||
if (( *mNormVec )[( *nr1 )] && ( *mNormVec )[( *nr2 )] && ( *mNormVec )[( *nr3 )] )
|
||||
if ( ( *mNormVec )[( *nr1 )] && ( *mNormVec )[( *nr2 )] && ( *mNormVec )[( *nr3 )] )
|
||||
{
|
||||
v1->setX(( *mNormVec )[( *nr1 )]->getX() );
|
||||
v1->setY(( *mNormVec )[( *nr1 )]->getY() );
|
||||
v1->setZ(( *mNormVec )[( *nr1 )]->getZ() );
|
||||
v1->setX( ( *mNormVec )[( *nr1 )]->getX() );
|
||||
v1->setY( ( *mNormVec )[( *nr1 )]->getY() );
|
||||
v1->setZ( ( *mNormVec )[( *nr1 )]->getZ() );
|
||||
|
||||
v2->setX(( *mNormVec )[( *nr2 )]->getX() );
|
||||
v2->setY(( *mNormVec )[( *nr2 )]->getY() );
|
||||
v2->setZ(( *mNormVec )[( *nr2 )]->getZ() );
|
||||
v2->setX( ( *mNormVec )[( *nr2 )]->getX() );
|
||||
v2->setY( ( *mNormVec )[( *nr2 )]->getY() );
|
||||
v2->setZ( ( *mNormVec )[( *nr2 )]->getZ() );
|
||||
|
||||
v3->setX(( *mNormVec )[( *nr3 )]->getX() );
|
||||
v3->setY(( *mNormVec )[( *nr3 )]->getY() );
|
||||
v3->setZ(( *mNormVec )[( *nr3 )]->getZ() );
|
||||
v3->setX( ( *mNormVec )[( *nr3 )]->getX() );
|
||||
v3->setY( ( *mNormVec )[( *nr3 )]->getY() );
|
||||
v3->setZ( ( *mNormVec )[( *nr3 )]->getZ() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -322,27 +322,27 @@ NormVecDecorator::PointState NormVecDecorator::getState( int pointno ) const
|
||||
}
|
||||
|
||||
|
||||
bool NormVecDecorator::getTriangle( double x, double y, Point3D* p1, int* ptn1, Vector3D* v1, PointState* state1, Point3D* p2, int* ptn2, Vector3D* v2, PointState* state2, Point3D* p3, int* ptn3, Vector3D* v3, PointState* state3 )
|
||||
bool NormVecDecorator::getTriangle( double x, double y, Point3D *p1, int *ptn1, Vector3D *v1, PointState *state1, Point3D *p2, int *ptn2, Vector3D *v2, PointState *state2, Point3D *p3, int *ptn3, Vector3D *v3, PointState *state3 )
|
||||
{
|
||||
if ( p1 && p2 && p3 && v1 && v2 && v3 && ptn1 && ptn2 && ptn3 && state1 && state2 && state3 )
|
||||
{
|
||||
if ( TriDecorator::getTriangle( x, y, p1, ptn1, p2, ptn2, p3, ptn3 ) )//everything allright
|
||||
{
|
||||
v1->setX(( *mNormVec )[( *ptn1 )]->getX() );
|
||||
v1->setY(( *mNormVec )[( *ptn1 )]->getY() );
|
||||
v1->setZ(( *mNormVec )[( *ptn1 )]->getZ() );
|
||||
v1->setX( ( *mNormVec )[( *ptn1 )]->getX() );
|
||||
v1->setY( ( *mNormVec )[( *ptn1 )]->getY() );
|
||||
v1->setZ( ( *mNormVec )[( *ptn1 )]->getZ() );
|
||||
|
||||
( *state1 ) = ( *mPointState )[( *ptn1 )];
|
||||
|
||||
v2->setX(( *mNormVec )[( *ptn2 )]->getX() );
|
||||
v2->setY(( *mNormVec )[( *ptn2 )]->getY() );
|
||||
v2->setZ(( *mNormVec )[( *ptn2 )]->getZ() );
|
||||
v2->setX( ( *mNormVec )[( *ptn2 )]->getX() );
|
||||
v2->setY( ( *mNormVec )[( *ptn2 )]->getY() );
|
||||
v2->setZ( ( *mNormVec )[( *ptn2 )]->getZ() );
|
||||
|
||||
( *state2 ) = ( *mPointState )[( *ptn2 )];
|
||||
|
||||
v3->setX(( *mNormVec )[( *ptn3 )]->getX() );
|
||||
v3->setY(( *mNormVec )[( *ptn3 )]->getY() );
|
||||
v3->setZ(( *mNormVec )[( *ptn3 )]->getZ() );
|
||||
v3->setX( ( *mNormVec )[( *ptn3 )]->getX() );
|
||||
v3->setY( ( *mNormVec )[( *ptn3 )]->getY() );
|
||||
v3->setZ( ( *mNormVec )[( *ptn3 )]->getZ() );
|
||||
|
||||
( *state3 ) = ( *mPointState )[( *ptn3 )];
|
||||
|
||||
@ -379,7 +379,7 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno )
|
||||
double currentweight = 0;//current weight
|
||||
PointState status;
|
||||
|
||||
QList<int>* vlist = getSurroundingTriangles( pointno );//get the value list
|
||||
QList<int> *vlist = getSurroundingTriangles( pointno );//get the value list
|
||||
|
||||
if ( !vlist )
|
||||
{
|
||||
@ -392,9 +392,9 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno )
|
||||
|
||||
//todo:resize mNormVec if necessary
|
||||
|
||||
if ( !(( *mNormVec )[pointno] ) )//insert a pointer to a Vector3D, if there is none at this position
|
||||
if ( !( ( *mNormVec )[pointno] ) ) //insert a pointer to a Vector3D, if there is none at this position
|
||||
{
|
||||
Vector3D* vec = new Vector3D( total.getX(), total.getY(), total.getZ() );
|
||||
Vector3D *vec = new Vector3D( total.getX(), total.getY(), total.getZ() );
|
||||
mNormVec->insert( pointno, vec );
|
||||
}
|
||||
else
|
||||
@ -406,7 +406,7 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno )
|
||||
return false;
|
||||
}
|
||||
|
||||
if (( vlist->count() % 4 ) != 0 ) //number of items in vlist has to be a multiple of 4
|
||||
if ( ( vlist->count() % 4 ) != 0 ) //number of items in vlist has to be a multiple of 4
|
||||
{
|
||||
QgsDebugMsg( "warning, wrong number of items in vlist" );
|
||||
return false;
|
||||
@ -441,7 +441,7 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno )
|
||||
double dist1 = getPoint( p3 )->dist3D( getPoint( p1 ) );
|
||||
double dist2 = getPoint( p3 )->dist3D( getPoint( p2 ) );
|
||||
//don't add the normal if the triangle is horizontal
|
||||
if (( getPoint( p1 )->getZ() != getPoint( p2 )->getZ() ) || ( getPoint( p1 )->getZ() != getPoint( p3 )->getZ() ) )
|
||||
if ( ( getPoint( p1 )->getZ() != getPoint( p2 )->getZ() ) || ( getPoint( p1 )->getZ() != getPoint( p3 )->getZ() ) )
|
||||
{
|
||||
currentweight = 1 / ( dist1 * dist1 * dist2 * dist2 );
|
||||
total.setX( total.getX() + part.getX()*currentweight );
|
||||
@ -487,9 +487,9 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno )
|
||||
mNormVec->resize( mNormVec->size() + 1 );
|
||||
}
|
||||
|
||||
if ( !(( *mNormVec )[pointno] ) )//insert a pointer to a Vector3D, if there is none at this position
|
||||
if ( !( ( *mNormVec )[pointno] ) ) //insert a pointer to a Vector3D, if there is none at this position
|
||||
{
|
||||
Vector3D* vec = new Vector3D( total.getX(), total.getY(), total.getZ() );
|
||||
Vector3D *vec = new Vector3D( total.getX(), total.getY(), total.getZ() );
|
||||
mNormVec->insert( pointno, vec );
|
||||
}
|
||||
else
|
||||
@ -512,7 +512,7 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno )
|
||||
}
|
||||
|
||||
//weighted method of little
|
||||
bool NormVecDecorator::estimateFirstDerivatives( QProgressDialog* d )
|
||||
bool NormVecDecorator::estimateFirstDerivatives( QProgressDialog *d )
|
||||
{
|
||||
if ( d )
|
||||
{
|
||||
@ -577,14 +577,14 @@ bool NormVecDecorator::swapEdge( double x, double y )
|
||||
bool b = false;
|
||||
if ( alreadyestimated )
|
||||
{
|
||||
QList<int>* list = getPointsAroundEdge( x, y );
|
||||
QList<int> *list = getPointsAroundEdge( x, y );
|
||||
if ( list )
|
||||
{
|
||||
b = mTIN->swapEdge( x, y );
|
||||
QList<int>::iterator it;
|
||||
for ( it = list->begin(); it != list->end(); ++it )
|
||||
{
|
||||
estimateFirstDerivative(( *it ) );
|
||||
estimateFirstDerivative( ( *it ) );
|
||||
}
|
||||
delete list;
|
||||
}
|
||||
@ -602,7 +602,7 @@ bool NormVecDecorator::swapEdge( double x, double y )
|
||||
}
|
||||
}
|
||||
|
||||
bool NormVecDecorator::saveAsShapefile( const QString& fileName ) const
|
||||
bool NormVecDecorator::saveAsShapefile( const QString &fileName ) const
|
||||
{
|
||||
if ( !mTIN )
|
||||
{
|
||||
|
@ -33,52 +33,52 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
|
||||
//! 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.
|
||||
enum PointState {Normal, BreakLine, EndPoint};
|
||||
NormVecDecorator();
|
||||
NormVecDecorator( Triangulation* tin );
|
||||
NormVecDecorator( Triangulation *tin );
|
||||
virtual ~NormVecDecorator();
|
||||
//! Adds a point to the triangulation
|
||||
int addPoint( Point3D* p ) override;
|
||||
int addPoint( Point3D *p ) override;
|
||||
//! Calculates the normal at a point on the surface and assigns it to 'result'. Returns true in case of success and false in case of failure
|
||||
bool calcNormal( double x, double y, Vector3D* result ) override;
|
||||
bool calcNormal( double x, double y, Vector3D *result ) override;
|
||||
//! Calculates the normal of a triangle-point for the point with coordinates x and y. This is needed, if a point is on a break line and there is no unique normal stored in 'mNormVec'. Returns false, it something went wrong and true otherwise
|
||||
bool calcNormalForPoint( double x, double y, int point, Vector3D* result );
|
||||
bool calcNormalForPoint( double x, double y, int point, Vector3D *result );
|
||||
//! Calculates x-, y and z-value of the point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure
|
||||
bool calcPoint( double x, double y, Point3D* result ) override;
|
||||
bool calcPoint( double x, double y, Point3D *result ) override;
|
||||
//! Eliminates the horizontal triangles by swapping or by insertion of new points. If alreadyestimated is true, a re-estimation of the normals will be done
|
||||
virtual void eliminateHorizontalTriangles() override;
|
||||
//! Estimates the first derivative a point. Return true in case of succes and false otherwise
|
||||
bool estimateFirstDerivative( int pointno );
|
||||
//! This method adds the functionality of estimating normals at the data points. Return true in the case of success and false otherwise
|
||||
bool estimateFirstDerivatives( QProgressDialog* d = nullptr );
|
||||
bool estimateFirstDerivatives( QProgressDialog *d = nullptr );
|
||||
//! Returns a pointer to the normal vector for the point with the number n
|
||||
Vector3D* getNormal( int n ) const;
|
||||
Vector3D *getNormal( int n ) const;
|
||||
//! Finds out, in which triangle a point with coordinates x and y is and assigns the triangle points to p1, p2, p3 and the estimated normals to v1, v2, v3. The vectors are normally taken from 'mNormVec', except if p1, p2 or p3 is a point on a breakline. In this case, the normal is calculated on-the-fly. Returns false, if something went wrong and true otherwise
|
||||
bool getTriangle( double x, double y, Point3D* p1, Vector3D* v1, Point3D* p2, Vector3D* v2, Point3D* p3, Vector3D* v3 );
|
||||
bool getTriangle( double x, double y, Point3D *p1, Vector3D *v1, Point3D *p2, Vector3D *v2, Point3D *p3, Vector3D *v3 );
|
||||
|
||||
/** This function behaves similar to the one above. Additionally, the numbers of the points are returned (ptn1, ptn2, ptn3) as well as the PointStates of the triangle points (state1, state2, state3)
|
||||
* @note not available in Python bindings
|
||||
*/
|
||||
bool getTriangle( double x, double y, Point3D* p1, int* ptn1, Vector3D* v1, PointState* state1, Point3D* p2, int* ptn2, Vector3D* v2, PointState* state2, Point3D* p3, int* ptn3, Vector3D* v3, PointState* state3 );
|
||||
bool getTriangle( double x, double y, Point3D *p1, int *ptn1, Vector3D *v1, PointState *state1, Point3D *p2, int *ptn2, Vector3D *v2, PointState *state2, Point3D *p3, int *ptn3, Vector3D *v3, PointState *state3 );
|
||||
//! Returns the state of the point with the number 'pointno'
|
||||
PointState getState( int pointno ) const;
|
||||
//! Sets an interpolator
|
||||
void setTriangleInterpolator( TriangleInterpolator* inter ) override;
|
||||
void setTriangleInterpolator( TriangleInterpolator *inter ) override;
|
||||
//! Swaps the edge which is closest to the point with x and y coordinates (if this is possible) and forces recalculation of the concerned normals (if alreadyestimated is true)
|
||||
virtual bool swapEdge( double x, double y ) override;
|
||||
|
||||
/** Saves the triangulation as a (line) shapefile
|
||||
@return true in case of success*/
|
||||
virtual bool saveAsShapefile( const QString& fileName ) const override;
|
||||
virtual bool saveAsShapefile( const QString &fileName ) const override;
|
||||
|
||||
protected:
|
||||
//! Is true, if the normals already have been estimated
|
||||
bool alreadyestimated;
|
||||
static const unsigned int DEFAULT_STORAGE_FOR_NORMALS = 100000;
|
||||
//! Association with an interpolator object
|
||||
TriangleInterpolator* mInterpolator = nullptr;
|
||||
TriangleInterpolator *mInterpolator = nullptr;
|
||||
//! Vector that stores the normals for the points. If 'estimateFirstDerivatives()' was called and there is a null pointer, this means, that the triangle point is on a breakline
|
||||
QVector<Vector3D*>* mNormVec;
|
||||
QVector<Vector3D *> *mNormVec;
|
||||
//! Vector who stores, it a point is not on a breakline, if it is a normal point of the breakline or if it is an endpoint of a breakline
|
||||
QVector<PointState>* mPointState;
|
||||
QVector<PointState> *mPointState;
|
||||
//! Sets the state (BreakLine, Normal, EndPoint) of a point
|
||||
void setState( int pointno, PointState s );
|
||||
};
|
||||
@ -88,17 +88,17 @@ inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( null
|
||||
alreadyestimated = false;
|
||||
}
|
||||
|
||||
inline NormVecDecorator::NormVecDecorator( Triangulation* tin ): TriDecorator( tin ), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) ), mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
|
||||
inline NormVecDecorator::NormVecDecorator( Triangulation *tin ): TriDecorator( tin ), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) ), mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
|
||||
{
|
||||
alreadyestimated = false;
|
||||
}
|
||||
|
||||
inline void NormVecDecorator::setTriangleInterpolator( TriangleInterpolator* inter )
|
||||
inline void NormVecDecorator::setTriangleInterpolator( TriangleInterpolator *inter )
|
||||
{
|
||||
mInterpolator = inter;
|
||||
}
|
||||
|
||||
inline Vector3D* NormVecDecorator::getNormal( int n ) const
|
||||
inline Vector3D *NormVecDecorator::getNormal( int n ) const
|
||||
{
|
||||
if ( mNormVec )
|
||||
{
|
||||
|
@ -17,20 +17,20 @@
|
||||
#include "ParametricLine.h"
|
||||
#include <qgslogger.h>
|
||||
|
||||
void ParametricLine::add( ParametricLine* pl )
|
||||
void ParametricLine::add( ParametricLine *pl )
|
||||
{
|
||||
Q_UNUSED( pl );
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
}
|
||||
|
||||
void ParametricLine::calcFirstDer( float t, Vector3D* v )
|
||||
void ParametricLine::calcFirstDer( float t, Vector3D *v )
|
||||
{
|
||||
Q_UNUSED( t );
|
||||
Q_UNUSED( v );
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
}
|
||||
|
||||
void ParametricLine::calcSecDer( float t, Vector3D* v )
|
||||
void ParametricLine::calcSecDer( float t, Vector3D *v )
|
||||
{
|
||||
Q_UNUSED( t );
|
||||
Q_UNUSED( v );
|
||||
@ -44,7 +44,7 @@ void ParametricLine::calcPoint( float t, Point3D *p )
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
}
|
||||
|
||||
ParametricLine* ParametricLine::getParent() const
|
||||
ParametricLine *ParametricLine::getParent() const
|
||||
{
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
return nullptr;
|
||||
@ -56,13 +56,13 @@ void ParametricLine::remove( int i )
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
}
|
||||
|
||||
void ParametricLine::setControlPoly( QVector<Point3D*>* cp )
|
||||
void ParametricLine::setControlPoly( QVector<Point3D *> *cp )
|
||||
{
|
||||
Q_UNUSED( cp );
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
}
|
||||
|
||||
void ParametricLine::setParent( ParametricLine* paral )
|
||||
void ParametricLine::setParent( ParametricLine *paral )
|
||||
{
|
||||
Q_UNUSED( paral );
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
@ -74,14 +74,14 @@ int ParametricLine::getDegree() const
|
||||
return mDegree;
|
||||
}
|
||||
|
||||
const Point3D* ParametricLine::getControlPoint( int number ) const
|
||||
const Point3D *ParametricLine::getControlPoint( int number ) const
|
||||
{
|
||||
Q_UNUSED( number );
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QVector<Point3D*>* ParametricLine::getControlPoly() const
|
||||
const QVector<Point3D *> *ParametricLine::getControlPoly() const
|
||||
{
|
||||
QgsDebugMsg( "warning, derive a class from ParametricLine" );
|
||||
return nullptr;
|
||||
|
@ -32,48 +32,48 @@ class ANALYSIS_EXPORT ParametricLine
|
||||
//! Degree of the parametric Line
|
||||
int mDegree;
|
||||
//! Pointer to the parent object. If there isn't one, mParent is 0
|
||||
ParametricLine* mParent = nullptr;
|
||||
ParametricLine *mParent = nullptr;
|
||||
//! MControlPoly stores the points of the control polygon
|
||||
QVector<Point3D*>* mControlPoly;
|
||||
QVector<Point3D *> *mControlPoly;
|
||||
public:
|
||||
//! Default constructor
|
||||
ParametricLine();
|
||||
|
||||
/** Constructor, par is a pointer to the parent object, controlpoly the controlpolygon
|
||||
*/
|
||||
ParametricLine( ParametricLine* par, QVector<Point3D*>* controlpoly );
|
||||
ParametricLine( ParametricLine *par, QVector<Point3D *> *controlpoly );
|
||||
virtual ~ParametricLine();
|
||||
virtual void add( ParametricLine* pl ) = 0;
|
||||
virtual void calcFirstDer( float t, Vector3D* v ) = 0;
|
||||
virtual void calcSecDer( float t, Vector3D* v ) = 0;
|
||||
virtual void add( ParametricLine *pl ) = 0;
|
||||
virtual void calcFirstDer( float t, Vector3D *v ) = 0;
|
||||
virtual void calcSecDer( float t, Vector3D *v ) = 0;
|
||||
//virtual Point3D calcPoint(float t);
|
||||
virtual void calcPoint( float t, Point3D* ) = 0;
|
||||
virtual void calcPoint( float t, Point3D * ) = 0;
|
||||
virtual void changeDirection() = 0;
|
||||
//virtual void draw(QPainter* p);
|
||||
virtual const Point3D* getControlPoint( int number ) const = 0;
|
||||
virtual const QVector<Point3D*>* getControlPoly() const = 0;
|
||||
virtual const Point3D *getControlPoint( int number ) const = 0;
|
||||
virtual const QVector<Point3D *> *getControlPoly() const = 0;
|
||||
virtual int getDegree() const = 0;
|
||||
virtual ParametricLine* getParent() const = 0;
|
||||
virtual ParametricLine *getParent() const = 0;
|
||||
//virtual bool intersects(ParametricLine* pal);
|
||||
virtual void remove( int i ) = 0;
|
||||
virtual void setControlPoly( QVector<Point3D*>* cp ) = 0;
|
||||
virtual void setParent( ParametricLine* paral ) = 0;
|
||||
virtual void setControlPoly( QVector<Point3D *> *cp ) = 0;
|
||||
virtual void setParent( ParametricLine *paral ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------constructors and destructor----------------------
|
||||
|
||||
inline ParametricLine::ParametricLine()
|
||||
: mDegree( 0 )
|
||||
, mParent( nullptr )
|
||||
, mControlPoly( nullptr )
|
||||
: mDegree( 0 )
|
||||
, mParent( nullptr )
|
||||
, mControlPoly( nullptr )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline ParametricLine::ParametricLine( ParametricLine* par, QVector<Point3D*>* controlpoly )
|
||||
: mDegree( 0 )
|
||||
, mParent( par )
|
||||
, mControlPoly( controlpoly )
|
||||
inline ParametricLine::ParametricLine( ParametricLine *par, QVector<Point3D *> *controlpoly )
|
||||
: mDegree( 0 )
|
||||
, mParent( par )
|
||||
, mControlPoly( controlpoly )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -17,17 +17,17 @@
|
||||
#include "Point3D.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
bool Point3D::operator==( const Point3D& p ) const
|
||||
bool Point3D::operator==( const Point3D &p ) const
|
||||
{
|
||||
return ( mX == p.getX() && mY == p.getY() && mZ == p.getZ() );
|
||||
}
|
||||
|
||||
bool Point3D::operator!=( const Point3D& p ) const
|
||||
bool Point3D::operator!=( const Point3D &p ) const
|
||||
{
|
||||
return ( !(( *this ) == p ) );
|
||||
return ( !( ( *this ) == p ) );
|
||||
}
|
||||
|
||||
double Point3D::dist3D( Point3D* p ) const
|
||||
double Point3D::dist3D( Point3D *p ) const
|
||||
{
|
||||
if ( p )
|
||||
{
|
||||
@ -35,7 +35,7 @@ double Point3D::dist3D( Point3D* p ) const
|
||||
dx = p->getX() - getX();
|
||||
dy = p->getY() - getY();
|
||||
dz = p->getZ() - getZ();
|
||||
return sqrt( dx*dx + dy*dy + dz*dz );
|
||||
return sqrt( dx * dx + dy * dy + dz * dz );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -35,11 +35,11 @@ class ANALYSIS_EXPORT Point3D
|
||||
Point3D();
|
||||
//! Constructor with the x-, y- and z-coordinate as arguments
|
||||
Point3D( double x, double y, double z );
|
||||
Point3D( const Point3D& p );
|
||||
bool operator==( const Point3D& p ) const;
|
||||
bool operator!=( const Point3D& p ) const;
|
||||
Point3D( const Point3D &p );
|
||||
bool operator==( const Point3D &p ) const;
|
||||
bool operator!=( const Point3D &p ) const;
|
||||
//! Calculates the three-dimensional distance to another point
|
||||
double dist3D( Point3D* p ) const;
|
||||
double dist3D( Point3D *p ) const;
|
||||
//! Returns the x-coordinate of the point
|
||||
double getX() const;
|
||||
//! Returns the y-coordinate of the point
|
||||
@ -55,22 +55,22 @@ class ANALYSIS_EXPORT Point3D
|
||||
};
|
||||
|
||||
inline Point3D::Point3D()
|
||||
: mX( 0 )
|
||||
, mY( 0 )
|
||||
, mZ( 0 )
|
||||
: mX( 0 )
|
||||
, mY( 0 )
|
||||
, mZ( 0 )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline Point3D::Point3D( double x, double y, double z )
|
||||
: mX( x )
|
||||
, mY( y )
|
||||
, mZ( z )
|
||||
: mX( x )
|
||||
, mY( y )
|
||||
, mZ( z )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline Point3D::Point3D( const Point3D& p ): mX( p.mX ), mY( p.mY ), mZ( p.mZ )
|
||||
inline Point3D::Point3D( const Point3D &p ): mX( p.mX ), mY( p.mY ), mZ( p.mZ )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "TriDecorator.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
void TriDecorator::addLine( Line3D* line, bool breakline )
|
||||
void TriDecorator::addLine( Line3D *line, bool breakline )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -29,7 +29,7 @@ void TriDecorator::addLine( Line3D* line, bool breakline )
|
||||
}
|
||||
}
|
||||
|
||||
int TriDecorator::addPoint( Point3D* p )
|
||||
int TriDecorator::addPoint( Point3D *p )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -55,7 +55,7 @@ void TriDecorator::performConsistencyTest()
|
||||
}
|
||||
}
|
||||
|
||||
bool TriDecorator::calcNormal( double x, double y, Vector3D* result )
|
||||
bool TriDecorator::calcNormal( double x, double y, Vector3D *result )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -69,7 +69,7 @@ bool TriDecorator::calcNormal( double x, double y, Vector3D* result )
|
||||
}
|
||||
}
|
||||
|
||||
bool TriDecorator::calcPoint( double x, double y, Point3D* result )
|
||||
bool TriDecorator::calcPoint( double x, double y, Point3D *result )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -83,11 +83,11 @@ bool TriDecorator::calcPoint( double x, double y, Point3D* result )
|
||||
}
|
||||
}
|
||||
|
||||
Point3D* TriDecorator::getPoint( unsigned int i ) const
|
||||
Point3D *TriDecorator::getPoint( unsigned int i ) const
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
Point3D* p = mTIN->getPoint( i );
|
||||
Point3D *p = mTIN->getPoint( i );
|
||||
return p;
|
||||
}
|
||||
else
|
||||
@ -97,7 +97,7 @@ Point3D* TriDecorator::getPoint( unsigned int i ) const
|
||||
}
|
||||
}
|
||||
|
||||
bool TriDecorator::getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 )
|
||||
bool TriDecorator::getTriangle( double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3 )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -111,7 +111,7 @@ bool TriDecorator::getTriangle( double x, double y, Point3D* p1, int* n1, Point3
|
||||
}
|
||||
}
|
||||
|
||||
bool TriDecorator::getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 )
|
||||
bool TriDecorator::getTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -152,11 +152,11 @@ int TriDecorator::getOppositePoint( int p1, int p2 )
|
||||
}
|
||||
}
|
||||
|
||||
QList<int>* TriDecorator::getSurroundingTriangles( int pointno )
|
||||
QList<int> *TriDecorator::getSurroundingTriangles( int pointno )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
QList<int>* vl = mTIN->getSurroundingTriangles( pointno );
|
||||
QList<int> *vl = mTIN->getSurroundingTriangles( pointno );
|
||||
return vl;
|
||||
}
|
||||
else
|
||||
@ -269,7 +269,7 @@ void TriDecorator::setBreakEdgeColor( int r, int g, int b )
|
||||
}
|
||||
}
|
||||
|
||||
void TriDecorator::setTriangleInterpolator( TriangleInterpolator* interpolator )
|
||||
void TriDecorator::setTriangleInterpolator( TriangleInterpolator *interpolator )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
@ -333,7 +333,7 @@ bool TriDecorator::swapEdge( double x, double y )
|
||||
}
|
||||
}
|
||||
|
||||
QList<int>* TriDecorator::getPointsAroundEdge( double x, double y )
|
||||
QList<int> *TriDecorator::getPointsAroundEdge( double x, double y )
|
||||
{
|
||||
if ( mTIN )
|
||||
{
|
||||
|
@ -26,22 +26,22 @@ class ANALYSIS_EXPORT TriDecorator : public Triangulation
|
||||
{
|
||||
public:
|
||||
TriDecorator();
|
||||
explicit TriDecorator( Triangulation* t );
|
||||
explicit TriDecorator( Triangulation *t );
|
||||
virtual ~TriDecorator();
|
||||
virtual void addLine( Line3D* line, bool breakline ) override;
|
||||
virtual int addPoint( Point3D* p ) override;
|
||||
virtual void addLine( Line3D *line, bool breakline ) override;
|
||||
virtual int addPoint( Point3D *p ) override;
|
||||
//! Adds an association to a triangulation
|
||||
virtual void addTriangulation( Triangulation* t );
|
||||
virtual void addTriangulation( Triangulation *t );
|
||||
//! Performs a consistency check, remove this later
|
||||
virtual void performConsistencyTest() override;
|
||||
virtual bool calcNormal( double x, double y, Vector3D* result ) override;
|
||||
virtual bool calcPoint( double x, double y, Point3D* result ) override;
|
||||
virtual Point3D* getPoint( unsigned int i ) const override;
|
||||
virtual bool calcNormal( double x, double y, Vector3D *result ) override;
|
||||
virtual bool calcPoint( double x, double y, Point3D *result ) override;
|
||||
virtual Point3D *getPoint( unsigned int i ) const override;
|
||||
virtual int getNumberOfPoints() const override;
|
||||
bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 ) override;
|
||||
bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 ) override;
|
||||
bool getTriangle( double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3 ) override;
|
||||
bool getTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 ) override;
|
||||
virtual int getOppositePoint( int p1, int p2 ) override;
|
||||
virtual QList<int>* getSurroundingTriangles( int pointno ) override;
|
||||
virtual QList<int> *getSurroundingTriangles( int pointno ) override;
|
||||
virtual double getXMax() const override;
|
||||
virtual double getXMin() const override;
|
||||
virtual double getYMax() const override;
|
||||
@ -50,15 +50,15 @@ class ANALYSIS_EXPORT TriDecorator : public Triangulation
|
||||
virtual void setEdgeColor( int r, int g, int b ) override;
|
||||
virtual void setForcedEdgeColor( int r, int g, int b ) override;
|
||||
virtual void setBreakEdgeColor( int r, int g, int b ) override;
|
||||
virtual void setTriangleInterpolator( TriangleInterpolator* interpolator ) override;
|
||||
virtual void setTriangleInterpolator( TriangleInterpolator *interpolator ) override;
|
||||
virtual void eliminateHorizontalTriangles() override;
|
||||
virtual void ruppertRefinement() override;
|
||||
virtual bool pointInside( double x, double y ) override;
|
||||
virtual bool swapEdge( double x, double y ) override;
|
||||
virtual QList<int>* getPointsAroundEdge( double x, double y ) override;
|
||||
virtual QList<int> *getPointsAroundEdge( double x, double y ) override;
|
||||
protected:
|
||||
//! Association with a Triangulation object
|
||||
Triangulation* mTIN = nullptr;
|
||||
Triangulation *mTIN = nullptr;
|
||||
};
|
||||
|
||||
inline TriDecorator::TriDecorator(): mTIN( nullptr )
|
||||
@ -66,7 +66,7 @@ inline TriDecorator::TriDecorator(): mTIN( nullptr )
|
||||
|
||||
}
|
||||
|
||||
inline TriDecorator::TriDecorator( Triangulation* t ): mTIN( t )
|
||||
inline TriDecorator::TriDecorator( Triangulation *t ): mTIN( t )
|
||||
{
|
||||
|
||||
}
|
||||
@ -76,7 +76,7 @@ inline TriDecorator::~TriDecorator()
|
||||
|
||||
}
|
||||
|
||||
inline void TriDecorator::addTriangulation( Triangulation* t )
|
||||
inline void TriDecorator::addTriangulation( Triangulation *t )
|
||||
{
|
||||
mTIN = t;
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ class ANALYSIS_EXPORT TriangleInterpolator
|
||||
public:
|
||||
virtual ~TriangleInterpolator() = default;
|
||||
//! Calculates the normal vector and assigns it to vec
|
||||
virtual bool calcNormVec( double x, double y, Vector3D* result ) = 0;
|
||||
virtual bool calcNormVec( double x, double y, Vector3D *result ) = 0;
|
||||
//! Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point
|
||||
virtual bool calcPoint( double x, double y, Point3D* result ) = 0;
|
||||
virtual bool calcPoint( double x, double y, Point3D *result ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -42,19 +42,19 @@ class ANALYSIS_EXPORT Triangulation
|
||||
* Adds a line (e.g. a break-, structure- or an isoline) to the triangulation.
|
||||
* The class takes ownership of the line object and its points
|
||||
*/
|
||||
virtual void addLine( Line3D* line, bool breakline ) = 0;
|
||||
virtual void addLine( Line3D *line, bool breakline ) = 0;
|
||||
|
||||
/**
|
||||
* Adds a point to the triangulation
|
||||
* Ownership is transferred to this class
|
||||
*/
|
||||
virtual int addPoint( Point3D* p ) = 0;
|
||||
virtual int addPoint( Point3D *p ) = 0;
|
||||
|
||||
/**
|
||||
* Calculates the normal at a point on the surface and assigns it to 'result'.
|
||||
* @return true in case of success and false in case of failure
|
||||
*/
|
||||
virtual bool calcNormal( double x, double y, Vector3D* result ) = 0;
|
||||
virtual bool calcNormal( double x, double y, Vector3D *result ) = 0;
|
||||
|
||||
//! Performs a consistency check, remove this later
|
||||
virtual void performConsistencyTest() = 0;
|
||||
@ -63,18 +63,18 @@ class ANALYSIS_EXPORT Triangulation
|
||||
* Calculates x-, y and z-value of the point on the surface and assigns it to 'result'.
|
||||
* Returns true in case of success and flase in case of failure
|
||||
*/
|
||||
virtual bool calcPoint( double x, double y, Point3D* result ) = 0;
|
||||
virtual bool calcPoint( double x, double y, Point3D *result ) = 0;
|
||||
|
||||
//! Returns a pointer to the point with number i. Any virtual points must have the number -1
|
||||
virtual Point3D* getPoint( unsigned int i ) const = 0;
|
||||
virtual Point3D *getPoint( unsigned int i ) const = 0;
|
||||
|
||||
/** Finds out in which triangle the point with coordinates x and y is and
|
||||
* assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'
|
||||
*/
|
||||
virtual bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 ) = 0;
|
||||
virtual bool getTriangle( double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3 ) = 0;
|
||||
|
||||
//! Finds out, in which triangle the point with coordinates x and y is and assigns the points at the vertices to 'p1', 'p2' and 'p3
|
||||
virtual bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 ) = 0;
|
||||
virtual bool getTriangle( double x, double y, Point3D *p1, Point3D *p2, Point3D *p3 ) = 0;
|
||||
|
||||
//! Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge)
|
||||
virtual int getOppositePoint( int p1, int p2 ) = 0;
|
||||
@ -101,14 +101,14 @@ class ANALYSIS_EXPORT Triangulation
|
||||
* The value list has to be deleted by the code which called the method.
|
||||
* Any virtual point needs to have the number -1
|
||||
*/
|
||||
virtual QList<int>* getSurroundingTriangles( int pointno ) = 0;
|
||||
virtual QList<int> *getSurroundingTriangles( int pointno ) = 0;
|
||||
|
||||
/** Returns a value list with the numbers of the four points, which would be affected by an edge swap.
|
||||
* This function is e.g. needed by NormVecDecorator to know the points,
|
||||
* for which the normals have to be recalculated.
|
||||
* The list has to be deleted by the code which calls this method
|
||||
*/
|
||||
virtual QList<int>* getPointsAroundEdge( double x, double y ) = 0;
|
||||
virtual QList<int> *getPointsAroundEdge( double x, double y ) = 0;
|
||||
|
||||
//! Draws the points, edges and the forced lines
|
||||
//virtual void draw(QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height) const=0;
|
||||
@ -126,7 +126,7 @@ class ANALYSIS_EXPORT Triangulation
|
||||
virtual void setBreakEdgeColor( int r, int g, int b ) = 0;
|
||||
|
||||
//! Sets an interpolator object
|
||||
virtual void setTriangleInterpolator( TriangleInterpolator* interpolator ) = 0;
|
||||
virtual void setTriangleInterpolator( TriangleInterpolator *interpolator ) = 0;
|
||||
|
||||
//! Eliminates the horizontal triangles by swapping
|
||||
virtual void eliminateHorizontalTriangles() = 0;
|
||||
@ -150,7 +150,7 @@ class ANALYSIS_EXPORT Triangulation
|
||||
* Saves the triangulation as a (line) shapefile
|
||||
* @return true in case of success
|
||||
*/
|
||||
virtual bool saveAsShapefile( const QString& fileName ) const = 0;
|
||||
virtual bool saveAsShapefile( const QString &fileName ) const = 0;
|
||||
};
|
||||
|
||||
inline Triangulation::~Triangulation()
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
double Vector3D::getLength() const
|
||||
{
|
||||
return sqrt( getX()*getX() + getY()*getY() + getZ()*getZ() );
|
||||
return sqrt( getX() * getX() + getY() * getY() + getZ() * getZ() );
|
||||
}
|
||||
|
||||
void Vector3D::standardise()
|
||||
@ -29,12 +29,12 @@ void Vector3D::standardise()
|
||||
setZ( getZ() / length );
|
||||
}
|
||||
|
||||
bool Vector3D::operator==( const Vector3D& v ) const
|
||||
bool Vector3D::operator==( const Vector3D &v ) const
|
||||
{
|
||||
return ( mX == v.getX() && mY == v.getY() && mZ == v.getZ() );
|
||||
}
|
||||
|
||||
bool Vector3D::operator!=( const Vector3D& v ) const
|
||||
bool Vector3D::operator!=( const Vector3D &v ) const
|
||||
{
|
||||
return ( !(( *this ) == v ) );
|
||||
return ( !( ( *this ) == v ) );
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ class ANALYSIS_EXPORT Vector3D
|
||||
//! Default constructor
|
||||
Vector3D();
|
||||
|
||||
bool operator==( const Vector3D& v ) const;
|
||||
bool operator!=( const Vector3D& v ) const;
|
||||
bool operator==( const Vector3D &v ) const;
|
||||
bool operator!=( const Vector3D &v ) const;
|
||||
//! Returns the x-component of the vector
|
||||
double getX() const;
|
||||
//! Returns the y-component of the vector
|
||||
@ -65,17 +65,17 @@ class ANALYSIS_EXPORT Vector3D
|
||||
//------------------------------------------constructors------------------------------------
|
||||
|
||||
inline Vector3D::Vector3D( double x, double y, double z )
|
||||
: mX( x )
|
||||
, mY( y )
|
||||
, mZ( z )
|
||||
: mX( x )
|
||||
, mY( y )
|
||||
, mZ( z )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline Vector3D::Vector3D()
|
||||
: mX( 0 )
|
||||
, mY( 0 )
|
||||
, mZ( 0 )//using a list
|
||||
: mX( 0 )
|
||||
, mY( 0 )
|
||||
, mZ( 0 )//using a list
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -22,24 +22,24 @@
|
||||
#include <QFileInfo>
|
||||
#include <QProgressDialog>
|
||||
|
||||
QgsGridFileWriter::QgsGridFileWriter( QgsInterpolator* i, const QString& outputPath, const QgsRectangle& extent, int nCols, int nRows, double cellSizeX, double cellSizeY )
|
||||
: mInterpolator( i )
|
||||
, mOutputFilePath( outputPath )
|
||||
, mInterpolationExtent( extent )
|
||||
, mNumColumns( nCols )
|
||||
, mNumRows( nRows )
|
||||
, mCellSizeX( cellSizeX )
|
||||
, mCellSizeY( cellSizeY )
|
||||
QgsGridFileWriter::QgsGridFileWriter( QgsInterpolator *i, const QString &outputPath, const QgsRectangle &extent, int nCols, int nRows, double cellSizeX, double cellSizeY )
|
||||
: mInterpolator( i )
|
||||
, mOutputFilePath( outputPath )
|
||||
, mInterpolationExtent( extent )
|
||||
, mNumColumns( nCols )
|
||||
, mNumRows( nRows )
|
||||
, mCellSizeX( cellSizeX )
|
||||
, mCellSizeY( cellSizeY )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsGridFileWriter::QgsGridFileWriter()
|
||||
: mInterpolator( nullptr )
|
||||
, mNumColumns( 0 )
|
||||
, mNumRows( 0 )
|
||||
, mCellSizeX( 0 )
|
||||
, mCellSizeY( 0 )
|
||||
: mInterpolator( nullptr )
|
||||
, mNumColumns( 0 )
|
||||
, mNumRows( 0 )
|
||||
, mCellSizeX( 0 )
|
||||
, mCellSizeY( 0 )
|
||||
{
|
||||
|
||||
}
|
||||
@ -67,7 +67,7 @@ int QgsGridFileWriter::writeFile( bool showProgressDialog )
|
||||
double currentXValue;
|
||||
double interpolatedValue;
|
||||
|
||||
QProgressDialog* progressDialog = nullptr;
|
||||
QProgressDialog *progressDialog = nullptr;
|
||||
if ( showProgressDialog )
|
||||
{
|
||||
progressDialog = new QProgressDialog( QObject::tr( "Interpolating..." ), QObject::tr( "Abort" ), 0, mNumRows, nullptr );
|
||||
@ -106,7 +106,7 @@ int QgsGridFileWriter::writeFile( bool showProgressDialog )
|
||||
// create prj file
|
||||
QgsInterpolator::LayerData ld;
|
||||
ld = mInterpolator->layerData().first();
|
||||
QgsVectorLayer* vl = ld.vectorLayer;
|
||||
QgsVectorLayer *vl = ld.vectorLayer;
|
||||
QString crs = vl->crs().toWkt();
|
||||
QFileInfo fi( mOutputFilePath );
|
||||
QString fileName = fi.absolutePath() + '/' + fi.completeBaseName() + ".prj";
|
||||
@ -124,7 +124,7 @@ int QgsGridFileWriter::writeFile( bool showProgressDialog )
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QgsGridFileWriter::writeHeader( QTextStream& outStream )
|
||||
int QgsGridFileWriter::writeHeader( QTextStream &outStream )
|
||||
{
|
||||
outStream << "NCOLS " << mNumColumns << endl;
|
||||
outStream << "NROWS " << mNumRows << endl;
|
||||
|
@ -31,7 +31,7 @@ class QgsInterpolator;
|
||||
class ANALYSIS_EXPORT QgsGridFileWriter
|
||||
{
|
||||
public:
|
||||
QgsGridFileWriter( QgsInterpolator* i, const QString& outputPath, const QgsRectangle& extent, int nCols, int nRows, double cellSizeX, double cellSizeY );
|
||||
QgsGridFileWriter( QgsInterpolator *i, const QString &outputPath, const QgsRectangle &extent, int nCols, int nRows, double cellSizeX, double cellSizeY );
|
||||
|
||||
/** Writes the grid file.
|
||||
@param showProgressDialog shows a dialog with the possibility to cancel
|
||||
@ -42,9 +42,9 @@ class ANALYSIS_EXPORT QgsGridFileWriter
|
||||
private:
|
||||
|
||||
QgsGridFileWriter(); //forbidden
|
||||
int writeHeader( QTextStream& outStream );
|
||||
int writeHeader( QTextStream &outStream );
|
||||
|
||||
QgsInterpolator* mInterpolator = nullptr;
|
||||
QgsInterpolator *mInterpolator = nullptr;
|
||||
QString mOutputFilePath;
|
||||
QgsRectangle mInterpolationExtent;
|
||||
int mNumColumns;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
QgsIDWInterpolator::QgsIDWInterpolator( const QList<LayerData>& layerData ): QgsInterpolator( layerData ), mDistanceCoefficient( 2.0 )
|
||||
QgsIDWInterpolator::QgsIDWInterpolator( const QList<LayerData> &layerData ): QgsInterpolator( layerData ), mDistanceCoefficient( 2.0 )
|
||||
{
|
||||
|
||||
}
|
||||
@ -29,7 +29,7 @@ QgsIDWInterpolator::QgsIDWInterpolator(): QgsInterpolator( QList<LayerData>() ),
|
||||
|
||||
}
|
||||
|
||||
int QgsIDWInterpolator::interpolatePoint( double x, double y, double& result )
|
||||
int QgsIDWInterpolator::interpolatePoint( double x, double y, double &result )
|
||||
{
|
||||
if ( !mDataIsCached )
|
||||
{
|
||||
@ -42,10 +42,10 @@ int QgsIDWInterpolator::interpolatePoint( double x, double y, double& result )
|
||||
double sumCounter = 0;
|
||||
double sumDenominator = 0;
|
||||
|
||||
Q_FOREACH ( const vertexData& vertex_it, mCachedBaseData )
|
||||
Q_FOREACH ( const vertexData &vertex_it, mCachedBaseData )
|
||||
{
|
||||
distance = sqrt(( vertex_it.x - x ) * ( vertex_it.x - x ) + ( vertex_it.y - y ) * ( vertex_it.y - y ) );
|
||||
if (( distance - 0 ) < std::numeric_limits<double>::min() )
|
||||
distance = sqrt( ( vertex_it.x - x ) * ( vertex_it.x - x ) + ( vertex_it.y - y ) * ( vertex_it.y - y ) );
|
||||
if ( ( distance - 0 ) < std::numeric_limits<double>::min() )
|
||||
{
|
||||
result = vertex_it.z;
|
||||
return 0;
|
||||
|
@ -27,14 +27,14 @@
|
||||
class ANALYSIS_EXPORT QgsIDWInterpolator: public QgsInterpolator
|
||||
{
|
||||
public:
|
||||
QgsIDWInterpolator( const QList<LayerData>& layerData );
|
||||
QgsIDWInterpolator( const QList<LayerData> &layerData );
|
||||
|
||||
/** Calculates interpolation value for map coordinates x, y
|
||||
@param x x-coordinate (in map units)
|
||||
@param y y-coordinate (in map units)
|
||||
@param result out: interpolation result
|
||||
@return 0 in case of success*/
|
||||
int interpolatePoint( double x, double y, double& result ) override;
|
||||
int interpolatePoint( double x, double y, double &result ) override;
|
||||
|
||||
void setDistanceCoefficient( double p ) {mDistanceCoefficient = p;}
|
||||
|
||||
|
@ -22,15 +22,15 @@
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgswkbptr.h"
|
||||
|
||||
QgsInterpolator::QgsInterpolator( const QList<LayerData>& layerData )
|
||||
: mDataIsCached( false )
|
||||
, mLayerData( layerData )
|
||||
QgsInterpolator::QgsInterpolator( const QList<LayerData> &layerData )
|
||||
: mDataIsCached( false )
|
||||
, mLayerData( layerData )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsInterpolator::QgsInterpolator()
|
||||
: mDataIsCached( false )
|
||||
: mDataIsCached( false )
|
||||
{
|
||||
|
||||
}
|
||||
@ -46,14 +46,14 @@ int QgsInterpolator::cacheBaseData()
|
||||
mCachedBaseData.clear();
|
||||
mCachedBaseData.reserve( 100000 );
|
||||
|
||||
Q_FOREACH ( const LayerData& layer, mLayerData )
|
||||
Q_FOREACH ( const LayerData &layer, mLayerData )
|
||||
{
|
||||
if ( !layer.vectorLayer )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vlayer = layer.vectorLayer;
|
||||
QgsVectorLayer *vlayer = layer.vectorLayer;
|
||||
if ( !vlayer )
|
||||
{
|
||||
return 2;
|
||||
@ -98,7 +98,7 @@ int QgsInterpolator::cacheBaseData()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QgsInterpolator::addVerticesToCache( const QgsGeometry& geom, bool zCoord, double attributeValue )
|
||||
int QgsInterpolator::addVerticesToCache( const QgsGeometry &geom, bool zCoord, double attributeValue )
|
||||
{
|
||||
if ( geom.isNull() )
|
||||
return 1;
|
||||
@ -156,7 +156,7 @@ int QgsInterpolator::addVerticesToCache( const QgsGeometry& geom, bool zCoord, d
|
||||
#if 0
|
||||
case QgsWkbTypes::Polygon25D:
|
||||
hasZValue = true;
|
||||
//intentional fall-through
|
||||
//intentional fall-through
|
||||
case QgsWkbTypes::Polygon:
|
||||
{
|
||||
int nRings;
|
||||
@ -201,7 +201,7 @@ int QgsInterpolator::addVerticesToCache( const QgsGeometry& geom, bool zCoord, d
|
||||
}
|
||||
case QgsWkbTypes::MultiPoint25D:
|
||||
hasZValue = true;
|
||||
//intentional fall-through
|
||||
//intentional fall-through
|
||||
case QgsWkbTypes::MultiPoint:
|
||||
{
|
||||
int nPoints;
|
||||
@ -226,7 +226,7 @@ int QgsInterpolator::addVerticesToCache( const QgsGeometry& geom, bool zCoord, d
|
||||
}
|
||||
case QgsWkbTypes::MultiLineString25D:
|
||||
hasZValue = true;
|
||||
//intentional fall-through
|
||||
//intentional fall-through
|
||||
case QgsWkbTypes::MultiLineString:
|
||||
{
|
||||
int nLines;
|
||||
@ -272,7 +272,7 @@ int QgsInterpolator::addVerticesToCache( const QgsGeometry& geom, bool zCoord, d
|
||||
}
|
||||
case QgsWkbTypes::MultiPolygon25D:
|
||||
hasZValue = true;
|
||||
//intentional fall-through
|
||||
//intentional fall-through
|
||||
case QgsWkbTypes::MultiPolygon:
|
||||
{
|
||||
int nPolys;
|
||||
|
@ -49,13 +49,13 @@ class ANALYSIS_EXPORT QgsInterpolator
|
||||
//! A layer together with the information about interpolation attribute / z-coordinate interpolation and the type (point, structure line, breakline)
|
||||
struct LayerData
|
||||
{
|
||||
QgsVectorLayer* vectorLayer = nullptr;
|
||||
QgsVectorLayer *vectorLayer = nullptr;
|
||||
bool zCoordInterpolation;
|
||||
int interpolationAttribute;
|
||||
InputType mInputType;
|
||||
};
|
||||
|
||||
QgsInterpolator( const QList<LayerData>& layerData );
|
||||
QgsInterpolator( const QList<LayerData> &layerData );
|
||||
|
||||
virtual ~QgsInterpolator() = default;
|
||||
|
||||
@ -64,7 +64,7 @@ class ANALYSIS_EXPORT QgsInterpolator
|
||||
@param y y-coordinate (in map units)
|
||||
@param result out: interpolation result
|
||||
@return 0 in case of success*/
|
||||
virtual int interpolatePoint( double x, double y, double& result ) = 0;
|
||||
virtual int interpolatePoint( double x, double y, double &result ) = 0;
|
||||
|
||||
//! @note not available in Python bindings
|
||||
QList<LayerData> layerData() const { return mLayerData; }
|
||||
@ -92,7 +92,7 @@ class ANALYSIS_EXPORT QgsInterpolator
|
||||
@param zCoord true if the z-coordinate of the geometry is to be interpolated
|
||||
@param attributeValue the attribute value for interpolation (if not interpolated from z-coordinate)
|
||||
@return 0 in case of success*/
|
||||
int addVerticesToCache( const QgsGeometry& geom, bool zCoord, double attributeValue );
|
||||
int addVerticesToCache( const QgsGeometry &geom, bool zCoord, double attributeValue );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -29,14 +29,14 @@
|
||||
#include "qgswkbptr.h"
|
||||
#include <QProgressDialog>
|
||||
|
||||
QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData>& inputData, TINInterpolation interpolation, bool showProgressDialog )
|
||||
: QgsInterpolator( inputData )
|
||||
, mTriangulation( nullptr )
|
||||
, mTriangleInterpolator( nullptr )
|
||||
, mIsInitialized( false )
|
||||
, mShowProgressDialog( showProgressDialog )
|
||||
, mExportTriangulationToFile( false )
|
||||
, mInterpolation( interpolation )
|
||||
QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData> &inputData, TINInterpolation interpolation, bool showProgressDialog )
|
||||
: QgsInterpolator( inputData )
|
||||
, mTriangulation( nullptr )
|
||||
, mTriangleInterpolator( nullptr )
|
||||
, mIsInitialized( false )
|
||||
, mShowProgressDialog( showProgressDialog )
|
||||
, mExportTriangulationToFile( false )
|
||||
, mInterpolation( interpolation )
|
||||
{
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ QgsTINInterpolator::~QgsTINInterpolator()
|
||||
delete mTriangleInterpolator;
|
||||
}
|
||||
|
||||
int QgsTINInterpolator::interpolatePoint( double x, double y, double& result )
|
||||
int QgsTINInterpolator::interpolatePoint( double x, double y, double &result )
|
||||
{
|
||||
if ( !mIsInitialized )
|
||||
{
|
||||
@ -69,10 +69,10 @@ int QgsTINInterpolator::interpolatePoint( double x, double y, double& result )
|
||||
|
||||
void QgsTINInterpolator::initialize()
|
||||
{
|
||||
DualEdgeTriangulation* dualEdgeTriangulation = new DualEdgeTriangulation( 100000, nullptr );
|
||||
DualEdgeTriangulation *dualEdgeTriangulation = new DualEdgeTriangulation( 100000, nullptr );
|
||||
if ( mInterpolation == CloughTocher )
|
||||
{
|
||||
NormVecDecorator* dec = new NormVecDecorator();
|
||||
NormVecDecorator *dec = new NormVecDecorator();
|
||||
dec->addTriangulation( dualEdgeTriangulation );
|
||||
mTriangulation = dec;
|
||||
}
|
||||
@ -86,7 +86,7 @@ void QgsTINInterpolator::initialize()
|
||||
int nProcessedFeatures = 0;
|
||||
if ( mShowProgressDialog )
|
||||
{
|
||||
Q_FOREACH ( const LayerData& layer, mLayerData )
|
||||
Q_FOREACH ( const LayerData &layer, mLayerData )
|
||||
{
|
||||
if ( layer.vectorLayer )
|
||||
{
|
||||
@ -95,7 +95,7 @@ void QgsTINInterpolator::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
QProgressDialog* progressDialog = nullptr;
|
||||
QProgressDialog *progressDialog = nullptr;
|
||||
if ( mShowProgressDialog )
|
||||
{
|
||||
progressDialog = new QProgressDialog( QObject::tr( "Building triangulation..." ), QObject::tr( "Abort" ), 0, nFeatures, nullptr );
|
||||
@ -104,7 +104,7 @@ void QgsTINInterpolator::initialize()
|
||||
|
||||
|
||||
QgsFeature f;
|
||||
Q_FOREACH ( const LayerData& layer, mLayerData )
|
||||
Q_FOREACH ( const LayerData &layer, mLayerData )
|
||||
{
|
||||
if ( layer.vectorLayer )
|
||||
{
|
||||
@ -136,11 +136,11 @@ void QgsTINInterpolator::initialize()
|
||||
|
||||
if ( mInterpolation == CloughTocher )
|
||||
{
|
||||
CloughTocherInterpolator* ctInterpolator = new CloughTocherInterpolator();
|
||||
NormVecDecorator* dec = dynamic_cast<NormVecDecorator*>( mTriangulation );
|
||||
CloughTocherInterpolator *ctInterpolator = new CloughTocherInterpolator();
|
||||
NormVecDecorator *dec = dynamic_cast<NormVecDecorator *>( mTriangulation );
|
||||
if ( dec )
|
||||
{
|
||||
QProgressDialog* progressDialog = nullptr;
|
||||
QProgressDialog *progressDialog = nullptr;
|
||||
if ( mShowProgressDialog ) //show a progress dialog because it can take a long time...
|
||||
{
|
||||
progressDialog = new QProgressDialog();
|
||||
@ -166,7 +166,7 @@ void QgsTINInterpolator::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputType type )
|
||||
int QgsTINInterpolator::insertData( QgsFeature *f, bool zCoord, int attr, InputType type )
|
||||
{
|
||||
if ( !f )
|
||||
{
|
||||
@ -205,7 +205,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
|
||||
QgsConstWkbPtr currentWkbPtr( wkb );
|
||||
currentWkbPtr.readHeader();
|
||||
//maybe a structure or break line
|
||||
Line3D* line = nullptr;
|
||||
Line3D *line = nullptr;
|
||||
|
||||
QgsWkbTypes::Type wkbType = g.wkbType();
|
||||
switch ( wkbType )
|
||||
@ -224,7 +224,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
|
||||
{
|
||||
z = attributeValue;
|
||||
}
|
||||
Point3D* point = new Point3D( x, y, z );
|
||||
Point3D *point = new Point3D( x, y, z );
|
||||
if ( mTriangulation->addPoint( point ) == -100 )
|
||||
{
|
||||
return -1;
|
||||
|
@ -37,7 +37,7 @@ class ANALYSIS_EXPORT QgsTINInterpolator: public QgsInterpolator
|
||||
Linear,
|
||||
CloughTocher
|
||||
};
|
||||
QgsTINInterpolator( const QList<LayerData>& inputData, TINInterpolation interpolation = Linear, bool showProgressDialog = false );
|
||||
QgsTINInterpolator( const QList<LayerData> &inputData, TINInterpolation interpolation = Linear, bool showProgressDialog = false );
|
||||
~QgsTINInterpolator();
|
||||
|
||||
/** Calculates interpolation value for map coordinates x, y
|
||||
@ -45,14 +45,14 @@ class ANALYSIS_EXPORT QgsTINInterpolator: public QgsInterpolator
|
||||
@param y y-coordinate (in map units)
|
||||
@param result out: interpolation result
|
||||
@return 0 in case of success*/
|
||||
int interpolatePoint( double x, double y, double& result ) override;
|
||||
int interpolatePoint( double x, double y, double &result ) override;
|
||||
|
||||
void setExportTriangulationToFile( bool e ) {mExportTriangulationToFile = e;}
|
||||
void setTriangulationFilePath( const QString& filepath ) {mTriangulationFilePath = filepath;}
|
||||
void setTriangulationFilePath( const QString &filepath ) {mTriangulationFilePath = filepath;}
|
||||
|
||||
private:
|
||||
Triangulation* mTriangulation = nullptr;
|
||||
TriangleInterpolator* mTriangleInterpolator = nullptr;
|
||||
Triangulation *mTriangulation = nullptr;
|
||||
TriangleInterpolator *mTriangleInterpolator = nullptr;
|
||||
bool mIsInitialized;
|
||||
bool mShowProgressDialog;
|
||||
//! If true: export triangulation to shapefile after initialization
|
||||
@ -71,7 +71,7 @@ class ANALYSIS_EXPORT QgsTINInterpolator: public QgsInterpolator
|
||||
@param attr interpolation attribute index (if zCoord is false)
|
||||
@param type point/structure line, break line
|
||||
@return 0 in case of success, -1 if the feature could not be inserted because of numerical problems*/
|
||||
int insertData( QgsFeature* f, bool zCoord, int attr, InputType type );
|
||||
int insertData( QgsFeature *f, bool zCoord, int attr, InputType type );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,13 +24,13 @@ QgsGraph::QgsGraph()
|
||||
{
|
||||
}
|
||||
|
||||
int QgsGraph::addVertex( const QgsPoint& pt )
|
||||
int QgsGraph::addVertex( const QgsPoint &pt )
|
||||
{
|
||||
mGraphVertexes.append( QgsGraphVertex( pt ) );
|
||||
return mGraphVertexes.size() - 1;
|
||||
}
|
||||
|
||||
int QgsGraph::addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& strategies )
|
||||
int QgsGraph::addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant > &strategies )
|
||||
{
|
||||
QgsGraphEdge e;
|
||||
|
||||
@ -46,12 +46,12 @@ int QgsGraph::addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVarian
|
||||
return mGraphEdges.size() - 1;
|
||||
}
|
||||
|
||||
const QgsGraphVertex& QgsGraph::vertex( int idx ) const
|
||||
const QgsGraphVertex &QgsGraph::vertex( int idx ) const
|
||||
{
|
||||
return mGraphVertexes[ idx ];
|
||||
}
|
||||
|
||||
const QgsGraphEdge& QgsGraph::edge( int idx ) const
|
||||
const QgsGraphEdge &QgsGraph::edge( int idx ) const
|
||||
{
|
||||
return mGraphEdges[ idx ];
|
||||
}
|
||||
@ -66,7 +66,7 @@ int QgsGraph::edgeCount() const
|
||||
return mGraphEdges.size();
|
||||
}
|
||||
|
||||
int QgsGraph::findVertex( const QgsPoint& pt ) const
|
||||
int QgsGraph::findVertex( const QgsPoint &pt ) const
|
||||
{
|
||||
int i = 0;
|
||||
for ( i = 0; i < mGraphVertexes.size(); ++i )
|
||||
@ -80,8 +80,8 @@ int QgsGraph::findVertex( const QgsPoint& pt ) const
|
||||
}
|
||||
|
||||
QgsGraphEdge::QgsGraphEdge()
|
||||
: mOut( 0 )
|
||||
, mIn( 0 )
|
||||
: mOut( 0 )
|
||||
, mIn( 0 )
|
||||
{
|
||||
|
||||
}
|
||||
@ -106,8 +106,8 @@ int QgsGraphEdge::outVertex() const
|
||||
return mOut;
|
||||
}
|
||||
|
||||
QgsGraphVertex::QgsGraphVertex( const QgsPoint& point )
|
||||
: mCoordinate( point )
|
||||
QgsGraphVertex::QgsGraphVertex( const QgsPoint &point )
|
||||
: mCoordinate( point )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class ANALYSIS_EXPORT QgsGraphVertex
|
||||
* This constructor initializes QgsGraphVertex object and associates a vertex with a point
|
||||
*/
|
||||
|
||||
QgsGraphVertex( const QgsPoint& point );
|
||||
QgsGraphVertex( const QgsPoint &point );
|
||||
|
||||
/**
|
||||
* Returns outgoing edges ids
|
||||
@ -138,12 +138,12 @@ class ANALYSIS_EXPORT QgsGraph
|
||||
/**
|
||||
* Add a vertex to the graph
|
||||
*/
|
||||
int addVertex( const QgsPoint& pt );
|
||||
int addVertex( const QgsPoint &pt );
|
||||
|
||||
/**
|
||||
* Add an edge to the graph
|
||||
*/
|
||||
int addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& strategies );
|
||||
int addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant > &strategies );
|
||||
|
||||
/**
|
||||
* Returns number of graph vertices
|
||||
@ -153,7 +153,7 @@ class ANALYSIS_EXPORT QgsGraph
|
||||
/**
|
||||
* Returns vertex at given index
|
||||
*/
|
||||
const QgsGraphVertex& vertex( int idx ) const;
|
||||
const QgsGraphVertex &vertex( int idx ) const;
|
||||
|
||||
/**
|
||||
* Returns number of graph edges
|
||||
@ -163,13 +163,13 @@ class ANALYSIS_EXPORT QgsGraph
|
||||
/**
|
||||
* Returns edge at given index
|
||||
*/
|
||||
const QgsGraphEdge& edge( int idx ) const;
|
||||
const QgsGraphEdge &edge( int idx ) const;
|
||||
|
||||
/**
|
||||
* Find vertex by associated point
|
||||
* \return vertex index
|
||||
*/
|
||||
int findVertex( const QgsPoint& pt ) const;
|
||||
int findVertex( const QgsPoint &pt ) const;
|
||||
|
||||
private:
|
||||
QVector<QgsGraphVertex> mGraphVertexes;
|
||||
|
@ -22,9 +22,9 @@
|
||||
#include "qgsgraph.h"
|
||||
#include "qgsgraphanalyzer.h"
|
||||
|
||||
void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int criterionNum, QVector<int>* resultTree, QVector<double>* resultCost )
|
||||
void QgsGraphAnalyzer::dijkstra( const QgsGraph *source, int startPointIdx, int criterionNum, QVector<int> *resultTree, QVector<double> *resultCost )
|
||||
{
|
||||
QVector< double > * result = nullptr;
|
||||
QVector< double > *result = nullptr;
|
||||
if ( resultCost )
|
||||
{
|
||||
result = resultCost;
|
||||
@ -83,7 +83,7 @@ void QgsGraphAnalyzer::dijkstra( const QgsGraph* source, int startPointIdx, int
|
||||
}
|
||||
}
|
||||
|
||||
QgsGraph* QgsGraphAnalyzer::shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum )
|
||||
QgsGraph *QgsGraphAnalyzer::shortestTree( const QgsGraph *source, int startVertexIdx, int criterionNum )
|
||||
{
|
||||
QgsGraph *treeResult = new QgsGraph();
|
||||
QVector<int> tree;
|
||||
@ -109,7 +109,7 @@ QgsGraph* QgsGraphAnalyzer::shortestTree( const QgsGraph* source, int startVerte
|
||||
{
|
||||
if ( tree[ i ] != -1 )
|
||||
{
|
||||
const QgsGraphEdge& arc = source->edge( tree[i] );
|
||||
const QgsGraphEdge &arc = source->edge( tree[i] );
|
||||
|
||||
treeResult->addEdge( source2result[ arc.outVertex()], source2result[ arc.inVertex()],
|
||||
arc.strategies() );
|
||||
|
@ -38,7 +38,7 @@ class ANALYSIS_EXPORT QgsGraphAnalyzer
|
||||
* @param resultTree array that represents shortest path tree. resultTree[ vertexIndex ] == inboundingArcIndex if vertex reachable, otherwise resultTree[ vertexIndex ] == -1
|
||||
* @param resultCost array of the paths costs
|
||||
*/
|
||||
static void dijkstra( const QgsGraph* source, int startVertexIdx, int criterionNum, QVector<int>* resultTree = nullptr, QVector<double>* resultCost = nullptr );
|
||||
static void dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = nullptr, QVector<double> *resultCost = nullptr );
|
||||
|
||||
/**
|
||||
* Returns shortest path tree with root-node in startVertexIdx
|
||||
@ -46,7 +46,7 @@ class ANALYSIS_EXPORT QgsGraphAnalyzer
|
||||
* @param startVertexIdx index of the start vertex
|
||||
* @param criterionNum index of the optimization strategy
|
||||
*/
|
||||
static QgsGraph* shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum );
|
||||
static QgsGraph *shortestTree( const QgsGraph *source, int startVertexIdx, int criterionNum );
|
||||
};
|
||||
|
||||
#endif // QGSGRAPHANALYZER_H
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include <qgsfeature.h>
|
||||
#include <qgsgeometry.h>
|
||||
|
||||
QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool otfEnabled, double topologyTolerance, const QString& ellipsoidID )
|
||||
: QgsGraphBuilderInterface( crs, otfEnabled, topologyTolerance, ellipsoidID )
|
||||
QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem &crs, bool otfEnabled, double topologyTolerance, const QString &ellipsoidID )
|
||||
: QgsGraphBuilderInterface( crs, otfEnabled, topologyTolerance, ellipsoidID )
|
||||
{
|
||||
mGraph = new QgsGraph();
|
||||
}
|
||||
@ -35,19 +35,19 @@ QgsGraphBuilder::~QgsGraphBuilder()
|
||||
delete mGraph;
|
||||
}
|
||||
|
||||
void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )
|
||||
void QgsGraphBuilder::addVertex( int, const QgsPoint &pt )
|
||||
{
|
||||
mGraph->addVertex( pt );
|
||||
}
|
||||
|
||||
void QgsGraphBuilder::addEdge( int pt1id, const QgsPoint&, int pt2id, const QgsPoint&, const QVector< QVariant >& prop )
|
||||
void QgsGraphBuilder::addEdge( int pt1id, const QgsPoint &, int pt2id, const QgsPoint &, const QVector< QVariant > &prop )
|
||||
{
|
||||
mGraph->addEdge( pt1id, pt2id, prop );
|
||||
}
|
||||
|
||||
QgsGraph* QgsGraphBuilder::graph()
|
||||
QgsGraph *QgsGraphBuilder::graph()
|
||||
{
|
||||
QgsGraph* res = mGraph;
|
||||
QgsGraph *res = mGraph;
|
||||
mGraph = nullptr;
|
||||
return res;
|
||||
}
|
||||
|
@ -38,21 +38,21 @@ class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool otfEnabled = true, double topologyTolerance = 0.0, const QString& ellipsoidID = "WGS84" );
|
||||
QgsGraphBuilder( const QgsCoordinateReferenceSystem &crs, bool otfEnabled = true, double topologyTolerance = 0.0, const QString &ellipsoidID = "WGS84" );
|
||||
|
||||
~QgsGraphBuilder();
|
||||
|
||||
/*
|
||||
* MANDATORY BUILDER PROPERTY DECLARATION
|
||||
*/
|
||||
virtual void addVertex( int id, const QgsPoint& pt ) override;
|
||||
virtual void addVertex( int id, const QgsPoint &pt ) override;
|
||||
|
||||
virtual void addEdge( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& prop ) override;
|
||||
virtual void addEdge( int pt1id, const QgsPoint &pt1, int pt2id, const QgsPoint &pt2, const QVector< QVariant > &prop ) override;
|
||||
|
||||
/**
|
||||
* Returns generated QgsGraph
|
||||
*/
|
||||
QgsGraph* graph();
|
||||
QgsGraph *graph();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -41,10 +41,10 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
|
||||
* @param topologyTolerance sqrt distance between source point as one graph vertex
|
||||
* @param ellipsoidID ellipsoid for edge measurement
|
||||
*/
|
||||
QgsGraphBuilderInterface( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled = true, double topologyTolerance = 0.0, const QString& ellipsoidID = "WGS84" )
|
||||
: mCrs( crs )
|
||||
, mCtfEnabled( ctfEnabled )
|
||||
, mTopologyTolerance( topologyTolerance )
|
||||
QgsGraphBuilderInterface( const QgsCoordinateReferenceSystem &crs, bool ctfEnabled = true, double topologyTolerance = 0.0, const QString &ellipsoidID = "WGS84" )
|
||||
: mCrs( crs )
|
||||
, mCtfEnabled( ctfEnabled )
|
||||
, mTopologyTolerance( topologyTolerance )
|
||||
{
|
||||
mDa.setSourceCrs( mCrs );
|
||||
mDa.setEllipsoid( ellipsoidID );
|
||||
@ -73,7 +73,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
|
||||
}
|
||||
|
||||
//! Returns measurement tool
|
||||
QgsDistanceArea* distanceArea()
|
||||
QgsDistanceArea *distanceArea()
|
||||
{
|
||||
return &mDa;
|
||||
}
|
||||
@ -99,7 +99,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
|
||||
* @param strategies optimization strategies
|
||||
* @note pt1id, pt1 and pt2id, pt2 is a redundant interface. You can use vertex coordinates or their identificators.
|
||||
*/
|
||||
virtual void addEdge( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& strategies )
|
||||
virtual void addEdge( int pt1id, const QgsPoint &pt1, int pt2id, const QgsPoint &pt2, const QVector< QVariant > &strategies )
|
||||
{
|
||||
Q_UNUSED( pt1id );
|
||||
Q_UNUSED( pt1 );
|
||||
|
@ -38,7 +38,7 @@ class ANALYSIS_EXPORT QgsGraphDirector : public QObject
|
||||
|
||||
signals:
|
||||
void buildProgress( int, int ) const;
|
||||
void buildMessage( const QString& ) const;
|
||||
void buildMessage( const QString & ) const;
|
||||
|
||||
public:
|
||||
|
||||
@ -62,7 +62,7 @@ class ANALYSIS_EXPORT QgsGraphDirector : public QObject
|
||||
}
|
||||
|
||||
//! Add optimization strategy
|
||||
void addStrategy( QgsNetworkStrategy* prop )
|
||||
void addStrategy( QgsNetworkStrategy *prop )
|
||||
{
|
||||
mStrategies.push_back( prop );
|
||||
}
|
||||
@ -71,7 +71,7 @@ class ANALYSIS_EXPORT QgsGraphDirector : public QObject
|
||||
virtual QString name() const = 0;
|
||||
|
||||
protected:
|
||||
QList<QgsNetworkStrategy*> mStrategies;
|
||||
QList<QgsNetworkStrategy *> mStrategies;
|
||||
};
|
||||
|
||||
#endif // QGSGRAPHDIRECTOR_H
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "qgsnetworkdistancestrategy.h"
|
||||
|
||||
QVariant QgsNetworkDistanceStrategy::cost( double distance, const QgsFeature& f ) const
|
||||
QVariant QgsNetworkDistanceStrategy::cost( double distance, const QgsFeature &f ) const
|
||||
{
|
||||
Q_UNUSED( f );
|
||||
return QVariant( distance );
|
||||
|
@ -28,7 +28,7 @@
|
||||
class ANALYSIS_EXPORT QgsNetworkDistanceStrategy : public QgsNetworkStrategy
|
||||
{
|
||||
public:
|
||||
virtual QVariant cost( double distance, const QgsFeature& ) const override;
|
||||
virtual QVariant cost( double distance, const QgsFeature & ) const override;
|
||||
};
|
||||
|
||||
#endif // QGSNETWORKDISTANCESTRATEGY_H
|
||||
|
@ -22,7 +22,7 @@ QgsNetworkSpeedStrategy::QgsNetworkSpeedStrategy( int attributeId, double defaul
|
||||
mToMetricFactor = toMetricFactor;
|
||||
}
|
||||
|
||||
QVariant QgsNetworkSpeedStrategy::cost( double distance, const QgsFeature& f ) const
|
||||
QVariant QgsNetworkSpeedStrategy::cost( double distance, const QgsFeature &f ) const
|
||||
{
|
||||
QgsAttributes attrs = f.attributes();
|
||||
|
||||
|
@ -35,7 +35,7 @@ class ANALYSIS_EXPORT QgsNetworkSpeedStrategy : public QgsNetworkStrategy
|
||||
QgsNetworkSpeedStrategy( int attributeId, double defaultValue, double toMetricFactor );
|
||||
|
||||
//! Returns edge cost
|
||||
QVariant cost( double distance, const QgsFeature& f ) const override;
|
||||
QVariant cost( double distance, const QgsFeature &f ) const override;
|
||||
|
||||
/**
|
||||
* Returns list of the source layer attributes needed for cost calculation.
|
||||
|
@ -39,10 +39,10 @@ class QgsPointCompare
|
||||
{
|
||||
public:
|
||||
explicit QgsPointCompare( double tolerance )
|
||||
: mTolerance( tolerance )
|
||||
: mTolerance( tolerance )
|
||||
{ }
|
||||
|
||||
bool operator()( const QgsPoint& p1, const QgsPoint& p2 ) const
|
||||
bool operator()( const QgsPoint &p1, const QgsPoint &p2 ) const
|
||||
{
|
||||
if ( mTolerance <= 0 )
|
||||
return p1.x() == p2.x() ? p1.y() < p2.y() : p1.x() < p2.x();
|
||||
@ -94,7 +94,7 @@ struct TiePointInfo
|
||||
QgsPoint mLastPoint;
|
||||
};
|
||||
|
||||
bool TiePointInfoCompare( const TiePointInfo& a, const TiePointInfo& b )
|
||||
bool TiePointInfoCompare( const TiePointInfo &a, const TiePointInfo &b )
|
||||
{
|
||||
if ( a.mFirstPoint == b.mFirstPoint )
|
||||
return a.mLastPoint.x() == b.mLastPoint.x() ? a.mLastPoint.y() < b.mLastPoint.y() : a.mLastPoint.x() < b.mLastPoint.x();
|
||||
@ -104,9 +104,9 @@ bool TiePointInfoCompare( const TiePointInfo& a, const TiePointInfo& b )
|
||||
|
||||
QgsVectorLayerDirector::QgsVectorLayerDirector( QgsVectorLayer *myLayer,
|
||||
int directionFieldId,
|
||||
const QString& directDirectionValue,
|
||||
const QString& reverseDirectionValue,
|
||||
const QString& bothDirectionValue,
|
||||
const QString &directDirectionValue,
|
||||
const QString &reverseDirectionValue,
|
||||
const QString &bothDirectionValue,
|
||||
const Direction defaultDirection
|
||||
)
|
||||
{
|
||||
@ -123,8 +123,8 @@ QString QgsVectorLayerDirector::name() const
|
||||
return QStringLiteral( "Vector line" );
|
||||
}
|
||||
|
||||
void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const QVector< QgsPoint >& additionalPoints,
|
||||
QVector< QgsPoint >& snappedPoints ) const
|
||||
void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const QVector< QgsPoint > &additionalPoints,
|
||||
QVector< QgsPoint > &snappedPoints ) const
|
||||
{
|
||||
QgsVectorLayer *vl = mVectorLayer;
|
||||
|
||||
@ -232,7 +232,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
|
||||
QVector< QgsPoint >::iterator tmp = std::unique( points.begin(), points.end() );
|
||||
points.resize( tmp - points.begin() );
|
||||
|
||||
for ( i = 0;i < points.size();++i )
|
||||
for ( i = 0; i < points.size(); ++i )
|
||||
builder->addVertex( i, points[ i ] );
|
||||
|
||||
for ( i = 0; i < snappedPoints.size() ; ++i )
|
||||
@ -248,7 +248,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
|
||||
tmpAttr.push_back( mDirectionFieldId );
|
||||
}
|
||||
|
||||
QList< QgsNetworkStrategy* >::const_iterator it;
|
||||
QList< QgsNetworkStrategy * >::const_iterator it;
|
||||
QgsAttributeList::const_iterator it2;
|
||||
|
||||
for ( it = mStrategies.begin(); it != mStrategies.end(); ++it )
|
||||
@ -361,10 +361,10 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
|
||||
{
|
||||
double distance = builder->distanceArea()->measureLine( pt1, pt2 );
|
||||
QVector< QVariant > prop;
|
||||
QList< QgsNetworkStrategy* >::const_iterator it;
|
||||
QList< QgsNetworkStrategy * >::const_iterator it;
|
||||
for ( it = mStrategies.begin(); it != mStrategies.end(); ++it )
|
||||
{
|
||||
prop.push_back(( *it )->cost( distance, feature ) );
|
||||
prop.push_back( ( *it )->cost( distance, feature ) );
|
||||
}
|
||||
|
||||
if ( directionType == Direction::DirectionForward ||
|
||||
|
@ -57,11 +57,11 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector
|
||||
* @param defaultDirection default direction. Will be used if corresponding
|
||||
* attribute value is not set or does not equal to the given values
|
||||
*/
|
||||
QgsVectorLayerDirector( QgsVectorLayer* myLayer,
|
||||
QgsVectorLayerDirector( QgsVectorLayer *myLayer,
|
||||
int directionFieldId,
|
||||
const QString& directDirectionValue,
|
||||
const QString& reverseDirectionValue,
|
||||
const QString& bothDirectionValue,
|
||||
const QString &directDirectionValue,
|
||||
const QString &reverseDirectionValue,
|
||||
const QString &bothDirectionValue,
|
||||
const Direction defaultDirection
|
||||
);
|
||||
|
||||
@ -71,8 +71,8 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector
|
||||
* MANDATORY DIRECTOR PROPERTY DECLARATION
|
||||
*/
|
||||
void makeGraph( QgsGraphBuilderInterface *builder,
|
||||
const QVector< QgsPoint >& additionalPoints,
|
||||
QVector< QgsPoint>& snappedPoints ) const override;
|
||||
const QVector< QgsPoint > &additionalPoints,
|
||||
QVector< QgsPoint> &snappedPoints ) const override;
|
||||
|
||||
QString name() const override;
|
||||
|
||||
|
@ -72,9 +72,9 @@ class ANALYSIS_EXPORT QgsOSMNode : public QgsOSMElement
|
||||
{
|
||||
public:
|
||||
QgsOSMNode() : mPoint() {}
|
||||
QgsOSMNode( QgsOSMId id, const QgsPoint& point )
|
||||
: QgsOSMElement( QgsOSMElementID::Node, id )
|
||||
, mPoint( point )
|
||||
QgsOSMNode( QgsOSMId id, const QgsPoint &point )
|
||||
: QgsOSMElement( QgsOSMElementID::Node, id )
|
||||
, mPoint( point )
|
||||
{}
|
||||
|
||||
QgsPoint point() const { return mPoint; }
|
||||
@ -95,9 +95,9 @@ class ANALYSIS_EXPORT QgsOSMWay : public QgsOSMElement
|
||||
{
|
||||
public:
|
||||
QgsOSMWay() {}
|
||||
QgsOSMWay( QgsOSMId id, const QList<QgsOSMId>& nodes )
|
||||
: QgsOSMElement( QgsOSMElementID::Way, id )
|
||||
, mNodes( nodes )
|
||||
QgsOSMWay( QgsOSMId id, const QList<QgsOSMId> &nodes )
|
||||
: QgsOSMElement( QgsOSMElementID::Way, id )
|
||||
, mNodes( nodes )
|
||||
{}
|
||||
|
||||
QList<QgsOSMId> nodes() const { return mNodes; }
|
||||
@ -137,9 +137,9 @@ class ANALYSIS_EXPORT QgsOSMTags
|
||||
|
||||
int count() const { return mMap.count(); }
|
||||
QList<QString> keys() const { return mMap.keys(); }
|
||||
bool contains( const QString& k ) const { return mMap.contains( k ); }
|
||||
void insert( const QString& k, const QString& v ) { mMap.insert( k, v ); }
|
||||
QString value( const QString& k ) const { return mMap.value( k ); }
|
||||
bool contains( const QString &k ) const { return mMap.contains( k ); }
|
||||
void insert( const QString &k, const QString &v ) { mMap.insert( k, v ); }
|
||||
QString value( const QString &k ) const { return mMap.value( k ); }
|
||||
|
||||
private:
|
||||
QMap<QString, QString> mMap;
|
||||
|
@ -19,15 +19,15 @@
|
||||
#include "qgslogger.h"
|
||||
|
||||
|
||||
QgsOSMDatabase::QgsOSMDatabase( const QString& dbFileName )
|
||||
: mDbFileName( dbFileName )
|
||||
, mDatabase( nullptr )
|
||||
, mStmtNode( nullptr )
|
||||
, mStmtNodeTags( nullptr )
|
||||
, mStmtWay( nullptr )
|
||||
, mStmtWayNode( nullptr )
|
||||
, mStmtWayNodePoints( nullptr )
|
||||
, mStmtWayTags( nullptr )
|
||||
QgsOSMDatabase::QgsOSMDatabase( const QString &dbFileName )
|
||||
: mDbFileName( dbFileName )
|
||||
, mDatabase( nullptr )
|
||||
, mStmtNode( nullptr )
|
||||
, mStmtNodeTags( nullptr )
|
||||
, mStmtWay( nullptr )
|
||||
, mStmtWayNode( nullptr )
|
||||
, mStmtWayNodePoints( nullptr )
|
||||
, mStmtWayTags( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ bool QgsOSMDatabase::open()
|
||||
}
|
||||
|
||||
|
||||
void QgsOSMDatabase::deleteStatement( sqlite3_stmt*& stmt )
|
||||
void QgsOSMDatabase::deleteStatement( sqlite3_stmt *&stmt )
|
||||
{
|
||||
if ( stmt )
|
||||
{
|
||||
@ -96,9 +96,9 @@ bool QgsOSMDatabase::close()
|
||||
}
|
||||
|
||||
|
||||
int QgsOSMDatabase::runCountStatement( const char* sql ) const
|
||||
int QgsOSMDatabase::runCountStatement( const char *sql ) const
|
||||
{
|
||||
sqlite3_stmt* stmt = nullptr;
|
||||
sqlite3_stmt *stmt = nullptr;
|
||||
int res = sqlite3_prepare_v2( mDatabase, sql, -1, &stmt, nullptr );
|
||||
if ( res != SQLITE_OK )
|
||||
return -1;
|
||||
@ -160,14 +160,14 @@ QgsOSMTags QgsOSMDatabase::tags( bool way, QgsOSMId id ) const
|
||||
{
|
||||
QgsOSMTags t;
|
||||
|
||||
sqlite3_stmt* stmtTags = way ? mStmtWayTags : mStmtNodeTags;
|
||||
sqlite3_stmt *stmtTags = way ? mStmtWayTags : mStmtNodeTags;
|
||||
|
||||
sqlite3_bind_int64( stmtTags, 1, id );
|
||||
|
||||
while ( sqlite3_step( stmtTags ) == SQLITE_ROW )
|
||||
{
|
||||
QString k = QString::fromUtf8(( const char* ) sqlite3_column_text( stmtTags, 0 ) );
|
||||
QString v = QString::fromUtf8(( const char* ) sqlite3_column_text( stmtTags, 1 ) );
|
||||
QString k = QString::fromUtf8( ( const char * ) sqlite3_column_text( stmtTags, 0 ) );
|
||||
QString v = QString::fromUtf8( ( const char * ) sqlite3_column_text( stmtTags, 1 ) );
|
||||
t.insert( k, v );
|
||||
}
|
||||
|
||||
@ -182,13 +182,13 @@ QList<QgsOSMTagCountPair> QgsOSMDatabase::usedTags( bool ways ) const
|
||||
|
||||
QString sql = QStringLiteral( "SELECT k, count(k) FROM %1_tags GROUP BY k" ).arg( ways ? "ways" : "nodes" );
|
||||
|
||||
sqlite3_stmt* stmt = nullptr;
|
||||
sqlite3_stmt *stmt = nullptr;
|
||||
if ( sqlite3_prepare_v2( mDatabase, sql.toUtf8().data(), -1, &stmt, nullptr ) != SQLITE_OK )
|
||||
return pairs;
|
||||
|
||||
while ( sqlite3_step( stmt ) == SQLITE_ROW )
|
||||
{
|
||||
QString k = QString::fromUtf8(( const char* ) sqlite3_column_text( stmt, 0 ) );
|
||||
QString k = QString::fromUtf8( ( const char * ) sqlite3_column_text( stmt, 0 ) );
|
||||
int count = sqlite3_column_int( stmt, 1 );
|
||||
pairs.append( qMakePair( k, count ) );
|
||||
}
|
||||
@ -255,7 +255,7 @@ QgsPolyline QgsOSMDatabase::wayPoints( QgsOSMId id ) const
|
||||
|
||||
bool QgsOSMDatabase::prepareStatements()
|
||||
{
|
||||
const char* sql[] =
|
||||
const char *sql[] =
|
||||
{
|
||||
"SELECT lon,lat FROM nodes WHERE id=?",
|
||||
"SELECT k,v FROM nodes_tags WHERE id=?",
|
||||
@ -264,7 +264,7 @@ bool QgsOSMDatabase::prepareStatements()
|
||||
"SELECT n.lon, n.lat FROM ways_nodes wn LEFT JOIN nodes n ON wn.node_id = n.id WHERE wn.way_id=? ORDER BY wn.way_pos",
|
||||
"SELECT k,v FROM ways_tags WHERE id=?"
|
||||
};
|
||||
sqlite3_stmt** sqlite[] =
|
||||
sqlite3_stmt **sqlite[] =
|
||||
{
|
||||
&mStmtNode,
|
||||
&mStmtNodeTags,
|
||||
@ -273,14 +273,14 @@ bool QgsOSMDatabase::prepareStatements()
|
||||
&mStmtWayNodePoints,
|
||||
&mStmtWayTags
|
||||
};
|
||||
int count = sizeof( sql ) / sizeof( const char* );
|
||||
Q_ASSERT( count == sizeof( sqlite ) / sizeof( sqlite3_stmt** ) );
|
||||
int count = sizeof( sql ) / sizeof( const char * );
|
||||
Q_ASSERT( count == sizeof( sqlite ) / sizeof( sqlite3_stmt ** ) );
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
if ( sqlite3_prepare_v2( mDatabase, sql[i], -1, sqlite[i], nullptr ) != SQLITE_OK )
|
||||
{
|
||||
const char* errMsg = sqlite3_errmsg( mDatabase ); // does not require free
|
||||
const char *errMsg = sqlite3_errmsg( mDatabase ); // does not require free
|
||||
mError = QStringLiteral( "Error preparing SQL command:\n%1\nSQL:\n%2" )
|
||||
.arg( QString::fromUtf8( errMsg ), QString::fromUtf8( sql[i] ) );
|
||||
return false;
|
||||
@ -290,9 +290,9 @@ bool QgsOSMDatabase::prepareStatements()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString& tableName,
|
||||
const QStringList& tagKeys,
|
||||
const QStringList& notNullTagKeys )
|
||||
bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString &tableName,
|
||||
const QStringList &tagKeys,
|
||||
const QStringList ¬NullTagKeys )
|
||||
{
|
||||
mError.clear();
|
||||
|
||||
@ -331,7 +331,7 @@ bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString& tableName
|
||||
}
|
||||
|
||||
|
||||
bool QgsOSMDatabase::createSpatialTable( const QString& tableName, const QString& geometryType, const QStringList& tagKeys )
|
||||
bool QgsOSMDatabase::createSpatialTable( const QString &tableName, const QString &geometryType, const QStringList &tagKeys )
|
||||
{
|
||||
QString sqlCreateTable = QStringLiteral( "CREATE TABLE %1 (id INTEGER PRIMARY KEY" ).arg( quotedIdentifier( tableName ) );
|
||||
for ( int i = 0; i < tagKeys.count(); ++i )
|
||||
@ -362,7 +362,7 @@ bool QgsOSMDatabase::createSpatialTable( const QString& tableName, const QString
|
||||
}
|
||||
|
||||
|
||||
bool QgsOSMDatabase::createSpatialIndex( const QString& tableName )
|
||||
bool QgsOSMDatabase::createSpatialIndex( const QString &tableName )
|
||||
{
|
||||
QString sqlSpatialIndex = QStringLiteral( "SELECT CreateSpatialIndex(%1, 'geometry')" ).arg( quotedValue( tableName ) );
|
||||
char *errMsg = nullptr;
|
||||
@ -378,13 +378,13 @@ bool QgsOSMDatabase::createSpatialIndex( const QString& tableName )
|
||||
}
|
||||
|
||||
|
||||
void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys )
|
||||
void QgsOSMDatabase::exportSpatiaLiteNodes( const QString &tableName, const QStringList &tagKeys, const QStringList ¬NullTagKeys )
|
||||
{
|
||||
QString sqlInsertPoint = QStringLiteral( "INSERT INTO %1 VALUES (?" ).arg( quotedIdentifier( tableName ) );
|
||||
for ( int i = 0; i < tagKeys.count(); ++i )
|
||||
sqlInsertPoint += QStringLiteral( ",?" );
|
||||
sqlInsertPoint += QLatin1String( ", GeomFromWKB(?, 4326))" );
|
||||
sqlite3_stmt* stmtInsert = nullptr;
|
||||
sqlite3_stmt *stmtInsert = nullptr;
|
||||
if ( sqlite3_prepare_v2( mDatabase, sqlInsertPoint.toUtf8().constData(), -1, &stmtInsert, nullptr ) != SQLITE_OK )
|
||||
{
|
||||
mError = QStringLiteral( "Prepare SELECT FROM nodes failed." );
|
||||
@ -393,7 +393,7 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
|
||||
|
||||
QgsOSMNodeIterator nodes = listNodes();
|
||||
QgsOSMNode n;
|
||||
while (( n = nodes.next() ).isValid() )
|
||||
while ( ( n = nodes.next() ).isValid() )
|
||||
{
|
||||
QgsOSMTags t = tags( false, n.id() );
|
||||
|
||||
@ -441,9 +441,9 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
|
||||
}
|
||||
|
||||
|
||||
void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName,
|
||||
const QStringList& tagKeys,
|
||||
const QStringList& notNullTagKeys )
|
||||
void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString &tableName,
|
||||
const QStringList &tagKeys,
|
||||
const QStringList ¬NullTagKeys )
|
||||
{
|
||||
Q_UNUSED( tagKeys );
|
||||
|
||||
@ -451,7 +451,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
|
||||
for ( int i = 0; i < tagKeys.count(); ++i )
|
||||
sqlInsertLine += QStringLiteral( ",?" );
|
||||
sqlInsertLine += QLatin1String( ", GeomFromWKB(?, 4326))" );
|
||||
sqlite3_stmt* stmtInsert = nullptr;
|
||||
sqlite3_stmt *stmtInsert = nullptr;
|
||||
if ( sqlite3_prepare_v2( mDatabase, sqlInsertLine.toUtf8().constData(), -1, &stmtInsert, nullptr ) != SQLITE_OK )
|
||||
{
|
||||
mError = QStringLiteral( "Prepare SELECT FROM ways failed." );
|
||||
@ -460,7 +460,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
|
||||
|
||||
QgsOSMWayIterator ways = listWays();
|
||||
QgsOSMWay w;
|
||||
while (( w = ways.next() ).isValid() )
|
||||
while ( ( w = ways.next() ).isValid() )
|
||||
{
|
||||
QgsOSMTags t = tags( true, w.id() );
|
||||
|
||||
@ -475,7 +475,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
|
||||
{
|
||||
// make sure tags that indicate areas are taken into consideration when deciding on a closed way is or isn't an area
|
||||
// and allow for a closed way to be exported both as a polygon and a line in case both area and non-area tags are present
|
||||
if (( t.value( QStringLiteral( "area" ) ) != QLatin1String( "yes" ) && !t.contains( QStringLiteral( "amenity" ) ) && !t.contains( QStringLiteral( "landuse" ) ) && !t.contains( QStringLiteral( "building" ) ) && !t.contains( QStringLiteral( "natural" ) ) && !t.contains( QStringLiteral( "leisure" ) ) && !t.contains( QStringLiteral( "aeroway" ) ) ) || !closed )
|
||||
if ( ( t.value( QStringLiteral( "area" ) ) != QLatin1String( "yes" ) && !t.contains( QStringLiteral( "amenity" ) ) && !t.contains( QStringLiteral( "landuse" ) ) && !t.contains( QStringLiteral( "building" ) ) && !t.contains( QStringLiteral( "natural" ) ) && !t.contains( QStringLiteral( "leisure" ) ) && !t.contains( QStringLiteral( "aeroway" ) ) ) || !closed )
|
||||
isArea = false;
|
||||
}
|
||||
|
||||
@ -546,10 +546,10 @@ QString QgsOSMDatabase::quotedValue( QString value )
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
QgsOSMNodeIterator::QgsOSMNodeIterator( sqlite3* handle )
|
||||
: mStmt( nullptr )
|
||||
QgsOSMNodeIterator::QgsOSMNodeIterator( sqlite3 *handle )
|
||||
: mStmt( nullptr )
|
||||
{
|
||||
const char* sql = "SELECT id,lon,lat FROM nodes";
|
||||
const char *sql = "SELECT id,lon,lat FROM nodes";
|
||||
if ( sqlite3_prepare_v2( handle, sql, -1, &mStmt, nullptr ) != SQLITE_OK )
|
||||
{
|
||||
qDebug( "OSMNodeIterator: error prepare" );
|
||||
@ -592,10 +592,10 @@ void QgsOSMNodeIterator::close()
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
QgsOSMWayIterator::QgsOSMWayIterator( sqlite3* handle )
|
||||
: mStmt( nullptr )
|
||||
QgsOSMWayIterator::QgsOSMWayIterator( sqlite3 *handle )
|
||||
: mStmt( nullptr )
|
||||
{
|
||||
const char* sql = "SELECT id FROM ways";
|
||||
const char *sql = "SELECT id FROM ways";
|
||||
if ( sqlite3_prepare_v2( handle, sql, -1, &mStmt, nullptr ) != SQLITE_OK )
|
||||
{
|
||||
qDebug( "OSMWayIterator: error prepare" );
|
||||
|
@ -47,15 +47,15 @@ typedef QPair<QString, int> QgsOSMTagCountPair;
|
||||
class ANALYSIS_EXPORT QgsOSMDatabase
|
||||
{
|
||||
public:
|
||||
explicit QgsOSMDatabase( const QString& dbFileName = QString() );
|
||||
explicit QgsOSMDatabase( const QString &dbFileName = QString() );
|
||||
~QgsOSMDatabase();
|
||||
|
||||
//! QgsOSMDatabase cannot be copied.
|
||||
QgsOSMDatabase( const QgsOSMDatabase& rh ) = delete;
|
||||
QgsOSMDatabase( const QgsOSMDatabase &rh ) = delete;
|
||||
//! QgsOSMDatabase cannot be copied.
|
||||
QgsOSMDatabase& operator=( const QgsOSMDatabase& rh ) = delete;
|
||||
QgsOSMDatabase &operator=( const QgsOSMDatabase &rh ) = delete;
|
||||
|
||||
void setFileName( const QString& dbFileName ) { mDbFileName = dbFileName; }
|
||||
void setFileName( const QString &dbFileName ) { mDbFileName = dbFileName; }
|
||||
QString filename() const { return mDbFileName; }
|
||||
bool isOpen() const;
|
||||
|
||||
@ -89,23 +89,23 @@ class ANALYSIS_EXPORT QgsOSMDatabase
|
||||
// export to spatialite
|
||||
|
||||
enum ExportType { Point, Polyline, Polygon };
|
||||
bool exportSpatiaLite( ExportType type, const QString& tableName,
|
||||
const QStringList& tagKeys = QStringList(),
|
||||
const QStringList& noNullTagKeys = QStringList() );
|
||||
bool exportSpatiaLite( ExportType type, const QString &tableName,
|
||||
const QStringList &tagKeys = QStringList(),
|
||||
const QStringList &noNullTagKeys = QStringList() );
|
||||
|
||||
protected:
|
||||
bool prepareStatements();
|
||||
int runCountStatement( const char* sql ) const;
|
||||
int runCountStatement( const char *sql ) const;
|
||||
|
||||
/**
|
||||
* @note not available in Python bindings
|
||||
*/
|
||||
void deleteStatement( sqlite3_stmt*& stmt );
|
||||
void deleteStatement( sqlite3_stmt *&stmt );
|
||||
|
||||
void exportSpatiaLiteNodes( const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys = QStringList() );
|
||||
void exportSpatiaLiteWays( bool closed, const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys = QStringList() );
|
||||
bool createSpatialTable( const QString& tableName, const QString& geometryType, const QStringList& tagKeys );
|
||||
bool createSpatialIndex( const QString& tableName );
|
||||
void exportSpatiaLiteNodes( const QString &tableName, const QStringList &tagKeys, const QStringList ¬NullTagKeys = QStringList() );
|
||||
void exportSpatiaLiteWays( bool closed, const QString &tableName, const QStringList &tagKeys, const QStringList ¬NullTagKeys = QStringList() );
|
||||
bool createSpatialTable( const QString &tableName, const QString &geometryType, const QStringList &tagKeys );
|
||||
bool createSpatialIndex( const QString &tableName );
|
||||
|
||||
QString quotedIdentifier( QString id );
|
||||
QString quotedValue( QString value );
|
||||
@ -117,14 +117,14 @@ class ANALYSIS_EXPORT QgsOSMDatabase
|
||||
QString mError;
|
||||
|
||||
//! pointer to sqlite3 database that keeps OSM data
|
||||
sqlite3* mDatabase = nullptr;
|
||||
sqlite3 *mDatabase = nullptr;
|
||||
|
||||
sqlite3_stmt* mStmtNode = nullptr;
|
||||
sqlite3_stmt* mStmtNodeTags = nullptr;
|
||||
sqlite3_stmt* mStmtWay = nullptr;
|
||||
sqlite3_stmt* mStmtWayNode = nullptr;
|
||||
sqlite3_stmt* mStmtWayNodePoints = nullptr;
|
||||
sqlite3_stmt* mStmtWayTags = nullptr;
|
||||
sqlite3_stmt *mStmtNode = nullptr;
|
||||
sqlite3_stmt *mStmtNodeTags = nullptr;
|
||||
sqlite3_stmt *mStmtWay = nullptr;
|
||||
sqlite3_stmt *mStmtWayNode = nullptr;
|
||||
sqlite3_stmt *mStmtWayNodePoints = nullptr;
|
||||
sqlite3_stmt *mStmtWayTags = nullptr;
|
||||
|
||||
};
|
||||
|
||||
@ -145,9 +145,9 @@ class ANALYSIS_EXPORT QgsOSMNodeIterator // clazy:exclude=rule-of-three
|
||||
|
||||
/** @note not available in Python bindings
|
||||
*/
|
||||
QgsOSMNodeIterator( sqlite3* handle );
|
||||
QgsOSMNodeIterator( sqlite3 *handle );
|
||||
|
||||
sqlite3_stmt* mStmt = nullptr;
|
||||
sqlite3_stmt *mStmt = nullptr;
|
||||
|
||||
friend class QgsOSMDatabase;
|
||||
|
||||
@ -171,9 +171,9 @@ class ANALYSIS_EXPORT QgsOSMWayIterator // clazy:exclude=rule-of-three
|
||||
|
||||
/** @note not available in Python bindings
|
||||
*/
|
||||
QgsOSMWayIterator( sqlite3* handle );
|
||||
QgsOSMWayIterator( sqlite3 *handle );
|
||||
|
||||
sqlite3_stmt* mStmt = nullptr;
|
||||
sqlite3_stmt *mStmt = nullptr;
|
||||
|
||||
friend class QgsOSMDatabase;
|
||||
|
||||
|
@ -28,7 +28,7 @@ QString QgsOSMDownload::defaultServiceUrl()
|
||||
}
|
||||
|
||||
|
||||
QString QgsOSMDownload::queryFromRect( const QgsRectangle& rect )
|
||||
QString QgsOSMDownload::queryFromRect( const QgsRectangle &rect )
|
||||
{
|
||||
return QStringLiteral( "(node(%1,%2,%3,%4);<;);out;" ).arg( rect.yMinimum() ).arg( rect.xMinimum() )
|
||||
.arg( rect.yMaximum() ).arg( rect.xMaximum() );
|
||||
@ -36,8 +36,8 @@ QString QgsOSMDownload::queryFromRect( const QgsRectangle& rect )
|
||||
|
||||
|
||||
QgsOSMDownload::QgsOSMDownload()
|
||||
: mServiceUrl( defaultServiceUrl() )
|
||||
, mReply( nullptr )
|
||||
: mServiceUrl( defaultServiceUrl() )
|
||||
, mReply( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ bool QgsOSMDownload::start()
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsNetworkAccessManager* nwam = QgsNetworkAccessManager::instance();
|
||||
QgsNetworkAccessManager *nwam = QgsNetworkAccessManager::instance();
|
||||
|
||||
QUrl url( mServiceUrl );
|
||||
url.addQueryItem( QStringLiteral( "data" ), mQuery );
|
||||
|
@ -46,18 +46,18 @@ class ANALYSIS_EXPORT QgsOSMDownload : public QObject
|
||||
static QString defaultServiceUrl();
|
||||
|
||||
//! Create query (in Overpass Query Language) that fetches everything in given rectangle
|
||||
static QString queryFromRect( const QgsRectangle& rect );
|
||||
static QString queryFromRect( const QgsRectangle &rect );
|
||||
|
||||
QgsOSMDownload();
|
||||
~QgsOSMDownload();
|
||||
|
||||
void setServiceUrl( const QString& serviceUrl ) { mServiceUrl = serviceUrl; }
|
||||
void setServiceUrl( const QString &serviceUrl ) { mServiceUrl = serviceUrl; }
|
||||
QString serviceUrl() const { return mServiceUrl; }
|
||||
|
||||
void setQuery( const QString& query ) { mQuery = query; }
|
||||
void setQuery( const QString &query ) { mQuery = query; }
|
||||
QString query() const { return mQuery; }
|
||||
|
||||
void setOutputFileName( const QString& outputFileName ) { mFile.setFileName( outputFileName ); }
|
||||
void setOutputFileName( const QString &outputFileName ) { mFile.setFileName( outputFileName ); }
|
||||
QString outputFileName() const { return mFile.fileName(); }
|
||||
|
||||
bool hasError() const { return !mError.isNull(); }
|
||||
@ -96,7 +96,7 @@ class ANALYSIS_EXPORT QgsOSMDownload : public QObject
|
||||
QString mQuery;
|
||||
QString mError;
|
||||
|
||||
QNetworkReply* mReply = nullptr;
|
||||
QNetworkReply *mReply = nullptr;
|
||||
QFile mFile;
|
||||
};
|
||||
|
||||
|
@ -20,15 +20,15 @@
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
||||
QgsOSMXmlImport::QgsOSMXmlImport( const QString& xmlFilename, const QString& dbFilename )
|
||||
: mXmlFileName( xmlFilename )
|
||||
, mDbFileName( dbFilename )
|
||||
, mDatabase( nullptr )
|
||||
, mStmtInsertNode( nullptr )
|
||||
, mStmtInsertNodeTag( nullptr )
|
||||
, mStmtInsertWay( nullptr )
|
||||
, mStmtInsertWayNode( nullptr )
|
||||
, mStmtInsertWayTag( nullptr )
|
||||
QgsOSMXmlImport::QgsOSMXmlImport( const QString &xmlFilename, const QString &dbFilename )
|
||||
: mXmlFileName( xmlFilename )
|
||||
, mDbFileName( dbFilename )
|
||||
, mDatabase( nullptr )
|
||||
, mStmtInsertNode( nullptr )
|
||||
, mStmtInsertNodeTag( nullptr )
|
||||
, mStmtInsertWay( nullptr )
|
||||
, mStmtInsertWayNode( nullptr )
|
||||
, mStmtInsertWayTag( nullptr )
|
||||
{
|
||||
|
||||
}
|
||||
@ -108,13 +108,13 @@ bool QgsOSMXmlImport::import()
|
||||
bool QgsOSMXmlImport::createIndexes()
|
||||
{
|
||||
// index on tags for faster access
|
||||
const char* sqlIndexes[] =
|
||||
const char *sqlIndexes[] =
|
||||
{
|
||||
"CREATE INDEX nodes_tags_idx ON nodes_tags(id)",
|
||||
"CREATE INDEX ways_tags_idx ON ways_tags(id)",
|
||||
"CREATE INDEX ways_nodes_way ON ways_nodes(way_id)"
|
||||
};
|
||||
int count = sizeof( sqlIndexes ) / sizeof( const char* );
|
||||
int count = sizeof( sqlIndexes ) / sizeof( const char * );
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
int ret = sqlite3_exec( mDatabase, sqlIndexes[i], nullptr, nullptr, nullptr );
|
||||
@ -150,7 +150,7 @@ bool QgsOSMXmlImport::createDatabase()
|
||||
}
|
||||
sqlite3_free_table( results );
|
||||
|
||||
const char* sqlInitStatements[] =
|
||||
const char *sqlInitStatements[] =
|
||||
{
|
||||
"PRAGMA cache_size = 100000", // TODO!!!
|
||||
"PRAGMA synchronous = OFF", // TODO!!!
|
||||
@ -162,10 +162,10 @@ bool QgsOSMXmlImport::createDatabase()
|
||||
"CREATE TABLE ways_tags ( id INTEGER, k TEXT, v TEXT )",
|
||||
};
|
||||
|
||||
int initCount = sizeof( sqlInitStatements ) / sizeof( const char* );
|
||||
int initCount = sizeof( sqlInitStatements ) / sizeof( const char * );
|
||||
for ( int i = 0; i < initCount; ++i )
|
||||
{
|
||||
char* errMsg = nullptr;
|
||||
char *errMsg = nullptr;
|
||||
if ( sqlite3_exec( mDatabase, sqlInitStatements[i], nullptr, nullptr, &errMsg ) != SQLITE_OK )
|
||||
{
|
||||
mError = QStringLiteral( "Error executing SQL command:\n%1\nSQL:\n%2" )
|
||||
@ -176,7 +176,7 @@ bool QgsOSMXmlImport::createDatabase()
|
||||
}
|
||||
}
|
||||
|
||||
const char* sqlInsertStatements[] =
|
||||
const char *sqlInsertStatements[] =
|
||||
{
|
||||
"INSERT INTO nodes ( id, lat, lon ) VALUES (?,?,?)",
|
||||
"INSERT INTO nodes_tags ( id, k, v ) VALUES (?,?,?)",
|
||||
@ -184,7 +184,7 @@ bool QgsOSMXmlImport::createDatabase()
|
||||
"INSERT INTO ways_nodes ( way_id, node_id, way_pos ) VALUES (?,?,?)",
|
||||
"INSERT INTO ways_tags ( id, k, v ) VALUES (?,?,?)"
|
||||
};
|
||||
sqlite3_stmt** sqliteInsertStatements[] =
|
||||
sqlite3_stmt **sqliteInsertStatements[] =
|
||||
{
|
||||
&mStmtInsertNode,
|
||||
&mStmtInsertNodeTag,
|
||||
@ -192,14 +192,14 @@ bool QgsOSMXmlImport::createDatabase()
|
||||
&mStmtInsertWayNode,
|
||||
&mStmtInsertWayTag
|
||||
};
|
||||
Q_ASSERT( sizeof( sqlInsertStatements ) / sizeof( const char* ) == sizeof( sqliteInsertStatements ) / sizeof( sqlite3_stmt** ) );
|
||||
int insertCount = sizeof( sqlInsertStatements ) / sizeof( const char* );
|
||||
Q_ASSERT( sizeof( sqlInsertStatements ) / sizeof( const char * ) == sizeof( sqliteInsertStatements ) / sizeof( sqlite3_stmt ** ) );
|
||||
int insertCount = sizeof( sqlInsertStatements ) / sizeof( const char * );
|
||||
|
||||
for ( int i = 0; i < insertCount; ++i )
|
||||
{
|
||||
if ( sqlite3_prepare_v2( mDatabase, sqlInsertStatements[i], -1, sqliteInsertStatements[i], nullptr ) != SQLITE_OK )
|
||||
{
|
||||
const char* errMsg = sqlite3_errmsg( mDatabase ); // does not require free
|
||||
const char *errMsg = sqlite3_errmsg( mDatabase ); // does not require free
|
||||
mError = QStringLiteral( "Error preparing SQL command:\n%1\nSQL:\n%2" )
|
||||
.arg( QString::fromUtf8( errMsg ), QString::fromUtf8( sqlInsertStatements[i] ) );
|
||||
closeDatabase();
|
||||
@ -211,7 +211,7 @@ bool QgsOSMXmlImport::createDatabase()
|
||||
}
|
||||
|
||||
|
||||
void QgsOSMXmlImport::deleteStatement( sqlite3_stmt*& stmt )
|
||||
void QgsOSMXmlImport::deleteStatement( sqlite3_stmt *&stmt )
|
||||
{
|
||||
if ( stmt )
|
||||
{
|
||||
@ -240,7 +240,7 @@ bool QgsOSMXmlImport::closeDatabase()
|
||||
}
|
||||
|
||||
|
||||
void QgsOSMXmlImport::readRoot( QXmlStreamReader& xml )
|
||||
void QgsOSMXmlImport::readRoot( QXmlStreamReader &xml )
|
||||
{
|
||||
int i = 0;
|
||||
int percent = -1;
|
||||
@ -276,7 +276,7 @@ void QgsOSMXmlImport::readRoot( QXmlStreamReader& xml )
|
||||
}
|
||||
|
||||
|
||||
void QgsOSMXmlImport::readNode( QXmlStreamReader& xml )
|
||||
void QgsOSMXmlImport::readNode( QXmlStreamReader &xml )
|
||||
{
|
||||
// <node id="2197214" lat="50.0682113" lon="14.4348483" user="viduka" uid="595326" visible="true" version="10" changeset="10714591" timestamp="2012-02-17T19:58:49Z">
|
||||
QXmlStreamAttributes attrs = xml.attributes();
|
||||
@ -313,14 +313,14 @@ void QgsOSMXmlImport::readNode( QXmlStreamReader& xml )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsOSMXmlImport::readTag( bool way, QgsOSMId id, QXmlStreamReader& xml )
|
||||
void QgsOSMXmlImport::readTag( bool way, QgsOSMId id, QXmlStreamReader &xml )
|
||||
{
|
||||
QXmlStreamAttributes attrs = xml.attributes();
|
||||
QByteArray k = attrs.value( QStringLiteral( "k" ) ).toString().toUtf8();
|
||||
QByteArray v = attrs.value( QStringLiteral( "v" ) ).toString().toUtf8();
|
||||
xml.skipCurrentElement();
|
||||
|
||||
sqlite3_stmt* stmtInsertTag = way ? mStmtInsertWayTag : mStmtInsertNodeTag;
|
||||
sqlite3_stmt *stmtInsertTag = way ? mStmtInsertWayTag : mStmtInsertNodeTag;
|
||||
|
||||
sqlite3_bind_int64( stmtInsertTag, 1, id );
|
||||
sqlite3_bind_text( stmtInsertTag, 2, k.constData(), -1, SQLITE_STATIC );
|
||||
@ -335,7 +335,7 @@ void QgsOSMXmlImport::readTag( bool way, QgsOSMId id, QXmlStreamReader& xml )
|
||||
sqlite3_reset( stmtInsertTag );
|
||||
}
|
||||
|
||||
void QgsOSMXmlImport::readWay( QXmlStreamReader& xml )
|
||||
void QgsOSMXmlImport::readWay( QXmlStreamReader &xml )
|
||||
{
|
||||
/*
|
||||
<way id="141756602" user="Vratislav Filler" uid="527259" visible="true" version="1" changeset="10145142" timestamp="2011-12-18T10:43:14Z">
|
||||
|
@ -37,16 +37,16 @@ class ANALYSIS_EXPORT QgsOSMXmlImport : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QgsOSMXmlImport( const QString& xmlFileName = QString(), const QString& dbFileName = QString() );
|
||||
explicit QgsOSMXmlImport( const QString &xmlFileName = QString(), const QString &dbFileName = QString() );
|
||||
|
||||
void setInputXmlFileName( const QString& xmlFileName ) { mXmlFileName = xmlFileName; }
|
||||
void setInputXmlFileName( const QString &xmlFileName ) { mXmlFileName = xmlFileName; }
|
||||
QString inputXmlFileName() const { return mXmlFileName; }
|
||||
|
||||
/**
|
||||
* Sets the filename for the output database.
|
||||
* @see outputDatabaseFileName()
|
||||
*/
|
||||
void setOutputDatabaseFileName( const QString& fileName ) { mDbFileName = fileName; }
|
||||
void setOutputDatabaseFileName( const QString &fileName ) { mDbFileName = fileName; }
|
||||
|
||||
/**
|
||||
* Returns the filename for the output database.
|
||||
@ -72,14 +72,14 @@ class ANALYSIS_EXPORT QgsOSMXmlImport : public QObject
|
||||
bool closeDatabase();
|
||||
|
||||
//! @note not available in Python bindings
|
||||
void deleteStatement( sqlite3_stmt*& stmt );
|
||||
void deleteStatement( sqlite3_stmt *&stmt );
|
||||
|
||||
bool createIndexes();
|
||||
|
||||
void readRoot( QXmlStreamReader& xml );
|
||||
void readNode( QXmlStreamReader& xml );
|
||||
void readWay( QXmlStreamReader& xml );
|
||||
void readTag( bool way, QgsOSMId id, QXmlStreamReader& xml );
|
||||
void readRoot( QXmlStreamReader &xml );
|
||||
void readNode( QXmlStreamReader &xml );
|
||||
void readWay( QXmlStreamReader &xml );
|
||||
void readTag( bool way, QgsOSMId id, QXmlStreamReader &xml );
|
||||
|
||||
private:
|
||||
QString mXmlFileName;
|
||||
@ -89,12 +89,12 @@ class ANALYSIS_EXPORT QgsOSMXmlImport : public QObject
|
||||
|
||||
QFile mInputFile;
|
||||
|
||||
sqlite3* mDatabase = nullptr;
|
||||
sqlite3_stmt* mStmtInsertNode = nullptr;
|
||||
sqlite3_stmt* mStmtInsertNodeTag = nullptr;
|
||||
sqlite3_stmt* mStmtInsertWay = nullptr;
|
||||
sqlite3_stmt* mStmtInsertWayNode = nullptr;
|
||||
sqlite3_stmt* mStmtInsertWayTag = nullptr;
|
||||
sqlite3 *mDatabase = nullptr;
|
||||
sqlite3_stmt *mStmtInsertNode = nullptr;
|
||||
sqlite3_stmt *mStmtInsertNodeTag = nullptr;
|
||||
sqlite3_stmt *mStmtInsertWay = nullptr;
|
||||
sqlite3_stmt *mStmtInsertWayNode = nullptr;
|
||||
sqlite3_stmt *mStmtInsertWayTag = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ static double fmod_with_tolerance( double num, double denom )
|
||||
}
|
||||
|
||||
|
||||
static QgsRectangle transform_to_extent( const double* geotransform, double xSize, double ySize )
|
||||
static QgsRectangle transform_to_extent( const double *geotransform, double xSize, double ySize )
|
||||
{
|
||||
QgsRectangle r( geotransform[0],
|
||||
geotransform[3],
|
||||
@ -61,11 +61,11 @@ static QgsRectangle transform_to_extent( const double* geotransform, double xSiz
|
||||
}
|
||||
|
||||
|
||||
static int CPL_STDCALL _progress( double dfComplete, const char* pszMessage, void* pProgressArg )
|
||||
static int CPL_STDCALL _progress( double dfComplete, const char *pszMessage, void *pProgressArg )
|
||||
{
|
||||
Q_UNUSED( pszMessage );
|
||||
|
||||
QgsAlignRaster::ProgressHandler* handler = (( QgsAlignRaster* ) pProgressArg )->progressHandler();
|
||||
QgsAlignRaster::ProgressHandler *handler = ( ( QgsAlignRaster * ) pProgressArg )->progressHandler();
|
||||
if ( handler )
|
||||
return handler->progress( dfComplete );
|
||||
else
|
||||
@ -73,14 +73,14 @@ static int CPL_STDCALL _progress( double dfComplete, const char* pszMessage, voi
|
||||
}
|
||||
|
||||
|
||||
static CPLErr rescalePreWarpChunkProcessor( void* pKern, void* pArg )
|
||||
static CPLErr rescalePreWarpChunkProcessor( void *pKern, void *pArg )
|
||||
{
|
||||
GDALWarpKernel* kern = ( GDALWarpKernel* ) pKern;
|
||||
double cellsize = (( double* )pArg )[0];
|
||||
GDALWarpKernel *kern = ( GDALWarpKernel * ) pKern;
|
||||
double cellsize = ( ( double * )pArg )[0];
|
||||
|
||||
for ( int nBand = 0; nBand < kern->nBands; ++nBand )
|
||||
{
|
||||
float* bandData = ( float * ) kern->papabySrcImage[nBand];
|
||||
float *bandData = ( float * ) kern->papabySrcImage[nBand];
|
||||
for ( int nLine = 0; nLine < kern->nSrcYSize; ++nLine )
|
||||
{
|
||||
for ( int nPixel = 0; nPixel < kern->nSrcXSize; ++nPixel )
|
||||
@ -94,14 +94,14 @@ static CPLErr rescalePreWarpChunkProcessor( void* pKern, void* pArg )
|
||||
}
|
||||
|
||||
|
||||
static CPLErr rescalePostWarpChunkProcessor( void* pKern, void* pArg )
|
||||
static CPLErr rescalePostWarpChunkProcessor( void *pKern, void *pArg )
|
||||
{
|
||||
GDALWarpKernel* kern = ( GDALWarpKernel* ) pKern;
|
||||
double cellsize = (( double* )pArg )[1];
|
||||
GDALWarpKernel *kern = ( GDALWarpKernel * ) pKern;
|
||||
double cellsize = ( ( double * )pArg )[1];
|
||||
|
||||
for ( int nBand = 0; nBand < kern->nBands; ++nBand )
|
||||
{
|
||||
float* bandData = ( float * ) kern->papabyDstImage[nBand];
|
||||
float *bandData = ( float * ) kern->papabyDstImage[nBand];
|
||||
for ( int nLine = 0; nLine < kern->nDstYSize; ++nLine )
|
||||
{
|
||||
for ( int nPixel = 0; nPixel < kern->nDstXSize; ++nPixel )
|
||||
@ -117,7 +117,7 @@ static CPLErr rescalePostWarpChunkProcessor( void* pKern, void* pArg )
|
||||
|
||||
|
||||
QgsAlignRaster::QgsAlignRaster()
|
||||
: mProgressHandler( nullptr )
|
||||
: mProgressHandler( nullptr )
|
||||
{
|
||||
// parameters
|
||||
mCellSizeX = mCellSizeY = 0;
|
||||
@ -138,7 +138,7 @@ void QgsAlignRaster::setClipExtent( double xmin, double ymin, double xmax, doubl
|
||||
mClipExtent[3] = ymax;
|
||||
}
|
||||
|
||||
void QgsAlignRaster::setClipExtent( const QgsRectangle& extent )
|
||||
void QgsAlignRaster::setClipExtent( const QgsRectangle &extent )
|
||||
{
|
||||
setClipExtent( extent.xMinimum(), extent.yMinimum(),
|
||||
extent.xMaximum(), extent.yMaximum() );
|
||||
@ -151,12 +151,12 @@ QgsRectangle QgsAlignRaster::clipExtent() const
|
||||
}
|
||||
|
||||
|
||||
bool QgsAlignRaster::setParametersFromRaster( const QString& filename, const QString& destWkt, QSizeF customCellSize, QPointF customGridOffset )
|
||||
bool QgsAlignRaster::setParametersFromRaster( const QString &filename, const QString &destWkt, QSizeF customCellSize, QPointF customGridOffset )
|
||||
{
|
||||
return setParametersFromRaster( RasterInfo( filename ), destWkt, customCellSize, customGridOffset );
|
||||
}
|
||||
|
||||
bool QgsAlignRaster::setParametersFromRaster( const RasterInfo& rasterInfo, const QString& customCRSWkt, QSizeF customCellSize, QPointF customGridOffset )
|
||||
bool QgsAlignRaster::setParametersFromRaster( const RasterInfo &rasterInfo, const QString &customCRSWkt, QSizeF customCellSize, QPointF customGridOffset )
|
||||
{
|
||||
if ( customCRSWkt.isEmpty() || customCRSWkt == rasterInfo.crs() )
|
||||
{
|
||||
@ -260,7 +260,7 @@ bool QgsAlignRaster::checkInputParameters()
|
||||
// for each raster: determine their extent in projected cfg
|
||||
for ( int i = 0; i < mRasters.count(); ++i )
|
||||
{
|
||||
Item& r = mRasters[i];
|
||||
Item &r = mRasters[i];
|
||||
|
||||
RasterInfo info( r.inputFilename );
|
||||
|
||||
@ -304,10 +304,10 @@ bool QgsAlignRaster::checkInputParameters()
|
||||
if ( !( mClipExtent[0] == 0 && mClipExtent[1] == 0 && mClipExtent[2] == 0 && mClipExtent[3] == 0 ) )
|
||||
{
|
||||
// extend clip extent to grid
|
||||
double clipX0 = floor_with_tolerance(( mClipExtent[0] - mGridOffsetX ) / mCellSizeX ) * mCellSizeX + mGridOffsetX;
|
||||
double clipY0 = floor_with_tolerance(( mClipExtent[1] - mGridOffsetY ) / mCellSizeY ) * mCellSizeY + mGridOffsetY;
|
||||
double clipX1 = ceil_with_tolerance(( mClipExtent[2] - clipX0 ) / mCellSizeX ) * mCellSizeX + clipX0;
|
||||
double clipY1 = ceil_with_tolerance(( mClipExtent[3] - clipY0 ) / mCellSizeY ) * mCellSizeY + clipY0;
|
||||
double clipX0 = floor_with_tolerance( ( mClipExtent[0] - mGridOffsetX ) / mCellSizeX ) * mCellSizeX + mGridOffsetX;
|
||||
double clipY0 = floor_with_tolerance( ( mClipExtent[1] - mGridOffsetY ) / mCellSizeY ) * mCellSizeY + mGridOffsetY;
|
||||
double clipX1 = ceil_with_tolerance( ( mClipExtent[2] - clipX0 ) / mCellSizeX ) * mCellSizeX + clipX0;
|
||||
double clipY1 = ceil_with_tolerance( ( mClipExtent[3] - clipY0 ) / mCellSizeY ) * mCellSizeY + clipY0;
|
||||
if ( clipX0 > finalExtent[0] ) finalExtent[0] = clipX0;
|
||||
if ( clipY0 > finalExtent[1] ) finalExtent[1] = clipY0;
|
||||
if ( clipX1 < finalExtent[2] ) finalExtent[2] = clipX1;
|
||||
@ -318,10 +318,10 @@ bool QgsAlignRaster::checkInputParameters()
|
||||
// output raster grid configuration (with no rotation/shear)
|
||||
// ... and raster width/height
|
||||
|
||||
double originX = ceil_with_tolerance(( finalExtent[0] - mGridOffsetX ) / mCellSizeX ) * mCellSizeX + mGridOffsetX;
|
||||
double originY = ceil_with_tolerance(( finalExtent[1] - mGridOffsetY ) / mCellSizeY ) * mCellSizeY + mGridOffsetY;
|
||||
int xSize = floor_with_tolerance(( finalExtent[2] - originX ) / mCellSizeX );
|
||||
int ySize = floor_with_tolerance(( finalExtent[3] - originY ) / mCellSizeY );
|
||||
double originX = ceil_with_tolerance( ( finalExtent[0] - mGridOffsetX ) / mCellSizeX ) * mCellSizeX + mGridOffsetX;
|
||||
double originY = ceil_with_tolerance( ( finalExtent[1] - mGridOffsetY ) / mCellSizeY ) * mCellSizeY + mGridOffsetY;
|
||||
int xSize = floor_with_tolerance( ( finalExtent[2] - originX ) / mCellSizeX );
|
||||
int ySize = floor_with_tolerance( ( finalExtent[3] - originY ) / mCellSizeY );
|
||||
|
||||
if ( xSize <= 0 || ySize <= 0 )
|
||||
{
|
||||
@ -365,7 +365,7 @@ bool QgsAlignRaster::run()
|
||||
|
||||
//dump();
|
||||
|
||||
Q_FOREACH ( const Item& r, mRasters )
|
||||
Q_FOREACH ( const Item &r, mRasters )
|
||||
{
|
||||
if ( !createAndWarp( r ) )
|
||||
return false;
|
||||
@ -400,7 +400,7 @@ int QgsAlignRaster::suggestedReferenceLayer() const
|
||||
QgsCoordinateReferenceSystem destCRS( QStringLiteral( "EPSG:4326" ) );
|
||||
QString destWkt = destCRS.toWkt();
|
||||
|
||||
Q_FOREACH ( const Item& raster, mRasters )
|
||||
Q_FOREACH ( const Item &raster, mRasters )
|
||||
{
|
||||
if ( !suggestedWarpOutput( RasterInfo( raster.inputFilename ), destWkt, &cs ) )
|
||||
return false;
|
||||
@ -418,7 +418,7 @@ int QgsAlignRaster::suggestedReferenceLayer() const
|
||||
}
|
||||
|
||||
|
||||
bool QgsAlignRaster::createAndWarp( const Item& raster )
|
||||
bool QgsAlignRaster::createAndWarp( const Item &raster )
|
||||
{
|
||||
GDALDriverH hDriver = GDALGetDriverByName( "GTiff" );
|
||||
if ( !hDriver )
|
||||
@ -463,7 +463,7 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Setup warp options.
|
||||
GDALWarpOptions* psWarpOptions = GDALCreateWarpOptions();
|
||||
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
|
||||
psWarpOptions->hSrcDS = hSrcDS;
|
||||
psWarpOptions->hDstDS = hDstDS;
|
||||
|
||||
@ -515,13 +515,13 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo& info, const QString& destWkt, QSizeF* cellSize, QPointF* gridOffset, QgsRectangle* rect )
|
||||
bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo &info, const QString &destWkt, QSizeF *cellSize, QPointF *gridOffset, QgsRectangle *rect )
|
||||
{
|
||||
// Create a transformer that maps from source pixel/line coordinates
|
||||
// to destination georeferenced coordinates (not destination
|
||||
// pixel line). We do that by omitting the destination dataset
|
||||
// handle (setting it to nullptr).
|
||||
void* hTransformArg = GDALCreateGenImgProjTransformer( info.mDataset, info.mCrsWkt.toLatin1().constData(), nullptr, destWkt.toLatin1().constData(), FALSE, 0, 1 );
|
||||
void *hTransformArg = GDALCreateGenImgProjTransformer( info.mDataset, info.mCrsWkt.toLatin1().constData(), nullptr, destWkt.toLatin1().constData(), FALSE, 0, 1 );
|
||||
if ( !hTransformArg )
|
||||
return false;
|
||||
|
||||
@ -554,10 +554,10 @@ bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo& info
|
||||
//----------
|
||||
|
||||
|
||||
QgsAlignRaster::RasterInfo::RasterInfo( const QString& layerpath )
|
||||
: mXSize( 0 )
|
||||
, mYSize( 0 )
|
||||
, mBandCnt( 0 )
|
||||
QgsAlignRaster::RasterInfo::RasterInfo( const QString &layerpath )
|
||||
: mXSize( 0 )
|
||||
, mYSize( 0 )
|
||||
, mBandCnt( 0 )
|
||||
{
|
||||
mDataset = GDALOpen( layerpath.toLocal8Bit().constData(), GA_ReadOnly );
|
||||
if ( !mDataset )
|
||||
@ -621,10 +621,10 @@ double QgsAlignRaster::RasterInfo::identify( double mx, double my )
|
||||
GDALRasterBandH hBand = GDALGetRasterBand( mDataset, 1 );
|
||||
|
||||
// must not be rotated in order for this to work
|
||||
int px = int(( mx - mGeoTransform[0] ) / mGeoTransform[1] );
|
||||
int py = int(( my - mGeoTransform[3] ) / mGeoTransform[5] );
|
||||
int px = int( ( mx - mGeoTransform[0] ) / mGeoTransform[1] );
|
||||
int py = int( ( my - mGeoTransform[3] ) / mGeoTransform[5] );
|
||||
|
||||
float* pafScanline = ( float * ) CPLMalloc( sizeof( float ) );
|
||||
float *pafScanline = ( float * ) CPLMalloc( sizeof( float ) );
|
||||
CPLErr err = GDALRasterIO( hBand, GF_Read, px, py, 1, 1,
|
||||
pafScanline, 1, 1, GDT_Float32, 0, 0 );
|
||||
double value = err == CE_None ? pafScanline[0] : std::numeric_limits<double>::quiet_NaN();
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
class QgsRectangle;
|
||||
|
||||
typedef void* GDALDatasetH;
|
||||
typedef void *GDALDatasetH;
|
||||
|
||||
|
||||
/** \ingroup analysis
|
||||
@ -45,53 +45,53 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
//! Utility class for gathering information about rasters
|
||||
struct ANALYSIS_EXPORT RasterInfo
|
||||
{
|
||||
public:
|
||||
//! Construct raster info with a path to a raster file
|
||||
RasterInfo( const QString& layerpath );
|
||||
~RasterInfo();
|
||||
public:
|
||||
//! Construct raster info with a path to a raster file
|
||||
RasterInfo( const QString &layerpath );
|
||||
~RasterInfo();
|
||||
|
||||
RasterInfo( const RasterInfo& rh ) = delete;
|
||||
RasterInfo& operator=( const RasterInfo& rh ) = delete;
|
||||
RasterInfo( const RasterInfo &rh ) = delete;
|
||||
RasterInfo &operator=( const RasterInfo &rh ) = delete;
|
||||
|
||||
//! Check whether the given path is a valid raster
|
||||
bool isValid() const { return nullptr != mDataset; }
|
||||
//! Check whether the given path is a valid raster
|
||||
bool isValid() const { return nullptr != mDataset; }
|
||||
|
||||
//! Return CRS in WKT format
|
||||
QString crs() const { return mCrsWkt; }
|
||||
//! Return size of the raster grid in pixels
|
||||
QSize rasterSize() const { return QSize( mXSize, mYSize ); }
|
||||
//! Return number of raster bands in the file
|
||||
int bandCount() const { return mBandCnt; }
|
||||
//! Return cell size in map units
|
||||
QSizeF cellSize() const;
|
||||
//! Return grid offset
|
||||
QPointF gridOffset() const;
|
||||
//! Return extent of the raster
|
||||
QgsRectangle extent() const;
|
||||
//! Return origin of the raster
|
||||
QPointF origin() const;
|
||||
//! Return CRS in WKT format
|
||||
QString crs() const { return mCrsWkt; }
|
||||
//! Return size of the raster grid in pixels
|
||||
QSize rasterSize() const { return QSize( mXSize, mYSize ); }
|
||||
//! Return number of raster bands in the file
|
||||
int bandCount() const { return mBandCnt; }
|
||||
//! Return cell size in map units
|
||||
QSizeF cellSize() const;
|
||||
//! Return grid offset
|
||||
QPointF gridOffset() const;
|
||||
//! Return extent of the raster
|
||||
QgsRectangle extent() const;
|
||||
//! Return origin of the raster
|
||||
QPointF origin() const;
|
||||
|
||||
//! write contents of the object to standard error stream - for debugging
|
||||
void dump() const;
|
||||
//! write contents of the object to standard error stream - for debugging
|
||||
void dump() const;
|
||||
|
||||
//! Get raster value at the given coordinates (from the first band)
|
||||
double identify( double mx, double my );
|
||||
//! Get raster value at the given coordinates (from the first band)
|
||||
double identify( double mx, double my );
|
||||
|
||||
protected:
|
||||
//! handle to open GDAL dataset
|
||||
GDALDatasetH mDataset;
|
||||
//! CRS stored in WKT format
|
||||
QString mCrsWkt;
|
||||
//! geotransform coefficients
|
||||
double mGeoTransform[6];
|
||||
//! raster grid size
|
||||
int mXSize, mYSize;
|
||||
//! number of raster's bands
|
||||
int mBandCnt;
|
||||
protected:
|
||||
//! handle to open GDAL dataset
|
||||
GDALDatasetH mDataset;
|
||||
//! CRS stored in WKT format
|
||||
QString mCrsWkt;
|
||||
//! geotransform coefficients
|
||||
double mGeoTransform[6];
|
||||
//! raster grid size
|
||||
int mXSize, mYSize;
|
||||
//! number of raster's bands
|
||||
int mBandCnt;
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
friend class QgsAlignRaster;
|
||||
friend class QgsAlignRaster;
|
||||
};
|
||||
|
||||
|
||||
@ -116,12 +116,12 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
//! Definition of one raster layer for alignment
|
||||
struct Item
|
||||
{
|
||||
Item( const QString& input, const QString& output )
|
||||
: inputFilename( input )
|
||||
, outputFilename( output )
|
||||
, resampleMethod( RA_NearestNeighbour )
|
||||
, rescaleValues( false )
|
||||
, srcCellSizeInDestCRS( 0.0 )
|
||||
Item( const QString &input, const QString &output )
|
||||
: inputFilename( input )
|
||||
, outputFilename( output )
|
||||
, resampleMethod( RA_NearestNeighbour )
|
||||
, rescaleValues( false )
|
||||
, srcCellSizeInDestCRS( 0.0 )
|
||||
{}
|
||||
|
||||
//! filename of the source raster
|
||||
@ -152,12 +152,12 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
};
|
||||
|
||||
//! Assign a progress handler instance. Does not take ownership. nullptr can be passed.
|
||||
void setProgressHandler( ProgressHandler* progressHandler ) { mProgressHandler = progressHandler; }
|
||||
void setProgressHandler( ProgressHandler *progressHandler ) { mProgressHandler = progressHandler; }
|
||||
//! Get associated progress handler. May be nullptr (default)
|
||||
ProgressHandler* progressHandler() const { return mProgressHandler; }
|
||||
ProgressHandler *progressHandler() const { return mProgressHandler; }
|
||||
|
||||
//! Set list of rasters that will be aligned
|
||||
void setRasters( const List& list ) { mRasters = list; }
|
||||
void setRasters( const List &list ) { mRasters = list; }
|
||||
//! Get list of rasters that will be aligned
|
||||
List rasters() const { return mRasters; }
|
||||
|
||||
@ -172,7 +172,7 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
QSizeF cellSize() const { return QSizeF( mCellSizeX, mCellSizeY ); }
|
||||
|
||||
//! Set the output CRS in WKT format
|
||||
void setDestinationCrs( const QString& crsWkt ) { mCrsWkt = crsWkt; }
|
||||
void setDestinationCrs( const QString &crsWkt ) { mCrsWkt = crsWkt; }
|
||||
//! Get the output CRS in WKT format
|
||||
QString destinationCrs() const { return mCrsWkt; }
|
||||
|
||||
@ -181,7 +181,7 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
void setClipExtent( double xmin, double ymin, double xmax, double ymax );
|
||||
//! Configure clipping extent (region of interest).
|
||||
//! No extra clipping is done if the rectangle is null
|
||||
void setClipExtent( const QgsRectangle& extent );
|
||||
void setClipExtent( const QgsRectangle &extent );
|
||||
//! Get clipping extent (region of interest).
|
||||
//! No extra clipping is done if the rectangle is null
|
||||
QgsRectangle clipExtent() const;
|
||||
@ -195,10 +195,10 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
//! to determine suitable defaults for cell size and grid offset.
|
||||
//!
|
||||
//! @return true on success (may fail if it is not possible to reproject raster to given CRS)
|
||||
bool setParametersFromRaster( const RasterInfo& rasterInfo, const QString& customCRSWkt = QString(), QSizeF customCellSize = QSizeF(), QPointF customGridOffset = QPointF( -1, -1 ) );
|
||||
bool setParametersFromRaster( const RasterInfo &rasterInfo, const QString &customCRSWkt = QString(), QSizeF customCellSize = QSizeF(), QPointF customGridOffset = QPointF( -1, -1 ) );
|
||||
//! Overridden variant for convenience, taking filename instead RasterInfo object.
|
||||
//! See the other variant for details.
|
||||
bool setParametersFromRaster( const QString& filename, const QString& customCRSWkt = QString(), QSizeF customCellSize = QSizeF(), QPointF customGridOffset = QPointF( -1, -1 ) );
|
||||
bool setParametersFromRaster( const QString &filename, const QString &customCRSWkt = QString(), QSizeF customCellSize = QSizeF(), QPointF customGridOffset = QPointF( -1, -1 ) );
|
||||
|
||||
//! Determine destination extent from the input rasters and calculate derived values
|
||||
//! @return true on success, sets error on error (see errorMessage())
|
||||
@ -228,17 +228,17 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
protected:
|
||||
|
||||
//! Internal function for processing of one raster (1. create output, 2. do the alignment)
|
||||
bool createAndWarp( const Item& raster );
|
||||
bool createAndWarp( const Item &raster );
|
||||
|
||||
//! Determine suggested output of raster warp to a different CRS. Returns true on success
|
||||
static bool suggestedWarpOutput( const RasterInfo& info, const QString& destWkt, QSizeF* cellSize = nullptr, QPointF* gridOffset = nullptr, QgsRectangle* rect = nullptr );
|
||||
static bool suggestedWarpOutput( const RasterInfo &info, const QString &destWkt, QSizeF *cellSize = nullptr, QPointF *gridOffset = nullptr, QgsRectangle *rect = nullptr );
|
||||
|
||||
protected:
|
||||
|
||||
// set by the client
|
||||
|
||||
//! Object that facilitates reporting of progress / cancelation
|
||||
ProgressHandler* mProgressHandler = nullptr;
|
||||
ProgressHandler *mProgressHandler = nullptr;
|
||||
|
||||
//! Last error message from run()
|
||||
QString mErrorMessage;
|
||||
|
@ -17,16 +17,16 @@
|
||||
|
||||
#include "qgsaspectfilter.h"
|
||||
|
||||
QgsAspectFilter::QgsAspectFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
|
||||
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
|
||||
QgsAspectFilter::QgsAspectFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
|
||||
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float QgsAspectFilter::processNineCellWindow(
|
||||
float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 )
|
||||
float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 )
|
||||
{
|
||||
float derX = calcFirstDerX( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
|
||||
float derY = calcFirstDerY( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
|
||||
|
@ -26,13 +26,13 @@
|
||||
class ANALYSIS_EXPORT QgsAspectFilter: public QgsDerivativeFilter
|
||||
{
|
||||
public:
|
||||
QgsAspectFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsAspectFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
|
||||
/** Calculates output value from nine input values. The input values and the output value can be equal to the
|
||||
nodata value if not present or outside of the border. Must be implemented by subclasses*/
|
||||
float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) override;
|
||||
float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
#include "qgsderivativefilter.h"
|
||||
|
||||
QgsDerivativeFilter::QgsDerivativeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
|
||||
: QgsNineCellFilter( inputFile, outputFile, outputFormat )
|
||||
QgsDerivativeFilter::QgsDerivativeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
|
||||
: QgsNineCellFilter( inputFile, outputFile, outputFormat )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float QgsDerivativeFilter::calcFirstDerX( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
|
||||
float QgsDerivativeFilter::calcFirstDerX( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 )
|
||||
{
|
||||
//the basic formula would be simple, but we need to test for nodata values...
|
||||
//return (( (*x31 - *x11) + 2 * (*x32 - *x12) + (*x33 - *x13) ) / (8 * mCellSizeX));
|
||||
@ -90,7 +90,7 @@ float QgsDerivativeFilter::calcFirstDerX( float* x11, float* x21, float* x31, fl
|
||||
return sum / ( weight * mCellSizeX * mZFactor );
|
||||
}
|
||||
|
||||
float QgsDerivativeFilter::calcFirstDerY( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
|
||||
float QgsDerivativeFilter::calcFirstDerY( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 )
|
||||
{
|
||||
//the basic formula would be simple, but we need to test for nodata values...
|
||||
//return (((*x11 - *x13) + 2 * (*x21 - *x23) + (*x31 - *x33)) / ( 8 * mCellSizeY));
|
||||
|
@ -26,18 +26,18 @@
|
||||
class ANALYSIS_EXPORT QgsDerivativeFilter : public QgsNineCellFilter
|
||||
{
|
||||
public:
|
||||
QgsDerivativeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsDerivativeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
virtual ~QgsDerivativeFilter() = default;
|
||||
//to be implemented by subclasses
|
||||
virtual float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) override = 0;
|
||||
virtual float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) override = 0;
|
||||
|
||||
protected:
|
||||
//! Calculates the first order derivative in x-direction according to Horn (1981)
|
||||
float calcFirstDerX( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 );
|
||||
float calcFirstDerX( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 );
|
||||
//! Calculates the first order derivative in y-direction according to Horn (1981)
|
||||
float calcFirstDerY( float* x11, float* x21, float* x31, float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 );
|
||||
float calcFirstDerY( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 );
|
||||
};
|
||||
|
||||
#endif // QGSDERIVATIVEFILTER_H
|
||||
|
@ -17,17 +17,17 @@
|
||||
|
||||
#include "qgshillshadefilter.h"
|
||||
|
||||
QgsHillshadeFilter::QgsHillshadeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat, double lightAzimuth,
|
||||
QgsHillshadeFilter::QgsHillshadeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat, double lightAzimuth,
|
||||
double lightAngle )
|
||||
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
|
||||
, mLightAzimuth( lightAzimuth )
|
||||
, mLightAngle( lightAngle )
|
||||
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
|
||||
, mLightAzimuth( lightAzimuth )
|
||||
, mLightAngle( lightAngle )
|
||||
{
|
||||
}
|
||||
|
||||
float QgsHillshadeFilter::processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 )
|
||||
float QgsHillshadeFilter::processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 )
|
||||
{
|
||||
float derX = calcFirstDerX( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
|
||||
float derY = calcFirstDerY( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
|
||||
@ -49,5 +49,5 @@ float QgsHillshadeFilter::processNineCellWindow( float* x11, float* x21, float*
|
||||
{
|
||||
aspect_rad = M_PI + atan2( derX, derY );
|
||||
}
|
||||
return qMax( 0.0, 255.0 * (( cos( zenith_rad ) * cos( slope_rad ) ) + ( sin( zenith_rad ) * sin( slope_rad ) * cos( azimuth_rad - aspect_rad ) ) ) );
|
||||
return qMax( 0.0, 255.0 * ( ( cos( zenith_rad ) * cos( slope_rad ) ) + ( sin( zenith_rad ) * sin( slope_rad ) * cos( azimuth_rad - aspect_rad ) ) ) );
|
||||
}
|
||||
|
@ -27,14 +27,14 @@
|
||||
class ANALYSIS_EXPORT QgsHillshadeFilter: public QgsDerivativeFilter
|
||||
{
|
||||
public:
|
||||
QgsHillshadeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat, double lightAzimuth = 300,
|
||||
QgsHillshadeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat, double lightAzimuth = 300,
|
||||
double lightAngle = 40 );
|
||||
|
||||
/** Calculates output value from nine input values. The input values and the output value can be equal to the
|
||||
nodata value if not present or outside of the border. Must be implemented by subclasses*/
|
||||
float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) override;
|
||||
float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) override;
|
||||
|
||||
float lightAzimuth() const { return mLightAzimuth; }
|
||||
void setLightAzimuth( float azimuth ) { mLightAzimuth = azimuth; }
|
||||
|
@ -23,20 +23,20 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEstimation::Parameters& parameters, const QString& outputFile, const QString& outputFormat )
|
||||
: mInputLayer( parameters.vectorLayer )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mRadiusField( -1 )
|
||||
, mWeightField( -1 )
|
||||
, mRadius( parameters.radius )
|
||||
, mPixelSize( parameters.pixelSize )
|
||||
, mShape( parameters.shape )
|
||||
, mDecay( parameters.decayRatio )
|
||||
, mOutputValues( parameters.outputValues )
|
||||
, mBufferSize( -1 )
|
||||
, mDatasetH( nullptr )
|
||||
, mRasterBandH( nullptr )
|
||||
QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEstimation::Parameters ¶meters, const QString &outputFile, const QString &outputFormat )
|
||||
: mInputLayer( parameters.vectorLayer )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mRadiusField( -1 )
|
||||
, mWeightField( -1 )
|
||||
, mRadius( parameters.radius )
|
||||
, mPixelSize( parameters.pixelSize )
|
||||
, mShape( parameters.shape )
|
||||
, mDecay( parameters.decayRatio )
|
||||
, mOutputValues( parameters.outputValues )
|
||||
, mBufferSize( -1 )
|
||||
, mDatasetH( nullptr )
|
||||
, mRasterBandH( nullptr )
|
||||
{
|
||||
if ( !parameters.radiusField.isEmpty() )
|
||||
mRadiusField = mInputLayer->fields().lookupField( parameters.radiusField );
|
||||
@ -107,7 +107,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::prepare()
|
||||
return Success;
|
||||
}
|
||||
|
||||
QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const QgsFeature& feature )
|
||||
QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const QgsFeature &feature )
|
||||
{
|
||||
QgsGeometry featureGeometry = feature.geometry();
|
||||
if ( featureGeometry.isNull() )
|
||||
@ -160,8 +160,8 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const
|
||||
}
|
||||
|
||||
// calculate the pixel position
|
||||
unsigned int xPosition = ((( *pointIt ).x() - mBounds.xMinimum() ) / mPixelSize ) - buffer;
|
||||
unsigned int yPosition = ((( *pointIt ).y() - mBounds.yMinimum() ) / mPixelSize ) - buffer;
|
||||
unsigned int xPosition = ( ( ( *pointIt ).x() - mBounds.xMinimum() ) / mPixelSize ) - buffer;
|
||||
unsigned int yPosition = ( ( ( *pointIt ).y() - mBounds.yMinimum() ) / mPixelSize ) - buffer;
|
||||
|
||||
// get the data
|
||||
float *dataBuffer = ( float * ) CPLMalloc( sizeof( float ) * blockSize * blockSize );
|
||||
@ -208,7 +208,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const
|
||||
|
||||
QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::finalise()
|
||||
{
|
||||
GDALClose(( GDALDatasetH ) mDatasetH );
|
||||
GDALClose( ( GDALDatasetH ) mDatasetH );
|
||||
mDatasetH = nullptr;
|
||||
mRasterBandH = nullptr;
|
||||
return Success;
|
||||
@ -224,7 +224,7 @@ int QgsKernelDensityEstimation::radiusSizeInPixels( double radius ) const
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool QgsKernelDensityEstimation::createEmptyLayer( GDALDriverH driver, const QgsRectangle& bounds, int rows, int columns ) const
|
||||
bool QgsKernelDensityEstimation::createEmptyLayer( GDALDriverH driver, const QgsRectangle &bounds, int rows, int columns ) const
|
||||
{
|
||||
double geoTransform[6] = { bounds.xMinimum(), mPixelSize, 0, bounds.yMinimum(), 0, mPixelSize };
|
||||
GDALDatasetH emptyDataset = GDALCreate( driver, mOutputFile.toUtf8(), columns, rows, 1, GDT_Float32, nullptr );
|
||||
@ -245,7 +245,7 @@ bool QgsKernelDensityEstimation::createEmptyLayer( GDALDriverH driver, const Qgs
|
||||
if ( GDALSetRasterNoDataValue( poBand, NO_DATA ) != CE_None )
|
||||
return false;
|
||||
|
||||
float* line = static_cast< float * >( CPLMalloc( sizeof( float ) * columns ) );
|
||||
float *line = static_cast< float * >( CPLMalloc( sizeof( float ) * columns ) );
|
||||
for ( int i = 0; i < columns; i++ )
|
||||
{
|
||||
line[i] = NO_DATA;
|
||||
@ -380,7 +380,7 @@ double QgsKernelDensityEstimation::triangularKernel( const double distance, cons
|
||||
|
||||
if ( mDecay >= 0 )
|
||||
{
|
||||
double k = 3. / (( 1. + 2. * mDecay ) * M_PI * pow( bandwidth, 2 ) );
|
||||
double k = 3. / ( ( 1. + 2. * mDecay ) * M_PI * pow( bandwidth, 2 ) );
|
||||
|
||||
// Derived from Wand and Jones (1995), p. 175 (with addition of decay parameter)
|
||||
return k * ( 1. - ( 1. - mDecay ) * ( distance / bandwidth ) );
|
||||
|
@ -71,7 +71,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation
|
||||
struct Parameters
|
||||
{
|
||||
//! Vector point layer
|
||||
QgsVectorLayer* vectorLayer = nullptr;
|
||||
QgsVectorLayer *vectorLayer = nullptr;
|
||||
|
||||
//! Fixed radius, in map units
|
||||
double radius;
|
||||
@ -99,7 +99,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation
|
||||
* Constructor for QgsKernelDensityEstimation. Requires a Parameters object specifying the options to use
|
||||
* to generate the surface. The output path and file format are also required.
|
||||
*/
|
||||
QgsKernelDensityEstimation( const Parameters& parameters, const QString& outputFile, const QString& outputFormat );
|
||||
QgsKernelDensityEstimation( const Parameters ¶meters, const QString &outputFile, const QString &outputFormat );
|
||||
|
||||
/**
|
||||
* Runs the KDE calculation across the whole layer at once. Either call this method, or manually
|
||||
@ -120,7 +120,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation
|
||||
* @see prepare()
|
||||
* @see finalise()
|
||||
*/
|
||||
Result addFeature( const QgsFeature& feature );
|
||||
Result addFeature( const QgsFeature &feature );
|
||||
|
||||
/**
|
||||
* Finalises the output file. Must be called after adding all features via addFeature().
|
||||
@ -146,7 +146,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation
|
||||
|
||||
QgsRectangle calculateBounds() const;
|
||||
|
||||
QgsVectorLayer* mInputLayer = nullptr;
|
||||
QgsVectorLayer *mInputLayer = nullptr;
|
||||
|
||||
QString mOutputFile;
|
||||
QString mOutputFormat;
|
||||
@ -167,7 +167,7 @@ class ANALYSIS_EXPORT QgsKernelDensityEstimation
|
||||
GDALRasterBandH mRasterBandH;
|
||||
|
||||
//! Creates a new raster layer and initializes it to the no data value
|
||||
bool createEmptyLayer( GDALDriverH driver, const QgsRectangle& bounds, int rows, int columns ) const;
|
||||
bool createEmptyLayer( GDALDriverH driver, const QgsRectangle &bounds, int rows, int columns ) const;
|
||||
int radiusSizeInPixels( double radius ) const;
|
||||
};
|
||||
|
||||
|
@ -21,29 +21,29 @@
|
||||
#include <QProgressDialog>
|
||||
#include <QFile>
|
||||
|
||||
QgsNineCellFilter::QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
|
||||
: mInputFile( inputFile )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mCellSizeX( -1.0 )
|
||||
, mCellSizeY( -1.0 )
|
||||
, mInputNodataValue( -1.0 )
|
||||
, mOutputNodataValue( -1.0 )
|
||||
, mZFactor( 1.0 )
|
||||
QgsNineCellFilter::QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
|
||||
: mInputFile( inputFile )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mCellSizeX( -1.0 )
|
||||
, mCellSizeY( -1.0 )
|
||||
, mInputNodataValue( -1.0 )
|
||||
, mOutputNodataValue( -1.0 )
|
||||
, mZFactor( 1.0 )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsNineCellFilter::QgsNineCellFilter()
|
||||
: mCellSizeX( -1.0 )
|
||||
, mCellSizeY( -1.0 )
|
||||
, mInputNodataValue( -1.0 )
|
||||
, mOutputNodataValue( -1.0 )
|
||||
, mZFactor( 1.0 )
|
||||
: mCellSizeX( -1.0 )
|
||||
, mCellSizeY( -1.0 )
|
||||
, mInputNodataValue( -1.0 )
|
||||
, mOutputNodataValue( -1.0 )
|
||||
, mZFactor( 1.0 )
|
||||
{
|
||||
}
|
||||
|
||||
int QgsNineCellFilter::processRaster( QProgressDialog* p )
|
||||
int QgsNineCellFilter::processRaster( QProgressDialog *p )
|
||||
{
|
||||
GDALAllRegister();
|
||||
|
||||
@ -97,11 +97,11 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
|
||||
}
|
||||
|
||||
//keep only three scanlines in memory at a time
|
||||
float* scanLine1 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float* scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float* scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *scanLine1 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
|
||||
float* resultLine = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *resultLine = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
|
||||
if ( p )
|
||||
{
|
||||
@ -161,18 +161,18 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
|
||||
{
|
||||
if ( j == 0 )
|
||||
{
|
||||
resultLine[j] = processNineCellWindow( &mInputNodataValue, &scanLine1[j], &scanLine1[j+1], &mInputNodataValue, &scanLine2[j],
|
||||
&scanLine2[j+1], &mInputNodataValue, &scanLine3[j], &scanLine3[j+1] );
|
||||
resultLine[j] = processNineCellWindow( &mInputNodataValue, &scanLine1[j], &scanLine1[j + 1], &mInputNodataValue, &scanLine2[j],
|
||||
&scanLine2[j + 1], &mInputNodataValue, &scanLine3[j], &scanLine3[j + 1] );
|
||||
}
|
||||
else if ( j == xSize - 1 )
|
||||
{
|
||||
resultLine[j] = processNineCellWindow( &scanLine1[j-1], &scanLine1[j], &mInputNodataValue, &scanLine2[j-1], &scanLine2[j],
|
||||
&mInputNodataValue, &scanLine3[j-1], &scanLine3[j], &mInputNodataValue );
|
||||
resultLine[j] = processNineCellWindow( &scanLine1[j - 1], &scanLine1[j], &mInputNodataValue, &scanLine2[j - 1], &scanLine2[j],
|
||||
&mInputNodataValue, &scanLine3[j - 1], &scanLine3[j], &mInputNodataValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
resultLine[j] = processNineCellWindow( &scanLine1[j-1], &scanLine1[j], &scanLine1[j+1], &scanLine2[j-1], &scanLine2[j],
|
||||
&scanLine2[j+1], &scanLine3[j-1], &scanLine3[j], &scanLine3[j+1] );
|
||||
resultLine[j] = processNineCellWindow( &scanLine1[j - 1], &scanLine1[j], &scanLine1[j + 1], &scanLine2[j - 1], &scanLine2[j],
|
||||
&scanLine2[j + 1], &scanLine3[j - 1], &scanLine3[j], &scanLine3[j + 1] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ int QgsNineCellFilter::processRaster( QProgressDialog* p )
|
||||
return 0;
|
||||
}
|
||||
|
||||
GDALDatasetH QgsNineCellFilter::openInputFile( int& nCellsX, int& nCellsY )
|
||||
GDALDatasetH QgsNineCellFilter::openInputFile( int &nCellsX, int &nCellsY )
|
||||
{
|
||||
GDALDatasetH inputDataset = GDALOpen( mInputFile.toUtf8().constData(), GA_ReadOnly );
|
||||
if ( inputDataset )
|
||||
@ -283,7 +283,7 @@ GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALD
|
||||
mCellSizeY = -mCellSizeY;
|
||||
}
|
||||
|
||||
const char* projection = GDALGetProjectionRef( inputDataset );
|
||||
const char *projection = GDALGetProjectionRef( inputDataset );
|
||||
GDALSetProjection( outputDataset, projection );
|
||||
|
||||
return outputDataset;
|
||||
|
@ -33,13 +33,13 @@ class ANALYSIS_EXPORT QgsNineCellFilter
|
||||
{
|
||||
public:
|
||||
//! Constructor that takes input file, output file and output format (GDAL string)
|
||||
QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
virtual ~QgsNineCellFilter() = default;
|
||||
|
||||
/** Starts the calculation, reads from mInputFile and stores the result in mOutputFile
|
||||
@param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
|
||||
@return 0 in case of success*/
|
||||
int processRaster( QProgressDialog* p );
|
||||
int processRaster( QProgressDialog *p );
|
||||
|
||||
double cellSizeX() const { return mCellSizeX; }
|
||||
void setCellSizeX( double size ) { mCellSizeX = size; }
|
||||
@ -56,16 +56,16 @@ class ANALYSIS_EXPORT QgsNineCellFilter
|
||||
|
||||
/** Calculates output value from nine input values. The input values and the output value can be equal to the
|
||||
nodata value if not present or outside of the border. Must be implemented by subclasses*/
|
||||
virtual float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) = 0;
|
||||
virtual float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) = 0;
|
||||
|
||||
private:
|
||||
//default constructor forbidden. We need input file, output file and format obligatory
|
||||
QgsNineCellFilter();
|
||||
|
||||
//! Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction
|
||||
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
|
||||
GDALDatasetH openInputFile( int &nCellsX, int &nCellsY );
|
||||
|
||||
/** Opens the output driver and tests if it supports the creation of a new dataset
|
||||
@return nullptr on error and the driver handle on success*/
|
||||
|
@ -18,54 +18,54 @@
|
||||
#include <cfloat>
|
||||
|
||||
QgsRasterCalcNode::QgsRasterCalcNode()
|
||||
: mType( tNumber )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( 0 )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( opNONE )
|
||||
: mType( tNumber )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( 0 )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( opNONE )
|
||||
{
|
||||
}
|
||||
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( double number )
|
||||
: mType( tNumber )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( number )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( opNONE )
|
||||
: mType( tNumber )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( number )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( opNONE )
|
||||
{
|
||||
}
|
||||
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( QgsRasterMatrix* matrix )
|
||||
: mType( tMatrix )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( 0 )
|
||||
, mMatrix( matrix )
|
||||
, mOperator( opNONE )
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( QgsRasterMatrix *matrix )
|
||||
: mType( tMatrix )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( 0 )
|
||||
, mMatrix( matrix )
|
||||
, mOperator( opNONE )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( Operator op, QgsRasterCalcNode* left, QgsRasterCalcNode* right )
|
||||
: mType( tOperator )
|
||||
, mLeft( left )
|
||||
, mRight( right )
|
||||
, mNumber( 0 )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( op )
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( Operator op, QgsRasterCalcNode *left, QgsRasterCalcNode *right )
|
||||
: mType( tOperator )
|
||||
, mLeft( left )
|
||||
, mRight( right )
|
||||
, mNumber( 0 )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( op )
|
||||
{
|
||||
}
|
||||
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( const QString& rasterName )
|
||||
: mType( tRasterRef )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( 0 )
|
||||
, mRasterName( rasterName )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( opNONE )
|
||||
QgsRasterCalcNode::QgsRasterCalcNode( const QString &rasterName )
|
||||
: mType( tRasterRef )
|
||||
, mLeft( nullptr )
|
||||
, mRight( nullptr )
|
||||
, mNumber( 0 )
|
||||
, mRasterName( rasterName )
|
||||
, mMatrix( nullptr )
|
||||
, mOperator( opNONE )
|
||||
{
|
||||
if ( mRasterName.startsWith( '"' ) && mRasterName.endsWith( '"' ) )
|
||||
mRasterName = mRasterName.mid( 1, mRasterName.size() - 2 );
|
||||
@ -83,14 +83,14 @@ QgsRasterCalcNode::~QgsRasterCalcNode()
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock* >& rasterData, QgsRasterMatrix& result, int row ) const
|
||||
bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock * > &rasterData, QgsRasterMatrix &result, int row ) const
|
||||
{
|
||||
//if type is raster ref: return a copy of the corresponding matrix
|
||||
|
||||
//if type is operator, call the proper matrix operations
|
||||
if ( mType == tRasterRef )
|
||||
{
|
||||
QMap<QString, QgsRasterBlock*>::iterator it = rasterData.find( mRasterName );
|
||||
QMap<QString, QgsRasterBlock *>::iterator it = rasterData.find( mRasterName );
|
||||
if ( it == rasterData.end() )
|
||||
{
|
||||
return false;
|
||||
@ -101,7 +101,7 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock* >& rasterData,
|
||||
int endRow = startRow + nRows;
|
||||
int nCols = ( *it )->width();
|
||||
int nEntries = nCols * nRows;
|
||||
double* data = new double[nEntries];
|
||||
double *data = new double[nEntries];
|
||||
|
||||
//convert input raster values to double, also convert input no data to result no data
|
||||
|
||||
@ -110,7 +110,7 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock* >& rasterData,
|
||||
{
|
||||
for ( int dataCol = 0; dataCol < nCols; ++dataCol )
|
||||
{
|
||||
data[ dataCol + nCols * outRow] = ( *it )->isNoData( dataRow , dataCol ) ? result.nodataValue() : ( *it )->value( dataRow, dataCol );
|
||||
data[ dataCol + nCols * outRow] = ( *it )->isNoData( dataRow, dataCol ) ? result.nodataValue() : ( *it )->value( dataRow, dataCol );
|
||||
}
|
||||
}
|
||||
result.setData( nCols, nRows, data, result.nodataValue() );
|
||||
@ -212,7 +212,7 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock* >& rasterData,
|
||||
}
|
||||
else if ( mType == tNumber )
|
||||
{
|
||||
double* data = new double[1];
|
||||
double *data = new double[1];
|
||||
data[0] = mNumber;
|
||||
result.setData( 1, 1, data, result.nodataValue() );
|
||||
return true;
|
||||
@ -220,7 +220,7 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock* >& rasterData,
|
||||
else if ( mType == tMatrix )
|
||||
{
|
||||
int nEntries = mMatrix->nColumns() * mMatrix->nRows();
|
||||
double* data = new double[nEntries];
|
||||
double *data = new double[nEntries];
|
||||
for ( int i = 0; i < nEntries; ++i )
|
||||
{
|
||||
data[i] = mMatrix->data()[i] == mMatrix->nodataValue() ? result.nodataValue() : mMatrix->data()[i];
|
||||
@ -231,9 +231,9 @@ bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterBlock* >& rasterData,
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsRasterCalcNode* QgsRasterCalcNode::parseRasterCalcString( const QString& str, QString& parserErrorMsg )
|
||||
QgsRasterCalcNode *QgsRasterCalcNode::parseRasterCalcString( const QString &str, QString &parserErrorMsg )
|
||||
{
|
||||
extern QgsRasterCalcNode* localParseRasterCalcString( const QString & str, QString & parserErrorMsg );
|
||||
extern QgsRasterCalcNode *localParseRasterCalcString( const QString & str, QString & parserErrorMsg );
|
||||
return localParseRasterCalcString( str, parserErrorMsg );
|
||||
}
|
||||
|
||||
|
@ -72,21 +72,21 @@ class ANALYSIS_EXPORT QgsRasterCalcNode
|
||||
|
||||
QgsRasterCalcNode();
|
||||
QgsRasterCalcNode( double number );
|
||||
QgsRasterCalcNode( QgsRasterMatrix* matrix );
|
||||
QgsRasterCalcNode( Operator op, QgsRasterCalcNode* left, QgsRasterCalcNode* right );
|
||||
QgsRasterCalcNode( const QString& rasterName );
|
||||
QgsRasterCalcNode( QgsRasterMatrix *matrix );
|
||||
QgsRasterCalcNode( Operator op, QgsRasterCalcNode *left, QgsRasterCalcNode *right );
|
||||
QgsRasterCalcNode( const QString &rasterName );
|
||||
~QgsRasterCalcNode();
|
||||
|
||||
//! QgsRasterCalcNode cannot be copied
|
||||
QgsRasterCalcNode( const QgsRasterCalcNode& rh ) = delete;
|
||||
QgsRasterCalcNode( const QgsRasterCalcNode &rh ) = delete;
|
||||
//! QgsRasterCalcNode cannot be copied
|
||||
QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh ) = delete;
|
||||
QgsRasterCalcNode &operator=( const QgsRasterCalcNode &rh ) = delete;
|
||||
|
||||
Type type() const { return mType; }
|
||||
|
||||
//set left node
|
||||
void setLeft( QgsRasterCalcNode* left ) { delete mLeft; mLeft = left; }
|
||||
void setRight( QgsRasterCalcNode* right ) { delete mRight; mRight = right; }
|
||||
void setLeft( QgsRasterCalcNode *left ) { delete mLeft; mLeft = left; }
|
||||
void setRight( QgsRasterCalcNode *right ) { delete mRight; mRight = right; }
|
||||
|
||||
/** Calculates result of raster calculation (might be real matrix or single number).
|
||||
* @param rasterData input raster data references, map of raster name to raster data block
|
||||
@ -96,17 +96,17 @@ class ANALYSIS_EXPORT QgsRasterCalcNode
|
||||
* @note added in QGIS 2.10
|
||||
* @note not available in Python bindings
|
||||
*/
|
||||
bool calculate( QMap<QString, QgsRasterBlock* >& rasterData, QgsRasterMatrix& result, int row = -1 ) const;
|
||||
bool calculate( QMap<QString, QgsRasterBlock * > &rasterData, QgsRasterMatrix &result, int row = -1 ) const;
|
||||
|
||||
static QgsRasterCalcNode* parseRasterCalcString( const QString& str, QString& parserErrorMsg );
|
||||
static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg );
|
||||
|
||||
private:
|
||||
Type mType;
|
||||
QgsRasterCalcNode* mLeft = nullptr;
|
||||
QgsRasterCalcNode* mRight = nullptr;
|
||||
QgsRasterCalcNode *mLeft = nullptr;
|
||||
QgsRasterCalcNode *mRight = nullptr;
|
||||
double mNumber;
|
||||
QString mRasterName;
|
||||
QgsRasterMatrix* mMatrix = nullptr;
|
||||
QgsRasterMatrix *mMatrix = nullptr;
|
||||
Operator mOperator;
|
||||
|
||||
};
|
||||
|
@ -29,45 +29,45 @@
|
||||
#include <cpl_string.h>
|
||||
#include <gdalwarper.h>
|
||||
|
||||
QgsRasterCalculator::QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
|
||||
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries )
|
||||
: mFormulaString( formulaString )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mOutputRectangle( outputExtent )
|
||||
, mNumOutputColumns( nOutputColumns )
|
||||
, mNumOutputRows( nOutputRows )
|
||||
, mRasterEntries( rasterEntries )
|
||||
QgsRasterCalculator::QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
|
||||
const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries )
|
||||
: mFormulaString( formulaString )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mOutputRectangle( outputExtent )
|
||||
, mNumOutputColumns( nOutputColumns )
|
||||
, mNumOutputRows( nOutputRows )
|
||||
, mRasterEntries( rasterEntries )
|
||||
{
|
||||
//default to first layer's crs
|
||||
mOutputCrs = mRasterEntries.at( 0 ).raster->crs();
|
||||
}
|
||||
|
||||
QgsRasterCalculator::QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
|
||||
const QgsRectangle& outputExtent, const QgsCoordinateReferenceSystem& outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries )
|
||||
: mFormulaString( formulaString )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mOutputRectangle( outputExtent )
|
||||
, mOutputCrs( outputCrs )
|
||||
, mNumOutputColumns( nOutputColumns )
|
||||
, mNumOutputRows( nOutputRows )
|
||||
, mRasterEntries( rasterEntries )
|
||||
QgsRasterCalculator::QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
|
||||
const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries )
|
||||
: mFormulaString( formulaString )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mOutputRectangle( outputExtent )
|
||||
, mOutputCrs( outputCrs )
|
||||
, mNumOutputColumns( nOutputColumns )
|
||||
, mNumOutputRows( nOutputRows )
|
||||
, mRasterEntries( rasterEntries )
|
||||
{
|
||||
}
|
||||
|
||||
int QgsRasterCalculator::processCalculation( QProgressDialog* p )
|
||||
int QgsRasterCalculator::processCalculation( QProgressDialog *p )
|
||||
{
|
||||
//prepare search string / tree
|
||||
QString errorString;
|
||||
QgsRasterCalcNode* calcNode = QgsRasterCalcNode::parseRasterCalcString( mFormulaString, errorString );
|
||||
QgsRasterCalcNode *calcNode = QgsRasterCalcNode::parseRasterCalcString( mFormulaString, errorString );
|
||||
if ( !calcNode )
|
||||
{
|
||||
//error
|
||||
return static_cast<int>( ParserError );
|
||||
}
|
||||
|
||||
QMap< QString, QgsRasterBlock* > inputBlocks;
|
||||
QMap< QString, QgsRasterBlock * > inputBlocks;
|
||||
QVector<QgsRasterCalculatorEntry>::const_iterator it = mRasterEntries.constBegin();
|
||||
for ( ; it != mRasterEntries.constEnd(); ++it )
|
||||
{
|
||||
@ -78,7 +78,7 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
|
||||
return static_cast< int >( InputLayerError );
|
||||
}
|
||||
|
||||
QgsRasterBlock* block = nullptr;
|
||||
QgsRasterBlock *block = nullptr;
|
||||
// if crs transform needed
|
||||
if ( it->raster->crs() != mOutputCrs )
|
||||
{
|
||||
@ -141,7 +141,7 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
|
||||
if ( calcNode->calculate( inputBlocks, resultMatrix, i ) )
|
||||
{
|
||||
bool resultIsNumber = resultMatrix.isNumber();
|
||||
float* calcData = new float[mNumOutputColumns];
|
||||
float *calcData = new float[mNumOutputColumns];
|
||||
|
||||
for ( int j = 0; j < mNumOutputColumns; ++j )
|
||||
{
|
||||
@ -181,8 +181,8 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
|
||||
}
|
||||
|
||||
QgsRasterCalculator::QgsRasterCalculator()
|
||||
: mNumOutputColumns( 0 )
|
||||
, mNumOutputRows( 0 )
|
||||
: mNumOutputColumns( 0 )
|
||||
, mNumOutputRows( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ GDALDatasetH QgsRasterCalculator::openOutputFile( GDALDriverH outputDriver )
|
||||
return outputDataset;
|
||||
}
|
||||
|
||||
void QgsRasterCalculator::outputGeoTransform( double* transform ) const
|
||||
void QgsRasterCalculator::outputGeoTransform( double *transform ) const
|
||||
{
|
||||
transform[0] = mOutputRectangle.xMinimum();
|
||||
transform[1] = mOutputRectangle.width() / mNumOutputColumns;
|
||||
|
@ -32,7 +32,7 @@ class QProgressDialog;
|
||||
struct ANALYSIS_EXPORT QgsRasterCalculatorEntry
|
||||
{
|
||||
QString ref; //name
|
||||
QgsRasterLayer* raster; //pointer to rasterlayer
|
||||
QgsRasterLayer *raster; //pointer to rasterlayer
|
||||
int bandNumber; //raster band number
|
||||
};
|
||||
|
||||
@ -62,8 +62,8 @@ class ANALYSIS_EXPORT QgsRasterCalculator
|
||||
* @param nOutputRows number of rows in output raster
|
||||
* @param rasterEntries list of referenced raster layers
|
||||
*/
|
||||
QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
|
||||
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
|
||||
QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
|
||||
const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
|
||||
|
||||
/** QgsRasterCalculator constructor.
|
||||
* @param formulaString formula for raster calculation
|
||||
@ -76,14 +76,14 @@ class ANALYSIS_EXPORT QgsRasterCalculator
|
||||
* @param rasterEntries list of referenced raster layers
|
||||
* @note added in QGIS 2.10
|
||||
*/
|
||||
QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
|
||||
const QgsRectangle& outputExtent, const QgsCoordinateReferenceSystem& outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
|
||||
QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
|
||||
const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
|
||||
|
||||
/** Starts the calculation and writes new raster
|
||||
@param p progress bar (or 0 if called from non-gui code)
|
||||
@return 0 in case of success*/
|
||||
//TODO QGIS 3.0 - return QgsRasterCalculator::Result
|
||||
int processCalculation( QProgressDialog* p = nullptr );
|
||||
int processCalculation( QProgressDialog *p = nullptr );
|
||||
|
||||
private:
|
||||
//default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
|
||||
@ -99,7 +99,7 @@ class ANALYSIS_EXPORT QgsRasterCalculator
|
||||
|
||||
/** Sets gdal 6 parameters array from mOutputRectangle, mNumOutputColumns, mNumOutputRows
|
||||
@param transform double[6] array that receives the GDAL parameters*/
|
||||
void outputGeoTransform( double* transform ) const;
|
||||
void outputGeoTransform( double *transform ) const;
|
||||
|
||||
QString mFormulaString;
|
||||
QString mOutputFile;
|
||||
|
@ -20,25 +20,25 @@
|
||||
#include <qmath.h>
|
||||
|
||||
QgsRasterMatrix::QgsRasterMatrix()
|
||||
: mColumns( 0 )
|
||||
, mRows( 0 )
|
||||
, mData( nullptr )
|
||||
, mNodataValue( -1 )
|
||||
: mColumns( 0 )
|
||||
, mRows( 0 )
|
||||
, mData( nullptr )
|
||||
, mNodataValue( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
QgsRasterMatrix::QgsRasterMatrix( int nCols, int nRows, double* data, double nodataValue )
|
||||
: mColumns( nCols )
|
||||
, mRows( nRows )
|
||||
, mData( data )
|
||||
, mNodataValue( nodataValue )
|
||||
QgsRasterMatrix::QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue )
|
||||
: mColumns( nCols )
|
||||
, mRows( nRows )
|
||||
, mData( data )
|
||||
, mNodataValue( nodataValue )
|
||||
{
|
||||
}
|
||||
|
||||
QgsRasterMatrix::QgsRasterMatrix( const QgsRasterMatrix& m )
|
||||
: mColumns( 0 )
|
||||
, mRows( 0 )
|
||||
, mData( nullptr )
|
||||
QgsRasterMatrix::QgsRasterMatrix( const QgsRasterMatrix &m )
|
||||
: mColumns( 0 )
|
||||
, mRows( 0 )
|
||||
, mData( nullptr )
|
||||
{
|
||||
operator=( m );
|
||||
}
|
||||
@ -48,7 +48,7 @@ QgsRasterMatrix::~QgsRasterMatrix()
|
||||
delete[] mData;
|
||||
}
|
||||
|
||||
QgsRasterMatrix& QgsRasterMatrix::operator=( const QgsRasterMatrix & m )
|
||||
QgsRasterMatrix &QgsRasterMatrix::operator=( const QgsRasterMatrix &m )
|
||||
{
|
||||
delete[] mData;
|
||||
mColumns = m.nColumns();
|
||||
@ -60,7 +60,7 @@ QgsRasterMatrix& QgsRasterMatrix::operator=( const QgsRasterMatrix & m )
|
||||
return *this;
|
||||
}
|
||||
|
||||
void QgsRasterMatrix::setData( int cols, int rows, double* data, double nodataValue )
|
||||
void QgsRasterMatrix::setData( int cols, int rows, double *data, double nodataValue )
|
||||
{
|
||||
delete[] mData;
|
||||
mColumns = cols;
|
||||
@ -69,76 +69,76 @@ void QgsRasterMatrix::setData( int cols, int rows, double* data, double nodataVa
|
||||
mNodataValue = nodataValue;
|
||||
}
|
||||
|
||||
double* QgsRasterMatrix::takeData()
|
||||
double *QgsRasterMatrix::takeData()
|
||||
{
|
||||
double* data = mData;
|
||||
double *data = mData;
|
||||
mData = nullptr;
|
||||
mColumns = 0;
|
||||
mRows = 0;
|
||||
return data;
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::add( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::add( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opPLUS, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::subtract( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::subtract( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opMINUS, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::multiply( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::multiply( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opMUL, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::divide( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::divide( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opDIV, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::power( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::power( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opPOW, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::equal( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::equal( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opEQ, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::notEqual( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::notEqual( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opNE, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::greaterThan( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::greaterThan( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opGT, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::lesserThan( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::lesserThan( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opLT, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::greaterEqual( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::greaterEqual( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opGE, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::lesserEqual( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::lesserEqual( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opLE, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::logicalAnd( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::logicalAnd( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opAND, other );
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::logicalOr( const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::logicalOr( const QgsRasterMatrix &other )
|
||||
{
|
||||
return twoArgumentOperation( opOR, other );
|
||||
}
|
||||
@ -314,7 +314,7 @@ double QgsRasterMatrix::calculateTwoArgumentOp( TwoArgOperator op, double arg1,
|
||||
return mNodataValue;
|
||||
}
|
||||
|
||||
bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other )
|
||||
bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other )
|
||||
{
|
||||
if ( isNumber() && other.isNumber() ) //operation on two 1x1 matrices
|
||||
{
|
||||
@ -333,7 +333,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
|
||||
//two matrices
|
||||
if ( !isNumber() && !other.isNumber() )
|
||||
{
|
||||
double* matrix = other.mData;
|
||||
double *matrix = other.mData;
|
||||
int nEntries = mColumns * mRows;
|
||||
double value1, value2;
|
||||
|
||||
@ -356,7 +356,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
|
||||
//this matrix is a single number and the other one a real matrix
|
||||
if ( isNumber() )
|
||||
{
|
||||
double* matrix = other.mData;
|
||||
double *matrix = other.mData;
|
||||
int nEntries = other.nColumns() * other.nRows();
|
||||
double value = mData[0];
|
||||
delete[] mData;
|
||||
@ -415,7 +415,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
|
||||
|
||||
bool QgsRasterMatrix::testPowerValidity( double base, double power ) const
|
||||
{
|
||||
if (( base == 0 && power < 0 ) || ( base < 0 && ( power - floor( power ) ) > 0 ) )
|
||||
if ( ( base == 0 && power < 0 ) || ( base < 0 && ( power - floor( power ) ) > 0 ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ class ANALYSIS_EXPORT QgsRasterMatrix
|
||||
//! Takes ownership of data array
|
||||
QgsRasterMatrix();
|
||||
//! @note note available in python bindings
|
||||
QgsRasterMatrix( int nCols, int nRows, double* data, double nodataValue );
|
||||
QgsRasterMatrix( const QgsRasterMatrix& m );
|
||||
QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue );
|
||||
QgsRasterMatrix( const QgsRasterMatrix &m );
|
||||
~QgsRasterMatrix();
|
||||
|
||||
//! Returns true if matrix is 1x1 (=scalar number)
|
||||
@ -71,12 +71,12 @@ class ANALYSIS_EXPORT QgsRasterMatrix
|
||||
|
||||
//! Returns data array (but not ownership)
|
||||
//! @note not available in python bindings
|
||||
double* data() { return mData; }
|
||||
double *data() { return mData; }
|
||||
//! Returns data and ownership. Sets data and nrows, ncols of this matrix to 0
|
||||
//! @note not available in python bindings
|
||||
double* takeData();
|
||||
double *takeData();
|
||||
|
||||
void setData( int cols, int rows, double* data, double nodataValue );
|
||||
void setData( int cols, int rows, double *data, double nodataValue );
|
||||
|
||||
int nColumns() const { return mColumns; }
|
||||
int nRows() const { return mRows; }
|
||||
@ -84,22 +84,22 @@ class ANALYSIS_EXPORT QgsRasterMatrix
|
||||
double nodataValue() const { return mNodataValue; }
|
||||
void setNodataValue( double d ) { mNodataValue = d; }
|
||||
|
||||
QgsRasterMatrix& operator=( const QgsRasterMatrix& m );
|
||||
QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
|
||||
//! Adds another matrix to this one
|
||||
bool add( const QgsRasterMatrix& other );
|
||||
bool add( const QgsRasterMatrix &other );
|
||||
//! Subtracts another matrix from this one
|
||||
bool subtract( const QgsRasterMatrix& other );
|
||||
bool multiply( const QgsRasterMatrix& other );
|
||||
bool divide( const QgsRasterMatrix& other );
|
||||
bool power( const QgsRasterMatrix& other );
|
||||
bool equal( const QgsRasterMatrix& other );
|
||||
bool notEqual( const QgsRasterMatrix& other );
|
||||
bool greaterThan( const QgsRasterMatrix& other );
|
||||
bool lesserThan( const QgsRasterMatrix& other );
|
||||
bool greaterEqual( const QgsRasterMatrix& other );
|
||||
bool lesserEqual( const QgsRasterMatrix& other );
|
||||
bool logicalAnd( const QgsRasterMatrix& other );
|
||||
bool logicalOr( const QgsRasterMatrix& other );
|
||||
bool subtract( const QgsRasterMatrix &other );
|
||||
bool multiply( const QgsRasterMatrix &other );
|
||||
bool divide( const QgsRasterMatrix &other );
|
||||
bool power( const QgsRasterMatrix &other );
|
||||
bool equal( const QgsRasterMatrix &other );
|
||||
bool notEqual( const QgsRasterMatrix &other );
|
||||
bool greaterThan( const QgsRasterMatrix &other );
|
||||
bool lesserThan( const QgsRasterMatrix &other );
|
||||
bool greaterEqual( const QgsRasterMatrix &other );
|
||||
bool lesserEqual( const QgsRasterMatrix &other );
|
||||
bool logicalAnd( const QgsRasterMatrix &other );
|
||||
bool logicalOr( const QgsRasterMatrix &other );
|
||||
|
||||
bool squareRoot();
|
||||
bool sinus();
|
||||
@ -115,11 +115,11 @@ class ANALYSIS_EXPORT QgsRasterMatrix
|
||||
private:
|
||||
int mColumns;
|
||||
int mRows;
|
||||
double* mData = nullptr;
|
||||
double *mData = nullptr;
|
||||
double mNodataValue;
|
||||
|
||||
//! +,-,*,/,^,<,>,<=,>=,=,!=, and, or
|
||||
bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other );
|
||||
bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
|
||||
double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
|
||||
|
||||
/*sqrt, sin, cos, tan, asin, acos, atan*/
|
||||
|
@ -28,15 +28,15 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
QgsRelief::QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
|
||||
: mInputFile( inputFile )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mCellSizeX( 0.0 )
|
||||
, mCellSizeY( 0.0 )
|
||||
, mInputNodataValue( -1 )
|
||||
, mOutputNodataValue( -1 )
|
||||
, mZFactor( 1.0 )
|
||||
QgsRelief::QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
|
||||
: mInputFile( inputFile )
|
||||
, mOutputFile( outputFile )
|
||||
, mOutputFormat( outputFormat )
|
||||
, mCellSizeX( 0.0 )
|
||||
, mCellSizeY( 0.0 )
|
||||
, mInputNodataValue( -1 )
|
||||
, mOutputNodataValue( -1 )
|
||||
, mZFactor( 1.0 )
|
||||
{
|
||||
mSlopeFilter = new QgsSlopeFilter( inputFile, outputFile, outputFormat );
|
||||
mAspectFilter = new QgsAspectFilter( inputFile, outputFile, outputFormat );
|
||||
@ -62,7 +62,7 @@ void QgsRelief::clearReliefColors()
|
||||
mReliefColors.clear();
|
||||
}
|
||||
|
||||
void QgsRelief::addReliefColorClass( const ReliefColor& color )
|
||||
void QgsRelief::addReliefColorClass( const ReliefColor &color )
|
||||
{
|
||||
mReliefColors.push_back( color );
|
||||
}
|
||||
@ -78,7 +78,7 @@ void QgsRelief::setDefaultReliefColors()
|
||||
addReliefColorClass( ReliefColor( QColor( 255, 255, 255 ), 4000, 9000 ) );
|
||||
}
|
||||
|
||||
int QgsRelief::processRaster( QProgressDialog* p )
|
||||
int QgsRelief::processRaster( QProgressDialog *p )
|
||||
{
|
||||
//open input file
|
||||
int xSize, ySize;
|
||||
@ -162,13 +162,13 @@ int QgsRelief::processRaster( QProgressDialog* p )
|
||||
}
|
||||
|
||||
//keep only three scanlines in memory at a time
|
||||
float* scanLine1 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float* scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float* scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *scanLine1 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
float *scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
|
||||
|
||||
unsigned char* resultRedLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
|
||||
unsigned char* resultGreenLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
|
||||
unsigned char* resultBlueLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
|
||||
unsigned char *resultRedLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
|
||||
unsigned char *resultGreenLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
|
||||
unsigned char *resultBlueLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
|
||||
|
||||
if ( p )
|
||||
{
|
||||
@ -230,20 +230,20 @@ int QgsRelief::processRaster( QProgressDialog* p )
|
||||
{
|
||||
if ( j == 0 )
|
||||
{
|
||||
resultOk = processNineCellWindow( &mInputNodataValue, &scanLine1[j], &scanLine1[j+1], &mInputNodataValue, &scanLine2[j], \
|
||||
&scanLine2[j+1], &mInputNodataValue, &scanLine3[j], &scanLine3[j+1], \
|
||||
resultOk = processNineCellWindow( &mInputNodataValue, &scanLine1[j], &scanLine1[j + 1], &mInputNodataValue, &scanLine2[j], \
|
||||
&scanLine2[j + 1], &mInputNodataValue, &scanLine3[j], &scanLine3[j + 1], \
|
||||
&resultRedLine[j], &resultGreenLine[j], &resultBlueLine[j] );
|
||||
}
|
||||
else if ( j == xSize - 1 )
|
||||
{
|
||||
resultOk = processNineCellWindow( &scanLine1[j-1], &scanLine1[j], &mInputNodataValue, &scanLine2[j-1], &scanLine2[j], \
|
||||
&mInputNodataValue, &scanLine3[j-1], &scanLine3[j], &mInputNodataValue, \
|
||||
resultOk = processNineCellWindow( &scanLine1[j - 1], &scanLine1[j], &mInputNodataValue, &scanLine2[j - 1], &scanLine2[j], \
|
||||
&mInputNodataValue, &scanLine3[j - 1], &scanLine3[j], &mInputNodataValue, \
|
||||
&resultRedLine[j], &resultGreenLine[j], &resultBlueLine[j] );
|
||||
}
|
||||
else
|
||||
{
|
||||
resultOk = processNineCellWindow( &scanLine1[j-1], &scanLine1[j], &scanLine1[j+1], &scanLine2[j-1], &scanLine2[j], \
|
||||
&scanLine2[j+1], &scanLine3[j-1], &scanLine3[j], &scanLine3[j+1], \
|
||||
resultOk = processNineCellWindow( &scanLine1[j - 1], &scanLine1[j], &scanLine1[j + 1], &scanLine2[j - 1], &scanLine2[j], \
|
||||
&scanLine2[j + 1], &scanLine3[j - 1], &scanLine3[j], &scanLine3[j + 1], \
|
||||
&resultRedLine[j], &resultGreenLine[j], &resultBlueLine[j] );
|
||||
}
|
||||
|
||||
@ -294,8 +294,8 @@ int QgsRelief::processRaster( QProgressDialog* p )
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
|
||||
unsigned char* red, unsigned char* green, unsigned char* blue )
|
||||
bool QgsRelief::processNineCellWindow( float *x1, float *x2, float *x3, float *x4, float *x5, float *x6, float *x7, float *x8, float *x9,
|
||||
unsigned char *red, unsigned char *green, unsigned char *blue )
|
||||
{
|
||||
//1. component: color and hillshade from 300 degrees
|
||||
int r = 0;
|
||||
@ -388,14 +388,14 @@ bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsRelief::setElevationColor( double elevation, int* red, int* green, int* blue )
|
||||
bool QgsRelief::setElevationColor( double elevation, int *red, int *green, int *blue )
|
||||
{
|
||||
QList< ReliefColor >::const_iterator reliefColorIt = mReliefColors.constBegin();
|
||||
for ( ; reliefColorIt != mReliefColors.constEnd(); ++reliefColorIt )
|
||||
{
|
||||
if ( elevation >= reliefColorIt->minElevation && elevation <= reliefColorIt->maxElevation )
|
||||
{
|
||||
const QColor& c = reliefColorIt->color;
|
||||
const QColor &c = reliefColorIt->color;
|
||||
*red = c.red();
|
||||
*green = c.green();
|
||||
*blue = c.blue();
|
||||
@ -407,7 +407,7 @@ bool QgsRelief::setElevationColor( double elevation, int* red, int* green, int*
|
||||
}
|
||||
|
||||
//duplicated from QgsNineCellFilter. Todo: make common base class
|
||||
GDALDatasetH QgsRelief::openInputFile( int& nCellsX, int& nCellsY )
|
||||
GDALDatasetH QgsRelief::openInputFile( int &nCellsX, int &nCellsY )
|
||||
{
|
||||
GDALDatasetH inputDataset = GDALOpen( mInputFile.toUtf8().constData(), GA_ReadOnly );
|
||||
if ( inputDataset )
|
||||
@ -490,14 +490,14 @@ GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH o
|
||||
mCellSizeY = -mCellSizeY;
|
||||
}
|
||||
|
||||
const char* projection = GDALGetProjectionRef( inputDataset );
|
||||
const char *projection = GDALGetProjectionRef( inputDataset );
|
||||
GDALSetProjection( outputDataset, projection );
|
||||
|
||||
return outputDataset;
|
||||
}
|
||||
|
||||
//this function is mainly there for debugging
|
||||
bool QgsRelief::exportFrequencyDistributionToCsv( const QString& file )
|
||||
bool QgsRelief::exportFrequencyDistributionToCsv( const QString &file )
|
||||
{
|
||||
int nCellsX, nCellsY;
|
||||
GDALDatasetH inputDataset = openInputFile( nCellsX, nCellsY );
|
||||
@ -536,7 +536,7 @@ bool QgsRelief::exportFrequencyDistributionToCsv( const QString& file )
|
||||
frequency[i] = 0;
|
||||
}
|
||||
|
||||
float* scanLine = ( float * ) CPLMalloc( sizeof( float ) * nCellsX );
|
||||
float *scanLine = ( float * ) CPLMalloc( sizeof( float ) * nCellsX );
|
||||
int elevationClass = -1;
|
||||
|
||||
for ( int i = 0; i < nCellsY; ++i )
|
||||
@ -623,7 +623,7 @@ QList< QgsRelief::ReliefColor > QgsRelief::calculateOptimizedReliefClasses()
|
||||
frequency[i] = 0;
|
||||
}
|
||||
|
||||
float* scanLine = ( float * ) CPLMalloc( sizeof( float ) * nCellsX );
|
||||
float *scanLine = ( float * ) CPLMalloc( sizeof( float ) * nCellsX );
|
||||
int elevationClass = -1;
|
||||
|
||||
for ( int i = 0; i < nCellsY; ++i )
|
||||
@ -704,11 +704,11 @@ QList< QgsRelief::ReliefColor > QgsRelief::calculateOptimizedReliefClasses()
|
||||
return resultList;
|
||||
}
|
||||
|
||||
void QgsRelief::optimiseClassBreaks( QList<int>& breaks, double* frequencies )
|
||||
void QgsRelief::optimiseClassBreaks( QList<int> &breaks, double *frequencies )
|
||||
{
|
||||
int nClasses = breaks.size() - 1;
|
||||
double* a = new double[nClasses]; //slopes
|
||||
double* b = new double[nClasses]; //y-offsets
|
||||
double *a = new double[nClasses]; //slopes
|
||||
double *b = new double[nClasses]; //y-offsets
|
||||
|
||||
for ( int i = 0; i < nClasses; ++i )
|
||||
{
|
||||
@ -779,7 +779,7 @@ int QgsRelief::frequencyClassForElevation( double elevation, double minElevation
|
||||
return ( elevation - minElevation ) / elevationClassRange;
|
||||
}
|
||||
|
||||
bool QgsRelief::calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b )
|
||||
bool QgsRelief::calculateRegression( const QList< QPair < int, double > > &input, double &a, double &b )
|
||||
{
|
||||
double xMean, yMean;
|
||||
double xSum = 0;
|
||||
@ -798,8 +798,8 @@ bool QgsRelief::calculateRegression( const QList< QPair < int, double > >& input
|
||||
inputIt = input.constBegin();
|
||||
for ( ; inputIt != input.constEnd(); ++inputIt )
|
||||
{
|
||||
sumCounter += (( inputIt->first - xMean ) * ( inputIt->second - yMean ) );
|
||||
sumDenominator += (( inputIt->first - xMean ) * ( inputIt->first - xMean ) );
|
||||
sumCounter += ( ( inputIt->first - xMean ) * ( inputIt->second - yMean ) );
|
||||
sumDenominator += ( ( inputIt->first - xMean ) * ( inputIt->first - xMean ) );
|
||||
}
|
||||
|
||||
a = sumCounter / sumDenominator;
|
||||
|
@ -37,39 +37,39 @@ class ANALYSIS_EXPORT QgsRelief
|
||||
public:
|
||||
struct ReliefColor
|
||||
{
|
||||
ReliefColor( const QColor& c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
|
||||
ReliefColor( const QColor &c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
|
||||
QColor color;
|
||||
double minElevation;
|
||||
double maxElevation;
|
||||
};
|
||||
|
||||
QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
~QgsRelief();
|
||||
|
||||
//! QgsRelief cannot be copied
|
||||
QgsRelief( const QgsRelief& rh ) = delete;
|
||||
QgsRelief( const QgsRelief &rh ) = delete;
|
||||
//! QgsRelief cannot be copied
|
||||
QgsRelief& operator=( const QgsRelief& rh ) = delete;
|
||||
QgsRelief &operator=( const QgsRelief &rh ) = delete;
|
||||
|
||||
/** Starts the calculation, reads from mInputFile and stores the result in mOutputFile
|
||||
@param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
|
||||
@return 0 in case of success*/
|
||||
int processRaster( QProgressDialog* p );
|
||||
int processRaster( QProgressDialog *p );
|
||||
|
||||
double zFactor() const { return mZFactor; }
|
||||
void setZFactor( double factor ) { mZFactor = factor; }
|
||||
|
||||
void clearReliefColors();
|
||||
void addReliefColorClass( const ReliefColor& color );
|
||||
void addReliefColorClass( const ReliefColor &color );
|
||||
QList< ReliefColor > reliefColors() const { return mReliefColors; }
|
||||
void setReliefColors( const QList< ReliefColor >& c ) { mReliefColors = c; }
|
||||
void setReliefColors( const QList< ReliefColor > &c ) { mReliefColors = c; }
|
||||
|
||||
/** Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression
|
||||
@return true in case of success*/
|
||||
QList< ReliefColor > calculateOptimizedReliefClasses();
|
||||
|
||||
//! Write frequency of elevation values to file for manual inspection
|
||||
bool exportFrequencyDistributionToCsv( const QString& file );
|
||||
bool exportFrequencyDistributionToCsv( const QString &file );
|
||||
|
||||
private:
|
||||
|
||||
@ -86,20 +86,20 @@ class ANALYSIS_EXPORT QgsRelief
|
||||
|
||||
double mZFactor;
|
||||
|
||||
QgsSlopeFilter* mSlopeFilter = nullptr;
|
||||
QgsAspectFilter* mAspectFilter = nullptr;
|
||||
QgsHillshadeFilter* mHillshadeFilter285 = nullptr;
|
||||
QgsHillshadeFilter* mHillshadeFilter300 = nullptr;
|
||||
QgsHillshadeFilter* mHillshadeFilter315 = nullptr;
|
||||
QgsSlopeFilter *mSlopeFilter = nullptr;
|
||||
QgsAspectFilter *mAspectFilter = nullptr;
|
||||
QgsHillshadeFilter *mHillshadeFilter285 = nullptr;
|
||||
QgsHillshadeFilter *mHillshadeFilter300 = nullptr;
|
||||
QgsHillshadeFilter *mHillshadeFilter315 = nullptr;
|
||||
|
||||
//relief colors and corresponding elevations
|
||||
QList< ReliefColor > mReliefColors;
|
||||
|
||||
bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
|
||||
unsigned char* red, unsigned char* green, unsigned char* blue );
|
||||
bool processNineCellWindow( float *x1, float *x2, float *x3, float *x4, float *x5, float *x6, float *x7, float *x8, float *x9,
|
||||
unsigned char *red, unsigned char *green, unsigned char *blue );
|
||||
|
||||
//! Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction
|
||||
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
|
||||
GDALDatasetH openInputFile( int &nCellsX, int &nCellsY );
|
||||
|
||||
/** Opens the output driver and tests if it supports the creation of a new dataset
|
||||
@return nullptr on error and the driver handle on success*/
|
||||
@ -110,7 +110,7 @@ class ANALYSIS_EXPORT QgsRelief
|
||||
GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
|
||||
|
||||
//! Set elevation color
|
||||
bool setElevationColor( double elevation, int* red, int* green, int* blue );
|
||||
bool setElevationColor( double elevation, int *red, int *green, int *blue );
|
||||
|
||||
//! Sets relief colors
|
||||
void setDefaultReliefColors();
|
||||
@ -119,14 +119,14 @@ class ANALYSIS_EXPORT QgsRelief
|
||||
@return elevation class or -1 in case of error*/
|
||||
int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
|
||||
//! Do one iteration of class break optimisation (algorithm from Garcia and Rodriguez)
|
||||
void optimiseClassBreaks( QList<int>& breaks, double* frequencies );
|
||||
void optimiseClassBreaks( QList<int> &breaks, double *frequencies );
|
||||
|
||||
/** Calculates coefficients a and b
|
||||
@param input data points ( elevation class / frequency )
|
||||
@param a slope
|
||||
@param b y value for x=0
|
||||
*/
|
||||
bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );
|
||||
bool calculateRegression( const QList< QPair < int, double > > &input, double &a, double &b );
|
||||
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "qgsruggednessfilter.h"
|
||||
|
||||
QgsRuggednessFilter::QgsRuggednessFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat ): QgsNineCellFilter( inputFile, outputFile, outputFormat )
|
||||
QgsRuggednessFilter::QgsRuggednessFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat ): QgsNineCellFilter( inputFile, outputFile, outputFormat )
|
||||
{
|
||||
|
||||
}
|
||||
@ -27,8 +27,8 @@ QgsRuggednessFilter::QgsRuggednessFilter(): QgsNineCellFilter( QLatin1String( ""
|
||||
|
||||
}
|
||||
|
||||
float QgsRuggednessFilter::processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
|
||||
float QgsRuggednessFilter::processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 )
|
||||
{
|
||||
//the formula would be that easy without nodata values...
|
||||
/*
|
||||
|
@ -27,16 +27,16 @@
|
||||
class ANALYSIS_EXPORT QgsRuggednessFilter: public QgsNineCellFilter
|
||||
{
|
||||
public:
|
||||
QgsRuggednessFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsRuggednessFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
~QgsRuggednessFilter() = default;
|
||||
|
||||
protected:
|
||||
|
||||
/** Calculates output value from nine input values. The input values and the output value can be equal to the
|
||||
nodata value if not present or outside of the border. Must be implemented by subclasses*/
|
||||
float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) override;
|
||||
float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) override;
|
||||
|
||||
private:
|
||||
QgsRuggednessFilter();
|
||||
|
@ -17,14 +17,14 @@
|
||||
|
||||
#include "qgsslopefilter.h"
|
||||
|
||||
QgsSlopeFilter::QgsSlopeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
|
||||
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
|
||||
QgsSlopeFilter::QgsSlopeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
|
||||
: QgsDerivativeFilter( inputFile, outputFile, outputFormat )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float QgsSlopeFilter::processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 )
|
||||
float QgsSlopeFilter::processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 )
|
||||
{
|
||||
float derX = calcFirstDerX( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
|
||||
float derY = calcFirstDerY( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
|
||||
|
@ -26,14 +26,14 @@
|
||||
class ANALYSIS_EXPORT QgsSlopeFilter: public QgsDerivativeFilter
|
||||
{
|
||||
public:
|
||||
QgsSlopeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsSlopeFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
~QgsSlopeFilter() = default;
|
||||
|
||||
/** Calculates output value from nine input values. The input values and the output value can be equal to the
|
||||
nodata value if not present or outside of the border. Must be implemented by subclasses*/
|
||||
float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) override;
|
||||
float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) override;
|
||||
};
|
||||
|
||||
#endif // QGSSLOPEFILTER_H
|
||||
|
@ -17,14 +17,14 @@
|
||||
|
||||
#include "qgstotalcurvaturefilter.h"
|
||||
|
||||
QgsTotalCurvatureFilter::QgsTotalCurvatureFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
|
||||
: QgsNineCellFilter( inputFile, outputFile, outputFormat )
|
||||
QgsTotalCurvatureFilter::QgsTotalCurvatureFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
|
||||
: QgsNineCellFilter( inputFile, outputFile, outputFormat )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float QgsTotalCurvatureFilter::processNineCellWindow( float* x11, float* x21, float* x31, float* x12,
|
||||
float* x22, float* x32, float* x13, float* x23, float* x33 )
|
||||
float QgsTotalCurvatureFilter::processNineCellWindow( float *x11, float *x21, float *x31, float *x12,
|
||||
float *x22, float *x32, float *x13, float *x23, float *x33 )
|
||||
{
|
||||
//return nodata if one value is the nodata value
|
||||
if ( *x11 == mInputNodataValue || *x21 == mInputNodataValue || *x31 == mInputNodataValue || *x12 == mInputNodataValue
|
||||
@ -39,5 +39,5 @@ float QgsTotalCurvatureFilter::processNineCellWindow( float* x11, float* x21, fl
|
||||
double dxy = ( -*x11 + *x31 + *x13 - *x33 ) / ( 4 * cellSizeAvg * cellSizeAvg );
|
||||
double dyy = ( *x21 - 2 * *x22 + *x23 ) / ( mCellSizeY * mCellSizeY );
|
||||
|
||||
return dxx*dxx + 2*dxy*dxy + dyy*dyy;
|
||||
return dxx * dxx + 2 * dxy * dxy + dyy * dyy;
|
||||
}
|
||||
|
@ -26,16 +26,16 @@
|
||||
class ANALYSIS_EXPORT QgsTotalCurvatureFilter: public QgsNineCellFilter
|
||||
{
|
||||
public:
|
||||
QgsTotalCurvatureFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
|
||||
QgsTotalCurvatureFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
|
||||
~QgsTotalCurvatureFilter() = default;
|
||||
|
||||
protected:
|
||||
|
||||
/** Calculates total curvature from nine input values. The input values and the output value can be equal to the
|
||||
nodata value if not present or outside of the border. Must be implemented by subclasses*/
|
||||
float processNineCellWindow( float* x11, float* x21, float* x31,
|
||||
float* x12, float* x22, float* x32,
|
||||
float* x13, float* x23, float* x33 ) override;
|
||||
float processNineCellWindow( float *x11, float *x21, float *x31,
|
||||
float *x12, float *x22, float *x32,
|
||||
float *x13, float *x23, float *x33 ) override;
|
||||
};
|
||||
|
||||
#endif // QGSTOTALCURVATUREFILTER_H
|
||||
|
@ -81,7 +81,7 @@ static inline void generate_numbers()
|
||||
}
|
||||
|
||||
// i = 226
|
||||
UNROLL(( i + PERIOD ) % SIZE );
|
||||
UNROLL( ( i + PERIOD ) % SIZE );
|
||||
|
||||
// i = [227 ... 622]
|
||||
while ( i < ( SIZE - 1 ) )
|
||||
@ -104,8 +104,8 @@ static inline void generate_numbers()
|
||||
}
|
||||
|
||||
// i = 623
|
||||
y = M32( MT[SIZE-1] ) | L31( MT[0] );
|
||||
MT[SIZE-1] = MT[PERIOD-1] ^( y >> 1 ) ^ MATRIX[ODD( y )];
|
||||
y = M32( MT[SIZE - 1] ) | L31( MT[0] );
|
||||
MT[SIZE - 1] = MT[PERIOD - 1] ^ ( y >> 1 ) ^ MATRIX[ODD( y )];
|
||||
}
|
||||
|
||||
extern "C" void seed( uint32_t value )
|
||||
@ -146,7 +146,7 @@ extern "C" void seed( uint32_t value )
|
||||
index = 0;
|
||||
|
||||
for ( unsigned i = 1; i < SIZE; ++i )
|
||||
MT[i] = 0x6c078965 * ( MT[i-1] ^ MT[i-1] >> 30 ) + i;
|
||||
MT[i] = 0x6c078965 * ( MT[i - 1] ^ MT[i - 1] >> 30 ) + i;
|
||||
}
|
||||
|
||||
extern "C" uint32_t rand_u32()
|
||||
|
@ -39,73 +39,73 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum number you can get from rand().
|
||||
*/
|
||||
/*
|
||||
* Maximum number you can get from rand().
|
||||
*/
|
||||
#define MD_RAND_MAX std::numeric_limits<int32_t>::max()
|
||||
|
||||
/*
|
||||
* Initialize the number generator with given seed.
|
||||
* (LIBC REPLACEMENT FUNCTION)
|
||||
*/
|
||||
void mt_srand( unsigned seed_value );
|
||||
/*
|
||||
* Initialize the number generator with given seed.
|
||||
* (LIBC REPLACEMENT FUNCTION)
|
||||
*/
|
||||
void mt_srand( unsigned seed_value );
|
||||
|
||||
/*
|
||||
* Extract a pseudo-random integer in the range 0 ... MD_RAND_MAX.
|
||||
* (LIBC REPLACEMENT FUNCTION)
|
||||
*/
|
||||
int mt_rand();
|
||||
/*
|
||||
* Extract a pseudo-random integer in the range 0 ... MD_RAND_MAX.
|
||||
* (LIBC REPLACEMENT FUNCTION)
|
||||
*/
|
||||
int mt_rand();
|
||||
|
||||
/*
|
||||
* Extract a pseudo-random unsigned 32-bit integer in the range 0 ... MD_UINT32_MAX
|
||||
*/
|
||||
uint32_t rand_u32();
|
||||
/*
|
||||
* Extract a pseudo-random unsigned 32-bit integer in the range 0 ... MD_UINT32_MAX
|
||||
*/
|
||||
uint32_t rand_u32();
|
||||
|
||||
/*
|
||||
* Combine two unsigned 32-bit pseudo-random numbers into one 64-bit
|
||||
*/
|
||||
uint64_t rand_u64();
|
||||
/*
|
||||
* Combine two unsigned 32-bit pseudo-random numbers into one 64-bit
|
||||
*/
|
||||
uint64_t rand_u64();
|
||||
|
||||
/*
|
||||
* Initialize Mersenne Twister with given seed value.
|
||||
*/
|
||||
void seed( uint32_t seed_value );
|
||||
/*
|
||||
* Initialize Mersenne Twister with given seed value.
|
||||
*/
|
||||
void seed( uint32_t seed_value );
|
||||
|
||||
/*
|
||||
* Return a random float in the CLOSED range [0, 1]
|
||||
* Mnemonic: randf_co = random float 0=closed 1=closed
|
||||
*/
|
||||
float randf_cc();
|
||||
/*
|
||||
* Return a random float in the CLOSED range [0, 1]
|
||||
* Mnemonic: randf_co = random float 0=closed 1=closed
|
||||
*/
|
||||
float randf_cc();
|
||||
|
||||
/*
|
||||
* Return a random float in the OPEN range [0, 1>
|
||||
* Mnemonic: randf_co = random float 0=closed 1=open
|
||||
*/
|
||||
float randf_co();
|
||||
/*
|
||||
* Return a random float in the OPEN range [0, 1>
|
||||
* Mnemonic: randf_co = random float 0=closed 1=open
|
||||
*/
|
||||
float randf_co();
|
||||
|
||||
/*
|
||||
* Return a random float in the OPEN range <0, 1>
|
||||
* Mnemonic: randf_oo = random float 0=open 1=open
|
||||
*/
|
||||
float randf_oo();
|
||||
/*
|
||||
* Return a random float in the OPEN range <0, 1>
|
||||
* Mnemonic: randf_oo = random float 0=open 1=open
|
||||
*/
|
||||
float randf_oo();
|
||||
|
||||
/*
|
||||
* Return a random double in the CLOSED range [0, 1]
|
||||
* Mnemonic: randd_co = random double 0=closed 1=closed
|
||||
*/
|
||||
double randd_cc();
|
||||
/*
|
||||
* Return a random double in the CLOSED range [0, 1]
|
||||
* Mnemonic: randd_co = random double 0=closed 1=closed
|
||||
*/
|
||||
double randd_cc();
|
||||
|
||||
/*
|
||||
* Return a random double in the OPEN range [0, 1>
|
||||
* Mnemonic: randd_co = random double 0=closed 1=open
|
||||
*/
|
||||
double randd_co();
|
||||
/*
|
||||
* Return a random double in the OPEN range [0, 1>
|
||||
* Mnemonic: randd_co = random double 0=closed 1=open
|
||||
*/
|
||||
double randd_co();
|
||||
|
||||
/*
|
||||
* Return a random double in the OPEN range <0, 1>
|
||||
* Mnemonic: randd_oo = random double 0=open 1=open
|
||||
*/
|
||||
double randd_oo();
|
||||
/*
|
||||
* Return a random double in the OPEN range <0, 1>
|
||||
* Mnemonic: randd_oo = random double 0=open 1=open
|
||||
*/
|
||||
double randd_oo();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
#include <QProgressDialog>
|
||||
|
||||
bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer,
|
||||
const QString& shapefileName,
|
||||
bool QgsGeometryAnalyzer::simplify( QgsVectorLayer *layer,
|
||||
const QString &shapefileName,
|
||||
double tolerance,
|
||||
bool onlySelectedFeatures,
|
||||
QProgressDialog *p )
|
||||
@ -42,7 +42,7 @@ bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer,
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsVectorDataProvider* dp = layer->dataProvider();
|
||||
QgsVectorDataProvider *dp = layer->dataProvider();
|
||||
if ( !dp )
|
||||
{
|
||||
return false;
|
||||
@ -124,7 +124,7 @@ bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer,
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsGeometryAnalyzer::simplifyFeature( QgsFeature& f, QgsVectorFileWriter* vfw, double tolerance )
|
||||
void QgsGeometryAnalyzer::simplifyFeature( QgsFeature &f, QgsVectorFileWriter *vfw, double tolerance )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
@ -147,8 +147,8 @@ void QgsGeometryAnalyzer::simplifyFeature( QgsFeature& f, QgsVectorFileWriter* v
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shapefileName,
|
||||
bool onlySelectedFeatures, QProgressDialog* p )
|
||||
bool QgsGeometryAnalyzer::centroids( QgsVectorLayer *layer, const QString &shapefileName,
|
||||
bool onlySelectedFeatures, QProgressDialog *p )
|
||||
{
|
||||
if ( !layer )
|
||||
{
|
||||
@ -156,7 +156,7 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsVectorDataProvider* dp = layer->dataProvider();
|
||||
QgsVectorDataProvider *dp = layer->dataProvider();
|
||||
if ( !dp )
|
||||
{
|
||||
QgsDebugMsg( "No data provider for layer passed to centroids" );
|
||||
@ -240,7 +240,7 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
|
||||
}
|
||||
|
||||
|
||||
void QgsGeometryAnalyzer::centroidFeature( QgsFeature& f, QgsVectorFileWriter* vfw )
|
||||
void QgsGeometryAnalyzer::centroidFeature( QgsFeature &f, QgsVectorFileWriter *vfw )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
@ -259,8 +259,8 @@ void QgsGeometryAnalyzer::centroidFeature( QgsFeature& f, QgsVectorFileWriter* v
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::extent( QgsVectorLayer* layer,
|
||||
const QString& shapefileName,
|
||||
bool QgsGeometryAnalyzer::extent( QgsVectorLayer *layer,
|
||||
const QString &shapefileName,
|
||||
bool onlySelectedFeatures,
|
||||
QProgressDialog * )
|
||||
{
|
||||
@ -269,7 +269,7 @@ bool QgsGeometryAnalyzer::extent( QgsVectorLayer* layer,
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsVectorDataProvider* dp = layer->dataProvider();
|
||||
QgsVectorDataProvider *dp = layer->dataProvider();
|
||||
if ( !dp )
|
||||
{
|
||||
return false;
|
||||
@ -331,7 +331,7 @@ bool QgsGeometryAnalyzer::extent( QgsVectorLayer* layer,
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<double> QgsGeometryAnalyzer::simpleMeasure( QgsGeometry& mpGeometry )
|
||||
QList<double> QgsGeometryAnalyzer::simpleMeasure( QgsGeometry &mpGeometry )
|
||||
{
|
||||
QList<double> list;
|
||||
double perim;
|
||||
@ -354,19 +354,19 @@ QList<double> QgsGeometryAnalyzer::simpleMeasure( QgsGeometry& mpGeometry )
|
||||
return list;
|
||||
}
|
||||
|
||||
double QgsGeometryAnalyzer::perimeterMeasure( const QgsGeometry& geometry, QgsDistanceArea& measure )
|
||||
double QgsGeometryAnalyzer::perimeterMeasure( const QgsGeometry &geometry, QgsDistanceArea &measure )
|
||||
{
|
||||
return measure.measurePerimeter( geometry );
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shapefileName,
|
||||
bool onlySelectedFeatures, int uniqueIdField, QProgressDialog* p )
|
||||
bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer *layer, const QString &shapefileName,
|
||||
bool onlySelectedFeatures, int uniqueIdField, QProgressDialog *p )
|
||||
{
|
||||
if ( !layer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QgsVectorDataProvider* dp = layer->dataProvider();
|
||||
QgsVectorDataProvider *dp = layer->dataProvider();
|
||||
if ( !dp )
|
||||
{
|
||||
return false;
|
||||
@ -542,7 +542,7 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
|
||||
}
|
||||
|
||||
|
||||
void QgsGeometryAnalyzer::convexFeature( QgsFeature& f, int nProcessedFeatures, QgsGeometry& dissolveGeometry )
|
||||
void QgsGeometryAnalyzer::convexFeature( QgsFeature &f, int nProcessedFeatures, QgsGeometry &dissolveGeometry )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
@ -562,14 +562,14 @@ void QgsGeometryAnalyzer::convexFeature( QgsFeature& f, int nProcessedFeatures,
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapefileName,
|
||||
bool onlySelectedFeatures, int uniqueIdField, QProgressDialog* p )
|
||||
bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer *layer, const QString &shapefileName,
|
||||
bool onlySelectedFeatures, int uniqueIdField, QProgressDialog *p )
|
||||
{
|
||||
if ( !layer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QgsVectorDataProvider* dp = layer->dataProvider();
|
||||
QgsVectorDataProvider *dp = layer->dataProvider();
|
||||
if ( !dp )
|
||||
{
|
||||
return false;
|
||||
@ -696,7 +696,7 @@ bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapef
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsGeometry QgsGeometryAnalyzer::dissolveFeature( const QgsFeature& f, const QgsGeometry& dissolveInto )
|
||||
QgsGeometry QgsGeometryAnalyzer::dissolveFeature( const QgsFeature &f, const QgsGeometry &dissolveInto )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
@ -715,15 +715,15 @@ QgsGeometry QgsGeometryAnalyzer::dissolveFeature( const QgsFeature& f, const Qgs
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::buffer( QgsVectorLayer* layer, const QString& shapefileName, double bufferDistance,
|
||||
bool onlySelectedFeatures, bool dissolve, int bufferDistanceField, QProgressDialog* p )
|
||||
bool QgsGeometryAnalyzer::buffer( QgsVectorLayer *layer, const QString &shapefileName, double bufferDistance,
|
||||
bool onlySelectedFeatures, bool dissolve, int bufferDistanceField, QProgressDialog *p )
|
||||
{
|
||||
if ( !layer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsVectorDataProvider* dp = layer->dataProvider();
|
||||
QgsVectorDataProvider *dp = layer->dataProvider();
|
||||
if ( !dp )
|
||||
{
|
||||
return false;
|
||||
@ -821,8 +821,8 @@ bool QgsGeometryAnalyzer::buffer( QgsVectorLayer* layer, const QString& shapefil
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsGeometryAnalyzer::bufferFeature( QgsFeature& f, int nProcessedFeatures, QgsVectorFileWriter* vfw, bool dissolve,
|
||||
QgsGeometry& dissolveGeometry, double bufferDistance, int bufferDistanceField )
|
||||
void QgsGeometryAnalyzer::bufferFeature( QgsFeature &f, int nProcessedFeatures, QgsVectorFileWriter *vfw, bool dissolve,
|
||||
QgsGeometry &dissolveGeometry, double bufferDistance, int bufferDistanceField )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
@ -869,9 +869,9 @@ void QgsGeometryAnalyzer::bufferFeature( QgsFeature& f, int nProcessedFeatures,
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString& outputLayer,
|
||||
const QString& outputFormat, int locationField1, int locationField2, int offsetField, double offsetScale,
|
||||
bool forceSingleGeometry, QgsVectorDataProvider* memoryProvider, QProgressDialog* p )
|
||||
bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer *lineLayer, QgsVectorLayer *eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString &outputLayer,
|
||||
const QString &outputFormat, int locationField1, int locationField2, int offsetField, double offsetScale,
|
||||
bool forceSingleGeometry, QgsVectorDataProvider *memoryProvider, QProgressDialog *p )
|
||||
{
|
||||
if ( !lineLayer || !eventLayer || !lineLayer->isValid() || !eventLayer->isValid() )
|
||||
{
|
||||
@ -888,7 +888,7 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
|
||||
}
|
||||
|
||||
//create output datasource or attributes in memory provider
|
||||
QgsVectorFileWriter* fileWriter = nullptr;
|
||||
QgsVectorFileWriter *fileWriter = nullptr;
|
||||
QgsFeatureList memoryProviderFeatures;
|
||||
if ( !memoryProvider )
|
||||
{
|
||||
@ -948,7 +948,7 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
|
||||
if ( locationField2 != -1 )
|
||||
{
|
||||
measure2 = fet.attribute( locationField2 ).toDouble();
|
||||
if ( qgsDoubleNear(( measure2 - measure1 ), 0.0 ) )
|
||||
if ( qgsDoubleNear( ( measure2 - measure1 ), 0.0 ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -992,7 +992,7 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, const QgsGeometry& geom, const QgsGeometry& lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures,
|
||||
void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature &feature, const QgsGeometry &geom, const QgsGeometry &lineGeom, QgsVectorFileWriter *fileWriter, QgsFeatureList &memoryFeatures,
|
||||
int offsetField, double offsetScale, bool forceSingleType )
|
||||
{
|
||||
if ( geom.isNull() )
|
||||
@ -1038,7 +1038,7 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, const QgsGe
|
||||
}
|
||||
}
|
||||
|
||||
QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom, const QgsGeometry& lineGeom, double offset )
|
||||
QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry &geom, const QgsGeometry &lineGeom, double offset )
|
||||
{
|
||||
if ( !geom || lineGeom.isNull() )
|
||||
{
|
||||
@ -1056,15 +1056,15 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
||||
inputGeomList.push_back( geom );
|
||||
}
|
||||
|
||||
QList<GEOSGeometry*> outputGeomList;
|
||||
QList<GEOSGeometry *> outputGeomList;
|
||||
QList<QgsGeometry>::const_iterator inputGeomIt = inputGeomList.constBegin();
|
||||
GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
|
||||
for ( ; inputGeomIt != inputGeomList.constEnd(); ++inputGeomIt )
|
||||
{
|
||||
if ( geom.type() == QgsWkbTypes::LineGeometry )
|
||||
{
|
||||
GEOSGeometry* inputGeomItGeos = inputGeomIt->exportToGeos();
|
||||
GEOSGeometry* offsetGeom = GEOSOffsetCurve_r( geosctxt, inputGeomItGeos, -offset, 8 /*quadSegments*/, 0 /*joinStyle*/, 5.0 /*mitreLimit*/ );
|
||||
GEOSGeometry *inputGeomItGeos = inputGeomIt->exportToGeos();
|
||||
GEOSGeometry *offsetGeom = GEOSOffsetCurve_r( geosctxt, inputGeomItGeos, -offset, 8 /*quadSegments*/, 0 /*joinStyle*/, 5.0 /*mitreLimit*/ );
|
||||
GEOSGeom_destroy_r( geosctxt, inputGeomItGeos );
|
||||
if ( !offsetGeom || !GEOSisValid_r( geosctxt, offsetGeom ) )
|
||||
{
|
||||
@ -1081,10 +1081,10 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
||||
{
|
||||
QgsPoint p = ( *inputGeomIt ).asPoint();
|
||||
p = createPointOffset( p.x(), p.y(), offset, lineGeom );
|
||||
GEOSCoordSequence* ptSeq = GEOSCoordSeq_create_r( geosctxt, 1, 2 );
|
||||
GEOSCoordSequence *ptSeq = GEOSCoordSeq_create_r( geosctxt, 1, 2 );
|
||||
GEOSCoordSeq_setX_r( geosctxt, ptSeq, 0, p.x() );
|
||||
GEOSCoordSeq_setY_r( geosctxt, ptSeq, 0, p.y() );
|
||||
GEOSGeometry* geosPt = GEOSGeom_createPoint_r( geosctxt, ptSeq );
|
||||
GEOSGeometry *geosPt = GEOSGeom_createPoint_r( geosctxt, ptSeq );
|
||||
outputGeomList.push_back( geosPt );
|
||||
}
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
||||
QgsGeometry outGeometry;
|
||||
if ( !geom.isMultipart() )
|
||||
{
|
||||
GEOSGeometry* outputGeom = outputGeomList.at( 0 );
|
||||
GEOSGeometry *outputGeom = outputGeomList.at( 0 );
|
||||
if ( outputGeom )
|
||||
{
|
||||
outGeometry.fromGeos( outputGeom );
|
||||
@ -1100,12 +1100,12 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
||||
}
|
||||
else
|
||||
{
|
||||
GEOSGeometry** geomArray = new GEOSGeometry*[outputGeomList.size()];
|
||||
GEOSGeometry **geomArray = new GEOSGeometry*[outputGeomList.size()];
|
||||
for ( int i = 0; i < outputGeomList.size(); ++i )
|
||||
{
|
||||
geomArray[i] = outputGeomList.at( i );
|
||||
}
|
||||
GEOSGeometry* collection = nullptr;
|
||||
GEOSGeometry *collection = nullptr;
|
||||
if ( geom.type() == QgsWkbTypes::PointGeometry )
|
||||
{
|
||||
collection = GEOSGeom_createCollection_r( geosctxt, GEOS_MULTIPOINT, geomArray, outputGeomList.size() );
|
||||
@ -1120,7 +1120,7 @@ QgsGeometry QgsGeometryAnalyzer::createOffsetGeometry( const QgsGeometry& geom,
|
||||
return outGeometry;
|
||||
}
|
||||
|
||||
QgsPoint QgsGeometryAnalyzer::createPointOffset( double x, double y, double dist, const QgsGeometry& lineGeom ) const
|
||||
QgsPoint QgsGeometryAnalyzer::createPointOffset( double x, double y, double dist, const QgsGeometry &lineGeom ) const
|
||||
{
|
||||
QgsPoint p( x, y );
|
||||
QgsPoint minDistPoint;
|
||||
@ -1145,7 +1145,7 @@ QgsPoint QgsGeometryAnalyzer::createPointOffset( double x, double y, double dist
|
||||
return QgsPoint( x - normalX, y - normalY ); //negative values -> left side, positive values -> right side //#spellok
|
||||
}
|
||||
|
||||
QgsGeometry QgsGeometryAnalyzer::locateBetweenMeasures( double fromMeasure, double toMeasure, const QgsGeometry& lineGeom )
|
||||
QgsGeometry QgsGeometryAnalyzer::locateBetweenMeasures( double fromMeasure, double toMeasure, const QgsGeometry &lineGeom )
|
||||
{
|
||||
if ( lineGeom.isNull() )
|
||||
{
|
||||
@ -1187,7 +1187,7 @@ QgsGeometry QgsGeometryAnalyzer::locateBetweenMeasures( double fromMeasure, doub
|
||||
return QgsGeometry::fromMultiPolyline( resultGeom );
|
||||
}
|
||||
|
||||
QgsGeometry QgsGeometryAnalyzer::locateAlongMeasure( double measure, const QgsGeometry& lineGeom )
|
||||
QgsGeometry QgsGeometryAnalyzer::locateAlongMeasure( double measure, const QgsGeometry &lineGeom )
|
||||
{
|
||||
if ( lineGeom.isNull() )
|
||||
{
|
||||
@ -1229,7 +1229,7 @@ QgsGeometry QgsGeometryAnalyzer::locateAlongMeasure( double measure, const QgsGe
|
||||
return QgsGeometry::fromMultiPoint( resultGeom );
|
||||
}
|
||||
|
||||
QgsConstWkbPtr QgsGeometryAnalyzer::locateBetweenWkbString( QgsConstWkbPtr wkbPtr, QgsMultiPolyline& result, double fromMeasure, double toMeasure )
|
||||
QgsConstWkbPtr QgsGeometryAnalyzer::locateBetweenWkbString( QgsConstWkbPtr wkbPtr, QgsMultiPolyline &result, double fromMeasure, double toMeasure )
|
||||
{
|
||||
int nPoints;
|
||||
wkbPtr >> nPoints;
|
||||
@ -1276,7 +1276,7 @@ QgsConstWkbPtr QgsGeometryAnalyzer::locateBetweenWkbString( QgsConstWkbPtr wkbPt
|
||||
return wkbPtr;
|
||||
}
|
||||
|
||||
QgsConstWkbPtr QgsGeometryAnalyzer::locateAlongWkbString( QgsConstWkbPtr wkbPtr, QgsMultiPoint& result, double measure )
|
||||
QgsConstWkbPtr QgsGeometryAnalyzer::locateAlongWkbString( QgsConstWkbPtr wkbPtr, QgsMultiPoint &result, double measure )
|
||||
{
|
||||
int nPoints;
|
||||
wkbPtr >> nPoints;
|
||||
@ -1309,8 +1309,8 @@ QgsConstWkbPtr QgsGeometryAnalyzer::locateAlongWkbString( QgsConstWkbPtr wkbPtr,
|
||||
return wkbPtr;
|
||||
}
|
||||
|
||||
bool QgsGeometryAnalyzer::clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint& pt1,
|
||||
QgsPoint& pt2, bool& secondPointClipped )
|
||||
bool QgsGeometryAnalyzer::clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint &pt1,
|
||||
QgsPoint &pt2, bool &secondPointClipped )
|
||||
{
|
||||
bool reversed = m1 > m2;
|
||||
double tmp;
|
||||
@ -1410,7 +1410,7 @@ bool QgsGeometryAnalyzer::clipSegmentByRange( double x1, double y1, double m1, d
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool& pt1Ok, QgsPoint& pt1, bool& pt2Ok, QgsPoint& pt2 )
|
||||
void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool &pt1Ok, QgsPoint &pt1, bool &pt2Ok, QgsPoint &pt2 )
|
||||
{
|
||||
bool reversed = false;
|
||||
pt1Ok = false;
|
||||
@ -1426,7 +1426,7 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
|
||||
}
|
||||
|
||||
//segment does not match
|
||||
if (( m1 - measure ) > tolerance || ( measure - m2 ) > tolerance )
|
||||
if ( ( m1 - measure ) > tolerance || ( measure - m2 ) > tolerance )
|
||||
{
|
||||
pt1Ok = false;
|
||||
pt2Ok = false;
|
||||
|
@ -43,8 +43,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
|
||||
* @param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool simplify( QgsVectorLayer* layer, const QString& shapefileName, double tolerance,
|
||||
bool onlySelectedFeatures = false, QProgressDialog* p = nullptr );
|
||||
bool simplify( QgsVectorLayer *layer, const QString &shapefileName, double tolerance,
|
||||
bool onlySelectedFeatures = false, QProgressDialog *p = nullptr );
|
||||
|
||||
/** Calculate the true centroids, or 'center of mass' for a vector layer and
|
||||
* write it to a new shape file
|
||||
@ -53,8 +53,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
|
||||
* @param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool centroids( QgsVectorLayer* layer, const QString& shapefileName,
|
||||
bool onlySelectedFeatures = false, QProgressDialog* p = nullptr );
|
||||
bool centroids( QgsVectorLayer *layer, const QString &shapefileName,
|
||||
bool onlySelectedFeatures = false, QProgressDialog *p = nullptr );
|
||||
|
||||
/** Create a polygon based on the extent of all (selected) features and write it to a new shape file
|
||||
* @param layer input vector layer
|
||||
@ -62,7 +62,7 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
|
||||
* @param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool extent( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false, QProgressDialog* p = 0 );
|
||||
bool extent( QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures = false, QProgressDialog *p = 0 );
|
||||
|
||||
/** Create buffers for a vector layer and write it to a new shape file
|
||||
* @param layer input vector layer
|
||||
@ -73,8 +73,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* @param bufferDistanceField index of the attribute field that contains the buffer distance (or -1 if all features have the same buffer distance)
|
||||
* @param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool buffer( QgsVectorLayer* layer, const QString& shapefileName, double bufferDistance,
|
||||
bool onlySelectedFeatures = false, bool dissolve = false, int bufferDistanceField = -1, QProgressDialog* p = nullptr );
|
||||
bool buffer( QgsVectorLayer *layer, const QString &shapefileName, double bufferDistance,
|
||||
bool onlySelectedFeatures = false, bool dissolve = false, int bufferDistanceField = -1, QProgressDialog *p = nullptr );
|
||||
|
||||
/** Create convex hull(s) of a vector layer and write it to a new shape file
|
||||
* @param layer input vector layer
|
||||
@ -84,8 +84,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* all features have the same buffer distance)
|
||||
* @param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool convexHull( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false,
|
||||
int uniqueIdField = -1, QProgressDialog* p = nullptr );
|
||||
bool convexHull( QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures = false,
|
||||
int uniqueIdField = -1, QProgressDialog *p = nullptr );
|
||||
|
||||
/** Dissolve a vector layer and write it to a new shape file
|
||||
* @param layer input vector layer
|
||||
@ -95,8 +95,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* all features should be dissolved together)
|
||||
* @param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool dissolve( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false,
|
||||
int uniqueIdField = -1, QProgressDialog* p = nullptr );
|
||||
bool dissolve( QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures = false,
|
||||
int uniqueIdField = -1, QProgressDialog *p = nullptr );
|
||||
|
||||
/** Creates an event layer (multipoint or multiline) by locating features from a (non-spatial) event table along the features of a line layer.
|
||||
* Note that currently (until QgsGeometry supports m-values) the z-coordinate of the line layer is used for linear referencing
|
||||
@ -115,47 +115,47 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
* @param memoryProvider memory provider to write output to (can be 0 if output is written to a file)
|
||||
* @param p progress dialog or 0 if no progress dialog should be shown
|
||||
*/
|
||||
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString& outputLayer,
|
||||
const QString& outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
|
||||
bool forceSingleGeometry = false, QgsVectorDataProvider* memoryProvider = nullptr, QProgressDialog* p = nullptr );
|
||||
bool eventLayer( QgsVectorLayer *lineLayer, QgsVectorLayer *eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString &outputLayer,
|
||||
const QString &outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
|
||||
bool forceSingleGeometry = false, QgsVectorDataProvider *memoryProvider = nullptr, QProgressDialog *p = nullptr );
|
||||
|
||||
//! Returns linear reference geometry as a multiline (or 0 if no match). Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)
|
||||
QgsGeometry locateBetweenMeasures( double fromMeasure, double toMeasure, const QgsGeometry& lineGeom );
|
||||
QgsGeometry locateBetweenMeasures( double fromMeasure, double toMeasure, const QgsGeometry &lineGeom );
|
||||
|
||||
/** Returns linear reference geometry. Unlike the PostGIS function, this method always returns multipoint or 0 if no match (not geometry collection).
|
||||
* Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)
|
||||
*/
|
||||
QgsGeometry locateAlongMeasure( double measure, const QgsGeometry& lineGeom );
|
||||
QgsGeometry locateAlongMeasure( double measure, const QgsGeometry &lineGeom );
|
||||
|
||||
private:
|
||||
|
||||
QList<double> simpleMeasure( QgsGeometry& geometry );
|
||||
double perimeterMeasure( const QgsGeometry& geometry, QgsDistanceArea& measure );
|
||||
QList<double> simpleMeasure( QgsGeometry &geometry );
|
||||
double perimeterMeasure( const QgsGeometry &geometry, QgsDistanceArea &measure );
|
||||
//! Helper function to simplify an individual feature
|
||||
void simplifyFeature( QgsFeature& f, QgsVectorFileWriter* vfw, double tolerance );
|
||||
void simplifyFeature( QgsFeature &f, QgsVectorFileWriter *vfw, double tolerance );
|
||||
//! Helper function to get the cetroid of an individual feature
|
||||
void centroidFeature( QgsFeature& f, QgsVectorFileWriter* vfw );
|
||||
void centroidFeature( QgsFeature &f, QgsVectorFileWriter *vfw );
|
||||
//! Helper function to buffer an individual feature
|
||||
void bufferFeature( QgsFeature& f, int nProcessedFeatures, QgsVectorFileWriter* vfw, bool dissolve, QgsGeometry& dissolveGeometry,
|
||||
void bufferFeature( QgsFeature &f, int nProcessedFeatures, QgsVectorFileWriter *vfw, bool dissolve, QgsGeometry &dissolveGeometry,
|
||||
double bufferDistance, int bufferDistanceField );
|
||||
//! Helper function to get the convex hull of feature(s)
|
||||
void convexFeature( QgsFeature& f, int nProcessedFeatures, QgsGeometry& dissolveGeometry );
|
||||
void convexFeature( QgsFeature &f, int nProcessedFeatures, QgsGeometry &dissolveGeometry );
|
||||
//! Helper function to dissolve feature(s)
|
||||
QgsGeometry dissolveFeature( const QgsFeature& f, const QgsGeometry& dissolveInto );
|
||||
QgsGeometry dissolveFeature( const QgsFeature &f, const QgsGeometry &dissolveInto );
|
||||
|
||||
//helper functions for event layer
|
||||
void addEventLayerFeature( QgsFeature& feature, const QgsGeometry& geom, const QgsGeometry& lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures, int offsetField = -1, double offsetScale = 1.0,
|
||||
void addEventLayerFeature( QgsFeature &feature, const QgsGeometry &geom, const QgsGeometry &lineGeom, QgsVectorFileWriter *fileWriter, QgsFeatureList &memoryFeatures, int offsetField = -1, double offsetScale = 1.0,
|
||||
bool forceSingleType = false );
|
||||
|
||||
/** Create geometry offset relative to line geometry.
|
||||
@param geom the geometry to modify
|
||||
@param lineGeom the line geometry to which the feature is referenced
|
||||
@param offset the offset value in layer unit. Negative values mean offset towards left, positive values offset to the right side*/
|
||||
QgsGeometry createOffsetGeometry( const QgsGeometry& geom, const QgsGeometry& lineGeom, double offset );
|
||||
QgsPoint createPointOffset( double x, double y, double dist, const QgsGeometry& lineGeom ) const;
|
||||
QgsConstWkbPtr locateBetweenWkbString( QgsConstWkbPtr ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure );
|
||||
QgsConstWkbPtr locateAlongWkbString( QgsConstWkbPtr ptr, QgsMultiPoint& result, double measure );
|
||||
static bool clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint& pt1, QgsPoint& pt2, bool& secondPointClipped );
|
||||
static void locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool& pt1Ok, QgsPoint& pt1, bool& pt2Ok, QgsPoint& pt2 );
|
||||
QgsGeometry createOffsetGeometry( const QgsGeometry &geom, const QgsGeometry &lineGeom, double offset );
|
||||
QgsPoint createPointOffset( double x, double y, double dist, const QgsGeometry &lineGeom ) const;
|
||||
QgsConstWkbPtr locateBetweenWkbString( QgsConstWkbPtr ptr, QgsMultiPolyline &result, double fromMeasure, double toMeasure );
|
||||
QgsConstWkbPtr locateAlongWkbString( QgsConstWkbPtr ptr, QgsMultiPoint &result, double measure );
|
||||
static bool clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint &pt1, QgsPoint &pt2, bool &secondPointClipped );
|
||||
static void locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool &pt1Ok, QgsPoint &pt1, bool &pt2Ok, QgsPoint &pt2 );
|
||||
};
|
||||
#endif //QGSVECTORANALYZER
|
||||
|
@ -29,9 +29,9 @@
|
||||
|
||||
///@cond PRIVATE
|
||||
|
||||
QgsSnapIndex::PointSnapItem::PointSnapItem( const QgsSnapIndex::CoordIdx* _idx )
|
||||
: SnapItem( QgsSnapIndex::SnapPoint )
|
||||
, idx( _idx )
|
||||
QgsSnapIndex::PointSnapItem::PointSnapItem( const QgsSnapIndex::CoordIdx *_idx )
|
||||
: SnapItem( QgsSnapIndex::SnapPoint )
|
||||
, idx( _idx )
|
||||
{}
|
||||
|
||||
QgsPointV2 QgsSnapIndex::PointSnapItem::getSnapPoint( const QgsPointV2 &/*p*/ ) const
|
||||
@ -39,10 +39,10 @@ QgsPointV2 QgsSnapIndex::PointSnapItem::getSnapPoint( const QgsPointV2 &/*p*/ )
|
||||
return idx->point();
|
||||
}
|
||||
|
||||
QgsSnapIndex::SegmentSnapItem::SegmentSnapItem( const QgsSnapIndex::CoordIdx* _idxFrom, const QgsSnapIndex::CoordIdx* _idxTo )
|
||||
: SnapItem( QgsSnapIndex::SnapSegment )
|
||||
, idxFrom( _idxFrom )
|
||||
, idxTo( _idxTo )
|
||||
QgsSnapIndex::SegmentSnapItem::SegmentSnapItem( const QgsSnapIndex::CoordIdx *_idxFrom, const QgsSnapIndex::CoordIdx *_idxTo )
|
||||
: SnapItem( QgsSnapIndex::SnapSegment )
|
||||
, idxFrom( _idxFrom )
|
||||
, idxTo( _idxTo )
|
||||
{}
|
||||
|
||||
QgsPointV2 QgsSnapIndex::SegmentSnapItem::getSnapPoint( const QgsPointV2 &p ) const
|
||||
@ -50,9 +50,9 @@ QgsPointV2 QgsSnapIndex::SegmentSnapItem::getSnapPoint( const QgsPointV2 &p ) co
|
||||
return QgsGeometryUtils::projPointOnSegment( p, idxFrom->point(), idxTo->point() );
|
||||
}
|
||||
|
||||
bool QgsSnapIndex::SegmentSnapItem::getIntersection( const QgsPointV2 &p1, const QgsPointV2 &p2, QgsPointV2& inter ) const
|
||||
bool QgsSnapIndex::SegmentSnapItem::getIntersection( const QgsPointV2 &p1, const QgsPointV2 &p2, QgsPointV2 &inter ) const
|
||||
{
|
||||
const QgsPointV2& q1 = idxFrom->point(), & q2 = idxTo->point();
|
||||
const QgsPointV2 &q1 = idxFrom->point(), & q2 = idxTo->point();
|
||||
QgsVector v( p2.x() - p1.x(), p2.y() - p1.y() );
|
||||
QgsVector w( q2.x() - q1.x(), q2.y() - q1.y() );
|
||||
double vl = v.length();
|
||||
@ -89,11 +89,11 @@ bool QgsSnapIndex::SegmentSnapItem::getIntersection( const QgsPointV2 &p1, const
|
||||
|
||||
bool QgsSnapIndex::SegmentSnapItem::getProjection( const QgsPointV2 &p, QgsPointV2 &pProj )
|
||||
{
|
||||
const QgsPointV2& s1 = idxFrom->point();
|
||||
const QgsPointV2& s2 = idxTo->point();
|
||||
const QgsPointV2 &s1 = idxFrom->point();
|
||||
const QgsPointV2 &s2 = idxTo->point();
|
||||
double nx = s2.y() - s1.y();
|
||||
double ny = -( s2.x() - s1.x() );
|
||||
double t = ( p.x() * ny - p.y() * nx - s1.x() * ny + s1.y() * nx ) / (( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
|
||||
double t = ( p.x() * ny - p.y() * nx - s1.x() * ny + s1.y() * nx ) / ( ( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
|
||||
if ( t < 0. || t > 1. )
|
||||
{
|
||||
return false;
|
||||
@ -110,11 +110,11 @@ class Raytracer
|
||||
// See http://playtechs.blogspot.ch/2007/03/raytracing-on-grid.html
|
||||
public:
|
||||
Raytracer( float x0, float y0, float x1, float y1 )
|
||||
: m_dx( qAbs( x1 - x0 ) )
|
||||
, m_dy( qAbs( y1 - y0 ) )
|
||||
, m_x( qFloor( x0 ) )
|
||||
, m_y( qFloor( y0 ) )
|
||||
, m_n( 1 )
|
||||
: m_dx( qAbs( x1 - x0 ) )
|
||||
, m_dy( qAbs( y1 - y0 ) )
|
||||
, m_x( qFloor( x0 ) )
|
||||
, m_y( qFloor( y0 ) )
|
||||
, m_n( 1 )
|
||||
{
|
||||
if ( m_dx == 0. )
|
||||
{
|
||||
@ -190,13 +190,13 @@ class Raytracer
|
||||
|
||||
QgsSnapIndex::GridRow::~GridRow()
|
||||
{
|
||||
Q_FOREACH ( const QgsSnapIndex::Cell& cell, mCells )
|
||||
Q_FOREACH ( const QgsSnapIndex::Cell &cell, mCells )
|
||||
{
|
||||
qDeleteAll( cell );
|
||||
}
|
||||
}
|
||||
|
||||
QgsSnapIndex::Cell& QgsSnapIndex::GridRow::getCreateCell( int col )
|
||||
QgsSnapIndex::Cell &QgsSnapIndex::GridRow::getCreateCell( int col )
|
||||
{
|
||||
if ( col < mColStartIdx )
|
||||
{
|
||||
@ -221,7 +221,7 @@ QgsSnapIndex::Cell& QgsSnapIndex::GridRow::getCreateCell( int col )
|
||||
}
|
||||
}
|
||||
|
||||
const QgsSnapIndex::Cell* QgsSnapIndex::GridRow::getCell( int col ) const
|
||||
const QgsSnapIndex::Cell *QgsSnapIndex::GridRow::getCell( int col ) const
|
||||
{
|
||||
if ( col < mColStartIdx || col >= mColStartIdx + mCells.size() )
|
||||
{
|
||||
@ -233,12 +233,12 @@ const QgsSnapIndex::Cell* QgsSnapIndex::GridRow::getCell( int col ) const
|
||||
}
|
||||
}
|
||||
|
||||
QList<QgsSnapIndex::SnapItem*> QgsSnapIndex::GridRow::getSnapItems( int colStart, int colEnd ) const
|
||||
QList<QgsSnapIndex::SnapItem *> QgsSnapIndex::GridRow::getSnapItems( int colStart, int colEnd ) const
|
||||
{
|
||||
colStart = qMax( colStart, mColStartIdx );
|
||||
colEnd = qMin( colEnd, mColStartIdx + mCells.size() - 1 );
|
||||
|
||||
QList<SnapItem*> items;
|
||||
QList<SnapItem *> items;
|
||||
|
||||
for ( int col = colStart; col <= colEnd; ++col )
|
||||
{
|
||||
@ -249,10 +249,10 @@ QList<QgsSnapIndex::SnapItem*> QgsSnapIndex::GridRow::getSnapItems( int colStart
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QgsSnapIndex::QgsSnapIndex( const QgsPointV2& origin, double cellSize )
|
||||
: mOrigin( origin )
|
||||
, mCellSize( cellSize )
|
||||
, mRowsStartIdx( 0 )
|
||||
QgsSnapIndex::QgsSnapIndex( const QgsPointV2 &origin, double cellSize )
|
||||
: mOrigin( origin )
|
||||
, mCellSize( cellSize )
|
||||
, mRowsStartIdx( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ const QgsSnapIndex::Cell *QgsSnapIndex::getCell( int col, int row ) const
|
||||
}
|
||||
}
|
||||
|
||||
QgsSnapIndex::Cell& QgsSnapIndex::getCreateCell( int col, int row )
|
||||
QgsSnapIndex::Cell &QgsSnapIndex::getCreateCell( int col, int row )
|
||||
{
|
||||
if ( row < mRowsStartIdx )
|
||||
{
|
||||
@ -299,15 +299,15 @@ QgsSnapIndex::Cell& QgsSnapIndex::getCreateCell( int col, int row )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSnapIndex::addPoint( const CoordIdx* idx )
|
||||
void QgsSnapIndex::addPoint( const CoordIdx *idx )
|
||||
{
|
||||
QgsPointV2 p = idx->point();
|
||||
int col = qFloor(( p.x() - mOrigin.x() ) / mCellSize );
|
||||
int row = qFloor(( p.y() - mOrigin.y() ) / mCellSize );
|
||||
int col = qFloor( ( p.x() - mOrigin.x() ) / mCellSize );
|
||||
int row = qFloor( ( p.y() - mOrigin.y() ) / mCellSize );
|
||||
getCreateCell( col, row ).append( new PointSnapItem( idx ) );
|
||||
}
|
||||
|
||||
void QgsSnapIndex::addSegment( const CoordIdx* idxFrom, const CoordIdx* idxTo )
|
||||
void QgsSnapIndex::addSegment( const CoordIdx *idxFrom, const CoordIdx *idxTo )
|
||||
{
|
||||
QgsPointV2 pFrom = idxFrom->point();
|
||||
QgsPointV2 pTo = idxTo->point();
|
||||
@ -324,7 +324,7 @@ void QgsSnapIndex::addSegment( const CoordIdx* idxFrom, const CoordIdx* idxTo )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSnapIndex::addGeometry( const QgsAbstractGeometry* geom )
|
||||
void QgsSnapIndex::addGeometry( const QgsAbstractGeometry *geom )
|
||||
{
|
||||
for ( int iPart = 0, nParts = geom->partCount(); iPart < nParts; ++iPart )
|
||||
{
|
||||
@ -332,9 +332,9 @@ void QgsSnapIndex::addGeometry( const QgsAbstractGeometry* geom )
|
||||
{
|
||||
int nVerts = geom->vertexCount( iPart, iRing );
|
||||
|
||||
if ( dynamic_cast< const QgsSurface* >( geom ) )
|
||||
if ( dynamic_cast< const QgsSurface * >( geom ) )
|
||||
nVerts--;
|
||||
else if ( const QgsCurve* curve = dynamic_cast< const QgsCurve* >( geom ) )
|
||||
else if ( const QgsCurve *curve = dynamic_cast< const QgsCurve * >( geom ) )
|
||||
{
|
||||
if ( curve->isClosed() )
|
||||
nVerts--;
|
||||
@ -342,8 +342,8 @@ void QgsSnapIndex::addGeometry( const QgsAbstractGeometry* geom )
|
||||
|
||||
for ( int iVert = 0; iVert < nVerts; ++iVert )
|
||||
{
|
||||
CoordIdx* idx = new CoordIdx( geom, QgsVertexId( iPart, iRing, iVert ) );
|
||||
CoordIdx* idx1 = new CoordIdx( geom, QgsVertexId( iPart, iRing, iVert + 1 ) );
|
||||
CoordIdx *idx = new CoordIdx( geom, QgsVertexId( iPart, iRing, iVert ) );
|
||||
CoordIdx *idx1 = new CoordIdx( geom, QgsVertexId( iPart, iRing, iVert + 1 ) );
|
||||
mCoordIdxs.append( idx );
|
||||
mCoordIdxs.append( idx1 );
|
||||
addPoint( idx );
|
||||
@ -355,7 +355,7 @@ void QgsSnapIndex::addGeometry( const QgsAbstractGeometry* geom )
|
||||
}
|
||||
|
||||
|
||||
QgsPointV2 QgsSnapIndex::getClosestSnapToPoint( const QgsPointV2& p, const QgsPointV2& q )
|
||||
QgsPointV2 QgsSnapIndex::getClosestSnapToPoint( const QgsPointV2 &p, const QgsPointV2 &q )
|
||||
{
|
||||
// Look for intersections on segment from the target point to the point opposite to the point reference point
|
||||
// p2 = p1 + 2 * (q - p1)
|
||||
@ -372,17 +372,17 @@ QgsPointV2 QgsSnapIndex::getClosestSnapToPoint( const QgsPointV2& p, const QgsPo
|
||||
QgsPointV2 pMin = p;
|
||||
for ( ; rt.isValid(); rt.next() )
|
||||
{
|
||||
const Cell* cell = getCell( rt.curCol(), rt.curRow() );
|
||||
const Cell *cell = getCell( rt.curCol(), rt.curRow() );
|
||||
if ( !cell )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Q_FOREACH ( const SnapItem* item, *cell )
|
||||
Q_FOREACH ( const SnapItem *item, *cell )
|
||||
{
|
||||
if ( item->type == SnapSegment )
|
||||
{
|
||||
QgsPointV2 inter;
|
||||
if ( static_cast<const SegmentSnapItem*>( item )->getIntersection( p, p2, inter ) )
|
||||
if ( static_cast<const SegmentSnapItem *>( item )->getIntersection( p, p2, inter ) )
|
||||
{
|
||||
double dist = QgsGeometryUtils::sqrDistance2D( q, inter );
|
||||
if ( dist < dMin )
|
||||
@ -398,17 +398,17 @@ QgsPointV2 QgsSnapIndex::getClosestSnapToPoint( const QgsPointV2& p, const QgsPo
|
||||
return pMin;
|
||||
}
|
||||
|
||||
QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double tol, QgsSnapIndex::PointSnapItem** pSnapPoint, QgsSnapIndex::SegmentSnapItem** pSnapSegment ) const
|
||||
QgsSnapIndex::SnapItem *QgsSnapIndex::getSnapItem( const QgsPointV2 &pos, double tol, QgsSnapIndex::PointSnapItem **pSnapPoint, QgsSnapIndex::SegmentSnapItem **pSnapSegment ) const
|
||||
{
|
||||
int colStart = qFloor(( pos.x() - tol - mOrigin.x() ) / mCellSize );
|
||||
int rowStart = qFloor(( pos.y() - tol - mOrigin.y() ) / mCellSize );
|
||||
int colEnd = qFloor(( pos.x() + tol - mOrigin.x() ) / mCellSize );
|
||||
int rowEnd = qFloor(( pos.y() + tol - mOrigin.y() ) / mCellSize );
|
||||
int colStart = qFloor( ( pos.x() - tol - mOrigin.x() ) / mCellSize );
|
||||
int rowStart = qFloor( ( pos.y() - tol - mOrigin.y() ) / mCellSize );
|
||||
int colEnd = qFloor( ( pos.x() + tol - mOrigin.x() ) / mCellSize );
|
||||
int rowEnd = qFloor( ( pos.y() + tol - mOrigin.y() ) / mCellSize );
|
||||
|
||||
rowStart = qMax( rowStart, mRowsStartIdx );
|
||||
rowEnd = qMin( rowEnd, mRowsStartIdx + mGridRows.size() - 1 );
|
||||
|
||||
QList<SnapItem*> items;
|
||||
QList<SnapItem *> items;
|
||||
for ( int row = rowStart; row <= rowEnd; ++row )
|
||||
{
|
||||
items.append( mGridRows[row - mRowsStartIdx].getSnapItems( colStart, colEnd ) );
|
||||
@ -416,10 +416,10 @@ QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double
|
||||
|
||||
double minDistSegment = std::numeric_limits<double>::max();
|
||||
double minDistPoint = std::numeric_limits<double>::max();
|
||||
QgsSnapIndex::SegmentSnapItem* snapSegment = nullptr;
|
||||
QgsSnapIndex::PointSnapItem* snapPoint = nullptr;
|
||||
QgsSnapIndex::SegmentSnapItem *snapSegment = nullptr;
|
||||
QgsSnapIndex::PointSnapItem *snapPoint = nullptr;
|
||||
|
||||
Q_FOREACH ( QgsSnapIndex::SnapItem* item, items )
|
||||
Q_FOREACH ( QgsSnapIndex::SnapItem *item, items )
|
||||
{
|
||||
if ( item->type == SnapPoint )
|
||||
{
|
||||
@ -427,13 +427,13 @@ QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double
|
||||
if ( dist < minDistPoint )
|
||||
{
|
||||
minDistPoint = dist;
|
||||
snapPoint = static_cast<PointSnapItem*>( item );
|
||||
snapPoint = static_cast<PointSnapItem *>( item );
|
||||
}
|
||||
}
|
||||
else if ( item->type == SnapSegment )
|
||||
{
|
||||
QgsPointV2 pProj;
|
||||
if ( !static_cast<SegmentSnapItem*>( item )->getProjection( pos, pProj ) )
|
||||
if ( !static_cast<SegmentSnapItem *>( item )->getProjection( pos, pProj ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -441,7 +441,7 @@ QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double
|
||||
if ( dist < minDistSegment )
|
||||
{
|
||||
minDistSegment = dist;
|
||||
snapSegment = static_cast<SegmentSnapItem*>( item );
|
||||
snapSegment = static_cast<SegmentSnapItem *>( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -449,7 +449,7 @@ QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double
|
||||
snapSegment = minDistSegment < tol * tol ? snapSegment : nullptr;
|
||||
if ( pSnapPoint ) *pSnapPoint = snapPoint;
|
||||
if ( pSnapSegment ) *pSnapSegment = snapSegment;
|
||||
return minDistPoint < minDistSegment ? static_cast<QgsSnapIndex::SnapItem*>( snapPoint ) : static_cast<QgsSnapIndex::SnapItem*>( snapSegment );
|
||||
return minDistPoint < minDistSegment ? static_cast<QgsSnapIndex::SnapItem *>( snapPoint ) : static_cast<QgsSnapIndex::SnapItem *>( snapSegment );
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
@ -458,7 +458,7 @@ QgsSnapIndex::SnapItem* QgsSnapIndex::getSnapItem( const QgsPointV2& pos, double
|
||||
|
||||
|
||||
QgsGeometrySnapper::QgsGeometrySnapper( QgsVectorLayer *referenceLayer )
|
||||
: mReferenceLayer( referenceLayer )
|
||||
: mReferenceLayer( referenceLayer )
|
||||
{
|
||||
// Build spatial index
|
||||
QgsFeatureRequest req;
|
||||
@ -466,22 +466,22 @@ QgsGeometrySnapper::QgsGeometrySnapper( QgsVectorLayer *referenceLayer )
|
||||
mIndex = QgsSpatialIndex( mReferenceLayer->getFeatures( req ) );
|
||||
}
|
||||
|
||||
QgsFeatureList QgsGeometrySnapper::snapFeatures( const QgsFeatureList& features, double snapTolerance, SnapMode mode )
|
||||
QgsFeatureList QgsGeometrySnapper::snapFeatures( const QgsFeatureList &features, double snapTolerance, SnapMode mode )
|
||||
{
|
||||
QgsFeatureList list = features;
|
||||
QtConcurrent::blockingMap( list, ProcessFeatureWrapper( this, snapTolerance, mode ) );
|
||||
return list;
|
||||
}
|
||||
|
||||
void QgsGeometrySnapper::processFeature( QgsFeature& feature, double snapTolerance, SnapMode mode )
|
||||
void QgsGeometrySnapper::processFeature( QgsFeature &feature, double snapTolerance, SnapMode mode )
|
||||
{
|
||||
if ( !feature.geometry().isNull() )
|
||||
feature.setGeometry( snapGeometry( feature.geometry(), snapTolerance, mode ) );
|
||||
}
|
||||
|
||||
QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, double snapTolerance, SnapMode mode ) const
|
||||
QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, double snapTolerance, SnapMode mode ) const
|
||||
{
|
||||
QgsPointV2 center = dynamic_cast< const QgsPointV2* >( geometry.geometry() ) ? *static_cast< const QgsPointV2* >( geometry.geometry() ) :
|
||||
QgsPointV2 center = dynamic_cast< const QgsPointV2 * >( geometry.geometry() ) ? *static_cast< const QgsPointV2 * >( geometry.geometry() ) :
|
||||
QgsPointV2( geometry.geometry()->boundingBox().center() );
|
||||
|
||||
// Get potential reference features and construct snap index
|
||||
@ -505,13 +505,13 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
|
||||
|
||||
QgsSnapIndex refSnapIndex( center, 10 * snapTolerance );
|
||||
Q_FOREACH ( const QgsGeometry& geom, refGeometries )
|
||||
Q_FOREACH ( const QgsGeometry &geom, refGeometries )
|
||||
{
|
||||
refSnapIndex.addGeometry( geom.geometry() );
|
||||
}
|
||||
|
||||
// Snap geometries
|
||||
QgsAbstractGeometry* subjGeom = geometry.geometry()->clone();
|
||||
QgsAbstractGeometry *subjGeom = geometry.geometry()->clone();
|
||||
QList < QList< QList<PointFlag> > > subjPointFlags;
|
||||
|
||||
// Pass 1: snap vertices of subject geometry to reference vertices
|
||||
@ -526,8 +526,8 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
for ( int iVert = 0, nVerts = polyLineSize( subjGeom, iPart, iRing ); iVert < nVerts; ++iVert )
|
||||
{
|
||||
|
||||
QgsSnapIndex::PointSnapItem* snapPoint = nullptr;
|
||||
QgsSnapIndex::SegmentSnapItem* snapSegment = nullptr;
|
||||
QgsSnapIndex::PointSnapItem *snapPoint = nullptr;
|
||||
QgsSnapIndex::SegmentSnapItem *snapSegment = nullptr;
|
||||
QgsVertexId vidx( iPart, iRing, iVert );
|
||||
QgsPointV2 p = subjGeom->vertexAt( vidx );
|
||||
if ( !refSnapIndex.getSnapItem( p, snapTolerance, &snapPoint, &snapSegment ) )
|
||||
@ -588,7 +588,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
}
|
||||
|
||||
//nothing more to do for points
|
||||
if ( dynamic_cast< const QgsPointV2* >( subjGeom ) )
|
||||
if ( dynamic_cast< const QgsPointV2 * >( subjGeom ) )
|
||||
return QgsGeometry( subjGeom );
|
||||
|
||||
// SnapIndex for subject feature
|
||||
@ -600,7 +600,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
origSubjSnapIndex->addGeometry( origSubjGeom.get() );
|
||||
|
||||
// Pass 2: add missing vertices to subject geometry
|
||||
Q_FOREACH ( const QgsGeometry& refGeom, refGeometries )
|
||||
Q_FOREACH ( const QgsGeometry &refGeom, refGeometries )
|
||||
{
|
||||
for ( int iPart = 0, nParts = refGeom.geometry()->partCount(); iPart < nParts; ++iPart )
|
||||
{
|
||||
@ -609,8 +609,8 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
for ( int iVert = 0, nVerts = polyLineSize( refGeom.geometry(), iPart, iRing ); iVert < nVerts; ++iVert )
|
||||
{
|
||||
|
||||
QgsSnapIndex::PointSnapItem* snapPoint = nullptr;
|
||||
QgsSnapIndex::SegmentSnapItem* snapSegment = nullptr;
|
||||
QgsSnapIndex::PointSnapItem *snapPoint = nullptr;
|
||||
QgsSnapIndex::SegmentSnapItem *snapSegment = nullptr;
|
||||
QgsPointV2 point = refGeom.geometry()->vertexAt( QgsVertexId( iPart, iRing, iVert ) );
|
||||
if ( subjSnapIndex->getSnapItem( point, snapTolerance, &snapPoint, &snapSegment ) )
|
||||
{
|
||||
@ -635,7 +635,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
continue;
|
||||
}
|
||||
|
||||
const QgsSnapIndex::CoordIdx* idx = snapSegment->idxFrom;
|
||||
const QgsSnapIndex::CoordIdx *idx = snapSegment->idxFrom;
|
||||
subjGeom->insertVertex( QgsVertexId( idx->vidx.part, idx->vidx.ring, idx->vidx.vertex + 1 ), point );
|
||||
subjPointFlags[idx->vidx.part][idx->vidx.ring].insert( idx->vidx.vertex + 1, SnappedToRefNode );
|
||||
subjSnapIndex.reset( new QgsSnapIndex( center, 10 * snapTolerance ) );
|
||||
@ -669,7 +669,7 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
subjPointFlags[iPart][iRing][iNext] != Unsnapped &&
|
||||
QgsGeometryUtils::sqrDistance2D( QgsGeometryUtils::projPointOnSegment( pMid, pPrev, pNext ), pMid ) < 1E-12 )
|
||||
{
|
||||
if (( ringIsClosed && nVerts > 3 ) || ( !ringIsClosed && nVerts > 2 ) )
|
||||
if ( ( ringIsClosed && nVerts > 3 ) || ( !ringIsClosed && nVerts > 2 ) )
|
||||
{
|
||||
subjGeom->deleteVertex( QgsVertexId( iPart, iRing, iVert ) );
|
||||
subjPointFlags[iPart][iRing].removeAt( iVert );
|
||||
@ -689,11 +689,11 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
|
||||
return QgsGeometry( subjGeom );
|
||||
}
|
||||
|
||||
int QgsGeometrySnapper::polyLineSize( const QgsAbstractGeometry* geom, int iPart, int iRing ) const
|
||||
int QgsGeometrySnapper::polyLineSize( const QgsAbstractGeometry *geom, int iPart, int iRing ) const
|
||||
{
|
||||
int nVerts = geom->vertexCount( iPart, iRing );
|
||||
|
||||
if ( dynamic_cast< const QgsSurface* >( geom ) )
|
||||
if ( dynamic_cast< const QgsSurface * >( geom ) )
|
||||
{
|
||||
QgsPointV2 front = geom->vertexAt( QgsVertexId( iPart, iRing, 0 ) );
|
||||
QgsPointV2 back = geom->vertexAt( QgsVertexId( iPart, iRing, nVerts - 1 ) );
|
||||
|
@ -53,21 +53,21 @@ class ANALYSIS_EXPORT QgsGeometrySnapper : public QObject
|
||||
* set. It is assumed that all geometries snapped using this object will have the
|
||||
* same CRS as the reference layer (ie, no reprojection is performed).
|
||||
*/
|
||||
QgsGeometrySnapper( QgsVectorLayer* referenceLayer );
|
||||
QgsGeometrySnapper( QgsVectorLayer *referenceLayer );
|
||||
|
||||
/**
|
||||
* Snaps a geometry to the reference layer and returns the result. The geometry must be in the same
|
||||
* CRS as the reference layer, and must have the same type as the reference layer geometry. The snap tolerance
|
||||
* is specified in the layer units for the reference layer.
|
||||
*/
|
||||
QgsGeometry snapGeometry( const QgsGeometry& geometry, double snapTolerance, SnapMode mode = PreferNodes ) const;
|
||||
QgsGeometry snapGeometry( const QgsGeometry &geometry, double snapTolerance, SnapMode mode = PreferNodes ) const;
|
||||
|
||||
/**
|
||||
* Snaps a set of features to the reference layer and returns the result. This operation is
|
||||
* multithreaded for performance. The featureSnapped() signal will be emitted each time a feature
|
||||
* is processed. The snap tolerance is specified in the layer units for the reference layer.
|
||||
*/
|
||||
QgsFeatureList snapFeatures( const QgsFeatureList& features, double snapTolerance, SnapMode mode = PreferNodes );
|
||||
QgsFeatureList snapFeatures( const QgsFeatureList &features, double snapTolerance, SnapMode mode = PreferNodes );
|
||||
|
||||
signals:
|
||||
|
||||
@ -77,29 +77,29 @@ class ANALYSIS_EXPORT QgsGeometrySnapper : public QObject
|
||||
private:
|
||||
struct ProcessFeatureWrapper
|
||||
{
|
||||
QgsGeometrySnapper* instance = nullptr;
|
||||
QgsGeometrySnapper *instance = nullptr;
|
||||
double snapTolerance;
|
||||
SnapMode mode;
|
||||
explicit ProcessFeatureWrapper( QgsGeometrySnapper* _instance, double snapTolerance, SnapMode mode )
|
||||
: instance( _instance )
|
||||
, snapTolerance( snapTolerance )
|
||||
, mode( mode )
|
||||
explicit ProcessFeatureWrapper( QgsGeometrySnapper *_instance, double snapTolerance, SnapMode mode )
|
||||
: instance( _instance )
|
||||
, snapTolerance( snapTolerance )
|
||||
, mode( mode )
|
||||
{}
|
||||
void operator()( QgsFeature& feature ) { return instance->processFeature( feature, snapTolerance, mode ); }
|
||||
void operator()( QgsFeature &feature ) { return instance->processFeature( feature, snapTolerance, mode ); }
|
||||
};
|
||||
|
||||
enum PointFlag { SnappedToRefNode, SnappedToRefSegment, Unsnapped };
|
||||
|
||||
QgsVectorLayer* mReferenceLayer = nullptr;
|
||||
QgsVectorLayer *mReferenceLayer = nullptr;
|
||||
QgsFeatureList mInputFeatures;
|
||||
|
||||
QgsSpatialIndex mIndex;
|
||||
mutable QMutex mIndexMutex;
|
||||
mutable QMutex mReferenceLayerMutex;
|
||||
|
||||
void processFeature( QgsFeature& feature, double snapTolerance, SnapMode mode );
|
||||
void processFeature( QgsFeature &feature, double snapTolerance, SnapMode mode );
|
||||
|
||||
int polyLineSize( const QgsAbstractGeometry* geom, int iPart, int iRing ) const;
|
||||
int polyLineSize( const QgsAbstractGeometry *geom, int iPart, int iRing ) const;
|
||||
};
|
||||
|
||||
///@cond PRIVATE
|
||||
@ -108,13 +108,13 @@ class QgsSnapIndex
|
||||
public:
|
||||
struct CoordIdx
|
||||
{
|
||||
CoordIdx( const QgsAbstractGeometry* _geom, QgsVertexId _vidx )
|
||||
: geom( _geom )
|
||||
, vidx( _vidx )
|
||||
CoordIdx( const QgsAbstractGeometry *_geom, QgsVertexId _vidx )
|
||||
: geom( _geom )
|
||||
, vidx( _vidx )
|
||||
{}
|
||||
QgsPointV2 point() const { return geom->vertexAt( vidx ); }
|
||||
|
||||
const QgsAbstractGeometry* geom = nullptr;
|
||||
const QgsAbstractGeometry *geom = nullptr;
|
||||
QgsVertexId vidx;
|
||||
};
|
||||
|
||||
@ -125,7 +125,7 @@ class QgsSnapIndex
|
||||
public:
|
||||
virtual ~SnapItem() = default;
|
||||
SnapType type;
|
||||
virtual QgsPointV2 getSnapPoint( const QgsPointV2& p ) const = 0;
|
||||
virtual QgsPointV2 getSnapPoint( const QgsPointV2 &p ) const = 0;
|
||||
|
||||
protected:
|
||||
explicit SnapItem( SnapType _type ) : type( _type ) {}
|
||||
@ -134,30 +134,30 @@ class QgsSnapIndex
|
||||
class PointSnapItem : public QgsSnapIndex::SnapItem
|
||||
{
|
||||
public:
|
||||
explicit PointSnapItem( const CoordIdx* _idx );
|
||||
explicit PointSnapItem( const CoordIdx *_idx );
|
||||
QgsPointV2 getSnapPoint( const QgsPointV2 &/*p*/ ) const override;
|
||||
const CoordIdx* idx = nullptr;
|
||||
const CoordIdx *idx = nullptr;
|
||||
};
|
||||
|
||||
class SegmentSnapItem : public QgsSnapIndex::SnapItem
|
||||
{
|
||||
public:
|
||||
SegmentSnapItem( const CoordIdx* _idxFrom, const CoordIdx* _idxTo );
|
||||
SegmentSnapItem( const CoordIdx *_idxFrom, const CoordIdx *_idxTo );
|
||||
QgsPointV2 getSnapPoint( const QgsPointV2 &p ) const override;
|
||||
bool getIntersection( const QgsPointV2& p1, const QgsPointV2& p2, QgsPointV2& inter ) const;
|
||||
bool getIntersection( const QgsPointV2 &p1, const QgsPointV2 &p2, QgsPointV2 &inter ) const;
|
||||
bool getProjection( const QgsPointV2 &p, QgsPointV2 &pProj );
|
||||
const CoordIdx* idxFrom = nullptr;
|
||||
const CoordIdx* idxTo = nullptr;
|
||||
const CoordIdx *idxFrom = nullptr;
|
||||
const CoordIdx *idxTo = nullptr;
|
||||
};
|
||||
|
||||
QgsSnapIndex( const QgsPointV2& origin, double cellSize );
|
||||
QgsSnapIndex( const QgsPointV2 &origin, double cellSize );
|
||||
~QgsSnapIndex();
|
||||
void addGeometry( const QgsAbstractGeometry *geom );
|
||||
QgsPointV2 getClosestSnapToPoint( const QgsPointV2& p, const QgsPointV2& q );
|
||||
SnapItem *getSnapItem( const QgsPointV2& pos, double tol, PointSnapItem **pSnapPoint = nullptr, SegmentSnapItem **pSnapSegment = nullptr ) const;
|
||||
QgsPointV2 getClosestSnapToPoint( const QgsPointV2 &p, const QgsPointV2 &q );
|
||||
SnapItem *getSnapItem( const QgsPointV2 &pos, double tol, PointSnapItem **pSnapPoint = nullptr, SegmentSnapItem **pSnapSegment = nullptr ) const;
|
||||
|
||||
private:
|
||||
typedef QList<SnapItem*> Cell;
|
||||
typedef QList<SnapItem *> Cell;
|
||||
typedef QPair<QgsPointV2, QgsPointV2> Segment;
|
||||
|
||||
class GridRow
|
||||
@ -166,8 +166,8 @@ class QgsSnapIndex
|
||||
GridRow() : mColStartIdx( 0 ) {}
|
||||
~GridRow();
|
||||
const Cell *getCell( int col ) const;
|
||||
Cell& getCreateCell( int col );
|
||||
QList<SnapItem*> getSnapItems( int colStart, int colEnd ) const;
|
||||
Cell &getCreateCell( int col );
|
||||
QList<SnapItem *> getSnapItems( int colStart, int colEnd ) const;
|
||||
|
||||
private:
|
||||
QList<QgsSnapIndex::Cell> mCells;
|
||||
@ -177,17 +177,17 @@ class QgsSnapIndex
|
||||
QgsPointV2 mOrigin;
|
||||
double mCellSize;
|
||||
|
||||
QList<CoordIdx*> mCoordIdxs;
|
||||
QList<CoordIdx *> mCoordIdxs;
|
||||
QList<GridRow> mGridRows;
|
||||
int mRowsStartIdx;
|
||||
|
||||
void addPoint( const CoordIdx* idx );
|
||||
void addSegment( const CoordIdx* idxFrom, const CoordIdx* idxTo );
|
||||
const Cell* getCell( int col, int row ) const;
|
||||
void addPoint( const CoordIdx *idx );
|
||||
void addSegment( const CoordIdx *idxFrom, const CoordIdx *idxTo );
|
||||
const Cell *getCell( int col, int row ) const;
|
||||
Cell &getCreateCell( int col, int row );
|
||||
|
||||
QgsSnapIndex( const QgsSnapIndex& rh );
|
||||
QgsSnapIndex& operator=( const QgsSnapIndex& rh );
|
||||
QgsSnapIndex( const QgsSnapIndex &rh );
|
||||
QgsSnapIndex &operator=( const QgsSnapIndex &rh );
|
||||
};
|
||||
|
||||
///@endcond
|
||||
|
@ -30,9 +30,9 @@
|
||||
#include "qgsdistancearea.h"
|
||||
#include <QProgressDialog>
|
||||
|
||||
bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* layerB,
|
||||
const QString& shapefileName, bool onlySelectedFeatures,
|
||||
QProgressDialog* p )
|
||||
bool QgsOverlayAnalyzer::intersection( QgsVectorLayer *layerA, QgsVectorLayer *layerB,
|
||||
const QString &shapefileName, bool onlySelectedFeatures,
|
||||
QProgressDialog *p )
|
||||
{
|
||||
if ( !layerA || !layerB )
|
||||
{
|
||||
@ -130,8 +130,8 @@ bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* l
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsOverlayAnalyzer::intersectFeature( QgsFeature& f, QgsVectorFileWriter* vfw,
|
||||
QgsVectorLayer* vl, QgsSpatialIndex* index )
|
||||
void QgsOverlayAnalyzer::intersectFeature( QgsFeature &f, QgsVectorFileWriter *vfw,
|
||||
QgsVectorLayer *vl, QgsSpatialIndex *index )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
@ -167,10 +167,10 @@ void QgsOverlayAnalyzer::intersectFeature( QgsFeature& f, QgsVectorFileWriter* v
|
||||
}
|
||||
}
|
||||
|
||||
void QgsOverlayAnalyzer::combineFieldLists( QgsFields& fieldListA, const QgsFields& fieldListB )
|
||||
void QgsOverlayAnalyzer::combineFieldLists( QgsFields &fieldListA, const QgsFields &fieldListB )
|
||||
{
|
||||
QList<QString> names;
|
||||
Q_FOREACH ( const QgsField& field, fieldListA )
|
||||
Q_FOREACH ( const QgsField &field, fieldListA )
|
||||
names.append( field.name() );
|
||||
|
||||
for ( int idx = 0; idx < fieldListB.count(); ++idx )
|
||||
@ -188,7 +188,7 @@ void QgsOverlayAnalyzer::combineFieldLists( QgsFields& fieldListA, const QgsFiel
|
||||
}
|
||||
}
|
||||
|
||||
void QgsOverlayAnalyzer::combineAttributeMaps( QgsAttributes& attributesA, const QgsAttributes& attributesB )
|
||||
void QgsOverlayAnalyzer::combineAttributeMaps( QgsAttributes &attributesA, const QgsAttributes &attributesB )
|
||||
{
|
||||
attributesA += attributesB;
|
||||
}
|
||||
|
@ -40,15 +40,15 @@ class ANALYSIS_EXPORT QgsOverlayAnalyzer
|
||||
@param onlySelectedFeatures if true, only selected features are considered, else all the features
|
||||
@param p progress dialog (or 0 if no progress dialog is to be shown)
|
||||
*/
|
||||
bool intersection( QgsVectorLayer* layerA, QgsVectorLayer* layerB,
|
||||
const QString& shapefileName, bool onlySelectedFeatures = false,
|
||||
QProgressDialog* p = nullptr );
|
||||
bool intersection( QgsVectorLayer *layerA, QgsVectorLayer *layerB,
|
||||
const QString &shapefileName, bool onlySelectedFeatures = false,
|
||||
QProgressDialog *p = nullptr );
|
||||
|
||||
private:
|
||||
|
||||
void combineFieldLists( QgsFields& fieldListA, const QgsFields& fieldListB );
|
||||
void intersectFeature( QgsFeature& f, QgsVectorFileWriter* vfw, QgsVectorLayer* dp, QgsSpatialIndex* index );
|
||||
void combineAttributeMaps( QgsAttributes& attributesA, const QgsAttributes& attributesB );
|
||||
void combineFieldLists( QgsFields &fieldListA, const QgsFields &fieldListB );
|
||||
void intersectFeature( QgsFeature &f, QgsVectorFileWriter *vfw, QgsVectorLayer *dp, QgsSpatialIndex *index );
|
||||
void combineAttributeMaps( QgsAttributes &attributesA, const QgsAttributes &attributesB );
|
||||
};
|
||||
|
||||
#endif //QGSVECTORANALYZER
|
||||
|
@ -22,18 +22,18 @@
|
||||
#include "mersenne-twister.h"
|
||||
|
||||
|
||||
QgsPointSample::QgsPointSample( QgsVectorLayer* inputLayer, const QString& outputLayer, const QString& nPointsAttribute, const QString& minDistAttribute ): mInputLayer( inputLayer ),
|
||||
mOutputLayer( outputLayer ), mNumberOfPointsAttribute( nPointsAttribute ), mMinDistanceAttribute( minDistAttribute ), mNCreatedPoints( 0 )
|
||||
QgsPointSample::QgsPointSample( QgsVectorLayer *inputLayer, const QString &outputLayer, const QString &nPointsAttribute, const QString &minDistAttribute ): mInputLayer( inputLayer ),
|
||||
mOutputLayer( outputLayer ), mNumberOfPointsAttribute( nPointsAttribute ), mMinDistanceAttribute( minDistAttribute ), mNCreatedPoints( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
QgsPointSample::QgsPointSample()
|
||||
: mInputLayer( nullptr )
|
||||
, mNCreatedPoints( 0 )
|
||||
: mInputLayer( nullptr )
|
||||
, mNCreatedPoints( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
int QgsPointSample::createRandomPoints( QProgressDialog* pd )
|
||||
int QgsPointSample::createRandomPoints( QProgressDialog *pd )
|
||||
{
|
||||
Q_UNUSED( pd );
|
||||
|
||||
@ -92,7 +92,7 @@ int QgsPointSample::createRandomPoints( QProgressDialog* pd )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QgsPointSample::addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWriter& writer, int nPoints, double minDistance )
|
||||
void QgsPointSample::addSamplePoints( QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance )
|
||||
{
|
||||
if ( !inputFeature.hasGeometry() )
|
||||
return;
|
||||
@ -116,8 +116,8 @@ void QgsPointSample::addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWri
|
||||
|
||||
while ( nIterations < maxIterations && points < nPoints )
|
||||
{
|
||||
randX = (( double )mt_rand() / MD_RAND_MAX ) * geomRect.width() + geomRect.xMinimum();
|
||||
randY = (( double )mt_rand() / MD_RAND_MAX ) * geomRect.height() + geomRect.yMinimum();
|
||||
randX = ( ( double )mt_rand() / MD_RAND_MAX ) * geomRect.width() + geomRect.xMinimum();
|
||||
randY = ( ( double )mt_rand() / MD_RAND_MAX ) * geomRect.height() + geomRect.yMinimum();
|
||||
QgsPoint randPoint( randX, randY );
|
||||
QgsGeometry ptGeom = QgsGeometry::fromPoint( randPoint );
|
||||
if ( ptGeom.within( geom ) && checkMinDistance( randPoint, sIndex, minDistance, pointMapForFeature ) )
|
||||
@ -138,7 +138,7 @@ void QgsPointSample::addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWri
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsPointSample::checkMinDistance( QgsPoint& pt, QgsSpatialIndex& index, double minDistance, QMap< QgsFeatureId, QgsPoint >& pointMap )
|
||||
bool QgsPointSample::checkMinDistance( QgsPoint &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPoint > &pointMap )
|
||||
{
|
||||
if ( minDistance <= 0 )
|
||||
{
|
||||
|
@ -31,20 +31,20 @@ class QProgressDialog;
|
||||
class ANALYSIS_EXPORT QgsPointSample
|
||||
{
|
||||
public:
|
||||
QgsPointSample( QgsVectorLayer* inputLayer, const QString& outputLayer, const QString& nPointsAttribute, const QString& minDistAttribute = QString() );
|
||||
QgsPointSample( QgsVectorLayer *inputLayer, const QString &outputLayer, const QString &nPointsAttribute, const QString &minDistAttribute = QString() );
|
||||
|
||||
/** Starts calculation of random points
|
||||
@return 0 in case of success*/
|
||||
int createRandomPoints( QProgressDialog* pd );
|
||||
int createRandomPoints( QProgressDialog *pd );
|
||||
|
||||
private:
|
||||
|
||||
QgsPointSample(); //default constructor is forbidden
|
||||
void addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWriter& writer, int nPoints, double minDistance );
|
||||
bool checkMinDistance( QgsPoint& pt, QgsSpatialIndex& index, double minDistance, QMap< QgsFeatureId, QgsPoint >& pointMap );
|
||||
void addSamplePoints( QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance );
|
||||
bool checkMinDistance( QgsPoint &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPoint > &pointMap );
|
||||
|
||||
//! Layer id of input polygon/multipolygon layer
|
||||
QgsVectorLayer* mInputLayer = nullptr;
|
||||
QgsVectorLayer *mInputLayer = nullptr;
|
||||
//! Output path of result layer
|
||||
QString mOutputLayer;
|
||||
//! Attribute containing number of points per feature
|
||||
|
@ -27,39 +27,39 @@
|
||||
#include "mersenne-twister.h"
|
||||
#include <limits>
|
||||
|
||||
QgsTransectSample::QgsTransectSample( QgsVectorLayer* strataLayer, const QString& strataIdAttribute, const QString& minDistanceAttribute, const QString& nPointsAttribute, DistanceUnits minDistUnits,
|
||||
QgsVectorLayer* baselineLayer, bool shareBaseline, const QString& baselineStrataId, const QString& outputPointLayer,
|
||||
const QString& outputLineLayer, const QString& usedBaselineLayer, double minTransectLength,
|
||||
QgsTransectSample::QgsTransectSample( QgsVectorLayer *strataLayer, const QString &strataIdAttribute, const QString &minDistanceAttribute, const QString &nPointsAttribute, DistanceUnits minDistUnits,
|
||||
QgsVectorLayer *baselineLayer, bool shareBaseline, const QString &baselineStrataId, const QString &outputPointLayer,
|
||||
const QString &outputLineLayer, const QString &usedBaselineLayer, double minTransectLength,
|
||||
double baselineBufferDistance, double baselineSimplificationTolerance )
|
||||
: mStrataLayer( strataLayer )
|
||||
, mStrataIdAttribute( strataIdAttribute )
|
||||
, mMinDistanceAttribute( minDistanceAttribute )
|
||||
, mNPointsAttribute( nPointsAttribute )
|
||||
, mBaselineLayer( baselineLayer )
|
||||
, mShareBaseline( shareBaseline )
|
||||
, mBaselineStrataId( baselineStrataId )
|
||||
, mOutputPointLayer( outputPointLayer )
|
||||
, mOutputLineLayer( outputLineLayer )
|
||||
, mUsedBaselineLayer( usedBaselineLayer )
|
||||
, mMinDistanceUnits( minDistUnits )
|
||||
, mMinTransectLength( minTransectLength )
|
||||
, mBaselineBufferDistance( baselineBufferDistance )
|
||||
, mBaselineSimplificationTolerance( baselineSimplificationTolerance )
|
||||
: mStrataLayer( strataLayer )
|
||||
, mStrataIdAttribute( strataIdAttribute )
|
||||
, mMinDistanceAttribute( minDistanceAttribute )
|
||||
, mNPointsAttribute( nPointsAttribute )
|
||||
, mBaselineLayer( baselineLayer )
|
||||
, mShareBaseline( shareBaseline )
|
||||
, mBaselineStrataId( baselineStrataId )
|
||||
, mOutputPointLayer( outputPointLayer )
|
||||
, mOutputLineLayer( outputLineLayer )
|
||||
, mUsedBaselineLayer( usedBaselineLayer )
|
||||
, mMinDistanceUnits( minDistUnits )
|
||||
, mMinTransectLength( minTransectLength )
|
||||
, mBaselineBufferDistance( baselineBufferDistance )
|
||||
, mBaselineSimplificationTolerance( baselineSimplificationTolerance )
|
||||
{
|
||||
}
|
||||
|
||||
QgsTransectSample::QgsTransectSample()
|
||||
: mStrataLayer( nullptr )
|
||||
, mBaselineLayer( nullptr )
|
||||
, mShareBaseline( false )
|
||||
, mMinDistanceUnits( Meters )
|
||||
, mMinTransectLength( 0.0 )
|
||||
, mBaselineBufferDistance( -1.0 )
|
||||
, mBaselineSimplificationTolerance( -1.0 )
|
||||
: mStrataLayer( nullptr )
|
||||
, mBaselineLayer( nullptr )
|
||||
, mShareBaseline( false )
|
||||
, mMinDistanceUnits( Meters )
|
||||
, mMinTransectLength( 0.0 )
|
||||
, mBaselineBufferDistance( -1.0 )
|
||||
, mBaselineSimplificationTolerance( -1.0 )
|
||||
{
|
||||
}
|
||||
|
||||
int QgsTransectSample::createSample( QProgressDialog* pd )
|
||||
int QgsTransectSample::createSample( QProgressDialog *pd )
|
||||
{
|
||||
Q_UNUSED( pd );
|
||||
|
||||
@ -191,7 +191,7 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QgsGeometry* bufferLineClipped = clipBufferLine( strataGeom, &clippedBaseline, bufferDist );
|
||||
QgsGeometry *bufferLineClipped = clipBufferLine( strataGeom, &clippedBaseline, bufferDist );
|
||||
if ( !bufferLineClipped )
|
||||
{
|
||||
continue;
|
||||
@ -215,7 +215,7 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
|
||||
|
||||
while ( nCreatedTransects < nTransects && nIterations < nMaxIterations )
|
||||
{
|
||||
double randomPosition = (( double )mt_rand() / MD_RAND_MAX ) * clippedBaseline.length();
|
||||
double randomPosition = ( ( double )mt_rand() / MD_RAND_MAX ) * clippedBaseline.length();
|
||||
QgsGeometry samplePoint = clippedBaseline.interpolate( randomPosition );
|
||||
++nIterations;
|
||||
if ( samplePoint.isNull() )
|
||||
@ -328,7 +328,7 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
|
||||
return 0;
|
||||
}
|
||||
|
||||
QgsGeometry QgsTransectSample::findBaselineGeometry( const QVariant& strataId )
|
||||
QgsGeometry QgsTransectSample::findBaselineGeometry( const QVariant &strataId )
|
||||
{
|
||||
if ( !mBaselineLayer )
|
||||
{
|
||||
@ -348,8 +348,8 @@ QgsGeometry QgsTransectSample::findBaselineGeometry( const QVariant& strataId )
|
||||
return QgsGeometry();
|
||||
}
|
||||
|
||||
bool QgsTransectSample::otherTransectWithinDistance( const QgsGeometry& geom, double minDistLayerUnit, double minDistance, QgsSpatialIndex& sIndex,
|
||||
const QMap< QgsFeatureId, QgsGeometry >& lineFeatureMap, QgsDistanceArea& da )
|
||||
bool QgsTransectSample::otherTransectWithinDistance( const QgsGeometry &geom, double minDistLayerUnit, double minDistance, QgsSpatialIndex &sIndex,
|
||||
const QMap< QgsFeatureId, QgsGeometry > &lineFeatureMap, QgsDistanceArea &da )
|
||||
{
|
||||
if ( geom.isNull() )
|
||||
{
|
||||
@ -385,7 +385,7 @@ bool QgsTransectSample::otherTransectWithinDistance( const QgsGeometry& geom, do
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsTransectSample::closestSegmentPoints( const QgsGeometry& g1, const QgsGeometry& g2, double& dist, QgsPoint& pt1, QgsPoint& pt2 )
|
||||
bool QgsTransectSample::closestSegmentPoints( const QgsGeometry &g1, const QgsGeometry &g2, double &dist, QgsPoint &pt1, QgsPoint &pt2 )
|
||||
{
|
||||
QgsWkbTypes::Type t1 = g1.wkbType();
|
||||
if ( t1 != QgsWkbTypes::LineString && t1 != QgsWkbTypes::LineString25D )
|
||||
@ -515,7 +515,7 @@ bool QgsTransectSample::closestSegmentPoints( const QgsGeometry& g1, const QgsGe
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsGeometry QgsTransectSample::closestMultilineElement( const QgsPoint& pt, const QgsGeometry& multiLine )
|
||||
QgsGeometry QgsTransectSample::closestMultilineElement( const QgsPoint &pt, const QgsGeometry &multiLine )
|
||||
{
|
||||
if ( !multiLine || ( multiLine.wkbType() != QgsWkbTypes::MultiLineString
|
||||
&& multiLine.wkbType() != QgsWkbTypes::MultiLineString25D ) )
|
||||
@ -545,7 +545,7 @@ QgsGeometry QgsTransectSample::closestMultilineElement( const QgsPoint& pt, cons
|
||||
return closestLine;
|
||||
}
|
||||
|
||||
QgsGeometry* QgsTransectSample::clipBufferLine( const QgsGeometry& stratumGeom, QgsGeometry* clippedBaseline, double tolerance )
|
||||
QgsGeometry *QgsTransectSample::clipBufferLine( const QgsGeometry &stratumGeom, QgsGeometry *clippedBaseline, double tolerance )
|
||||
{
|
||||
if ( !stratumGeom || !clippedBaseline || clippedBaseline->wkbType() == QgsWkbTypes::Unknown )
|
||||
{
|
||||
|
@ -39,27 +39,27 @@ class ANALYSIS_EXPORT QgsTransectSample
|
||||
StrataUnits //units are the same as stratum layer
|
||||
};
|
||||
|
||||
QgsTransectSample( QgsVectorLayer* strataLayer, const QString& strataIdAttribute, const QString& minDistanceAttribute, const QString& nPointsAttribute,
|
||||
DistanceUnits minDistUnits, QgsVectorLayer* baselineLayer, bool shareBaseline,
|
||||
const QString& baselineStrataId, const QString& outputPointLayer, const QString& outputLineLayer, const QString& usedBaselineLayer, double minTransectLength = 0.0,
|
||||
QgsTransectSample( QgsVectorLayer *strataLayer, const QString &strataIdAttribute, const QString &minDistanceAttribute, const QString &nPointsAttribute,
|
||||
DistanceUnits minDistUnits, QgsVectorLayer *baselineLayer, bool shareBaseline,
|
||||
const QString &baselineStrataId, const QString &outputPointLayer, const QString &outputLineLayer, const QString &usedBaselineLayer, double minTransectLength = 0.0,
|
||||
double baselineBufferDistance = -1.0, double baselineSimplificationTolerance = -1.0 );
|
||||
|
||||
int createSample( QProgressDialog* pd );
|
||||
int createSample( QProgressDialog *pd );
|
||||
|
||||
private:
|
||||
QgsTransectSample(); //default constructor forbidden
|
||||
|
||||
QgsGeometry findBaselineGeometry( const QVariant& strataId );
|
||||
QgsGeometry findBaselineGeometry( const QVariant &strataId );
|
||||
|
||||
//! Returns true if another transect is within the specified minimum distance
|
||||
static bool otherTransectWithinDistance( const QgsGeometry& geom, double minDistLayerUnit, double minDistance, QgsSpatialIndex& sIndex, const QMap<QgsFeatureId, QgsGeometry>& lineFeatureMap, QgsDistanceArea& da );
|
||||
static bool otherTransectWithinDistance( const QgsGeometry &geom, double minDistLayerUnit, double minDistance, QgsSpatialIndex &sIndex, const QMap<QgsFeatureId, QgsGeometry> &lineFeatureMap, QgsDistanceArea &da );
|
||||
|
||||
QgsVectorLayer* mStrataLayer = nullptr;
|
||||
QgsVectorLayer *mStrataLayer = nullptr;
|
||||
QString mStrataIdAttribute;
|
||||
QString mMinDistanceAttribute;
|
||||
QString mNPointsAttribute;
|
||||
|
||||
QgsVectorLayer* mBaselineLayer = nullptr;
|
||||
QgsVectorLayer *mBaselineLayer = nullptr;
|
||||
bool mShareBaseline;
|
||||
QString mBaselineStrataId;
|
||||
|
||||
@ -83,16 +83,16 @@ class ANALYSIS_EXPORT QgsTransectSample
|
||||
@param pt1 out: closest point on first geometry
|
||||
@param pt2 out: closest point on secont geometry
|
||||
@return true in case of success*/
|
||||
static bool closestSegmentPoints( const QgsGeometry& g1, const QgsGeometry& g2, double& dist, QgsPoint& pt1, QgsPoint& pt2 );
|
||||
static bool closestSegmentPoints( const QgsGeometry &g1, const QgsGeometry &g2, double &dist, QgsPoint &pt1, QgsPoint &pt2 );
|
||||
//! Returns a copy of the multiline element closest to a point (caller takes ownership)
|
||||
static QgsGeometry closestMultilineElement( const QgsPoint& pt, const QgsGeometry& multiLine );
|
||||
static QgsGeometry closestMultilineElement( const QgsPoint &pt, const QgsGeometry &multiLine );
|
||||
|
||||
/** Returns clipped buffer line. Iteratively applies reduced tolerances if the result is not a single line
|
||||
@param stratumGeom stratum polygon
|
||||
@param clippedBaseline base line geometry clipped to the stratum
|
||||
@param tolerance buffer distance (in layer units)
|
||||
@return clipped buffer line or 0 in case of error*/
|
||||
QgsGeometry* clipBufferLine( const QgsGeometry& stratumGeom, QgsGeometry* clippedBaseline, double tolerance );
|
||||
QgsGeometry *clipBufferLine( const QgsGeometry &stratumGeom, QgsGeometry *clippedBaseline, double tolerance );
|
||||
|
||||
//! Returns distance to buffer the baseline (takes care of units and buffer settings
|
||||
double bufferDistance( double minDistanceFromAttribute ) const;
|
||||
|
@ -29,22 +29,22 @@
|
||||
#include <QProgressDialog>
|
||||
#include <QFile>
|
||||
|
||||
QgsZonalStatistics::QgsZonalStatistics( QgsVectorLayer* polygonLayer, QgsRasterLayer* rasterLayer, const QString& attributePrefix, int rasterBand, Statistics stats )
|
||||
: mRasterLayer( rasterLayer )
|
||||
, mRasterBand( rasterBand )
|
||||
, mPolygonLayer( polygonLayer )
|
||||
, mAttributePrefix( attributePrefix )
|
||||
, mStatistics( stats )
|
||||
QgsZonalStatistics::QgsZonalStatistics( QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, const QString &attributePrefix, int rasterBand, Statistics stats )
|
||||
: mRasterLayer( rasterLayer )
|
||||
, mRasterBand( rasterBand )
|
||||
, mPolygonLayer( polygonLayer )
|
||||
, mAttributePrefix( attributePrefix )
|
||||
, mStatistics( stats )
|
||||
{}
|
||||
|
||||
int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
|
||||
int QgsZonalStatistics::calculateStatistics( QProgressDialog *p )
|
||||
{
|
||||
if ( !mPolygonLayer || mPolygonLayer->geometryType() != QgsWkbTypes::PolygonGeometry )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QgsVectorDataProvider* vectorProvider = mPolygonLayer->dataProvider();
|
||||
QgsVectorDataProvider *vectorProvider = mPolygonLayer->dataProvider();
|
||||
if ( !vectorProvider )
|
||||
{
|
||||
return 2;
|
||||
@ -172,17 +172,17 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
|
||||
int majorityIndex = mStatistics & QgsZonalStatistics::Majority ? vectorProvider->fieldNameIndex( majorityFieldName ) : -1;
|
||||
int varietyIndex = mStatistics & QgsZonalStatistics::Variety ? vectorProvider->fieldNameIndex( varietyFieldName ) : -1;
|
||||
|
||||
if (( mStatistics & QgsZonalStatistics::Count && countIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Sum && sumIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Mean && meanIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Median && medianIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::StDev && stdevIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Min && minIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Max && maxIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Range && rangeIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Minority && minorityIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Majority && majorityIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Variety && varietyIndex == -1 )
|
||||
if ( ( mStatistics & QgsZonalStatistics::Count && countIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Sum && sumIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Mean && meanIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Median && medianIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::StDev && stdevIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Min && minIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Max && maxIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Range && rangeIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Minority && minorityIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Majority && majorityIndex == -1 )
|
||||
|| ( mStatistics & QgsZonalStatistics::Variety && varietyIndex == -1 )
|
||||
)
|
||||
{
|
||||
//failed to create a required field
|
||||
@ -245,11 +245,11 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
|
||||
}
|
||||
|
||||
//avoid access to cells outside of the raster (may occur because of rounding)
|
||||
if (( offsetX + nCellsX ) > nCellsXProvider )
|
||||
if ( ( offsetX + nCellsX ) > nCellsXProvider )
|
||||
{
|
||||
nCellsX = nCellsXProvider - offsetX;
|
||||
}
|
||||
if (( offsetY + nCellsY ) > nCellsYProvider )
|
||||
if ( ( offsetY + nCellsY ) > nCellsYProvider )
|
||||
{
|
||||
nCellsY = nCellsYProvider - offsetY;
|
||||
}
|
||||
@ -287,7 +287,7 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
|
||||
}
|
||||
else //odd
|
||||
{
|
||||
medianValue = featureStats.values.at(( size + 1 ) / 2 - 1 );
|
||||
medianValue = featureStats.values.at( ( size + 1 ) / 2 - 1 );
|
||||
}
|
||||
changeAttributeMap.insert( medianIndex, QVariant( medianValue ) );
|
||||
}
|
||||
@ -348,8 +348,8 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QgsZonalStatistics::cellInfoForBBox( const QgsRectangle& rasterBBox, const QgsRectangle& featureBBox, double cellSizeX, double cellSizeY,
|
||||
int& offsetX, int& offsetY, int& nCellsX, int& nCellsY ) const
|
||||
int QgsZonalStatistics::cellInfoForBBox( const QgsRectangle &rasterBBox, const QgsRectangle &featureBBox, double cellSizeX, double cellSizeY,
|
||||
int &offsetX, int &offsetY, int &nCellsX, int &nCellsY ) const
|
||||
{
|
||||
//get intersecting bbox
|
||||
QgsRectangle intersectBox = rasterBBox.intersect( &featureBBox );
|
||||
@ -363,11 +363,11 @@ int QgsZonalStatistics::cellInfoForBBox( const QgsRectangle& rasterBBox, const Q
|
||||
}
|
||||
|
||||
//get offset in pixels in x- and y- direction
|
||||
offsetX = ( int )(( intersectBox.xMinimum() - rasterBBox.xMinimum() ) / cellSizeX );
|
||||
offsetY = ( int )(( rasterBBox.yMaximum() - intersectBox.yMaximum() ) / cellSizeY );
|
||||
offsetX = ( int )( ( intersectBox.xMinimum() - rasterBBox.xMinimum() ) / cellSizeX );
|
||||
offsetY = ( int )( ( rasterBBox.yMaximum() - intersectBox.yMaximum() ) / cellSizeY );
|
||||
|
||||
int maxColumn = ( int )(( intersectBox.xMaximum() - rasterBBox.xMinimum() ) / cellSizeX ) + 1;
|
||||
int maxRow = ( int )(( rasterBBox.yMaximum() - intersectBox.yMinimum() ) / cellSizeY ) + 1;
|
||||
int maxColumn = ( int )( ( intersectBox.xMaximum() - rasterBBox.xMinimum() ) / cellSizeX ) + 1;
|
||||
int maxRow = ( int )( ( rasterBBox.yMaximum() - intersectBox.yMinimum() ) / cellSizeY ) + 1;
|
||||
|
||||
nCellsX = maxColumn - offsetX;
|
||||
nCellsY = maxRow - offsetY;
|
||||
@ -375,35 +375,35 @@ int QgsZonalStatistics::cellInfoForBBox( const QgsRectangle& rasterBBox, const Q
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry& poly, int pixelOffsetX,
|
||||
int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, FeatureStats &stats )
|
||||
void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly, int pixelOffsetX,
|
||||
int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, FeatureStats &stats )
|
||||
{
|
||||
double cellCenterX, cellCenterY;
|
||||
|
||||
cellCenterY = rasterBBox.yMaximum() - pixelOffsetY * cellSizeY - cellSizeY / 2;
|
||||
stats.reset();
|
||||
|
||||
GEOSGeometry* polyGeos = poly.exportToGeos();
|
||||
GEOSGeometry *polyGeos = poly.exportToGeos();
|
||||
if ( !polyGeos )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
|
||||
const GEOSPreparedGeometry* polyGeosPrepared = GEOSPrepare_r( geosctxt, polyGeos );
|
||||
const GEOSPreparedGeometry *polyGeosPrepared = GEOSPrepare_r( geosctxt, polyGeos );
|
||||
if ( !polyGeosPrepared )
|
||||
{
|
||||
GEOSGeom_destroy_r( geosctxt, polyGeos );
|
||||
return;
|
||||
}
|
||||
|
||||
GEOSCoordSequence* cellCenterCoords = nullptr;
|
||||
GEOSGeometry* currentCellCenter = nullptr;
|
||||
GEOSCoordSequence *cellCenterCoords = nullptr;
|
||||
GEOSGeometry *currentCellCenter = nullptr;
|
||||
|
||||
QgsRectangle featureBBox = poly.boundingBox().intersect( &rasterBBox );
|
||||
QgsRectangle intersectBBox = rasterBBox.intersect( &featureBBox );
|
||||
|
||||
QgsRasterBlock* block = mRasterProvider->block( mRasterBand, intersectBBox, nCellsX, nCellsY );
|
||||
QgsRasterBlock *block = mRasterProvider->block( mRasterBand, intersectBBox, nCellsX, nCellsY );
|
||||
for ( int i = 0; i < nCellsY; ++i )
|
||||
{
|
||||
cellCenterX = rasterBBox.xMinimum() + pixelOffsetX * cellSizeX + cellSizeX / 2;
|
||||
@ -432,8 +432,8 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry& poly,
|
||||
delete block;
|
||||
}
|
||||
|
||||
void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry& poly, int pixelOffsetX,
|
||||
int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, FeatureStats &stats )
|
||||
void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry &poly, int pixelOffsetX,
|
||||
int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, FeatureStats &stats )
|
||||
{
|
||||
stats.reset();
|
||||
|
||||
@ -448,7 +448,7 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry& p
|
||||
QgsRectangle featureBBox = poly.boundingBox().intersect( &rasterBBox );
|
||||
QgsRectangle intersectBBox = rasterBBox.intersect( &featureBBox );
|
||||
|
||||
QgsRasterBlock* block = mRasterProvider->block( mRasterBand, intersectBBox, nCellsX, nCellsY );
|
||||
QgsRasterBlock *block = mRasterProvider->block( mRasterBand, intersectBBox, nCellsX, nCellsY );
|
||||
for ( int i = 0; i < nCellsY; ++i )
|
||||
{
|
||||
double currentX = rasterBBox.xMinimum() + cellSizeX / 2.0 + pixelOffsetX * cellSizeX;
|
||||
@ -491,9 +491,9 @@ bool QgsZonalStatistics::validPixel( float value ) const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString QgsZonalStatistics::getUniqueFieldName( const QString& fieldName, const QList<QgsField>& newFields )
|
||||
QString QgsZonalStatistics::getUniqueFieldName( const QString &fieldName, const QList<QgsField> &newFields )
|
||||
{
|
||||
QgsVectorDataProvider* dp = mPolygonLayer->dataProvider();
|
||||
QgsVectorDataProvider *dp = mPolygonLayer->dataProvider();
|
||||
|
||||
if ( !dp->storageType().contains( QLatin1String( "ESRI Shapefile" ) ) )
|
||||
{
|
||||
|
@ -59,12 +59,12 @@ class ANALYSIS_EXPORT QgsZonalStatistics
|
||||
/**
|
||||
* Constructor for QgsZonalStatistics.
|
||||
*/
|
||||
QgsZonalStatistics( QgsVectorLayer* polygonLayer, QgsRasterLayer* rasterLayer, const QString& attributePrefix = "", int rasterBand = 1,
|
||||
QgsZonalStatistics( QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, const QString &attributePrefix = "", int rasterBand = 1,
|
||||
Statistics stats = Statistics( Count | Sum | Mean ) );
|
||||
|
||||
/** Starts the calculation
|
||||
@return 0 in case of success*/
|
||||
int calculateStatistics( QProgressDialog* p );
|
||||
int calculateStatistics( QProgressDialog *p );
|
||||
|
||||
private:
|
||||
QgsZonalStatistics() = default;
|
||||
@ -73,8 +73,8 @@ class ANALYSIS_EXPORT QgsZonalStatistics
|
||||
{
|
||||
public:
|
||||
FeatureStats( bool storeValues = false, bool storeValueCounts = false )
|
||||
: mStoreValues( storeValues )
|
||||
, mStoreValueCounts( storeValueCounts )
|
||||
: mStoreValues( storeValues )
|
||||
, mStoreValueCounts( storeValueCounts )
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@ -112,27 +112,27 @@ class ANALYSIS_EXPORT QgsZonalStatistics
|
||||
|
||||
/** Analysis what cells need to be considered to cover the bounding box of a feature
|
||||
@return 0 in case of success*/
|
||||
int cellInfoForBBox( const QgsRectangle& rasterBBox, const QgsRectangle& featureBBox, double cellSizeX, double cellSizeY,
|
||||
int& offsetX, int& offsetY, int& nCellsX, int& nCellsY ) const;
|
||||
int cellInfoForBBox( const QgsRectangle &rasterBBox, const QgsRectangle &featureBBox, double cellSizeX, double cellSizeY,
|
||||
int &offsetX, int &offsetY, int &nCellsX, int &nCellsY ) const;
|
||||
|
||||
//! Returns statistics by considering the pixels where the center point is within the polygon (fast)
|
||||
void statisticsFromMiddlePointTest( const QgsGeometry& poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
|
||||
double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, FeatureStats& stats );
|
||||
void statisticsFromMiddlePointTest( const QgsGeometry &poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
|
||||
double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, FeatureStats &stats );
|
||||
|
||||
//! Returns statistics with precise pixel - polygon intersection test (slow)
|
||||
void statisticsFromPreciseIntersection( const QgsGeometry& poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
|
||||
double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, FeatureStats& stats );
|
||||
void statisticsFromPreciseIntersection( const QgsGeometry &poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
|
||||
double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, FeatureStats &stats );
|
||||
|
||||
//! Tests whether a pixel's value should be included in the result
|
||||
bool validPixel( float value ) const;
|
||||
|
||||
QString getUniqueFieldName( const QString& fieldName, const QList<QgsField>& newFields );
|
||||
QString getUniqueFieldName( const QString &fieldName, const QList<QgsField> &newFields );
|
||||
|
||||
QgsRasterLayer* mRasterLayer = nullptr;
|
||||
QgsRasterDataProvider* mRasterProvider = nullptr;
|
||||
QgsRasterLayer *mRasterLayer = nullptr;
|
||||
QgsRasterDataProvider *mRasterProvider = nullptr;
|
||||
//! Raster band to calculate statistics
|
||||
int mRasterBand = 0;
|
||||
QgsVectorLayer* mPolygonLayer = nullptr;
|
||||
QgsVectorLayer *mPolygonLayer = nullptr;
|
||||
QString mAttributePrefix;
|
||||
//! The nodata value of the input layer
|
||||
float mInputNodataValue = -1;
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
|
||||
QgsAuthBasicEdit::QgsAuthBasicEdit( QWidget *parent )
|
||||
: QgsAuthMethodEdit( parent )
|
||||
, mValid( 0 )
|
||||
: QgsAuthMethodEdit( parent )
|
||||
, mValid( 0 )
|
||||
{
|
||||
setupUi( this );
|
||||
}
|
||||
@ -83,5 +83,5 @@ void QgsAuthBasicEdit::on_leUsername_textChanged( const QString &txt )
|
||||
|
||||
void QgsAuthBasicEdit::on_chkPasswordShow_stateChanged( int state )
|
||||
{
|
||||
lePassword->setEchoMode(( state > 0 ) ? QLineEdit::Normal : QLineEdit::Password );
|
||||
lePassword->setEchoMode( ( state > 0 ) ? QLineEdit::Normal : QLineEdit::Password );
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class QgsAuthBasicEdit : public QgsAuthMethodEdit, private Ui::QgsAuthBasicEdit
|
||||
void clearConfig() override;
|
||||
|
||||
private slots:
|
||||
void on_leUsername_textChanged( const QString& txt );
|
||||
void on_leUsername_textChanged( const QString &txt );
|
||||
|
||||
void on_chkPasswordShow_stateChanged( int state );
|
||||
|
||||
|
@ -27,7 +27,7 @@ QMap<QString, QgsAuthMethodConfig> QgsAuthBasicMethod::sAuthConfigCache = QMap<Q
|
||||
|
||||
|
||||
QgsAuthBasicMethod::QgsAuthBasicMethod()
|
||||
: QgsAuthMethod()
|
||||
: QgsAuthMethod()
|
||||
{
|
||||
setVersion( 2 );
|
||||
setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::DataSourceUri );
|
||||
@ -172,7 +172,7 @@ QgsAuthMethodConfig QgsAuthBasicMethod::getMethodConfig( const QString &authcfg,
|
||||
return mconfig;
|
||||
}
|
||||
|
||||
void QgsAuthBasicMethod::putMethodConfig( const QString &authcfg, const QgsAuthMethodConfig& mconfig )
|
||||
void QgsAuthBasicMethod::putMethodConfig( const QString &authcfg, const QgsAuthMethodConfig &mconfig )
|
||||
{
|
||||
QgsDebugMsg( QString( "Putting basic config for authcfg: %1" ).arg( authcfg ) );
|
||||
sAuthConfigCache.insert( authcfg, mconfig );
|
||||
|
@ -51,7 +51,7 @@ class QgsAuthBasicMethod : public QgsAuthMethod
|
||||
private:
|
||||
QgsAuthMethodConfig getMethodConfig( const QString &authcfg, bool fullconfig = true );
|
||||
|
||||
void putMethodConfig( const QString &authcfg, const QgsAuthMethodConfig& mconfig );
|
||||
void putMethodConfig( const QString &authcfg, const QgsAuthMethodConfig &mconfig );
|
||||
|
||||
void removeMethodConfig( const QString &authcfg );
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
|
||||
QgsAuthIdentCertEdit::QgsAuthIdentCertEdit( QWidget *parent )
|
||||
: QgsAuthMethodEdit( parent )
|
||||
, mValid( 0 )
|
||||
: QgsAuthMethodEdit( parent )
|
||||
, mValid( 0 )
|
||||
{
|
||||
setupUi( this );
|
||||
populateIdentityComboBox();
|
||||
@ -84,7 +84,7 @@ void QgsAuthIdentCertEdit::populateIdentityComboBox()
|
||||
{
|
||||
cmbIdentityCert->setIconSize( QSize( 26, 22 ) );
|
||||
QgsStringMap idents;
|
||||
Q_FOREACH ( const QSslCertificate& cert, certs )
|
||||
Q_FOREACH ( const QSslCertificate &cert, certs )
|
||||
{
|
||||
QString org( SSL_SUBJECT_INFO( cert, QSslCertificate::Organization ) );
|
||||
if ( org.isEmpty() )
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user