- Main Page
- Related Pages
- Classes
- Files

# thinplatespline.h

    00001 /******************************************************************************
    00002  * $Id: thinplatespline.h 20193 2010-08-06 17:12:10Z 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 #include "gdal_alg.h"
    00034 #include "cpl_conv.h"
    00035
    00036 typedef enum
    00037 {
    00038         VIZ_GEOREF_SPLINE_ZERO_POINTS,
    00039         VIZ_GEOREF_SPLINE_ONE_POINT,
    00040         VIZ_GEOREF_SPLINE_TWO_POINTS,
    00041         VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL,
    00042         VIZ_GEOREF_SPLINE_FULL,
    00043
    00044         VIZ_GEOREF_SPLINE_POINT_WAS_ADDED,
    00045         VIZ_GEOREF_SPLINE_POINT_WAS_DELETED
    00046
    00047 } vizGeorefInterType;
    00048
    00049 //#define VIZ_GEOREF_SPLINE_MAX_POINTS 40
    00050 #define VIZGEOREF_MAX_VARS 2
    00051
    00052 class VizGeorefSpline2D
    00053 {
    00054   public:
    00055
    00056     VizGeorefSpline2D(int nof_vars = 1){
    00057         x = y = u = NULL;
    00058         unused = index = NULL;
    00059         for( int i = 0; i < nof_vars; i++ )
    00060         {
    00061             rhs[i] = NULL;
    00062             coef[i] = NULL;
    00063         }
    00064
    00065         _tx = _ty = 0.0;
    00066         _ta = 10.0;
    00067         _nof_points = 0;
    00068         _nof_vars = nof_vars;
    00069         _max_nof_points = 0;
    00070         _AA = NULL;
    00071         _Ainv = NULL;
    00072         grow_points();
    00073         type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
    00074     }
    00075
    00076     ~VizGeorefSpline2D(){
    00077         if ( _AA )
    00078             CPLFree(_AA);
    00079         if ( _Ainv )
    00080             CPLFree(_Ainv);
    00081
    00082         CPLFree( x );
    00083         CPLFree( y );
    00084         CPLFree( u );
    00085         CPLFree( unused );
    00086         CPLFree( index );
    00087         for( int i = 0; i < _nof_vars; i++ )
    00088         {
    00089             CPLFree( rhs[i] );
    00090             CPLFree( coef[i] );
    00091         }
    00092     }
    00093
    00094     int get_nof_points(){
    00095         return _nof_points;
    00096     }
    00097
    00098     void set_toler( double tx, double ty ){
    00099         _tx = tx;
    00100         _ty = ty;
    00101     }
    00102
    00103     void get_toler( double& tx, double& ty) {
    00104         tx = _tx;
    00105         ty = _ty;
    00106     }
    00107
    00108     vizGeorefInterType get_interpolation_type ( ){
    00109         return type;
    00110     }
    00111
    00112     void dump_data_points()
    00113         {
    00114             for ( int i = 0; i < _nof_points; i++ )
    00115             {
    00116                 fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]);
    00117                 for ( int v = 0; v < _nof_vars; v++ )
    00118                     fprintf(stderr, "%f ", rhs[v][i+3]);
    00119                 fprintf(stderr, "\n");
    00120             }
    00121         }
    00122     int delete_list()
    00123         {
    00124             _nof_points = 0;
    00125             type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
    00126             if ( _AA )
    00127             {
    00128                 CPLFree(_AA);
    00129                 _AA = NULL;
    00130             }
    00131             if ( _Ainv )
    00132             {
    00133                 CPLFree(_Ainv);
    00134                 _Ainv = NULL;
    00135             }
    00136             return _nof_points;
    00137         }
    00138
    00139     void grow_points();
    00140     int add_point( const double Px, const double Py, const double *Pvars );
    00141     int delete_point(const double Px, const double Py );
    00142     int get_point( const double Px, const double Py, double *Pvars );
    00143     bool get_xy(int index, double& x, double& y);
    00144     bool change_point(int index, double x, double y, double* Pvars);
    00145     void reset(void) { _nof_points = 0; }
    00146     int solve(void);
    00147
    00148   private:
    00149     double base_func( const double x1, const double y1,
    00150                       const double x2, const double y2 );
    00151
    00152     vizGeorefInterType type;
    00153
    00154     int _nof_vars;
    00155     int _nof_points;
    00156     int _max_nof_points;
    00157     int _nof_eqs;
    00158
    00159     double _tx, _ty;
    00160     double _ta;
    00161     double _dx, _dy;
    00162
    00163     double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
    00164     double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3];
    00165
    00166 //    double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
    00167 //    double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
    00168     double *rhs[VIZGEOREF_MAX_VARS];
    00169     double *coef[VIZGEOREF_MAX_VARS];
    00170
    00171     double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
    00172     int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
    00173     int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS];
    00174
    00175     double *_AA, *_Ainv;
    00176 };
    00177
    00178

Generated for GDAL by 1.5.6.