diff --git a/src/analysis/interpolation/DualEdgeTriangulation.cc b/src/analysis/interpolation/DualEdgeTriangulation.cc index 26809197f3b5..3c770af6bd60 100644 --- a/src/analysis/interpolation/DualEdgeTriangulation.cc +++ b/src/analysis/interpolation/DualEdgeTriangulation.cc @@ -426,6 +426,7 @@ int DualEdgeTriangulation::baseEdgeOfPoint( int point ) // QgsDebugMsg( "warning, endless loop" ); //use the secure and slow method + //qWarning( "******************warning, using the slow method in baseEdgeOfPoint****************************************" ); for ( int i = 0;i < mHalfEdge.count();i++ ) { if ( mHalfEdge[i]->getPoint() == point && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 )//we found it @@ -444,6 +445,7 @@ int DualEdgeTriangulation::baseEdgeOfPoint( int point ) { if ( mHalfEdge[i]->getPoint() == point && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 )//we found it { + mEdgeInside = i; return i; } } @@ -454,6 +456,7 @@ int DualEdgeTriangulation::baseEdgeOfPoint( int point ) if ( mHalfEdge[actedge]->getPoint() == point && mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint() != -1 )//we found the edge { + mEdgeInside = actedge; return actedge; break; } diff --git a/src/analysis/interpolation/DualEdgeTriangulation.h b/src/analysis/interpolation/DualEdgeTriangulation.h index 7d2e895448fd..3d008b4c2938 100644 --- a/src/analysis/interpolation/DualEdgeTriangulation.h +++ b/src/analysis/interpolation/DualEdgeTriangulation.h @@ -119,7 +119,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation /**Y-coordinate of the lower left corner of the bounding box*/ double yMin; /**Default value for the number of storable points at the beginning*/ - const static unsigned int mDefaultStorageForPoints = 50000; + const static unsigned int mDefaultStorageForPoints = 100000; /**Stores pointers to all points in the triangulations (including the points contained in the lines)*/ QVector mPointVector; /**Default value for the number of storable HalfEdges at the beginning*/ @@ -182,13 +182,13 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation void evaluateInfluenceRegion( Point3D* point, int edge, std::set* set ); }; -inline DualEdgeTriangulation::DualEdgeTriangulation() : xMax( 0 ), xMin( 0 ), yMax( 0 ), yMin( 0 ), mTriangleInterpolator( 0 ), mForcedCrossBehaviour( Triangulation::INSERT_VERTICE ), mEdgeColor( 0, 255, 0 ), mForcedEdgeColor( 0, 0, 255 ), mBreakEdgeColor( 100, 100, 0 ), mDecorator( this ) +inline DualEdgeTriangulation::DualEdgeTriangulation() : xMax( 0 ), xMin( 0 ), yMax( 0 ), yMin( 0 ), mTriangleInterpolator( 0 ), mForcedCrossBehaviour( Triangulation::DELETE_FIRST ), mEdgeColor( 0, 255, 0 ), mForcedEdgeColor( 0, 0, 255 ), mBreakEdgeColor( 100, 100, 0 ), mDecorator( this ) { mPointVector.reserve( mDefaultStorageForPoints ); mHalfEdge.reserve( mDefaultStorageForHalfEdges ); } -inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* decorator ): xMax( 0 ), xMin( 0 ), yMax( 0 ), yMin( 0 ), mTriangleInterpolator( 0 ), mForcedCrossBehaviour( Triangulation::INSERT_VERTICE ), mEdgeColor( 0, 255, 0 ), mForcedEdgeColor( 0, 0, 255 ), mBreakEdgeColor( 100, 100, 0 ), mDecorator( decorator ) +inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* decorator ): xMax( 0 ), xMin( 0 ), yMax( 0 ), yMin( 0 ), mTriangleInterpolator( 0 ), mForcedCrossBehaviour( Triangulation::DELETE_FIRST ), mEdgeColor( 0, 255, 0 ), mForcedEdgeColor( 0, 0, 255 ), mBreakEdgeColor( 100, 100, 0 ), mDecorator( decorator ) { mPointVector.reserve( nop ); mHalfEdge.reserve( nop ); diff --git a/src/analysis/interpolation/NormVecDecorator.cc b/src/analysis/interpolation/NormVecDecorator.cc index cf62ca8e117d..97f1bca96e2c 100644 --- a/src/analysis/interpolation/NormVecDecorator.cc +++ b/src/analysis/interpolation/NormVecDecorator.cc @@ -16,6 +16,8 @@ #include "NormVecDecorator.h" #include "qgslogger.h" +#include +#include NormVecDecorator::~NormVecDecorator() { @@ -482,7 +484,6 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno ) //insert the new calculated vector if ( mNormVec->size() <= mNormVec->count() )//allocate more memory if neccessary { - QgsDebugMsg( QString( "resizing mNormVec from %1 to %2" ).arg( mNormVec->size() ).arg( mNormVec->size() + 1 ) ); mNormVec->resize( mNormVec->size() + 1 ); } @@ -502,7 +503,6 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno ) if ( pointno >= mPointState->size() ) { - QgsDebugMsg( QString( "resizing mPointState from %1 to %2" ).arg( mPointState->size() ).arg( mPointState->size() + 1 ) ); mPointState->resize( mPointState->size() + 1 ); } @@ -512,14 +512,30 @@ bool NormVecDecorator::estimateFirstDerivative( int pointno ) } //weighted method of little -bool NormVecDecorator::estimateFirstDerivatives() +bool NormVecDecorator::estimateFirstDerivatives( QProgressDialog* d ) { + if ( d ) + { + d->setMinimum( 0 ); + d->setMaximum( getNumberOfPoints() ); + d->setCancelButton( 0 ); //we cannot cancel derivative estimation + d->show(); + } + for ( int i = 0; i < getNumberOfPoints(); i++ ) { + if ( d ) + { + d->setValue( i ); + } estimateFirstDerivative( i ); } - return true; + if ( d ) + { + d->setValue( getNumberOfPoints() ); + } + return true; } void NormVecDecorator::eliminateHorizontalTriangles() diff --git a/src/analysis/interpolation/NormVecDecorator.h b/src/analysis/interpolation/NormVecDecorator.h index 38d09c345c3b..d57bf53ef873 100644 --- a/src/analysis/interpolation/NormVecDecorator.h +++ b/src/analysis/interpolation/NormVecDecorator.h @@ -21,6 +21,7 @@ #include #include #include "qgslogger.h" +class QProgressDialog; /**Decorator class which adds the functionality of estimating normals at the data points*/ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator @@ -44,7 +45,7 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator /**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(); + bool estimateFirstDerivatives( QProgressDialog* d = 0 ); /**Returns a pointer to the normal vector for the point with the number n*/ 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 normaly taken from 'mNormVec', exept 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*/ @@ -64,7 +65,7 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator protected: /**Is true, if the normals already have been estimated*/ bool alreadyestimated; - const static unsigned int mDefaultStorageForNormals = 50000; + const static unsigned int mDefaultStorageForNormals = 100000; /**Association with an interpolator object*/ TriangleInterpolator* mInterpolator; /**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*/ diff --git a/src/analysis/interpolation/qgstininterpolator.cpp b/src/analysis/interpolation/qgstininterpolator.cpp index bd7e79de9a57..4db6bf5a6b11 100644 --- a/src/analysis/interpolation/qgstininterpolator.cpp +++ b/src/analysis/interpolation/qgstininterpolator.cpp @@ -142,7 +142,14 @@ void QgsTINInterpolator::initialize() NormVecDecorator* dec = dynamic_cast( mTriangulation ); if ( dec ) { - dec->estimateFirstDerivatives(); + QProgressDialog* progressDialog = 0; + if ( mShowProgressDialog ) //show a progress dialog because it can take a long time... + { + progressDialog = new QProgressDialog(); + progressDialog->setLabelText( QObject::tr( "Estimating normal derivatives..." ) ); + } + dec->estimateFirstDerivatives( progressDialog ); + delete progressDialog; ctInterpolator->setTriangulation( dec ); dec->setTriangleInterpolator( ctInterpolator ); mTriangleInterpolator = ctInterpolator;