GDAL
thinplatespline.h
1 /******************************************************************************
2  * $Id: thinplatespline.h 26650 2013-11-24 14:05:58Z rouault $
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 
53 {
54  public:
55 
56  VizGeorefSpline2D(int nof_vars = 1){
57  x = y = u = NULL;
58  unused = index = NULL;
59  for( int i = 0; i < nof_vars; i++ )
60  {
61  rhs[i] = NULL;
62  coef[i] = NULL;
63  }
64 
65  _tx = _ty = 0.0;
66  _ta = 10.0;
67  _nof_points = 0;
68  _nof_vars = nof_vars;
69  _max_nof_points = 0;
70  grow_points();
71  type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
72  }
73 
75  CPLFree( x );
76  CPLFree( y );
77  CPLFree( u );
78  CPLFree( unused );
79  CPLFree( index );
80  for( int i = 0; i < _nof_vars; i++ )
81  {
82  CPLFree( rhs[i] );
83  CPLFree( coef[i] );
84  }
85  }
86 
87 #if 0
88  int get_nof_points(){
89  return _nof_points;
90  }
91 
92  void set_toler( double tx, double ty ){
93  _tx = tx;
94  _ty = ty;
95  }
96 
97  void get_toler( double& tx, double& ty) {
98  tx = _tx;
99  ty = _ty;
100  }
101 
102  vizGeorefInterType get_interpolation_type ( ){
103  return type;
104  }
105 
106  void dump_data_points()
107  {
108  for ( int i = 0; i < _nof_points; i++ )
109  {
110  fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]);
111  for ( int v = 0; v < _nof_vars; v++ )
112  fprintf(stderr, "%f ", rhs[v][i+3]);
113  fprintf(stderr, "\n");
114  }
115  }
116 
117  int delete_list()
118  {
119  _nof_points = 0;
120  type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
121  if ( _AA )
122  {
123  CPLFree(_AA);
124  _AA = NULL;
125  }
126  if ( _Ainv )
127  {
128  CPLFree(_Ainv);
129  _Ainv = NULL;
130  }
131  return _nof_points;
132  }
133 #endif
134 
135  void grow_points();
136  int add_point( const double Px, const double Py, const double *Pvars );
137  int get_point( const double Px, const double Py, double *Pvars );
138 #if 0
139  int delete_point(const double Px, const double Py );
140  bool get_xy(int index, double& x, double& y);
141  bool change_point(int index, double x, double y, double* Pvars);
142  void reset(void) { _nof_points = 0; }
143 #endif
144  int solve(void);
145 
146  private:
147 
148  vizGeorefInterType type;
149 
150  int _nof_vars;
151  int _nof_points;
152  int _max_nof_points;
153  int _nof_eqs;
154 
155  double _tx, _ty;
156  double _ta;
157  double _dx, _dy;
158 
159  double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
160  double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
161 
162 // double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
163 // double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
164  double *rhs[VIZGEOREF_MAX_VARS];
165  double *coef[VIZGEOREF_MAX_VARS];
166 
167  double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
168  int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
169  int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
170 };
Definition: thinplatespline.h:52
Various convenience functions for CPL.
Public (C callable) GDAL algorithm entry points, and definitions.

Generated for GDAL by doxygen 1.8.11.