27 #include <QProgressDialog>
32 , mTriangleInterpolator( 0 )
33 , mIsInitialized( false )
34 , mShowProgressDialog( showProgressDialog )
35 , mExportTriangulationToFile( false )
36 , mInterpolation( interpolation )
83 int nProcessedFeatures = 0;
86 QList<LayerData>::iterator layerDataIt =
mLayerData.begin();
87 for ( ; layerDataIt !=
mLayerData.end(); ++layerDataIt )
89 if ( layerDataIt->vectorLayer )
91 nFeatures += layerDataIt->vectorLayer->featureCount();
96 QProgressDialog* theProgressDialog = 0;
99 theProgressDialog =
new QProgressDialog(
QObject::tr(
"Building triangulation..." ),
QObject::tr(
"Abort" ), 0, nFeatures, 0 );
100 theProgressDialog->setWindowModality( Qt::WindowModal );
105 QList<LayerData>::iterator layerDataIt =
mLayerData.begin();
106 for ( ; layerDataIt !=
mLayerData.end(); ++layerDataIt )
108 if ( layerDataIt->vectorLayer )
111 if ( !layerDataIt->zCoordInterpolation )
113 attList.push_back( layerDataIt->interpolationAttribute );
122 if ( theProgressDialog->wasCanceled() )
126 theProgressDialog->setValue( nProcessedFeatures );
128 insertData( &f, layerDataIt->zCoordInterpolation, layerDataIt->interpolationAttribute, layerDataIt->mInputType );
129 ++nProcessedFeatures;
134 delete theProgressDialog;
142 QProgressDialog* progressDialog = 0;
145 progressDialog =
new QProgressDialog();
146 progressDialog->setLabelText(
QObject::tr(
"Estimating normal derivatives..." ) );
149 delete progressDialog;
184 double attributeValue = 0;
185 bool attributeConversionOk =
false;
188 QVariant attributeVariant = f->
attribute( attr );
189 if ( !attributeVariant.isValid() )
193 attributeValue = attributeVariant.toDouble( &attributeConversionOk );
194 if ( !attributeConversionOk || qIsNaN( attributeValue ) )
201 bool hasZValue =
false;
214 currentWkbPtr >> x >> y;
215 if ( zCoord && hasZValue )
235 currentWkbPtr >> nPoints;
238 currentWkbPtr += 1 +
sizeof( int );
239 currentWkbPtr >> x >> y;
260 currentWkbPtr >> nPoints;
263 currentWkbPtr >> x >> y;
264 if ( zCoord && hasZValue )
295 currentWkbPtr >> nLines;
303 currentWkbPtr >> nPoints;
304 for (
int index2 = 0; index2 < nPoints; ++index2 )
306 currentWkbPtr >> x >> y;
338 currentWkbPtr >> nRings;
347 currentWkbPtr >> nPoints;
348 for (
int index2 = 0; index2 < nPoints; ++index2 )
350 currentWkbPtr >> x >> y;
383 currentWkbPtr >> nPolys;
386 currentWkbPtr += 1 +
sizeof( int );
388 currentWkbPtr >> nRings;
389 for (
int index2 = 0; index2 < nRings; ++index2 )
396 currentWkbPtr >> nPoints;
397 for (
int index3 = 0; index3 < nPoints; ++index3 )
399 currentWkbPtr >> x >> y;
Decorator class which adds the functionality of estimating normals at the data points.
Wrapper for iterator of features from vector data provider or vector layer.
QList< LayerData > mLayerData
virtual int addPoint(Point3D *p)=0
Adds a point to the triangulation.
Interface class for interpolations.
int insertData(QgsFeature *f, bool zCoord, int attr, InputType type)
Inserts the vertices of a feature into the triangulation.
virtual void addTriangulation(Triangulation *t)
Adds an association to a triangulation.
LinTriangleInterpolator is a class which interpolates linearly on a triangulation.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
virtual void setTriangulation(NormVecDecorator *tin)
WkbType
Used for symbology operations.
QgsTINInterpolator(const QList< LayerData > &inputData, TIN_INTERPOLATION interpolation=Linear, bool showProgressDialog=false)
TriangleInterpolator * mTriangleInterpolator
This class represents a line.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double getZ() const
Returns the z-coordinate of the point.
DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data struc...
void setTriangleInterpolator(TriangleInterpolator *inter)
Sets an interpolator.
virtual bool saveAsShapefile(const QString &fileName) const
Saves the triangulation as a (line) shapefile.
InputType
Describes the type of input data.
Point3D is a class to represent a three dimensional point.
void initialize()
Create dual edge triangulation.
Triangulation * mTriangulation
int interpolatePoint(double x, double y, double &result)
Calculates interpolation value for map coordinates x, y.
bool estimateFirstDerivatives(QProgressDialog *d=0)
This method adds the functionality of estimating normals at the data points.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
virtual void addLine(Line3D *line, bool breakline)=0
Adds a line (e.g.
void insertPoint(Point3D *p)
inserts a node behind the current position and sets the current position to this new node ...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
This is an implementation of a Clough-Tocher interpolator based on a triangular tessellation.
virtual bool calcPoint(double x, double y, Point3D *result)=0
Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point...
TIN_INTERPOLATION mInterpolation
Type of interpolation.
bool mExportTriangulationToFile
If true: export triangulation to shapefile after initialisation.
bool nextFeature(QgsFeature &f)
QString mTriangulationFilePath
File path to export the triangulation.
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.