[GRASS5] G3D-api error

Hello,

I'm writing a geophysical routine and I'd like to store a 3D temperature
field as G3D raster.
In the past I encountered some problems to find all the includes and lib -
this is properly solved.
I'm using Grass5.0.2 under Suse Linux 8.2

but,

I'm not succeeding in writing my data to a g3d file.
I'm using the following functions (and some more..):
G3d_openCellNew (char *name, int type, int cache, G3D_Region *region); that
returns a void* which is a pointer to the newly created g3d-raster - Am I
right?

G3d_putValue (void *map, int x, int y, int z, char *value, int type); where
void *map revers to the opened g3d-raster

my g++ compiler tells me that *map should be of type G3D_Map instead of
void*.

checking the grass5.0.2/src/include/G3d.h confirms this with the following
function declaration:
int G3d_putValue(G3D_Map *, int, int, int, char *, int);

What am I doing wrong? - Or do some inconsistencies exist in the g3d-api?

with kindest regards,

Nico

N.J. Hardebol wrote:

I'm writing a geophysical routine and I'd like to store a 3D temperature
field as G3D raster.
In the past I encountered some problems to find all the includes and lib -
this is properly solved.
I'm using Grass5.0.2 under Suse Linux 8.2

but,

I'm not succeeding in writing my data to a g3d file.
I'm using the following functions (and some more..):
G3d_openCellNew (char *name, int type, int cache, G3D_Region *region); that
returns a void* which is a pointer to the newly created g3d-raster - Am I
right?

G3d_putValue (void *map, int x, int y, int z, char *value, int type); where
void *map revers to the opened g3d-raster

my g++ compiler tells me that *map should be of type G3D_Map instead of
void*.

checking the grass5.0.2/src/include/G3d.h confirms this with the following
function declaration:
int G3d_putValue(G3D_Map *, int, int, int, char *, int);

What am I doing wrong? - Or do some inconsistencies exist in the g3d-api?

GRASS (including G3D) is written in (and written for) C, not C++. In
C, it's legal to implictly cast between void* and other pointers. In
C++, you have to use an explicit cast, e.g.

  map = (G3D_Map *) G3d_openCellNew(...);

--
Glynn Clements <glynn.clements@virgin.net>

thank you for your comments - it turns out that I'm still a newby to grass
api and c/c++ programming..
I'm sorry... still some other questions:

Q1: Am I mailing to the appropriate mailinglist? Is the developers list
soley for dev. of grass code or also for questions on the usage of grass
api?

************************

Q2: Some new problems arises:
  for (ix=0 ; ix <nx .....)
    for (iy ; iy < ny ......)
      for (iz ; iz < nz......)

      TileIndex = G3d_tile2tileIndex (g3d_map, ix, iy, iz);
      G3d_writeTile (g3d_map, TileIndex, data, G3D_DOUBLE) offers error run out
of TileIndex for TileIndex = 3312, which means TileIndex > nTiles.

My 3d raster should have the dimension nx: 128 ny: 64 nz: 201 - and if
possible in future bigger...
So earlier in the code I declared the dimensions:

  g3d_map = (G3D_Map *) G3d_openCellNew ("comp_G3D_Grid", G3D_DOUBLE,
G3D_USE_CACHE_DEFAULT, region );
       G3d_setTileDimension (nx, ny, 201);

       int na, nb, nc;
       G3d_getNofTilesMap (g3d_map, &na, &nb, &nc);
         cout << na << " " << nb << " " << nc << endl; // - returns 16 8 25
     G3d_getTileDimensionsMap (g3d_map, &na, &nb, &nc);
         cout << na << " " << nb << " " << nc << endl; // - returns 8 8 8 -
?as defined in default.c?
     G3d_getTileDimension ( &na, &nb, &nc);
         cout << na << " " << nb << " " << nc << endl; // - returns 128 64
201 - as dimensions should be!!!

     data = G3d_allocTilesType (g3d_map, 1, G3D_DOUBLE);

  with function g3d_map->nTiles (if I'm rigth) I could check nTiles -
returned nTiles: 3200. = 16x8x25 as returned by G3d_getNofTilesMap
(g3d_map, &na, &nb, &nc);
  So error above becomes apparent, but why 128x64x201 = 1646592 instead of
3200 - why not set with G3d_setTileDimension (nx, ny, 201).
  The diffence between the following functions is not clear to me - may due
to some ignorance an error arises:
  G3d_getNofTilesMap(): returns dimension of tile-cube to tile region of map.
  G3d_getTileDimensionsMap(): returns tile dimension used for map.
  G3d_getTileDimension (): .....

************************

Q3: I've no experience with the visualisation of g3d rasters within grass.
What are the possibilites for easy visualisation.
I've used vis5d+ for some visualisations. Am I dependend on
r3.mkdspf/r3.showdspf or r3.out.v5d - using vis5d+.
Does sg3d / SG4D offer nice alternatives? - I don't get them compiled since
don't get Ygl not compiled.
Is G3D part of recent development? grass.itc.it/roadmap.thml grass5.0.3 G3D
activated?

thanking in advance,

Nico

-----Oorspronkelijk bericht-----
Van: grass5-admin@grass.itc.it [mailto:grass5-admin@grass.itc.it]Namens
Glynn Clements
Verzonden: woensdag 3 september 2003 6:28
Aan: harj@geo.vu.nl
CC: grass5@grass.itc.it
Onderwerp: Re: [GRASS5] G3D-api error

N.J. Hardebol wrote:

I'm writing a geophysical routine and I'd like to store a 3D temperature
field as G3D raster.
In the past I encountered some problems to find all the includes and lib -
this is properly solved.
I'm using Grass5.0.2 under Suse Linux 8.2

but,

I'm not succeeding in writing my data to a g3d file.
I'm using the following functions (and some more..):
G3d_openCellNew (char *name, int type, int cache, G3D_Region *region);

that

returns a void* which is a pointer to the newly created g3d-raster - Am I
right?

G3d_putValue (void *map, int x, int y, int z, char *value, int type);

where

void *map revers to the opened g3d-raster

my g++ compiler tells me that *map should be of type G3D_Map instead of
void*.

checking the grass5.0.2/src/include/G3d.h confirms this with the following
function declaration:
int G3d_putValue(G3D_Map *, int, int, int, char *, int);

What am I doing wrong? - Or do some inconsistencies exist in the g3d-api?

GRASS (including G3D) is written in (and written for) C, not C++. In
C, it's legal to implictly cast between void* and other pointers. In
C++, you have to use an explicit cast, e.g.

  map = (G3D_Map *) G3d_openCellNew(...);

--
Glynn Clements <glynn.clements@virgin.net>

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5