|
GDAL
|
00001 /****************************************************************************** 00002 * $Id: thinplatespline.h 36411 2016-11-21 22:03:48Z rouault $ 00003 * 00004 * Project: GDAL Warp API 00005 * Purpose: Declarations for 2D Thin Plate Spline transformer. 00006 * Author: VIZRT Development Team. 00007 * 00008 * This code was provided by Gilad Ronnen (gro at visrt dot com) with 00009 * permission to reuse under the following license. 00010 * 00011 ****************************************************************************** 00012 * Copyright (c) 2004, VIZRT Inc. 00013 * 00014 * Permission is hereby granted, free of charge, to any person obtaining a 00015 * copy of this software and associated documentation files (the "Software"), 00016 * to deal in the Software without restriction, including without limitation 00017 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00018 * and/or sell copies of the Software, and to permit persons to whom the 00019 * Software is furnished to do so, subject to the following conditions: 00020 * 00021 * The above copyright notice and this permission notice shall be included 00022 * in all copies or substantial portions of the Software. 00023 * 00024 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00025 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00026 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00027 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00028 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00029 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00030 * DEALINGS IN THE SOFTWARE. 00031 ****************************************************************************/ 00032 00033 #ifndef THINPLATESPLINE_H_INCLUDED 00034 #define THINPLATESPLINE_H_INCLUDED 00035 00036 #ifndef DOXYGEN_SKIP 00037 00038 #include "gdal_alg.h" 00039 #include "cpl_conv.h" 00040 00041 typedef enum 00042 { 00043 VIZ_GEOREF_SPLINE_ZERO_POINTS, 00044 VIZ_GEOREF_SPLINE_ONE_POINT, 00045 VIZ_GEOREF_SPLINE_TWO_POINTS, 00046 VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL, 00047 VIZ_GEOREF_SPLINE_FULL, 00048 00049 VIZ_GEOREF_SPLINE_POINT_WAS_ADDED, 00050 VIZ_GEOREF_SPLINE_POINT_WAS_DELETED 00051 } vizGeorefInterType; 00052 00053 //#define VIZ_GEOREF_SPLINE_MAX_POINTS 40 00054 #define VIZGEOREF_MAX_VARS 2 00055 00056 class VizGeorefSpline2D 00057 { 00058 bool grow_points(); 00059 00060 public: 00061 00062 explicit VizGeorefSpline2D(int nof_vars = 1) : 00063 type(VIZ_GEOREF_SPLINE_ZERO_POINTS), 00064 _nof_vars(nof_vars), 00065 _nof_points(0), 00066 _max_nof_points(0), 00067 _nof_eqs(0), 00068 #if 0 00069 _tx(0.0), 00070 _ty(0.0), 00071 _ta(10.0), 00072 #endif 00073 _dx(0.0), 00074 _dy(0.0), 00075 x(NULL), 00076 y(NULL), 00077 u(NULL), 00078 unused(NULL), 00079 index(NULL) 00080 { 00081 for( int i = 0; i < VIZGEOREF_MAX_VARS; i++ ) 00082 { 00083 rhs[i] = NULL; 00084 coef[i] = NULL; 00085 } 00086 00087 grow_points(); 00088 } 00089 00090 ~VizGeorefSpline2D() { 00091 CPLFree( x ); 00092 CPLFree( y ); 00093 CPLFree( u ); 00094 CPLFree( unused ); 00095 CPLFree( index ); 00096 for( int i = 0; i < _nof_vars; i++ ) 00097 { 00098 CPLFree( rhs[i] ); 00099 CPLFree( coef[i] ); 00100 } 00101 } 00102 00103 #if 0 00104 int get_nof_points(){ 00105 return _nof_points; 00106 } 00107 00108 void set_toler( double tx, double ty ){ 00109 _tx = tx; 00110 _ty = ty; 00111 } 00112 00113 void get_toler( double& tx, double& ty) { 00114 tx = _tx; 00115 ty = _ty; 00116 } 00117 00118 vizGeorefInterType get_interpolation_type ( ){ 00119 return type; 00120 } 00121 00122 void dump_data_points() 00123 { 00124 for ( int i = 0; i < _nof_points; i++ ) 00125 { 00126 fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]); 00127 for ( int v = 0; v < _nof_vars; v++ ) 00128 fprintf(stderr, "%f ", rhs[v][i+3]); 00129 fprintf(stderr, "\n"); 00130 } 00131 } 00132 00133 int delete_list() 00134 { 00135 _nof_points = 0; 00136 type = VIZ_GEOREF_SPLINE_ZERO_POINTS; 00137 if ( _AA ) 00138 { 00139 CPLFree(_AA); 00140 _AA = NULL; 00141 } 00142 if ( _Ainv ) 00143 { 00144 CPLFree(_Ainv); 00145 _Ainv = NULL; 00146 } 00147 return _nof_points; 00148 } 00149 #endif 00150 00151 bool add_point( const double Px, const double Py, const double *Pvars ); 00152 int get_point( const double Px, const double Py, double *Pvars ); 00153 #if 0 00154 int delete_point(const double Px, const double Py ); 00155 bool get_xy(int index, double& x, double& y); 00156 bool change_point(int index, double x, double y, double* Pvars); 00157 void reset(void) { _nof_points = 0; } 00158 #endif 00159 int solve(void); 00160 00161 private: 00162 00163 vizGeorefInterType type; 00164 00165 const int _nof_vars; 00166 int _nof_points; 00167 int _max_nof_points; 00168 int _nof_eqs; 00169 00170 #if 0 00171 // Disabled because the methods that use there is disabled. 00172 double _tx, _ty; 00173 double _ta; 00174 #endif 00175 00176 double _dx, _dy; 00177 00178 double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3]; 00179 double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3]; 00180 00181 // double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS]; 00182 // double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS]; 00183 double *rhs[VIZGEOREF_MAX_VARS]; 00184 double *coef[VIZGEOREF_MAX_VARS]; 00185 00186 double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; 00187 int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; 00188 int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; 00189 00190 private: 00191 CPL_DISALLOW_COPY_ASSIGN(VizGeorefSpline2D) 00192 }; 00193 00194 #endif /* #ifndef DOXYGEN_SKIP */ 00195 00196 #endif /* THINPLATESPLINE_H_INCLUDED */
1.7.6.1.