Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PanoToolsTransformGPU.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #include <hugin_config.h>
28 
29 #include <stdlib.h>
30 
31 #include "PanoToolsInterface.h"
32 
33 #include <iostream>
34 #include <iomanip>
35 
36 using std::ostringstream;
37 using std::endl;
38 
39 #define distanceparam (*((double*)params))
40 #define shift (*((double*)params))
41 #define var0 ((double*)params)[0]
42 #define var1 ((double*)params)[1]
43 #define var2 ((double*)params)[2]
44 #define var3 ((double*)params)[3]
45 #define var4 ((double*)params)[4]
46 #define var5 ((double*)params)[5]
47 #define mp ((struct MakeParams*)params)
48 
49 // Instead of discard, need to set coords to something far outside the src image and return.
50 // e.g. (-1000, -1000).
51 #define DISCARD "{ discardA = 0.0; discardB = 1.0; }"
52 
53 static void rotate_erect_glsl(ostringstream& oss, const void* params) {
54  //oss << " // rotate_erect(" << var0 << ", " << var1 << ")" << endl
55  // << " " << ((var1 == 0.0) ? "//" : "") << "src.s += " << var1 << ";" << endl
56  // << " while (src.s < " << -var0 << ") src.s += " << (2.0 * var0) << ";" << endl
57  // << " while (src.s > " << var0 << ") src.s -= " << (2.0 * var0) << ";" << endl
58  // << endl;
59 
60  // Version without loops
61  oss << " // rotate_erect(" << var0 << ", " << var1 << ")" << endl
62  << " {" << endl
63  << " " << ((var1 == 0.0) ? "//" : "") << "src.s += " << var1 << ";" << endl
64  << " float w = (abs(src.s) > " << var0 << ") ? 1.0 : 0.0;" << endl
65  << " float n = (src.s < 0.0) ? 0.5 : -0.5;" << endl
66  << " src.s += w * " << (-2.0 * var0) << " * ceil(src.s / " << (2.0 * var0) << " + n);" << endl
67  << " }" << endl
68  << endl;
69 }
70 
71 static void resize_glsl(ostringstream& oss, const void* params) {
72  oss << " // resize(" << var0 << ", " << var1 << ")" << endl
73  << " src *= vec2(" << var0 << ", " << var1 << ");" << endl
74  << endl;
75 }
76 
77 static void vert_glsl(ostringstream& oss, const void* params) {
78  oss << " // vert(" << shift << ")" << endl
79  << " src.t += " << shift << ";" << endl
80  << endl;
81 }
82 
83 static void horiz_glsl(ostringstream& oss, const void* params) {
84  oss << " // horiz(" << shift << ")" << endl
85  << " src.s += " << shift << ";" << endl
86  << endl;
87 }
88 
89 static void shear_glsl(ostringstream& oss, const void* params) {
90  oss << " // shear(" << var0 << ", " << var1 << ")" << endl
91  << " src += (src.ts * vec2(" << var0 << ", " << var1 << "));" << endl
92  << endl;
93 }
94 
95 static void erect_pano_glsl(ostringstream& oss, const void* params) {
96  oss << " // erect_pano(" << distanceparam << ")" << endl
97  << " src.t = " << distanceparam << " * atan_safe(src.t / " << distanceparam << ");" << endl
98  << endl;
99 }
100 
101 static void erect_rect_glsl(ostringstream& oss, const void* params) {
102  oss << " // erect_rect(" << distanceparam << ")" << endl
103  << " src.t = " << distanceparam << " * atan2_xge0(src.t, length(vec2(" << distanceparam << ", src.s)));" << endl
104  << " src.s = " << distanceparam << " * atan2_safe(src.s, " << distanceparam << ");" << endl
105  << endl;
106 }
107 
108 static void erect_sphere_tp_glsl(ostringstream& oss, const void* params) {
109  oss << " // erect_sphere_tp(" << distanceparam << ")" << endl
110  << " {" << endl
111  << " float r = length(src);" << endl
112  << " float theta = r / " << distanceparam << ";" << endl
113  << " float s = " << (1.0 / distanceparam) << ";" << endl
114  << " if (theta != 0.0) { s = sin(theta) / r; }" << endl
115  << " float v1 = s * src.s;" << endl
116  << " float v0 = cos(theta);" << endl
117  << " src.s = " << distanceparam << " * atan2_safe(v1, v0);" << endl
118  << " src.t = " << distanceparam << " * atan_safe(s * src.t / length(vec2(v0, v1)));" << endl
119  << " }" << endl
120  << endl;
121 }
122 
123 static void sphere_tp_erect_glsl(ostringstream& oss, const void* params) {
124  oss << " // sphere_tp_erect(" << distanceparam << ")" << endl
125  << " {" << endl
126  << " float phi = src.s / " << distanceparam << ";" << endl
127  << " float theta = -src.t / " << distanceparam << " + " << (M_PI/2) << ";" << endl
128  << " if (theta < 0.0) {" << endl
129  << " theta = -theta;" << endl
130  << " phi += " << M_PI << ";" << endl
131  << " }" << endl
132  << " if (theta > " << M_PI << ") {" << endl
133  << " theta = " << M_PI << " - (theta - " << M_PI << ");" << endl
134  << " phi += " << M_PI << ";" << endl
135  << " }" << endl
136  << " float s = sin(theta);" << endl
137  << " vec2 v = vec2(s * sin(phi), cos(theta));" << endl
138  << " float r = length(v);" << endl
139  << " theta = " << distanceparam << " * atan2_safe(r, s * cos(phi));" << endl
140  << " src = v * (theta / r);" << endl
141  << " }" << endl
142  << endl;
143 }
144 
145 static void vertical_glsl(ostringstream& oss, const void* params) {
146  oss << " // vertical(" << var0 << ", " << var1 << ", " << var2 << ", " << var3 << ", " << var4 << ")" << endl
147  << " {" << endl
148  << " float r = abs(src.t / " << var4 << ");" << endl
149  << " float scale = ((" << var3 << " * r + " << var2 << ") * r + " << var1 << ") * r + " << var0 << ";" << endl
150  << " src.t *= scale;" << endl
151  << " }" << endl
152  << endl;
153 }
154 
155 static void deregister_glsl(ostringstream& oss, const void* params) {
156  oss << " // deregister(" << var1 << ", " << var2 << ", " << var3 << ", " << var4 << ")" << endl
157  << " {" << endl
158  << " float r = abs(src.t / " << var4 << ");" << endl
159  << " float scale = (" << var3 << " * r + " << var2 << ") * r + " << var1 << ";" << endl
160  << " src.s += abs(src.t) * scale;" << endl
161  << " }" << endl
162  << endl;
163 }
164 
165 static void radial_glsl(ostringstream& oss, const void* params) {
166  oss << " // radial(" << var0 << ", " << var1 << ", " << var2 << ", " << var3 << ", " << var4 << ", " << var5 << ")" << endl
167  << " {" << endl
168  << " float r = length(src) / " << var4 << ";" << endl
169  << " float scale = 1000.0; " << endl
170  << " if (r < " << var5 << ") {" << endl
171  << " scale = ((" << var3 << " * r + " << var2 << ") * r + " << var1 << ") * r + " << var0 << ";" << endl
172  << " }" << endl
173  << " src *= scale;" << endl
174  << " }" << endl
175  << endl;
176 }
177 
178 static void pano_sphere_tp_glsl(ostringstream& oss, const void* params) {
179  oss << " // pano_sphere_tp(" << distanceparam << ")" << endl
180  << " {" << endl
181  << " float r = length(src);" << endl
182  << " float theta = r / " << distanceparam << ";" << endl
183  << " float s = " << (1.0 / distanceparam) << ";" << endl
184  << " if (theta != 0.0) s = sin(theta) / r;" << endl
185  << " vec2 v = vec2(cos(theta), s * src.s);" << endl
186  << " src.s = " << distanceparam << " * atan2_safe(v.t, v.s);" << endl
187  << " src.t = " << distanceparam << " * s * src.t / length(v);" << endl
188  << " }" << endl
189  << endl;
190 }
191 
192 static void rect_sphere_tp_glsl(ostringstream& oss, const void* params) {
193  oss << " // rect_sphere_tp(" << distanceparam << ")" << endl
194  << " {" << endl
195  << " float r = length(src);" << endl
196  << " float theta = r / " << distanceparam << ";" << endl
197  << " float rho = 0.0;" << endl
198  << " if (theta >= " << (M_PI / 2.0) << ") rho = 1.6e16;" << endl
199  << " else if (theta == 0.0) rho = 1.0;" << endl
200  << " else rho = tan(theta) / theta;" << endl
201  << " src *= rho;" << endl
202  << " }" << endl
203  << endl;
204 }
205 
206 static void persp_sphere_glsl(ostringstream& oss, const void* params) {
207  double d = *((double*) ((void**)params)[1]);
208  double (*m)[3] = (double(*)[3]) ((void**)params)[0];
209  oss << " // persp_sphere(" << d << ")" << endl
210  << " {" << endl
211  << " mat3 m = mat3(" << m[0][0] << ", " << m[1][0] << ", " << m[2][0] << "," << endl
212  << " " << m[0][1] << ", " << m[1][1] << ", " << m[2][1] << "," << endl
213  << " " << m[0][2] << ", " << m[1][2] << ", " << m[2][2] << ");" << endl
214  << " float r = length(src);" << endl
215  << " float theta = r / " << d << ";" << endl
216  << " float s = 0.0;" << endl
217  << " if (r != 0.0) s = sin(theta) / r;" << endl
218  << " vec3 v = vec3(s * src.s, s * src.t, cos(theta));" << endl
219  << " vec3 u = v * m;" << endl
220  << " r = length(u.st);" << endl
221  << " theta = 0.0;" << endl
222  << " if (r != 0.0) theta = " << d << " * atan2_safe(r, u.p) / r;" << endl
223  << " src = theta * u.st;" << endl
224  << " }" << endl
225  << endl;
226 }
227 
228 static void erect_mercator_glsl(ostringstream& oss, const void* params) {
229  oss << " // erect_mercator(" << distanceparam << ")" << endl
230  << " src.t = " << distanceparam << " * atan_safe(sinh(src.t/" << distanceparam << "));" << endl
231  << endl;
232 }
233 
234 static void erect_millercylindrical_glsl(ostringstream& oss, const void* params) {
235  oss << " // erect_millercylindrical(" << distanceparam << ")" << endl
236  << " src.t = " << (1.25 * distanceparam) << " * atan_safe(sinh(src.t * " << (4 / (5.0 * distanceparam)) << "));" << endl
237  << endl;
238 }
239 
240 static void erect_lambert_glsl(ostringstream& oss, const void* params) {
241  oss << " // erect_lambert(" << distanceparam << ")" << endl
242  << " src.t = " << distanceparam << " * asin(src.t / " << distanceparam << ");" << endl
243  << endl;
244 }
245 
246 static void erect_transmercator_glsl(ostringstream& oss, const void* params) {
247  oss << " // erect_transmercator(" << distanceparam << ")" << endl
248  << " {" << endl
249  << " src /= " << distanceparam << ";" << endl
250  << " if (abs(src.t) > " << M_PI << ") " << DISCARD << endl
251  << " float x = src.s;" << endl
252  << " src.s = " << distanceparam << " * atan2_safe(sinh(src.s), cos(src.t));" << endl
253  << " src.t = " << distanceparam << " * asin(sin(src.t) / cosh(x));" << endl
254  << " }" << endl
255  << endl;
256 }
257 
258 static void erect_sinusoidal_glsl(ostringstream& oss, const void* params) {
259  oss << " // erect_sinusoidal(" << distanceparam << ")" << endl
260  << " src.s /= cos(src.t / " << distanceparam << ");" << endl
261  << " if (abs(src.s) > " << (M_PI * distanceparam) << ") " << DISCARD << endl
262  << endl;
263 }
264 
265 static void erect_lambertazimuthal_glsl(ostringstream& oss, const void* params) {
266  oss << " // erect_lambertazimuthal(" << distanceparam << ")" << endl
267  << " {" << endl
268  << " src /= " << distanceparam << ";" << endl
269  << " if (any(greaterThan(abs(src), vec2(" << M_PI << ", " << M_PI << ")))) " << DISCARD << endl
270  << " float ro = length(src);" << endl
271  << " if (abs(ro) <= 1.0e-10) src = vec2(0.0, 0.0);" << endl
272  << " else {" << endl
273  << " float c = 2.0 * asin(ro / 2.0);" << endl
274  << " src.t = " << distanceparam << " * asin((src.t * sin(c)) / ro);" << endl
275  << " if (abs(ro * cos(c)) <= 1.0e-10) src.s = 0.0;" << endl
276  << " else src.s = " << distanceparam << " * atan2_safe(src.s * sin(c), (ro * cos(c)));" << endl
277  << " }" << endl
278  << " }" << endl
279  << endl;
280 }
281 
282 static void erect_hammer_glsl(ostringstream& oss, const void* params) {
283  oss << " // erect_hammer(" << distanceparam << ")" << endl
284  << " {" << endl
285  << " src /= " << distanceparam << ";" << endl
286  << " float z2 = 1.0 - src.s * src.s / 16.0 - src.t * src.t / 4.0;" << endl
287  << " if (z2 < 0.0 ) " << DISCARD << endl
288  << " float z = sqrt(z2);" << endl
289  << " src.s = 2.0 * atan2_safe( z * src.s, 2.0*(2.0*z2-1.0));" << endl
290  << " src.t = asin (src.t * z);" << endl
291  << " if(any(greaterThan(abs(src), vec2(" << M_PI << "," << HALF_PI << "))))" << DISCARD << endl
292  << " src *= " << distanceparam << ";" << endl
293  << " }" << endl
294  << endl;
295 }
296 
297 static void erect_arch_glsl(ostringstream& oss, const void* params) {
298  oss << " // erect_arch(" << distanceparam << ")" << endl
299  << " {" << endl
300  << " if(src.t < 0.0) {" << endl
301  << " src.t = " << (1.25 * distanceparam) << " * atan_safe(sinh(src.t * " << (4 / (5.0 * distanceparam)) << "));" << endl
302  << " } else {" << endl
303  << " src.t = " << distanceparam << " * asin(src.t / " << distanceparam << ");" << endl
304  << " }" << endl
305  << " }" << endl
306  << endl;
307 }
308 
309 static void erect_stereographic_glsl(ostringstream& oss, const void* params) {
310  oss << " // erect_stereographic(" << distanceparam << ")" << endl
311  << " {" << endl
312  << " src /= " << distanceparam << ";" << endl
313  << " float rh = length(src);" << endl
314  << " float c = 2.0 * atan_safe(rh / 2.0);" << endl
315  << " float sin_c = sin(c);" << endl
316  << " float cos_c = cos(c);" << endl
317  << " if (abs(rh) <= 1.0e-10) " << DISCARD << endl
318  << " src.t = asin((src.t * sin_c) / rh) * " << distanceparam << ";" << endl
319  << " if (abs(cos_c) < 1.0e-10 && abs(src.s) < 1.0e-10) " << DISCARD << endl
320  << " float y = src.s * sin_c;" << endl
321  << " float x = cos_c * rh;" << endl
322  << " src.s = atan2_safe(y, x) * " << distanceparam << ";" << endl
323  << " }" << endl
324  << endl;
325 }
326 
327 static void stereographic_erect_glsl(ostringstream& oss, const void* params) {
328  oss << " // stereographic_erect(" << distanceparam << ")" << endl
329  << " {" << endl
330  << " src /= " << distanceparam << ";" << endl
331  << " vec2 cos_lon_lat=cos(src);" << endl
332  << " float g=cos_lon_lat.s * cos_lon_lat.t;" << endl
333  << " src = " << distanceparam << " * 2.0 / (1.0 + g) * vec2(cos_lon_lat.t * sin(src.s), sin(src.t));" << endl
334  << " }" << endl
335  << endl;
336 }
337 
338 static void erect_albersequalareaconic_glsl(ostringstream& oss, const void* params) {
339  oss << " // erect_albersequalareaconic(...)" << endl
340  << " {" << endl;
341 
342  // Get the albersEqualAreaConic_ParamCheck to run.
343  double junk0, junk1;
344  int result = erect_albersequalareaconic(0.0, 0.0, &junk0, &junk1, const_cast<void*>(params));
345  if (result == 0) {
346  oss << " // albersEqualAreaConic_ParamCheck failed" << endl;
347  }
348 
349  const double n = mp->pn->precomputedValue[3];
350  const double C = mp->pn->precomputedValue[4];
351  const double rho0 = mp->pn->precomputedValue[5];
352  const double yoffset = mp->pn->precomputedValue[6];
353  const double n2 = mp->pn->precomputedValue[7];
354  const double twiceN = mp->pn->precomputedValue[9];
355 
356  oss << " src /= " << mp->distance << ";" << endl
357  << " src.t += " << yoffset << ";" << endl
358  << " float rho2 = (src.s * src.s + (" << rho0 << " - src.t) * (" << rho0 << " - src.t));" << endl
359  << " float theta = atan2_safe(" << ((n < 0) ? "-" : "") << "src.s, " << ((n < 0) ? "-1.0 * " : "") << "(" << rho0 << " - src.t));" << endl
360  << " float phi = asin((" << C << " - rho2 * " << n2 << ") / " << twiceN << ");" << endl
361  << " float lambda = theta / " << n << ";" << endl
362  << " if (abs(lambda) > " << M_PI << ") " << DISCARD << endl
363  << " src.s = " << mp->distance << " * lambda;" << endl
364  << " src.t = " << mp->distance << " * phi;" << endl
365  << " }" << endl
366  << endl;
367 
368 }
369 
370 static void lambertazimuthal_erect_glsl(ostringstream& oss, const void* params) {
371  oss << " // lambertazimuthal_erect(" << distanceparam << ")" << endl
372  << " {" << endl
373  << " src /= " << distanceparam << ";" << endl
374  << " float a=cos(src.t) * cos(src.s) + 1.0;" << endl
375  << " if (abs(a) <= 1e-10) " << DISCARD << endl
376  << " src = " << distanceparam << " * sqrt (2.0/a) * vec2 ( cos(src.t) * sin(src.s), sin(src.t));" << endl
377  << " }" << endl
378  << endl;
379 }
380 
381 static void sphere_tp_equisolid_glsl(ostringstream& oss, const void* params) {
382  oss << " // sphere_tp_equisolid(" << distanceparam << ")" << endl
383  << " {" << endl
384  << " float phi = atan2_safe(src.t, src.s);" << endl
385  << " src = " << distanceparam << " * 2.0 * asin( length(src) / (2.0 * " << distanceparam << ")) * vec2 (cos(phi), sin(phi));" << endl
386  << " }" << endl
387  << endl;
388 }
389 
390 static void sphere_tp_orthographic_glsl(ostringstream& oss, const void* params) {
391  oss << " // sphere_tp_orthographic(" << distanceparam << ")" << endl
392  << " {" << endl
393  << " float rho=length(src);" << endl
394  << " if (rho >" << distanceparam << ") " << DISCARD << endl
395  << " float phi = atan2_safe(src.t, src.s);" << endl
396  << " src = " << distanceparam << " * asin( rho / " << distanceparam << ") * vec2 (cos(phi), sin(phi));" << endl
397  << " }" << endl
398  << endl;
399 }
400 
401 static void orthographic_sphere_tp_glsl(ostringstream& oss, const void* params) {
402  oss << " // orthographic_sphere_tp(" << distanceparam << ")" << endl
403  << " {" << endl
404  << " float theta = length(src) / " << distanceparam << ";" << endl
405  << " float phi = atan2_safe(src.t, src.s);" << endl
406  << " if ( abs(theta) > " << HALF_PI << ") " << DISCARD << endl
407  << " " << endl
408  << " src = " << distanceparam << " * sin( theta ) * vec2 (cos(phi), sin(phi));" << endl
409  << " }" << endl
410  << endl;
411 }
412 
413 static void sphere_tp_thoby_glsl(ostringstream& oss, const void* params) {
414  oss << " // sphere_tp_thoby(" << distanceparam << ")" << endl
415  << " {" << endl
416  << " float rho = length(src) / " << distanceparam << ";" << endl
417  << " if (abs(rho) > " << THOBY_K1_PARM << ") " << DISCARD << endl
418  << " float phi = atan2_safe(src.t, src.s);" << endl
419  << " src = " << distanceparam << " * asin(rho/" << THOBY_K1_PARM << ") / " << THOBY_K2_PARM << " * vec2 (cos(phi), sin(phi));" << endl
420  << " }" << endl
421  << endl;
422 }
423 
424 static void thoby_sphere_tp_glsl(ostringstream& oss, const void* params) {
425  oss << " // thoby_sphere_tp(" << distanceparam << ")" << endl
426  << " {" << endl
427  << " float theta = length(src) / " << distanceparam << ";" << endl
428  << " float phi = atan2_safe(src.t, src.s);" << endl
429  << " src = " << distanceparam << " * " << THOBY_K1_PARM << " * sin(theta * " << THOBY_K2_PARM << ") * vec2 (cos(phi), sin(phi));" << endl
430  << " }" << endl
431  << endl;
432 }
433 
434 static void plane_transfer_to_camera_glsl(ostringstream& oss, const void* params) {
435  oss << " // plane_transfer_to_camera" << endl
436  << " // distance : " << mp->distance << endl
437  << " // x : " << mp->trans[0] << endl
438  << " // y : " << mp->trans[1] << endl
439  << " // z : " << mp->trans[2] << endl
440  << " // plane yaw : " << mp->trans[3] << endl
441  << " // plane pitch: " << mp->trans[4] << endl
442  << " {" << endl
443  << " float phi = src.s / " << mp->distance << ";" << endl
444  << " float theta = " << HALF_PI << " - src.t / " << mp->distance << ";" << endl
445  << " vec3 p = vec3(sin(theta)*sin(phi), cos(theta), sin(theta)*-cos(phi));" << endl
446  << " 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
447  << " float den = -dot(plane_coeff, p);" << endl
448  << " if ( abs(den) < 1E-15 ) " << DISCARD << endl
449  << " float u = length(plane_coeff);" << endl
450  << " u = -u * u / den;" << endl
451  << " if ( u < 0.0 ) " << DISCARD << endl
452  << " p *= u;" << endl
453  << " p -= vec3(" << mp->trans[0] << "," << mp->trans[1] << "," << mp->trans[2] << ");" << endl
454  << " src = " << mp->distance << " * vec2( atan2_safe(p.s, -p.p), asin(p.t/length(p)));" << endl
455  << " }" << endl
456  << endl;
457 }
458 
459 namespace HuginBase { namespace PTools {
460 
461 bool Transform::emitGLSL(ostringstream& oss) const {
462 
463  oss << " vec2 src = gl_TexCoord[0].st;" << endl
464  << " src -= vec2(" << m_srcTX << ", " << m_srcTY << ");" << endl
465  << endl;
466 
467  bool foundUnsupportedFunction = false;
468  int i = 0;
469  const fDesc* stack = m_stack;
470 
471  while ( (stack->func) != NULL ) {
472  if (stack->func == rotate_erect) rotate_erect_glsl(oss, stack->param);
473  else if (stack->func == resize) resize_glsl(oss, stack->param);
474  else if (stack->func == vert) vert_glsl(oss, stack->param);
475  else if (stack->func == horiz) horiz_glsl(oss, stack->param);
476  else if (stack->func == shear) shear_glsl(oss, stack->param);
477  else if (stack->func == erect_pano) erect_pano_glsl(oss, stack->param);
478  else if (stack->func == erect_rect) erect_rect_glsl(oss, stack->param);
479  else if (stack->func == erect_sphere_tp) erect_sphere_tp_glsl(oss, stack->param);
480  else if (stack->func == sphere_tp_erect) sphere_tp_erect_glsl(oss, stack->param);
481  else if (stack->func == vertical) vertical_glsl(oss, stack->param);
482  else if (stack->func == deregister) deregister_glsl(oss, stack->param);
483  else if (stack->func == radial) radial_glsl(oss, stack->param);
484  else if (stack->func == pano_sphere_tp) pano_sphere_tp_glsl(oss, stack->param);
485  else if (stack->func == rect_sphere_tp) rect_sphere_tp_glsl(oss, stack->param);
486  else if (stack->func == persp_sphere) persp_sphere_glsl(oss, stack->param);
487  else if (stack->func == erect_mercator) erect_mercator_glsl(oss, stack->param);
488  else if (stack->func == erect_millercylindrical) erect_millercylindrical_glsl(oss, stack->param);
489  else if (stack->func == erect_lambert) erect_lambert_glsl(oss, stack->param);
490  else if (stack->func == erect_transmercator) erect_transmercator_glsl(oss, stack->param);
491  else if (stack->func == erect_sinusoidal) erect_sinusoidal_glsl(oss, stack->param);
492  else if (stack->func == erect_lambertazimuthal) erect_lambertazimuthal_glsl(oss, stack->param);
493  else if (stack->func == erect_stereographic) erect_stereographic_glsl(oss, stack->param);
494  else if (stack->func == erect_albersequalareaconic) erect_albersequalareaconic_glsl(oss, stack->param);
495  else if (stack->func == erect_hammer) erect_hammer_glsl(oss, stack->param);
496  else if (stack->func == erect_arch) erect_arch_glsl(oss, stack->param);
497  else if (stack->func == stereographic_erect) stereographic_erect_glsl(oss, stack->param);
498  else if (stack->func == lambertazimuthal_erect) lambertazimuthal_erect_glsl(oss, stack->param);
499  else if (stack->func == sphere_tp_equisolid) sphere_tp_equisolid_glsl(oss, stack->param);
500  else if (stack->func == sphere_tp_orthographic) sphere_tp_orthographic_glsl(oss, stack->param);
501  else if (stack->func == orthographic_sphere_tp) orthographic_sphere_tp_glsl(oss, stack->param);
502  else if (stack->func == sphere_tp_thoby) sphere_tp_thoby_glsl(oss, stack->param);
503  else if (stack->func == thoby_sphere_tp) thoby_sphere_tp_glsl(oss, stack->param);
504  else if (stack->func == plane_transfer_to_camera) plane_transfer_to_camera_glsl(oss, stack->param);
505  else {
506  oss << " // Unknown function " << (const void*)stack->func << endl << endl;
507  foundUnsupportedFunction = true;
508  }
509  ++stack;
510  ++i;
511  }
512 
513  oss << " src += vec2(" << (m_destTX-0.5) << ", " << (m_destTY-0.5) << ");" << endl
514  << endl;
515 
516  return !foundUnsupportedFunction;
517 }
518 
519 bool Transform::transformImgCoordPartial(double & x_dest, double & y_dest, double x_src, double y_src) const
520 {
521  x_src -= m_srcTX - 0.5;
522  y_src -= m_srcTY - 0.5;
523 
524  double xd = x_src;
525  double yd = y_src;
526 
527  const fDesc* stack = m_stack;
528 
529  for (int i = 0; i < 2; ++i) {
530  if ((stack->func) == NULL) break;
531  if ( (stack->func)(xd, yd, &x_dest, &y_dest, stack->param) ) {
532  xd = x_dest;
533  yd = y_dest;
534  stack++;
535  } else {
536  return 0;
537  }
538  }
539 
540  x_dest += m_destTX - 0.5;
541  y_dest += m_destTY - 0.5;
542 
543  return 1;
544 }
545 
546 
547 }} // namespace
#define mp
static void radial_glsl(ostringstream &oss, const void *params)
void stereographic_erect(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
convert from erect to stereographic
void sphere_tp_erect(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void resize_glsl(ostringstream &oss, const void *params)
static void stereographic_erect_glsl(ostringstream &oss, const void *params)
#define var3
static void erect_lambert_glsl(ostringstream &oss, const void *params)
static void persp_sphere_glsl(ostringstream &oss, const void *params)
static void sphere_tp_thoby_glsl(ostringstream &oss, const void *params)
void radial(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void horiz_glsl(ostringstream &oss, const void *params)
static void rotate_erect_glsl(ostringstream &oss, const void *params)
static void sphere_tp_equisolid_glsl(ostringstream &oss, const void *params)
bool transformImgCoordPartial(double &x_dest, double &y_dest, double x_src, double y_src) const
#define DISCARD
void erect_rect(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
#define var4
static void shear_glsl(ostringstream &oss, const void *params)
void erect_sinusoidal(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
convert from sinusoidal to erect
void erect_stereographic(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
convert from stereographic to erect
void rotate_erect(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void vert_glsl(ostringstream &oss, const void *params)
static void pano_sphere_tp_glsl(ostringstream &oss, const void *params)
#define var5
static void plane_transfer_to_camera_glsl(ostringstream &oss, const void *params)
void erect_sphere_tp(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void orthographic_sphere_tp_glsl(ostringstream &oss, const void *params)
static void erect_sinusoidal_glsl(ostringstream &oss, const void *params)
static void rect_sphere_tp_glsl(ostringstream &oss, const void *params)
static void erect_mercator_glsl(ostringstream &oss, const void *params)
#define var0
static void erect_albersequalareaconic_glsl(ostringstream &oss, const void *params)
static void erect_hammer_glsl(ostringstream &oss, const void *params)
#define shift
static void erect_transmercator_glsl(ostringstream &oss, const void *params)
void vert(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
void pano_sphere_tp(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void erect_stereographic_glsl(ostringstream &oss, const void *params)
static void lambertazimuthal_erect_glsl(ostringstream &oss, const void *params)
static void erect_rect_glsl(ostringstream &oss, const void *params)
#define distanceparam
bool emitGLSL(std::ostringstream &oss) const
static void deregister_glsl(ostringstream &oss, const void *params)
static void sphere_tp_erect_glsl(ostringstream &oss, const void *params)
#define var2
static void erect_lambertazimuthal_glsl(ostringstream &oss, const void *params)
static void erect_millercylindrical_glsl(ostringstream &oss, const void *params)
void resize(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
void persp_sphere(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void vertical_glsl(ostringstream &oss, const void *params)
void erect_pano(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
static void thoby_sphere_tp_glsl(ostringstream &oss, const void *params)
static void erect_sphere_tp_glsl(ostringstream &oss, const void *params)
void rect_sphere_tp(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
void erect_mercator(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
convert from mercator to erect
#define M_PI
Definition: GaborFilter.cpp:34
static void sphere_tp_orthographic_glsl(ostringstream &oss, const void *params)
static void erect_pano_glsl(ostringstream &oss, const void *params)
static void erect_arch_glsl(ostringstream &oss, const void *params)
#define var1
void horiz(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
void erect_transmercator(double x_dest, double y_dest, double *x_src, double *y_src, const _FuncParams &params)
convert from erect to transverse mercator