Quantum GIS API Documentation  1.8
src/analysis/interpolation/NormVecDecorator.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           NormVecDecorator.h  -  description
00003                              -------------------
00004     copyright            : (C) 2004 by Marco Hugentobler
00005     email                : [email protected]
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #ifndef NORMVECDECORATOR_H
00018 #define NORMVECDECORATOR_H
00019 
00020 #include "TriDecorator.h"
00021 #include <TriangleInterpolator.h>
00022 #include <MathUtils.h>
00023 #include "qgslogger.h"
00024 class QProgressDialog;
00025 
00027 class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
00028 {
00029   public:
00031     enum pointState {NORMAL, BREAKLINE, ENDPOINT};
00032     NormVecDecorator();
00033     NormVecDecorator( Triangulation* tin );
00034     virtual ~NormVecDecorator();
00036     int addPoint( Point3D* p );
00038     bool calcNormal( double x, double y, Vector3D* result );
00040     bool calcNormalForPoint( double x, double y, int point, Vector3D* result );
00042     bool calcPoint( double x, double y, Point3D* result );
00044     virtual void eliminateHorizontalTriangles();
00046     bool estimateFirstDerivative( int pointno );
00048     bool estimateFirstDerivatives( QProgressDialog* d = 0 );
00050     Vector3D* getNormal( int n ) const;
00052     bool getTriangle( double x, double y, Point3D* p1, Vector3D* v1, Point3D* p2, Vector3D* v2, Point3D* p3, Vector3D* v3 );
00054     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 );
00056     pointState getState( int pointno ) const;
00058     void setTriangleInterpolator( TriangleInterpolator* inter );
00060     virtual bool swapEdge( double x, double y );
00063     virtual bool saveAsShapefile( const QString& fileName ) const;
00064 
00065   protected:
00067     bool alreadyestimated;
00068     const static unsigned int mDefaultStorageForNormals = 100000;
00070     TriangleInterpolator* mInterpolator;
00072     QVector<Vector3D*>* mNormVec;
00074     QVector<pointState>* mPointState;
00076     void setState( int pointno, pointState s );
00077 };
00078 
00079 inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( 0 ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<pointState>( mDefaultStorageForNormals ) )
00080 {
00081   alreadyestimated = false;
00082 }
00083 
00084 inline NormVecDecorator::NormVecDecorator( Triangulation* tin ): TriDecorator( tin ), mInterpolator( 0 ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<pointState>( mDefaultStorageForNormals ) )
00085 {
00086   alreadyestimated = false;
00087 }
00088 
00089 inline void NormVecDecorator::setTriangleInterpolator( TriangleInterpolator* inter )
00090 {
00091   mInterpolator = inter;
00092 }
00093 
00094 inline Vector3D* NormVecDecorator::getNormal( int n ) const
00095 {
00096   if ( mNormVec )
00097   {
00098     return mNormVec->at( n );
00099   }
00100   else
00101   {
00102     QgsDebugMsg( "warning, null pointer" );
00103     return 0;
00104   }
00105 }
00106 
00107 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines