PanoToolsTransformGPU.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00027 #include <hugin_config.h>
00028 
00029 #include <stdlib.h>
00030 
00031 #include "PanoToolsInterface.h"
00032 
00033 #include <iostream>
00034 #include <iomanip>
00035 
00036 using std::ostringstream;
00037 using std::endl;
00038 
00039 #define         distanceparam   (*((double*)params))
00040 #define         shift           (*((double*)params))
00041 #define         var0            ((double*)params)[0]
00042 #define         var1            ((double*)params)[1]
00043 #define         var2            ((double*)params)[2]
00044 #define         var3            ((double*)params)[3]
00045 #define         var4            ((double*)params)[4]
00046 #define         var5            ((double*)params)[5]
00047 #define         mp              ((struct MakeParams*)params)
00048 
00049 // Instead of discard, need to set coords to something far outside the src image and return.
00050 // e.g. (-1000, -1000).
00051 #define DISCARD "{ discardA = 0.0; discardB = 1.0; }"
00052 
00053 static void rotate_erect_glsl(ostringstream& oss, const void* params) {
00054     //oss << "    // rotate_erect(" << var0 << ", " << var1 << ")" << endl
00055     //    << "    " << ((var1 == 0.0) ? "//" : "") << "src.s += " << var1 << ";" << endl
00056     //    << "    while (src.s < " << -var0 << ") src.s += " << (2.0 * var0) << ";" << endl
00057     //    << "    while (src.s > " <<  var0 << ") src.s -= " << (2.0 * var0) << ";" << endl
00058     //    << endl;
00059 
00060     // Version without loops
00061     oss << "    // rotate_erect(" << var0 << ", " << var1 << ")" << endl
00062         << "    {" << endl
00063         << "        " << ((var1 == 0.0) ? "//" : "") << "src.s += " << var1 << ";" << endl
00064         << "        float w = (abs(src.s) > " << var0 << ") ? 1.0 : 0.0;" << endl
00065         << "        float n = (src.s < 0.0) ? 0.5 : -0.5;" << endl
00066         << "        src.s += w * " << (-2.0 * var0) << " * ceil(src.s / " << (2.0 * var0) << " + n);" << endl
00067         << "    }" << endl
00068         << endl;
00069 }
00070 
00071 static void resize_glsl(ostringstream& oss, const void* params) {
00072     oss << "    // resize(" << var0 << ", " << var1 << ")" << endl
00073         << "    src *= vec2(" << var0 << ", " << var1 << ");" << endl
00074         << endl;
00075 }
00076 
00077 static void vert_glsl(ostringstream& oss, const void* params) {
00078     oss << "    // vert(" << shift << ")" << endl
00079         << "    src.t += " << shift << ";" << endl
00080         << endl;
00081 }
00082 
00083 static void horiz_glsl(ostringstream& oss, const void* params) {
00084     oss << "    // horiz(" << shift << ")" << endl
00085         << "    src.s += " << shift << ";" << endl
00086         << endl;
00087 }
00088 
00089 static void shear_glsl(ostringstream& oss, const void* params) {
00090     oss << "    // shear(" << var0 << ", " << var1 << ")" << endl
00091         << "    src += (src.ts * vec2(" << var0 << ", " << var1 << "));" << endl
00092         << endl;
00093 }
00094 
00095 static void erect_pano_glsl(ostringstream& oss, const void* params) {
00096     oss << "    // erect_pano(" << distanceparam << ")" << endl
00097         << "    src.t = " << distanceparam << " * atan_safe(src.t / " << distanceparam << ");" << endl
00098         << endl;
00099 }
00100 
00101 static void erect_rect_glsl(ostringstream& oss, const void* params) {
00102     oss << "    // erect_rect(" << distanceparam << ")" << endl
00103         << "    src.t = " << distanceparam << " * atan2_xge0(src.t, length(vec2(" << distanceparam << ", src.s)));" << endl
00104         << "    src.s = " << distanceparam << " * atan2_safe(src.s, " << distanceparam << ");" << endl
00105         << endl;
00106 }
00107 
00108 static void erect_sphere_tp_glsl(ostringstream& oss, const void* params) {
00109     oss << "    // erect_sphere_tp(" << distanceparam << ")" << endl
00110         << "    {" << endl
00111         << "        float r = length(src);" << endl
00112         << "        float theta = r / " << distanceparam << ";" << endl
00113         << "        float s = " << (1.0 / distanceparam) << ";" << endl
00114         << "        if (theta != 0.0) { s = sin(theta) / r; }" << endl
00115         << "        float v1 = s * src.s;" << endl
00116         << "        float v0 = cos(theta);" << endl
00117         << "        src.s = " << distanceparam << " * atan2_safe(v1, v0);" << endl
00118         << "        src.t = " << distanceparam << " * atan_safe(s * src.t / length(vec2(v0, v1)));" << endl
00119         << "    }" << endl
00120         << endl;
00121 }
00122 
00123 static void sphere_tp_erect_glsl(ostringstream& oss, const void* params) {
00124     oss << "    // sphere_tp_erect(" << distanceparam << ")" << endl
00125         << "    {" << endl
00126         << "        float phi = src.s / " << distanceparam << ";" << endl
00127         << "        float theta = -src.t / " << distanceparam << " + " << (M_PI/2) << ";" << endl
00128         << "        if (theta < 0.0) {" << endl
00129         << "            theta = -theta;" << endl
00130         << "            phi += " << M_PI << ";" << endl
00131         << "        }" << endl
00132         << "        if (theta > " << M_PI << ") {" << endl
00133         << "            theta = " << M_PI << " - (theta - " << M_PI << ");" << endl
00134         << "            phi += " << M_PI << ";" << endl
00135         << "        }" << endl
00136         << "        float s = sin(theta);" << endl
00137         << "        vec2 v = vec2(s * sin(phi), cos(theta));" << endl
00138         << "        float r = length(v);" << endl
00139         << "        theta = " << distanceparam << " * atan2_safe(r, s * cos(phi));" << endl
00140         << "        src = v * (theta / r);" << endl
00141         << "    }" << endl
00142         << endl;
00143 }
00144 
00145 static void vertical_glsl(ostringstream& oss, const void* params) {
00146     oss << "    // vertical(" << var0 << ", " << var1 << ", " << var2 << ", " << var3 << ", " << var4 << ")" << endl
00147         << "    {" << endl
00148         << "        float r = abs(src.t / " << var4 << ");" << endl
00149         << "        float scale = ((" << var3 << " * r + " << var2 << ") * r + " << var1 << ") * r + " << var0 << ";" << endl
00150         << "        src.t *= scale;" << endl
00151         << "    }" << endl
00152         << endl;
00153 }
00154 
00155 static void deregister_glsl(ostringstream& oss, const void* params) {
00156     oss << "    // deregister(" << var1 << ", " << var2 << ", " << var3 << ", " << var4 << ")" << endl
00157         << "    {" << endl
00158         << "        float r = abs(src.t / " << var4 << ");" << endl
00159         << "        float scale = (" << var3 << " * r + " << var2 << ") * r + " << var1 << ";" << endl
00160         << "        src.s += abs(src.t) * scale;" << endl
00161         << "    }" << endl
00162         << endl;
00163 }
00164 
00165 static void radial_glsl(ostringstream& oss, const void* params) {
00166     oss << "    // radial(" << var0 << ", " << var1 << ", " << var2 << ", " << var3 << ", " << var4 << ", " << var5 << ")" << endl
00167         << "    {" << endl
00168         << "        float r = length(src) / " << var4 << ";" << endl
00169         << "        float scale = 1000.0; " << endl
00170         << "        if (r < " << var5 << ") {" << endl
00171         << "            scale = ((" << var3 << " * r + " << var2 << ") * r + " << var1 << ") * r + " << var0 << ";" << endl
00172         << "        }" << endl
00173         << "        src *= scale;" << endl
00174         << "    }" << endl
00175         << endl;
00176 }
00177 
00178 static void pano_sphere_tp_glsl(ostringstream& oss, const void* params) {
00179     oss << "    // pano_sphere_tp(" << distanceparam << ")" << endl
00180         << "    {" << endl
00181         << "        float r = length(src);" << endl
00182         << "        float theta = r / " << distanceparam << ";" << endl
00183         << "        float s = " << (1.0 / distanceparam) << ";" << endl
00184         << "        if (theta != 0.0) s = sin(theta) / r;" << endl
00185         << "        vec2 v = vec2(cos(theta), s * src.s);" << endl
00186         << "        src.s = " << distanceparam << " * atan2_safe(v.t, v.s);" << endl
00187         << "        src.t = " << distanceparam << " * s * src.t / length(v);" << endl
00188         << "    }" << endl
00189         << endl;
00190 }
00191 
00192 static void rect_sphere_tp_glsl(ostringstream& oss, const void* params) {
00193     oss << "    // rect_sphere_tp(" << distanceparam << ")" << endl
00194         << "    {" << endl
00195         << "        float r = length(src);" << endl
00196         << "        float theta = r / " << distanceparam << ";" << endl
00197         << "        float rho = 0.0;" << endl
00198         << "        if (theta >= " << (M_PI / 2.0) << ") rho = 1.6e16;" << endl
00199         << "        else if (theta == 0.0) rho = 1.0;" << endl
00200         << "        else rho = tan(theta) / theta;" << endl
00201         << "        src *= rho;" << endl
00202         << "    }" << endl
00203         << endl;
00204 }
00205 
00206 static void persp_sphere_glsl(ostringstream& oss, const void* params) {
00207     double d = *((double*) ((void**)params)[1]);
00208     double (*m)[3] = (double(*)[3]) ((void**)params)[0];
00209     oss << "    // persp_sphere(" << d << ")" << endl
00210         << "    {" << endl
00211         << "        mat3 m = mat3(" << m[0][0] << ", " << m[1][0] << ", " << m[2][0] << "," << endl
00212         << "                      " << m[0][1] << ", " << m[1][1] << ", " << m[2][1] << "," << endl
00213         << "                      " << m[0][2] << ", " << m[1][2] << ", " << m[2][2] << ");" << endl
00214         << "        float r = length(src);" << endl
00215         << "        float theta = r / " << d << ";" << endl
00216         << "        float s = 0.0;" << endl
00217         << "        if (r != 0.0) s = sin(theta) / r;" << endl
00218         << "        vec3 v = vec3(s * src.s, s * src.t, cos(theta));" << endl
00219         << "        vec3 u = v * m;" << endl
00220         << "        r = length(u.st);" << endl
00221         << "        theta = 0.0;" << endl
00222         << "        if (r != 0.0) theta = " << d << " * atan2_safe(r, u.p) / r;" << endl
00223         << "        src = theta * u.st;" << endl
00224         << "    }" << endl
00225         << endl;
00226 }
00227 
00228 static void erect_mercator_glsl(ostringstream& oss, const void* params) {
00229     oss << "    // erect_mercator(" << distanceparam << ")" << endl
00230         << "    src.t = " << distanceparam << " * atan_safe(sinh(src.t/" << distanceparam << "));" << endl
00231         << endl;
00232 }
00233 
00234 static void erect_millercylindrical_glsl(ostringstream& oss, const void* params) {
00235     oss << "    // erect_millercylindrical(" << distanceparam << ")" << endl
00236         << "    src.t = " << (1.25 * distanceparam) << " * atan_safe(sinh(src.t * " << (4 / (5.0 * distanceparam)) << "));" << endl
00237         << endl;
00238 }
00239 
00240 static void erect_lambert_glsl(ostringstream& oss, const void* params) {
00241     oss << "    // erect_lambert(" << distanceparam << ")" << endl
00242         << "    src.t = " << distanceparam << " * asin(src.t / " << distanceparam << ");" << endl
00243         << endl;
00244 }
00245 
00246 static void erect_transmercator_glsl(ostringstream& oss, const void* params) {
00247     oss << "    // erect_transmercator(" << distanceparam << ")" << endl
00248         << "    {" << endl
00249         << "        src /= " << distanceparam << ";" << endl
00250         << "        if (abs(src.t) > " << M_PI << ") " << DISCARD << endl
00251         << "        float x = src.s;" << endl
00252         << "        src.s = " << distanceparam << " * atan2_safe(sinh(src.s), cos(src.t));" << endl
00253         << "        src.t = " << distanceparam << " * asin(sin(src.t) / cosh(x));" << endl
00254         << "    }" << endl
00255         << endl;
00256 }
00257 
00258 static void erect_sinusoidal_glsl(ostringstream& oss, const void* params) {
00259     oss << "    // erect_sinusoidal(" << distanceparam << ")" << endl
00260         << "    src.s /= cos(src.t / " << distanceparam << ");" << endl
00261         << "    if (abs(src.s) > " << (M_PI * distanceparam) << ") " << DISCARD << endl
00262         << endl;
00263 }
00264 
00265 static void erect_lambertazimuthal_glsl(ostringstream& oss, const void* params) {
00266     oss << "    // erect_lambertazimuthal(" << distanceparam << ")" << endl
00267         << "    {" << endl
00268         << "        src /= " << distanceparam << ";" << endl
00269         << "        if (any(greaterThan(abs(src), vec2(" << M_PI << ", " << M_PI << ")))) " << DISCARD << endl
00270         << "        float ro = length(src);" << endl
00271         << "        if (abs(ro) <= 1.0e-10) src = vec2(0.0, 0.0);" << endl
00272         << "        else {" << endl
00273         << "            float c = 2.0 * asin(ro / 2.0);" << endl
00274         << "            src.t = " << distanceparam << " * asin((src.t * sin(c)) / ro);" << endl
00275         << "            if (abs(ro * cos(c)) <= 1.0e-10) src.s = 0.0;" << endl
00276         << "            else src.s = " << distanceparam << " * atan2_safe(src.s * sin(c), (ro * cos(c)));" << endl
00277         << "        }" << endl
00278         << "    }" << endl
00279         << endl;
00280 }
00281 
00282 static void erect_hammer_glsl(ostringstream& oss, const void* params) {
00283     oss << "    // erect_hammer(" << distanceparam << ")" << endl
00284         << "    {" << endl
00285         << "        src /= " << distanceparam << ";" << endl
00286         << "        float z2 = 1.0 - src.s * src.s / 16.0 - src.t * src.t / 4.0;" << endl
00287         << "        if (z2 < 0 ) " << DISCARD << endl
00288         << "        float z = sqrt(z2);" << endl
00289         << "        src.s = 2.0 * atan2_safe( z * src.s, 2.0*(2.0*z2-1.0));" << endl
00290         << "        src.t = asin (src.t * z);" << endl
00291         << "        if(any(greaterThan(abs(src), vec2(" << M_PI << "," << HALF_PI << "))))" << DISCARD << endl
00292         << "        src *= " << distanceparam << ";" << endl
00293         << "    }" << endl
00294         << endl;
00295 }
00296 
00297 static void erect_arch_glsl(ostringstream& oss, const void* params) {
00298     oss << "    // erect_arch(" << distanceparam << ")" << endl
00299         << "    {" << endl
00300         << "        if(src.t < 0) {" << endl
00301         << "            src.t = " << (1.25 * distanceparam) << " * atan_safe(sinh(src.t * " << (4 / (5.0 * distanceparam)) << "));" << endl
00302         << "        } else {" << endl
00303         << "            src.t = " << distanceparam << " * asin(src.t / " << distanceparam << ");" << endl
00304         << "        }" << endl
00305         << "    }" << endl
00306         << endl;
00307 }
00308 
00309 static void erect_stereographic_glsl(ostringstream& oss, const void* params) {
00310     oss << "    // erect_stereographic(" << distanceparam << ")" << endl
00311         << "    {" << endl
00312         << "        src /= " << distanceparam << ";" << endl
00313         << "        float rh = length(src);" << endl
00314         << "        float c = 2.0 * atan_safe(rh / 2.0);" << endl
00315         << "        float sin_c = sin(c);" << endl
00316         << "        float cos_c = cos(c);" << endl
00317         << "        if (abs(rh) <= 1.0e-10) " << DISCARD << endl
00318         << "        src.t = asin((src.t * sin_c) / rh) * " << distanceparam << ";" << endl
00319         << "        if (abs(cos_c) < 1.0e-10 && abs(src.s) < 1.0e-10) " << DISCARD << endl
00320         << "        float y = src.s * sin_c;" << endl
00321         << "        float x = cos_c * rh;" << endl
00322         << "        src.s = atan2_safe(y, x) * " << distanceparam << ";" << endl
00323         << "    }" << endl
00324         << endl;
00325 }
00326 
00327 static void stereographic_erect_glsl(ostringstream& oss, const void* params) {
00328     oss << "    // stereographic_erect(" << distanceparam << ")" << endl
00329         << "    {" << endl
00330         << "        src /= " << distanceparam << ";" << endl
00331         << "        vec2 cos_lon_lat=cos(src);" << endl
00332         << "        float g=cos_lon_lat.s * cos_lon_lat.t;" << endl
00333         << "        src = " << distanceparam << " * 2.0 / (1.0 + g) * vec2(cos_lon_lat.t * sin(src.s), sin(src.t));" << endl
00334         << "    }" << endl
00335         << endl;
00336 }
00337 
00338 static void erect_albersequalareaconic_glsl(ostringstream& oss, const void* params) {
00339     oss << "    // erect_albersequalareaconic(...)" << endl
00340         << "    {" << endl;
00341 
00342     // Get the albersEqualAreaConic_ParamCheck to run.
00343     double junk0, junk1;
00344     int result = erect_albersequalareaconic(0.0, 0.0, &junk0, &junk1, const_cast<void*>(params));
00345     if (result == 0) {
00346         oss << "        // albersEqualAreaConic_ParamCheck failed" << endl;
00347     }
00348 
00349     const double n = mp->pn->precomputedValue[3];
00350     const double C = mp->pn->precomputedValue[4];
00351     const double rho0 = mp->pn->precomputedValue[5];
00352     const double yoffset = mp->pn->precomputedValue[6];
00353     const double n2 = mp->pn->precomputedValue[7];
00354     const double twiceN = mp->pn->precomputedValue[9];
00355 
00356     oss << "        src /= " << mp->distance << ";" << endl
00357         << "        src.t += " << yoffset << ";" << endl
00358         << "        float rho2 = (src.s * src.s + (" << rho0 << " - src.t) * (" << rho0 << " - src.t));" << endl
00359         << "        float theta = atan2_safe(" << ((n < 0) ? "-" : "") << "src.s, " << ((n < 0) ? "-1.0 * " : "") << "(" << rho0 << " - src.t));" << endl
00360         << "        float phi = asin((" << C << " - rho2 * " << n2 << ") / " << twiceN << ");" << endl
00361         << "        float lambda = theta / " << n << ";" << endl
00362         << "        if (abs(lambda) > " << M_PI << ") " << DISCARD << endl
00363         << "        src.s = " << mp->distance << " * lambda;" << endl
00364         << "        src.t = " << mp->distance << " * phi;" << endl
00365         << "    }" << endl
00366         << endl;
00367 
00368 }
00369 
00370 static void lambertazimuthal_erect_glsl(ostringstream& oss, const void* params) {
00371     oss << "    // lambertazimuthal_erect(" << distanceparam << ")" << endl
00372         << "    {" << endl
00373         << "        src /= " << distanceparam << ";" << endl
00374         << "        float a=cos(src.t) * cos(src.s) + 1.0;" << endl
00375         << "        if (abs(a) <= 1e-10) " << DISCARD << endl
00376         << "        src = " << distanceparam << " * sqrt (2.0/a) * vec2 ( cos(src.t) * sin(src.s), sin(src.t));" << endl
00377         << "    }" << endl
00378         << endl;
00379 }
00380 
00381 static void sphere_tp_equisolid_glsl(ostringstream& oss, const void* params) {
00382     oss << "    // sphere_tp_equisolid(" << distanceparam << ")" << endl
00383         << "    {" << endl
00384         << "        float phi = atan2_safe(src.t, src.s);" << endl
00385         << "        src = " << distanceparam << " * 2.0 * asin( length(src) / (2.0 * " << distanceparam << ")) * vec2 (cos(phi), sin(phi));" << endl
00386         << "    }" << endl
00387         << endl;
00388 }
00389 
00390 static void sphere_tp_orthographic_glsl(ostringstream& oss, const void* params) {
00391     oss << "    // sphere_tp_orthographic(" << distanceparam << ")" << endl
00392         << "    {" << endl
00393         << "        float rho=length(src);" << endl
00394         << "        if (rho >" << distanceparam << ") " << DISCARD << endl
00395         << "        float phi = atan2_safe(src.t, src.s);" << endl
00396         << "        src = " << distanceparam << " * asin( rho / " << distanceparam << ") * vec2 (cos(phi), sin(phi));" << endl
00397         << "    }" << endl
00398         << endl;
00399 }
00400 
00401 static void orthographic_sphere_tp_glsl(ostringstream& oss, const void* params) {
00402     oss << "    // orthographic_sphere_tp(" << distanceparam << ")" << endl
00403         << "    {" << endl
00404         << "        float theta = length(src) / " << distanceparam << ";" << endl
00405         << "        float phi = atan2_safe(src.t, src.s);" << endl
00406         << "        if ( abs(theta) > " << HALF_PI << ") " << DISCARD << endl
00407         << "        " << endl
00408         << "        src = " << distanceparam << " * sin( theta ) * vec2 (cos(phi), sin(phi));" << endl
00409         << "    }" << endl
00410         << endl;
00411 }
00412 
00413 static void sphere_tp_thoby_glsl(ostringstream& oss, const void* params) {
00414     oss << "    // sphere_tp_thoby(" << distanceparam << ")" << endl
00415         << "    {" << endl
00416         << "        float rho = length(src) / " << distanceparam << ";" << endl
00417         << "        if (abs(rho) > " << THOBY_K1_PARM << ") " << DISCARD << endl
00418         << "        float phi = atan2_safe(src.t, src.s);" << endl
00419         << "        src = " << distanceparam << " * asin(rho/" << THOBY_K1_PARM << ") / " << THOBY_K2_PARM << " * vec2 (cos(phi), sin(phi));" << endl
00420         << "    }" << endl
00421         << endl;
00422 }
00423 
00424 static void thoby_sphere_tp_glsl(ostringstream& oss, const void* params) {
00425     oss << "    // thoby_sphere_tp(" << distanceparam << ")" << endl
00426         << "    {" << endl
00427         << "        float theta = length(src) / " << distanceparam << ";" << endl
00428         << "        float phi = atan2_safe(src.t, src.s);" << endl
00429         << "        src = " << distanceparam << " * " << THOBY_K1_PARM << " * sin(theta * " << THOBY_K2_PARM << ") * vec2 (cos(phi), sin(phi));" << endl
00430         << "    }" << endl
00431         << endl;
00432 }
00433 
00434 static void plane_transfer_to_camera_glsl(ostringstream& oss, const void* params) {
00435     oss << "    // plane_transfer_to_camera" << endl
00436         << "    //     distance   : " << mp->distance << endl
00437         << "    //     x          : " << mp->trans[0] << endl
00438         << "    //     y          : " << mp->trans[1] << endl
00439         << "    //     z          : " << mp->trans[2] << endl
00440         << "    //     plane yaw  : " << mp->trans[3] << endl
00441         << "    //     plane pitch: " << mp->trans[4] << endl
00442         << "    {" << endl
00443         << "        float phi = src.s / " << mp->distance << ";" << endl
00444         << "        float theta = " << HALF_PI << " - src.t / " << mp->distance << ";" << endl
00445         << "        vec3 p = vec3(sin(theta)*sin(phi), cos(theta), sin(theta)*-cos(phi));" << endl
00446         << "        vec3 plane_coeff=vec3(" << sin(HALF_PI+mp->trans[4])*sin(mp->trans[3]) << ", " << cos(HALF_PI+mp->trans[4]) << ", " << sin(HALF_PI+mp->trans[4])*-cos(mp->trans[3]) << ");" << endl
00447         << "        float den = -dot(plane_coeff, p);" << endl
00448         << "        if ( abs(den) < 1E-15 ) " << DISCARD << endl
00449         << "        float u = length(plane_coeff);" << endl
00450         << "        u = -u * u / den;" << endl
00451         << "        if ( u < 0 ) " << DISCARD << endl
00452         << "        p *= u;" << endl
00453         << "        p -= vec3(" << mp->trans[0] << "," << mp->trans[1] << "," << mp->trans[2] << ");" << endl
00454         << "        src = " << mp->distance << " * vec2( atan2_safe(p.s, -p.p), asin(p.t/length(p)));" << endl
00455         << "    }" << endl
00456         << endl;
00457 }
00458 
00459 namespace HuginBase { namespace PTools {
00460 
00461 bool Transform::emitGLSL(ostringstream& oss) const {
00462 
00463     oss << "    vec2 src = gl_TexCoord[0].st;" << endl
00464         << "    src -= vec2(" << m_srcTX << ", " << m_srcTY << ");" << endl
00465         << endl;
00466 
00467     bool foundUnsupportedFunction = false;
00468     int i = 0;
00469     const fDesc* stack = m_stack;
00470 
00471     while ( (stack->func) != NULL ) {
00472         if      (stack->func == rotate_erect)               rotate_erect_glsl(oss, stack->param);
00473         else if (stack->func == resize)                     resize_glsl(oss, stack->param);
00474         else if (stack->func == vert)                       vert_glsl(oss, stack->param);
00475         else if (stack->func == horiz)                      horiz_glsl(oss, stack->param);
00476         else if (stack->func == shear)                      shear_glsl(oss, stack->param);
00477         else if (stack->func == erect_pano)                 erect_pano_glsl(oss, stack->param);
00478         else if (stack->func == erect_rect)                 erect_rect_glsl(oss, stack->param);
00479         else if (stack->func == erect_sphere_tp)            erect_sphere_tp_glsl(oss, stack->param);
00480         else if (stack->func == sphere_tp_erect)            sphere_tp_erect_glsl(oss, stack->param);
00481         else if (stack->func == vertical)                   vertical_glsl(oss, stack->param);
00482         else if (stack->func == deregister)                 deregister_glsl(oss, stack->param);
00483         else if (stack->func == radial)                     radial_glsl(oss, stack->param);
00484         else if (stack->func == pano_sphere_tp)             pano_sphere_tp_glsl(oss, stack->param);
00485         else if (stack->func == rect_sphere_tp)             rect_sphere_tp_glsl(oss, stack->param);
00486         else if (stack->func == persp_sphere)               persp_sphere_glsl(oss, stack->param);
00487         else if (stack->func == erect_mercator)             erect_mercator_glsl(oss, stack->param);
00488         else if (stack->func == erect_millercylindrical)    erect_millercylindrical_glsl(oss, stack->param);
00489         else if (stack->func == erect_lambert)              erect_lambert_glsl(oss, stack->param);
00490         else if (stack->func == erect_transmercator)        erect_transmercator_glsl(oss, stack->param);
00491         else if (stack->func == erect_sinusoidal)           erect_sinusoidal_glsl(oss, stack->param);
00492         else if (stack->func == erect_lambertazimuthal)     erect_lambertazimuthal_glsl(oss, stack->param);
00493         else if (stack->func == erect_stereographic)        erect_stereographic_glsl(oss, stack->param);
00494         else if (stack->func == erect_albersequalareaconic) erect_albersequalareaconic_glsl(oss, stack->param);
00495         else if (stack->func == erect_hammer)               erect_hammer_glsl(oss, stack->param);
00496         else if (stack->func == erect_arch)                 erect_arch_glsl(oss, stack->param);
00497         else if (stack->func == stereographic_erect)        stereographic_erect_glsl(oss, stack->param);
00498         else if (stack->func == lambertazimuthal_erect)     lambertazimuthal_erect_glsl(oss, stack->param);
00499         else if (stack->func == sphere_tp_equisolid)        sphere_tp_equisolid_glsl(oss, stack->param);
00500         else if (stack->func == sphere_tp_orthographic)     sphere_tp_orthographic_glsl(oss, stack->param);
00501         else if (stack->func == orthographic_sphere_tp)     orthographic_sphere_tp_glsl(oss, stack->param);
00502         else if (stack->func == sphere_tp_thoby)            sphere_tp_thoby_glsl(oss, stack->param);
00503         else if (stack->func == thoby_sphere_tp)            thoby_sphere_tp_glsl(oss, stack->param);
00504         else if (stack->func == plane_transfer_to_camera)   plane_transfer_to_camera_glsl(oss, stack->param);
00505         else {
00506             oss << "    // Unknown function " << (const void*)stack->func << endl << endl;
00507             foundUnsupportedFunction = true;
00508         }
00509         ++stack;
00510         ++i;
00511     }
00512 
00513     oss << "    src += vec2(" << (m_destTX-0.5) << ", " << (m_destTY-0.5) << ");" << endl
00514         << endl;
00515 
00516     return !foundUnsupportedFunction;
00517 }
00518 
00519 bool Transform::transformImgCoordPartial(double & x_dest, double & y_dest, double x_src, double y_src) const
00520 {
00521     x_src -= m_srcTX - 0.5;
00522     y_src -= m_srcTY - 0.5;
00523 
00524     double xd = x_src;
00525     double yd = y_src;
00526 
00527     const fDesc* stack = m_stack;
00528 
00529     for (int i = 0; i < 2; ++i) {
00530         if ((stack->func) == NULL) break;
00531         if ( (stack->func)(xd, yd, &x_dest, &y_dest, stack->param) ) {
00532             xd = x_dest;
00533             yd = y_dest;
00534             stack++;
00535         } else {
00536             return 0;
00537         }
00538     }
00539  
00540     x_dest += m_destTX - 0.5;
00541     y_dest += m_destTY - 0.5;
00542 
00543     return 1;
00544 }
00545 
00546     
00547 }} // namespace

Generated on 30 Oct 2014 for Hugintrunk by  doxygen 1.4.7