[GRASS-dev] ctypes mystery

Hi all,

when developing wxNviz I am facing to the strange problem with ctypes.

Nviz_get_exag_height() [1] returns correct values.

D1/1: Nviz_get_exag_height(): value = 805.696899 min = -2944.302979
max = 4555.696777

SetViewDefault() [2] which is calling Nviz_get_exag_height() gets
incorrect values.

GUI D1/1: Nviz::SetViewDefault(): hdef=2.000000, hmin=0.000000,
hmax=36893488147419103232.000000

Any idea what can be wrong?

Thanks, Martin

[1] http://trac.osgeo.org/grass/browser/grass/trunk/lib/nviz/exag.c#L63
[2] http://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/gui_modules/wxnviz.py#L95

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Martin Landa wrote:

Hi all,

when developing wxNviz I am facing to the strange problem with ctypes.

Nviz_get_exag_height() [1] returns correct values.

D1/1: Nviz_get_exag_height(): value = 805.696899 min = -2944.302979
max = 4555.696777

SetViewDefault() [2] which is calling Nviz_get_exag_height() gets
incorrect values.

GUI D1/1: Nviz::SetViewDefault(): hdef=2.000000, hmin=0.000000,
hmax=36893488147419103232.000000

Any idea what can be wrong?

Thanks, Martin

[1] http://trac.osgeo.org/grass/browser/grass/trunk/lib/nviz/exag.c#L63
[2] http://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/gui_modules/wxnviz.py#L95

Just a wild guess, try in wxnviz.py c_double() instead of c_float()
because Nviz_get_exag_height() wants double pointers, not float
pointers (confusing: python doc says python float = C double).

BTW, I get a number of compile errors in
trunk/gui/wxpython/nviz/change_view.cpp about type conversions. In
nviz.h, one error about too many arguments:
include/grass/nviz.h:134: error: too many arguments to function ‘int
Nviz_set_viewpoint_twist(int)’

No changes in my local copy, updated 1 hour ago.

Maybe this is pointing into the right direction,

Markus M

Hi,

2010/6/23 Markus Metz <markus.metz.giswork@googlemail.com>:

[...]

Just a wild guess, try in wxnviz.py c_double() instead of c_float()
because Nviz_get_exag_height() wants double pointers, not float
pointers (confusing: python doc says python float = C double).

ops, right. I completely overlook this issue. Thanks for pointing this out.

BTW, I get a number of compile errors in
trunk/gui/wxpython/nviz/change_view.cpp about type conversions. In
nviz.h, one error about too many arguments:
include/grass/nviz.h:134: error: too many arguments to function ‘int
Nviz_set_viewpoint_twist(int)’

C++ nviz component is not used in trunk (replaced by wxnviz.py). I
would suggest to remove it if there are no objections. Another issue
is to backport ctypes interface to devbr6.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa