GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

thinplatespline.h
1 /******************************************************************************
2 * $Id: thinplatespline.h 33715 2016-03-13 08:52:06Z goatbar $
3 *
4 * Project: GDAL Warp API
5 * Purpose: Declarations for 2D Thin Plate Spline transformer.
6 * Author: VIZRT Development Team.
7 *
8 * This code was provided by Gilad Ronnen (gro at visrt dot com) with
9 * permission to reuse under the following license.
10 *
11 ******************************************************************************
12 * Copyright (c) 2004, VIZRT Inc.
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 * DEALINGS IN THE SOFTWARE.
31 ****************************************************************************/
32
33 #include "gdal_alg.h"
34 #include "cpl_conv.h"
35
36 typedef enum
37 {
38 VIZ_GEOREF_SPLINE_ZERO_POINTS,
39 VIZ_GEOREF_SPLINE_ONE_POINT,
40 VIZ_GEOREF_SPLINE_TWO_POINTS,
41 VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL,
42 VIZ_GEOREF_SPLINE_FULL,
43
44 VIZ_GEOREF_SPLINE_POINT_WAS_ADDED,
45 VIZ_GEOREF_SPLINE_POINT_WAS_DELETED
46
47 } vizGeorefInterType;
48
49 //#define VIZ_GEOREF_SPLINE_MAX_POINTS 40
50 #define VIZGEOREF_MAX_VARS 2
51
52 class VizGeorefSpline2D
53 {
54 bool grow_points();
55
56 public:
57
58 VizGeorefSpline2D(int nof_vars = 1) :
59 type(VIZ_GEOREF_SPLINE_ZERO_POINTS),
60 _nof_vars(nof_vars),
61 _nof_points(0),
62 _max_nof_points(0),
63 _nof_eqs(0),
64 #if 0
65 _tx(0.0),
66 _ty(0.0),
67 _ta(10.0),
68 #endif
69 _dx(0.0),
70 _dy(0.0),
71 x(NULL),
72 y(NULL),
73 u(NULL),
74 unused(NULL),
75 index(NULL)
76 {
77 for( int i = 0; i < VIZGEOREF_MAX_VARS; i++ )
78 {
79 rhs[i] = NULL;
80 coef[i] = NULL;
81 }
82
83 grow_points();
84 }
85
86 ~VizGeorefSpline2D() {
87 CPLFree( x );
88 CPLFree( y );
89 CPLFree( u );
90 CPLFree( unused );
91 CPLFree( index );
92 for( int i = 0; i < _nof_vars; i++ )
93 {
94 CPLFree( rhs[i] );
95 CPLFree( coef[i] );
96 }
97 }
98
99 #if 0
100 int get_nof_points(){
101 return _nof_points;
102 }
103
104 void set_toler( double tx, double ty ){
105 _tx = tx;
106 _ty = ty;
107 }
108
109 void get_toler( double& tx, double& ty) {
110 tx = _tx;
111 ty = _ty;
112 }
113
114 vizGeorefInterType get_interpolation_type ( ){
115 return type;
116 }
117
118 void dump_data_points()
119 {
120 for ( int i = 0; i < _nof_points; i++ )
121 {
122 fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]);
123 for ( int v = 0; v < _nof_vars; v++ )
124 fprintf(stderr, "%f ", rhs[v][i+3]);
125 fprintf(stderr, "\n");
126 }
127 }
128
129 int delete_list()
130 {
131 _nof_points = 0;
132 type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
133 if ( _AA )
134 {
135 CPLFree(_AA);
136 _AA = NULL;
137 }
138 if ( _Ainv )
139 {
140 CPLFree(_Ainv);
141 _Ainv = NULL;
142 }
143 return _nof_points;
144 }
145 #endif
146
147 bool add_point( const double Px, const double Py, const double *Pvars );
148 int get_point( const double Px, const double Py, double *Pvars );
149 #if 0
150 int delete_point(const double Px, const double Py );
151 bool get_xy(int index, double& x, double& y);
152 bool change_point(int index, double x, double y, double* Pvars);
153 void reset(void) { _nof_points = 0; }
154 #endif
155 int solve(void);
156
157 private:
158
159 vizGeorefInterType type;
160
161 const int _nof_vars;
162 int _nof_points;
163 int _max_nof_points;
164 int _nof_eqs;
165
166 #if 0
167 // Disabled because the methods that use there is disabled.
168 double _tx, _ty;
169 double _ta;
170 #endif
171
172 double _dx, _dy;
173
174 double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
175 double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
176
177 // double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
178 // double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
179 double *rhs[VIZGEOREF_MAX_VARS];
180 double *coef[VIZGEOREF_MAX_VARS];
181
182 double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
183 int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
184 int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
185
186 private:
187 CPL_DISALLOW_COPY_ASSIGN(VizGeorefSpline2D);
188 };
VizGeorefSpline2D
Definition: thinplatespline.h:52
cpl_conv.h
Various convenience functions for CPL.
gdal_alg.h
Public (C callable) GDAL algorithm entry points, and definitions.

Generated for GDAL by 1.8.8.