[QGIS Commit] r12221 - trunk/qgis/src/analysis/interpolation

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Nov 22 09:41:01 EST 2009


Author: mhugent
Date: 2009-11-22 09:41:00 -0500 (Sun, 22 Nov 2009)
New Revision: 12221

Modified:
   trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.cc
   trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.h
   trunk/qgis/src/analysis/interpolation/NormVecDecorator.cc
   trunk/qgis/src/analysis/interpolation/NormVecDecorator.h
   trunk/qgis/src/analysis/interpolation/qgstininterpolator.cpp
Log:
Improved robustness of constrained triangulation. Added a progress dialog for normal vector estimation

Modified: trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.cc
===================================================================
--- trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.cc	2009-11-22 02:42:53 UTC (rev 12220)
+++ trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.cc	2009-11-22 14:41:00 UTC (rev 12221)
@@ -426,6 +426,7 @@
       // 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 @@
       {
         if ( mHalfEdge[i]->getPoint() == point && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 )//we found it
         {
+          mEdgeInside = i;
           return i;
         }
       }
@@ -454,6 +456,7 @@
 
     if ( mHalfEdge[actedge]->getPoint() == point && mHalfEdge[mHalfEdge[actedge]->getNext()]->getPoint() != -1 )//we found the edge
     {
+      mEdgeInside = actedge;
       return actedge;
       break;
     }

Modified: trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.h
===================================================================
--- trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.h	2009-11-22 02:42:53 UTC (rev 12220)
+++ trunk/qgis/src/analysis/interpolation/DualEdgeTriangulation.h	2009-11-22 14:41:00 UTC (rev 12221)
@@ -119,7 +119,7 @@
     /**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<Point3D*> mPointVector;
     /**Default value for the number of storable HalfEdges at the beginning*/
@@ -182,13 +182,13 @@
     void evaluateInfluenceRegion( Point3D* point, int edge, std::set<int>* 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 );

Modified: trunk/qgis/src/analysis/interpolation/NormVecDecorator.cc
===================================================================
--- trunk/qgis/src/analysis/interpolation/NormVecDecorator.cc	2009-11-22 02:42:53 UTC (rev 12220)
+++ trunk/qgis/src/analysis/interpolation/NormVecDecorator.cc	2009-11-22 14:41:00 UTC (rev 12221)
@@ -16,6 +16,8 @@
 
 #include "NormVecDecorator.h"
 #include "qgslogger.h"
+#include <QApplication>
+#include <QProgressDialog>
 
 NormVecDecorator::~NormVecDecorator()
 {
@@ -482,7 +484,6 @@
   //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 @@
 
   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 @@
 }
 
 //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 );
   }
+
+  if ( d )
+  {
+    d->setValue( getNumberOfPoints() );
+  }
   return true;
-
 }
 
 void NormVecDecorator::eliminateHorizontalTriangles()

Modified: trunk/qgis/src/analysis/interpolation/NormVecDecorator.h
===================================================================
--- trunk/qgis/src/analysis/interpolation/NormVecDecorator.h	2009-11-22 02:42:53 UTC (rev 12220)
+++ trunk/qgis/src/analysis/interpolation/NormVecDecorator.h	2009-11-22 14:41:00 UTC (rev 12221)
@@ -21,6 +21,7 @@
 #include <TriangleInterpolator.h>
 #include <MathUtils.h>
 #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 @@
     /**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 @@
   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*/

Modified: trunk/qgis/src/analysis/interpolation/qgstininterpolator.cpp
===================================================================
--- trunk/qgis/src/analysis/interpolation/qgstininterpolator.cpp	2009-11-22 02:42:53 UTC (rev 12220)
+++ trunk/qgis/src/analysis/interpolation/qgstininterpolator.cpp	2009-11-22 14:41:00 UTC (rev 12221)
@@ -142,7 +142,14 @@
     NormVecDecorator* dec = dynamic_cast<NormVecDecorator*>( 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;



More information about the QGIS-commit mailing list