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;
203 const unsigned char* currentWkbPtr = g->
asWkb();
214 currentWkbPtr += ( 1 +
sizeof( int ) );
215 x = *((
double * )( currentWkbPtr ) );
216 currentWkbPtr +=
sizeof( double );
217 y = *((
double * )( currentWkbPtr ) );
218 if ( zCoord && hasZValue )
220 currentWkbPtr +=
sizeof( double );
221 z = *((
double * )( currentWkbPtr ) );
238 currentWkbPtr += ( 1 +
sizeof( int ) );
239 int* npoints = (
int* )currentWkbPtr;
240 currentWkbPtr +=
sizeof( int );
241 for (
int index = 0; index < *npoints; ++index )
243 currentWkbPtr += ( 1 +
sizeof( int ) );
244 x = *((
double* )currentWkbPtr );
245 currentWkbPtr +=
sizeof( double );
246 y = *((
double* )currentWkbPtr );
247 currentWkbPtr +=
sizeof( double );
250 z = *((
double* )currentWkbPtr );
251 currentWkbPtr +=
sizeof( double );
268 currentWkbPtr += ( 1 +
sizeof( int ) );
269 int* npoints = (
int* )currentWkbPtr;
270 currentWkbPtr +=
sizeof( int );
271 for (
int index = 0; index < *npoints; ++index )
273 x = *((
double * )( currentWkbPtr ) );
274 currentWkbPtr +=
sizeof( double );
275 y = *((
double * )( currentWkbPtr ) );
276 currentWkbPtr +=
sizeof( double );
277 if ( zCoord && hasZValue )
279 z = *((
double * )( currentWkbPtr ) );
287 currentWkbPtr +=
sizeof( double );
311 currentWkbPtr += ( 1 +
sizeof( int ) );
312 int* nlines = (
int* )currentWkbPtr;
314 currentWkbPtr +=
sizeof( int );
315 for (
int index = 0; index < *nlines; ++index )
321 currentWkbPtr += (
sizeof( int ) + 1 );
322 npoints = (
int* )currentWkbPtr;
323 currentWkbPtr +=
sizeof( int );
324 for (
int index2 = 0; index2 < *npoints; ++index2 )
326 x = *((
double* )currentWkbPtr );
327 currentWkbPtr +=
sizeof( double );
328 y = *((
double* )currentWkbPtr );
329 currentWkbPtr +=
sizeof( double );
333 z = *((
double* ) currentWkbPtr );
334 currentWkbPtr +=
sizeof( double );
362 currentWkbPtr += ( 1 +
sizeof( int ) );
363 int* nrings = (
int* )currentWkbPtr;
364 currentWkbPtr +=
sizeof( int );
366 for (
int index = 0; index < *nrings; ++index )
373 npoints = (
int* )currentWkbPtr;
374 currentWkbPtr +=
sizeof( int );
375 for (
int index2 = 0; index2 < *npoints; ++index2 )
377 x = *((
double* )currentWkbPtr );
378 currentWkbPtr +=
sizeof( double );
379 y = *((
double* )currentWkbPtr );
380 currentWkbPtr +=
sizeof( double );
383 z = *((
double* )currentWkbPtr );;
384 currentWkbPtr +=
sizeof( double );
413 currentWkbPtr += ( 1 +
sizeof( int ) );
414 int* npolys = (
int* )currentWkbPtr;
417 currentWkbPtr +=
sizeof( int );
418 for (
int index = 0; index < *npolys; ++index )
420 currentWkbPtr += ( 1 +
sizeof( int ) );
421 nrings = (
int* )currentWkbPtr;
422 currentWkbPtr +=
sizeof( int );
423 for (
int index2 = 0; index2 < *nrings; ++index2 )
429 npoints = (
int* )currentWkbPtr;
430 currentWkbPtr +=
sizeof( int );
431 for (
int index3 = 0; index3 < *npoints; ++index3 )
433 x = *((
double* )currentWkbPtr );
434 currentWkbPtr +=
sizeof( double );
435 y = *((
double* )currentWkbPtr );
436 currentWkbPtr +=
sizeof( double );
439 z = *((
double* )currentWkbPtr );
440 currentWkbPtr +=
sizeof( double );
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)
A geometry is the spatial representation of a feature.
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.