Branch data Line data Source code
1 : : /***************************************************************************
2 : : CloughTocherInterpolator.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 CLOUGHTOCHERINTERPOLATOR_H
18 : : #define CLOUGHTOCHERINTERPOLATOR_H
19 : :
20 : : #include "TriangleInterpolator.h"
21 : : #include "qgspoint.h"
22 : : #include "qgis_analysis.h"
23 : :
24 : : class NormVecDecorator;
25 : :
26 : : #define SIP_NO_FILE
27 : :
28 : : /**
29 : : * \ingroup analysis
30 : : * \brief This is an implementation of a Clough-Tocher interpolator based on a triangular tessellation.
31 : : *
32 : : * The derivatives orthogonal to the boundary curves are interpolated linearly along a triangle edge.
33 : : * \note Not available in Python bindings
34 : : */
35 : 0 : class ANALYSIS_EXPORT CloughTocherInterpolator : public TriangleInterpolator
36 : : {
37 : : protected:
38 : : //! Association with a triangulation object
39 : 0 : NormVecDecorator *mTIN = nullptr;
40 : : //! Tolerance of the barycentric coordinates at the borders of the triangles (to prevent errors because of very small negative baricentric coordinates)
41 : 0 : double mEdgeTolerance = 0.00001;
42 : : //! First point of the triangle in x-,y-,z-coordinates
43 : 0 : QgsPoint point1 = QgsPoint( 0, 0, 0 );
44 : : //! Second point of the triangle in x-,y-,z-coordinates
45 : 0 : QgsPoint point2 = QgsPoint( 0, 0, 0 );
46 : : //! Third point of the triangle in x-,y-,z-coordinates
47 : 0 : QgsPoint point3 = QgsPoint( 0, 0, 0 );
48 : : //! Control point 1
49 : 0 : QgsPoint cp1 = QgsPoint( 0, 0, 0 );
50 : : //! Control point 2
51 : 0 : QgsPoint cp2 = QgsPoint( 0, 0, 0 );
52 : : //! Control point 3
53 : 0 : QgsPoint cp3 = QgsPoint( 0, 0, 0 );
54 : : //! Control point 4
55 : 0 : QgsPoint cp4 = QgsPoint( 0, 0, 0 );
56 : : //! Control point 5
57 : 0 : QgsPoint cp5 = QgsPoint( 0, 0, 0 );
58 : : //! Control point 6
59 : 0 : QgsPoint cp6 = QgsPoint( 0, 0, 0 );
60 : : //! Control point 7
61 : 0 : QgsPoint cp7 = QgsPoint( 0, 0, 0 );
62 : : //! Control point 8
63 : 0 : QgsPoint cp8 = QgsPoint( 0, 0, 0 );
64 : : //! Control point 9
65 : 0 : QgsPoint cp9 = QgsPoint( 0, 0, 0 );
66 : : //! Control point 10
67 : 0 : QgsPoint cp10 = QgsPoint( 0, 0, 0 );
68 : : //! Control point 11
69 : 0 : QgsPoint cp11 = QgsPoint( 0, 0, 0 );
70 : : //! Control point 12
71 : 0 : QgsPoint cp12 = QgsPoint( 0, 0, 0 );
72 : : //! Control point 13
73 : 0 : QgsPoint cp13 = QgsPoint( 0, 0, 0 );
74 : : //! Control point 14
75 : 0 : QgsPoint cp14 = QgsPoint( 0, 0, 0 );
76 : : //! Control point 15
77 : 0 : QgsPoint cp15 = QgsPoint( 0, 0, 0 );
78 : : //! Control point 16
79 : 0 : QgsPoint cp16 = QgsPoint( 0, 0, 0 );
80 : : //! Derivative in x-direction at point1
81 : 0 : double der1X = 0.0;
82 : : //! Derivative in y-direction at point1
83 : 0 : double der1Y = 0.0;
84 : : //! Derivative in x-direction at point2
85 : 0 : double der2X = 0.0;
86 : : //! Derivative in y-direction at point2
87 : 0 : double der2Y = 0.0;
88 : : //! Derivative in x-direction at point3
89 : 0 : double der3X = 0.0;
90 : : //! Derivative in y-direction at point3
91 : 0 : double der3Y = 0.0;
92 : : //! Stores point1 of the last run
93 : 0 : QgsPoint lpoint1 = QgsPoint( 0, 0, 0 );
94 : : //! Stores point2 of the last run
95 : 0 : QgsPoint lpoint2 = QgsPoint( 0, 0, 0 );
96 : : //! Stores point3 of the last run
97 : 0 : QgsPoint lpoint3 = QgsPoint( 0, 0, 0 );
98 : : //! Finds out, in which triangle the point with the coordinates x and y is
99 : : void init( double x, double y );
100 : : //! Calculates the Bernsteinpolynomials to calculate the Beziertriangle. 'n' is three in the cubical case, 'i', 'j', 'k' are the indices of the controllpoint and 'u', 'v', 'w' are the barycentric coordinates of the point
101 : : double calcBernsteinPoly( int n, int i, int j, int k, double u, double v, double w );
102 : :
103 : : public:
104 : : //! Standard constructor
105 : 0 : CloughTocherInterpolator() = default;
106 : :
107 : : //! Constructor with a pointer to the triangulation as argument
108 : : CloughTocherInterpolator( NormVecDecorator *tin );
109 : :
110 : : //! Calculates the normal vector and assigns it to vec (not implemented at the moment)
111 : : bool calcNormVec( double x, double y, QgsPoint &result SIP_OUT ) override;
112 : : bool calcPoint( double x, double y, QgsPoint &result SIP_OUT ) override;
113 : : virtual void setTriangulation( NormVecDecorator *tin );
114 : : };
115 : :
116 : : #endif
117 : :
118 : :
119 : :
|