- Main Page
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# thinplatespline.h

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

Generated for GDAL by 1.4.5.