QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 : [email protected]
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 );
56  pointState getState( int pointno ) const;
60  virtual bool swapEdge( double x, double y );
63  virtual bool saveAsShapefile( const QString& fileName ) const;
64 
65  protected:
68  const static unsigned int mDefaultStorageForNormals = 100000;
72  QVector<Vector3D*>* mNormVec;
74  QVector<pointState>* mPointState;
76  void setState( int pointno, pointState s );
77 };
78 
79 inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( 0 ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<pointState>( mDefaultStorageForNormals ) )
80 {
81  alreadyestimated = false;
82 }
83 
84 inline NormVecDecorator::NormVecDecorator( Triangulation* tin ): TriDecorator( tin ), mInterpolator( 0 ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<pointState>( mDefaultStorageForNormals ) )
85 {
86  alreadyestimated = false;
87 }
88 
90 {
91  mInterpolator = inter;
92 }
93 
94 inline Vector3D* NormVecDecorator::getNormal( int n ) const
95 {
96  if ( mNormVec )
97  {
98  return mNormVec->at( n );
99  }
100  else
101  {
102  QgsDebugMsg( "warning, null pointer" );
103  return 0;
104  }
105 }
106 
107 #endif