QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
NormVecDecorator.h
Go to the documentation of this file.
1 /***************************************************************************
2  NormVecDecorator.h - description
3  -------------------
4  copyright : (C) 2004 by Marco Hugentobler
5  email : mhugent@geo.unizh.ch
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef NORMVECDECORATOR_H
18 #define NORMVECDECORATOR_H
19 
20 #include "TriDecorator.h"
21 #include <TriangleInterpolator.h>
22 #include <MathUtils.h>
23 #include "qgslogger.h"
24 class QProgressDialog;
25 
27 class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
28 {
29  public:
31  enum pointState {NORMAL, BREAKLINE, ENDPOINT};
34  virtual ~NormVecDecorator();
36  int addPoint( Point3D* p );
38  bool calcNormal( double x, double y, Vector3D* result );
40  bool calcNormalForPoint( double x, double y, int point, Vector3D* result );
42  bool calcPoint( double x, double y, Point3D* result );
44  virtual void eliminateHorizontalTriangles();
46  bool estimateFirstDerivative( int pointno );
48  bool estimateFirstDerivatives( QProgressDialog* d = 0 );
50  Vector3D* getNormal( int n ) const;
52  bool getTriangle( double x, double y, Point3D* p1, Vector3D* v1, Point3D* p2, Vector3D* v2, Point3D* p3, Vector3D* v3 );
54  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 );
57  pointState getState( int pointno ) const;
61  virtual bool swapEdge( double x, double y );
64  virtual bool saveAsShapefile( const QString& fileName ) const;
65 
66  protected:
69  const static unsigned int mDefaultStorageForNormals = 100000;
73  QVector<Vector3D*>* mNormVec;
75  QVector<pointState>* mPointState;
77  void setState( int pointno, pointState s );
78 };
79 
80 inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( 0 ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<pointState>( mDefaultStorageForNormals ) )
81 {
82  alreadyestimated = false;
83 }
84 
85 inline NormVecDecorator::NormVecDecorator( Triangulation* tin ): TriDecorator( tin ), mInterpolator( 0 ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<pointState>( mDefaultStorageForNormals ) )
86 {
87  alreadyestimated = false;
88 }
89 
91 {
92  mInterpolator = inter;
93 }
94 
95 inline Vector3D* NormVecDecorator::getNormal( int n ) const
96 {
97  if ( mNormVec )
98  {
99  return mNormVec->at( n );
100  }
101  else
102  {
103  QgsDebugMsg( "warning, null pointer" );
104  return 0;
105  }
106 }
107 
108 #endif
TriangleInterpolator * mInterpolator
Association with an interpolator object.
Decorator class which adds the functionality of estimating normals at the data points.
Vector3D * getNormal(int n) const
Returns a pointer to the normal vector for the point with the number n.
virtual bool swapEdge(double x, double y)
Reads the content of a taff-file.
#define QgsDebugMsg(str)
Definition: qgslogger.h:36
virtual bool saveAsShapefile(const QString &fileName) const =0
Saves the triangulation as a (line) shapefile.
virtual void eliminateHorizontalTriangles()
Eliminates the horizontal triangles by swapping.
QVector< Vector3D * > * mNormVec
Vector that stores the normals for the points.
void setTriangleInterpolator(TriangleInterpolator *inter)
Sets an interpolator.
QVector< pointState > * mPointState
Vector who stores, it a point is not on a breakline, if it is a normal point of the breakline or if i...
virtual bool calcPoint(double x, double y, Point3D *result)
Calculates x-, y and z-value of the point on the surface and assigns it to 'result'.
Point3D is a class to represent a three dimensional point.
Definition: Point3D.h:23
virtual bool calcNormal(double x, double y, Vector3D *result)
Calculates the normal at a point on the surface and assigns it to 'result'.
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
Definition: Vector3D.h:22
This is an interface for interpolator classes for triangulations.
bool getTriangle(double x, double y, Point3D *p1, int *n1, Point3D *p2, int *n2, Point3D *p3, int *n3)
Interface for Triangulation classes.
Definition: Triangulation.h:28
pointState
Enumeration for the state of a point.
Decorator class for Triangulations (s.
Definition: TriDecorator.h:23
virtual void setTriangleInterpolator(TriangleInterpolator *interpolator)
Sets an interpolator object.
bool alreadyestimated
Is true, if the normals already have been estimated.
virtual int addPoint(Point3D *p)
Adds a point to the triangulation.