~ubuntu-branches/ubuntu/natty/qgis/natty

« back to all changes in this revision

Viewing changes to src/analysis/interpolation/Triangulation.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          Triangulation.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 TRIANGULATION_H
 
18
#define TRIANGULATION_H
 
19
 
 
20
#include <QList>
 
21
#include "Line3D.h"
 
22
#include "Vector3D.h"
 
23
#include <qpainter.h>
 
24
#include "Line3D.h"
 
25
#include <TriangleInterpolator.h>
 
26
 
 
27
/**Interface for Triangulation classes*/
 
28
class ANALYSIS_EXPORT Triangulation
 
29
{
 
30
  public:
 
31
    /**Enumeration describing the behaviour, if two forced lines cross. SnappingType_VERTICE means, that the second inserted forced line is snapped to the closest vertice of the first inserted forced line. DELETE_FIRST means, that the status of the first inserted forced line is reset to that of a normal edge (so that the second inserted forced line remain and the first not*/
 
32
    enum forcedCrossBehaviour {SnappingType_VERTICE, DELETE_FIRST, INSERT_VERTICE};
 
33
    virtual ~Triangulation();
 
34
    /**Adds a line (e.g. a break-, structure- or an isoline) to the triangulation. The class takes ownership of the line object and its points*/
 
35
    virtual void addLine( Line3D* line, bool breakline ) = 0;
 
36
    /**Adds a point to the triangulation*/
 
37
    virtual int addPoint( Point3D* p ) = 0;
 
38
    /**Calculates the normal at a point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure*/
 
39
    virtual bool calcNormal( double x, double y, Vector3D* result ) = 0;
 
40
    /**Performs a consistency check, remove this later*/
 
41
    virtual void performConsistencyTest() = 0;
 
42
    /**Calculates x-, y and z-value of the point on the surface and assigns it to 'result'. Returns true in case of success and flase in case of failure*/
 
43
    virtual bool calcPoint( double x, double y, Point3D* result ) = 0;
 
44
    /**Returns a pointer to the point with number i. Any virtual points must have the number -1*/
 
45
    virtual Point3D* getPoint( unsigned int i ) const = 0;
 
46
    /**Finds out, in which triangle the point with coordinates x and y is and assigns the numbers of the vertices to 'n1', 'n2' and 'n3' and the vertices to 'p1', 'p2' and 'p3'*/
 
47
    virtual bool getTriangle( double x, double y, Point3D* p1, int* n1, Point3D* p2, int* n2, Point3D* p3, int* n3 ) = 0;
 
48
    /**Finds out, in which triangle the point with coordinates x and y is and assigns the  points at the vertices to 'p1', 'p2' and 'p3*/
 
49
    virtual bool getTriangle( double x, double y, Point3D* p1, Point3D* p2, Point3D* p3 ) = 0;
 
50
    /**Returns the number of the point opposite to the triangle points p1, p2 (which have to be on a halfedge)*/
 
51
    virtual int getOppositePoint( int p1, int p2 ) = 0;
 
52
    /**Returns the largest x-coordinate value of the bounding box*/
 
53
    virtual double getXMax() const = 0;
 
54
    /**Returns the smallest x-coordinate value of the bounding box*/
 
55
    virtual double getXMin() const = 0;
 
56
    /**Returns the largest y-coordinate value of the bounding box*/
 
57
    virtual double getYMax() const = 0;
 
58
    /**Returns the smallest x-coordinate value of the bounding box*/
 
59
    virtual double getYMin() const = 0;
 
60
    /**Returns the number of points*/
 
61
    virtual int getNumberOfPoints() const = 0;
 
62
    /**Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point. Four integer values describe a triangle, the first three are the number of the half edges of the triangle and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise. The value list has to be deleted by the code which called the method. Any virtual point needs to have the number -1*/
 
63
    virtual QList<int>* getSurroundingTriangles( int pointno ) = 0;
 
64
    /**Returns a value list with the numbers of the four points, which would be affected by an edge swap. This function is e.g. needed by NormVecDecorator to know the points, for which the normals have to be recalculated. The list has to be deleted by the code which calls this method*/
 
65
    virtual QList<int>* getPointsAroundEdge( double x, double y ) = 0;
 
66
    /**draws the points, edges and the forced lines*/
 
67
    //virtual void draw(QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height) const=0;
 
68
    /**Sets the behaviour of the triangulation in case of crossing forced lines*/
 
69
    virtual void setForcedCrossBehaviour( Triangulation::forcedCrossBehaviour b ) = 0;
 
70
    /**Sets the color of the normal edges*/
 
71
    virtual void setEdgeColor( int r, int g, int b ) = 0;
 
72
    /**Sets the color of the forced edges*/
 
73
    virtual void setForcedEdgeColor( int r, int g, int b ) = 0;
 
74
    /**Sets the color of the breaklines*/
 
75
    virtual void setBreakEdgeColor( int r, int g, int b ) = 0;
 
76
    /**Sets an interpolator object*/
 
77
    virtual void setTriangleInterpolator( TriangleInterpolator* interpolator ) = 0;
 
78
    /**Eliminates the horizontal triangles by swapping*/
 
79
    virtual void eliminateHorizontalTriangles() = 0;
 
80
    /**Adds points to make the triangles better shaped (algorithm of ruppert)
 
81
     \param tin the triangulation or decorator which interpolates the elevation*/
 
82
    virtual void ruppertRefinement() = 0;
 
83
    /**Returns true, if the point with coordinates x and y is inside the convex hull and false otherwise*/
 
84
    virtual bool pointInside( double x, double y ) = 0;
 
85
    /**Reads the content of a taff-file*/
 
86
    //virtual bool readFromTAFF(QString fileName)=0;
 
87
    /**Saves the content to a taff file*/
 
88
    //virtual bool saveToTAFF(QString fileName) const=0;
 
89
    /**Swaps the edge which is closest to the point with x and y coordinates (if this is possible)*/
 
90
    virtual bool swapEdge( double x, double y ) = 0;
 
91
    /**Saves the triangulation as a (line) shapefile
 
92
    @return true in case of success*/
 
93
    virtual bool saveAsShapefile( const QString& fileName ) const = 0;
 
94
};
 
95
 
 
96
inline Triangulation::~Triangulation()
 
97
{
 
98
 
 
99
}
 
100
 
 
101
#endif