[GRASS-dev] Re: [GRASS-user] [bug #3041] nviz max resolution ppm image dump

Glynn Clements glynn at gclements.plus.com
Wed Aug 30 08:54:36 EDT 2006


Hamish wrote:

> adding in some more debug statements:  [Before|After row x col]
> 
> Writing Tile 2 of 9
> D0/0: Nstart_zoom_cmd(): [B1x3] img_width=1024  img_height=1024
> D0/0: Nstart_zoom_cmd(): [B1x3] maxx=2048  XX=-2048  maxy=2048  YY=0 c=1024
>   /* Re-set image width or height if required */
> D0/0: Nstart_zoom_cmd(): [A1x3] img_width=0  img_height=1024
> 
> 
> !! XX=-2048
> 
> 	    if ((maxx + XX) < c)
> 		img_width = maxx + XX;
> 	    if ((maxy + YY) < d)
> 		img_height = maxy + YY;
> 
> 
> XX,YY start as:
> 
> 
> /* Set X & Y to zero for lower left corner */
>     XX = YY = 0;
> 
> then in the for loops:
> 
> 	    XX -= c;
> 	    cnt++;
> 	 } /* Done col */
> 	/* Reset XX and img_width */
> 	XX = 0;
> 	img_width = c;
> 	YY -= d;
>     } /* done row */
> 
> 
> 
> Final Assembled Image will be 2048 x 2048
> D0/0: Nstart_zoom_cmd(): XX=0  YY=0
> D0/0: gsd_viewport(): l=0,b=0,r=2048,t=2048
> D0/0: Nstart_zoom_cmd(): XX=0  YY=0
> D0/0: Nstart_zoom_cmd(): [B1x1] img_width=1024  img_height=1024
> D0/0: Nstart_zoom_cmd(): [B1x1] maxx=2048  XX=0  maxy=2048  YY=0 c=1024
> D0/0: Nstart_zoom_cmd(): [A1x1] img_width=1024  img_height=1024
> Writing Tile 1 of 9
> D0/0: Nstart_zoom_cmd(): XX=-1024  YY=0
> D0/0: gsd_viewport(): l=-1024,b=0,r=2048,t=2048
> D0/0: Nstart_zoom_cmd(): XX=-1024  YY=0
> D0/0: Nstart_zoom_cmd(): [B1x2] img_width=1024  img_height=1024
> D0/0: Nstart_zoom_cmd(): [B1x2] maxx=2048  XX=-1024  maxy=2048  YY=0 c=1024
> D0/0: Nstart_zoom_cmd(): [A1x2] img_width=1024  img_height=1024
> Writing Tile 2 of 9
> D0/0: Nstart_zoom_cmd(): XX=-2048  YY=0
> D0/0: gsd_viewport(): l=-2048,b=0,r=2048,t=2048
> D0/0: Nstart_zoom_cmd(): XX=-2048  YY=0
> D0/0: Nstart_zoom_cmd(): [B1x3] img_width=1024  img_height=1024
> D0/0: Nstart_zoom_cmd(): [B1x3] maxx=2048  XX=-2048  maxy=2048  YY=0 c=1024
> D0/0: Nstart_zoom_cmd(): [A1x3] img_width=0  img_height=1024
> Writing Tile 3 of 9
> D0/0: Nstart_zoom_cmd(): XX=0  YY=-1024
> D0/0: gsd_viewport(): l=0,b=-1024,r=2048,t=2048
> D0/0: Nstart_zoom_cmd(): XX=0  YY=-1024
> D0/0: Nstart_zoom_cmd(): [B2x1] img_width=1024  img_height=1024
> D0/0: Nstart_zoom_cmd(): [B2x1] maxx=2048  XX=0  maxy=2048  YY=-1024 c=1024
> D0/0: Nstart_zoom_cmd(): [A2x1] img_width=1024  img_height=1024
> Writing Tile 4 of 9
> ...
> 
> 
> 
> if I change the XX and YY -= to += (just a guess) I don't get any errors
> and it creates a single test.ppm which is 3072x3072, but the contents 
> are still bogus.

The values are meant to be negative; they are shifts which are applied
to the view transformation. The view is shifted down and left so that
the desired tile has its bottom-left at the bottom-left of the drawing
surface.

The problem appears to be that it computes the number of tiles as:

	    var_i = (int) (maxx/(c-a)) + 1;

when it should probably be:

	    var_i = (int) ((maxx + c-a - 1)/(c-a));

I.e. it rounds down then adds 1 rather than rounding up, resulting in
one too many tiles when the total size is an exact multiple of the
window size.

Note that the technique used (setting a viewport larger than the
window) is an ugly hack which may be very inefficient (the OpenGL
implementation may clip 3D operations to the viewport rather than the
visible portion of it).

However, this is due to a limitation of the OGSF library: the only
mechanism for setting a perspective projection uses gluPerspective(),
which doesn't allow an oblique projection.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list