File render.c

RCS Header: /cvsroot/petscgraphics/render.c,v 1.5 2004/08/17 15:05:56 hazelsct Exp

This file contains the rendering code for Illuminator, which renders 2-D or 3-D data into an RGB(A) unsigned char array (using perspective in 3-D).


Included Files


Preprocessor definitions

#define __FUNCT__ "pseudocolor"

#define __FUNCT__ "pseudohueintcolor"

#define __FUNCT__ "pseudoternarycolor"

#define __FUNCT__ "render_rgb_local_2d"


Global Function render_rgb_local_2d()

Render data from global_array into local part of an RGB buffer. When running in parallel, these local buffers should be collected and layered to produce the full image.

int render_rgb_local_2d ( guchar* rgb, int rwidth, int rheight, int bytes_per_pixel, PetscScalar* global_array, int num_fields, int display_field, field_plot_type fieldtype, PetscScalar* minmax, int nx, int ny, int xs, int ys, int xm, int ym )

int render_rgb_local_2d
Returns zero or an error code.
guchar* rgb
RGB buffer in which to render.
int rwidth
Total width of the RGB buffer.
int rheight
Total height of the RGB buffer.
int bytes_per_pixel
Number of bytes per pixel in this RGB buffer (typically 3 or 4).
PetscScalar* global_array
Local array of global vector data to render.
int num_fields
Number of field variables in the array.
int display_field
The (first) field we are rendering now.
field_plot_type fieldtype
The type of this field.
PetscScalar* minmax
Array of minimum and maximum values to pass to the various pseudocolor functions; if NULL, call minmax_scale to determine those values.
int nx
Width of the array.
int ny
Height of the array.
int xs
Starting x-coordinate of the local part of the global vector.
int ys
Starting y-coordinate of the local part of the global vector.
int xm
Width of the local part of the global vector.
int ym
Height of the local part of the global vector.

Global Function render_rgb_local_3d()

Render triangle data into an RGB buffer. When called in parallel, the resulting images should be layered to give the complete picture. Zooming is done by adjusting the ratio of the dir vector to the right vector.

int render_rgb_local_3d ( guchar* rgb, int rwidth, int rheight, int bytes_per_pixel, int num_triangles, PetscScalar* vertices, PetscScalar* eye, PetscScalar* dir, PetscScalar* right )

int render_rgb_local_3d
Returns zero or an error code.
guchar* rgb
RGB buffer in which to render.
int rwidth
Total width of the RGB buffer.
int rheight
Total height of the RGB buffer.
int bytes_per_pixel
Number of bytes per pixel in this RGB buffer (typically 3 or 4).
int num_triangles
Number of triangles to render.
PetscScalar* vertices
Table of coordinates (x1,y1,z1, x2,y2,z2, x3,y3,z3) and colors (RGBA 0-1) making thirteen values per triangle.
PetscScalar* eye
Point from where we're looking (x,y,z).
PetscScalar* dir
Direction we're looking (x,y,z).
PetscScalar* right
Rightward direction in physical space (x,y,z).

Local Function pseudocolor()

This little function converts a scalar value into an rgb color from red to blue.

static inline void pseudocolor ( PetscScalar val, PetscScalar* minmax, guchar* pixel )

PetscScalar val
Value to convert.
PetscScalar* minmax
Array with minimum and maximum values in which to scale val.
guchar* pixel
Address in rgb buffer where this pixel should be painted.

Local Function pseudohueintcolor()

This little function converts a vector into an rgb color with hue indicating direction (green, yellow, red, blue at 0, 90, 180, 270 degrees) and intensity indicating magnitude relative to reference magnitude in minmax[1].

static inline void pseudohueintcolor ( PetscScalar vx, PetscScalar vy, PetscScalar* minmax, guchar* pixel )

PetscScalar vx
Vector's x-component.
PetscScalar vy
Vector's y-component.
PetscScalar* minmax
Array whose second entry has the reference magnitude.
guchar* pixel
Address in rgb buffer where this pixel should be painted.

Local Function pseudoternarycolor()

This little function converts two ternary fractions into an rgb color, with yellow, cyan and magenta indicating the corners.

static inline void pseudoternarycolor ( PetscScalar A, PetscScalar B, PetscScalar* minmax, guchar* pixel )

PetscScalar A
First ternary fraction.
PetscScalar B
Second ternary fraction.
PetscScalar* minmax
Array first and second ternary fractions of each of the three corner values for scaling.
guchar* pixel
Address in rgb buffer where this pixel should be painted.