GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

thinplatespline.h
1 /******************************************************************************
2 * $Id$
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 #ifndef THINPLATESPLINE_H_INCLUDED
34 #define THINPLATESPLINE_H_INCLUDED
35
36 #ifndef DOXYGEN_SKIP
37
38 #include "gdal_alg.h"
39 #include "cpl_conv.h"
40
41 typedef enum
42 {
43 VIZ_GEOREF_SPLINE_ZERO_POINTS,
44 VIZ_GEOREF_SPLINE_ONE_POINT,
45 VIZ_GEOREF_SPLINE_TWO_POINTS,
46 VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL,
47 VIZ_GEOREF_SPLINE_FULL,
48
49 VIZ_GEOREF_SPLINE_POINT_WAS_ADDED,
50 VIZ_GEOREF_SPLINE_POINT_WAS_DELETED
51 } vizGeorefInterType;
52
53 //#define VIZ_GEOREF_SPLINE_MAX_POINTS 40
54 #define VIZGEOREF_MAX_VARS 2
55
56 class VizGeorefSpline2D
57 {
58 bool grow_points();
59
60 public:
61
62 explicit VizGeorefSpline2D(int nof_vars = 1) :
63 type(VIZ_GEOREF_SPLINE_ZERO_POINTS),
64 _nof_vars(nof_vars),
65 _nof_points(0),
66 _max_nof_points(0),
67 _nof_eqs(0),
68 #if 0
69 _tx(0.0),
70 _ty(0.0),
71 _ta(10.0),
72 #endif
73 _dx(0.0),
74 _dy(0.0),
75 x(nullptr),
76 y(nullptr),
77 u(nullptr),
78 unused(nullptr),
79 index(nullptr)
80 {
81 for( int i = 0; i < VIZGEOREF_MAX_VARS; i++ )
82 {
83 rhs[i] = nullptr;
84 coef[i] = nullptr;
85 }
86
87 grow_points();
88 }
89
90 ~VizGeorefSpline2D() {
91 CPLFree( x );
92 CPLFree( y );
93 CPLFree( u );
94 CPLFree( unused );
95 CPLFree( index );
96 for( int i = 0; i < _nof_vars; i++ )
97 {
98 CPLFree( rhs[i] );
99 CPLFree( coef[i] );
100 }
101 }
102
103 #if 0
104 int get_nof_points(){
105 return _nof_points;
106 }
107
108 void set_toler( double tx, double ty ){
109 _tx = tx;
110 _ty = ty;
111 }
112
113 void get_toler( double& tx, double& ty) {
114 tx = _tx;
115 ty = _ty;
116 }
117
118 vizGeorefInterType get_interpolation_type ( ){
119 return type;
120 }
121
122 void dump_data_points()
123 {
124 for ( int i = 0; i < _nof_points; i++ )
125 {
126 fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]);
127 for ( int v = 0; v < _nof_vars; v++ )
128 fprintf(stderr, "%f ", rhs[v][i+3]);
129 fprintf(stderr, "\n");
130 }
131 }
132
133 int delete_list()
134 {
135 _nof_points = 0;
136 type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
137 if ( _AA )
138 {
139 CPLFree(_AA);
140 _AA = NULL;
141 }
142 if ( _Ainv )
143 {
144 CPLFree(_Ainv);
145 _Ainv = NULL;
146 }
147 return _nof_points;
148 }
149 #endif
150
151 bool add_point( const double Px, const double Py, const double *Pvars );
152 int get_point( const double Px, const double Py, double *Pvars );
153 #if 0
154 int delete_point(const double Px, const double Py );
155 bool get_xy(int index, double& x, double& y);
156 bool change_point(int index, double x, double y, double* Pvars);
157 void reset(void) { _nof_points = 0; }
158 #endif
159 int solve(void);
160
161 private:
162
163 vizGeorefInterType type;
164
165 const int _nof_vars;
166 int _nof_points;
167 int _max_nof_points;
168 int _nof_eqs;
169
170 #if 0
171 // Disabled because the methods that use there is disabled.
172 double _tx, _ty;
173 double _ta;
174 #endif
175
176 double _dx, _dy;
177
178 double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
179 double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
180
181 // double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
182 // double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
183 double *rhs[VIZGEOREF_MAX_VARS];
184 double *coef[VIZGEOREF_MAX_VARS];
185
186 double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
187 int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
188 int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
189
190 private:
191 CPL_DISALLOW_COPY_ASSIGN(VizGeorefSpline2D)
192 };
193
194 #endif /* #ifndef DOXYGEN_SKIP */
195
196 #endif /* THINPLATESPLINE_H_INCLUDED */
CPLFree
#define CPLFree
Alias of VSIFree()
Definition: cpl_conv.h:81
cpl_conv.h
Various convenience functions for CPL.
gdal_alg.h
Public (C callable) GDAL algorithm entry points, and definitions.
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:987

Generated for GDAL by 1.8.8.