<<<<<<<<<<<<<<<<<

lookup_table(oscar) Animation lookup_table(oscar)

NAME

lookup_table - maps scalar values to color values

DESCRIPTION

The lookup_table class provides mappings beteen scalar values, color triplets and table indices. The table values can be set directly or generated automatically by describing the range of colors to cover.

The lookup_table is used by the modellers in the system to transform vertex scalar values into object colors. By default, all modelling objects in the system use the lookup_table class for these mappings. Multiple simultaneous lookup tables are possible by creating instances of lookup_table and assigning them to the appropriate display_modeller(s).

Note: if vertex scalar values are not available, or scalar visibility is turned off, then the actor color is used to color the geometry.

SUPERCLASS

object

INSTANCE VARIABLES

hue_range The min and max hue values that are interpolated by the lookup table. Both the min and the max values can range between 0.0 and 1.0. Hue is the fractional distance around the circumference of the HSV cone. The diagram below shows the top view of this cone with the locations of the primary and secondary colors.

0.33 (green) 0.167 (yellow) -------- / \ / \ 0.5 (cyan) | | 0.0, 1.0 (red) \ / \ / -------- 0.67 (blue) 0.833 (magenta)

saturation_range The min and max saturation values that are interpolated by the lookup table. Both the min and the max values can range between 0.0 and 1.0. Saturation is the radial distance from the axis of the cone to the edge. It controls the proportion of hue to white. A low saturation produces pastels of a color, while a high saturation produces pure hues.

value_range The min and max intensity values that are interpolated by the lookup table. Both the min and the max values can range between 0.0 and 1.0. Value is the distance above the tip of the HSV cone along its axis. It controls the intensity of the colors. Low values (near 0.0) produce dark shades of a color, while high values (near 1.0) produce purer intensities.

clamp_range Controls the min and max table indices at which table clamping is performed. When a table is clamped, its colors span indices that map into the clamp range, but all entires outside of this range return the min and max table entry (or the min and max clamp colors, if specified).

min_clamp_color The color returned if scalars map below the min clamp value.

max_clamp_color The color returned if scalars map above the max clamp value.

table_index The current index set by the user. Used to lookup a color entry.

table_color The current color set by the user. Used to lookup an index value.

clamp A boolean flag indicating whether table clamping is on or off.

size The size of the table. The default size is 256, which is also the maximum size. The size can be set smaller, but the table must be rebuilt.

MESSAGES

hue_range[=?] Set/get the hue range.

saturation_range[=?] Set/get the saturation range.

value_range[=?] Set/get the value range.

table_index[=?] Set/get the table index.

table_color[=?] Set/get the table color.

index? Get the index of the table entry that is closest to the value specified in table_color.

color? Get the value of the table entry pointed to by table_index.

scalars_to_colors: args Convert a table of scalars to color values. Must be called from a program. Requires the following arguments:

int num_scalars; The number of scalars to be converted. float min_scalar; The scalar value mapped to the lowest index. float max_scalar; The scalar value mapped to the highest index. float colors[num_scalars][3]; The destination of the colors.

In addition, the colors table must have the first component filled with the scalar value to be converted. Each triplet will then be filled with the appropriate table entry. See example below.

clamp_range[=?] Set/get the clamp range. This range always maps the interval (0,1) to the range of table indices. Thus a clamp range of (0.25, 0.75) would clamp colors at the top and bottom fourths of the lookup table, no matter what the table size is.

min_clamp_color[=?] Set/get the min clamp color. The color defaults to the min table value.

max_clamp_color[=?] Set/get the max clamp color. The color defaults to the max table value.

clamp[=?] Set/get the clamp boolean flag.

clamp_on! Turn clamping on.

clamp_off! Turn clamping off (the default).

reset_clamp_colors! Sets the min and max clamp colors back to the min and max table values, respectively.

entries[=+?] Set/add/get the table entries directly. This allows

the user to set the lookup tables entries to anything. The table size is adjusted accordingly. See example below.

build! Builds the table according to the hue, saturation and value ranges.

install! Takes the current lookup table definition and installs it into the class lookup table. By default, the class lookup table is used by all of the modelling objects in the system. However, it is possible to use multiple lookup tables on those systems that support them (see example).

EXAMPLES

The following LYMB script sets up two color tables. The first instance builds a gray scale from dark gray (intensity = 0.2) to white. The second instance builds a hue range from blue (hue = 0.67) to red (hue = 0.0). The order of the range determines the mapping of scalars to colors. For instance, the gray scale below has dark gray values for low table indices and values close to white for high table indices.

lookup_table new: gray_scale hue_range=(0,0) saturation_range=(0,0) value_range=(0.2,1) ;

lookup_table new: hue_scale hue_range=(0.67,0) saturation_range=(1,1) value_range=(1,1) ;

gray scale install!;

(draw something)

hue_scale install!;

(draw something else)

The following LYMB script shows how to find the color value of an index, and also how to find the index of a color value.

lookup_table table_index=127 print:"color" ; lookup_table: color= (0.000000,1.000000,0.000011)

lookup_table table_color=(0.5,0.3,0.1) print:index ; lookup_table index= (23)

The following LYMB script shows how to set the table values directly.

lookup_table entries=( 0.0, 0.0, 0.0, -- black 1.0, 0.0, 0.0, -- red 0.0, 1.0, 0.0, -- green 1.0, 1.0, 0.0, -- yellow 0.0, 0.0, 1.0, -- blue 1.0, 0.0, 1.0, -- magenta 0.0, 1.0, 1.0, -- cyan 1.0, 1.0, 1.0) -- white ;

The follwing example demonstrates how to convert a large table of scalars to colors in a C program. A table of float triplets is initialized with scalar values occupuying the first (red) location of each triplet. The lookup_table class then fills in each triplet with RGB values corresponding to the scalar value. That is, the range {min_scalar, max_scalar} is mapped to {0, [lookup_table size?]}.

... float colors[1000][3]; float min_scalar = 0.0, max_scalar = 1.0;

for (i = 0; i < 1000; i++) colors[i][0] = lymb_rand();

ARGS_BEGIN; ARGS_ADD_INTEGER(1000); ARGS_ADD_FLOAT(min_scalar); ARGS_ADD_FLOAT(max_scalar); ARGS_ADD_OBJECT(colors); /* push the address of colors */ msg_send_object("lookup_table", "scalars_to_colors:", ARGS_COUNT, ARGS_LIST); ARGS_END;

The follwing example demonstrates the use of multiple simultaneous lookup tables. /* * Script to illustrate use of data_geometry */ string new: data_name=case1;

string new: data_set = data_name + "_gridset01"; string new: geometry = data_set + "_grid";

string new: scalar_data = data_set + "_density"; string new: vector_data = data_set + "_momentum";

plot3d_reader new: areader file_prefix=data_name derived_data_off! read! ;

object# data_set scalar_data= scalar_data vector_data= vector_data compute_properties! ;

/* * Compute the initial threshold and other parameters */

scalar new: current_scale= 0.1 * [object# geometry length?] / [object# vector_data max_length?] ; vector new: current_range dimension=2 = ([object# scalar_data range?]) ;

/* * Pipeline: outline plus geometry */ display_outline new: outline data_in= data_set ; display_lines new: draw_outline data_in=outline ; actor new: outline_actor modeller=draw_outline ;

data_geometry new: dg data_in= data_set extent= (1,1,1,100,1,100) ; display_all new: draw data_in= dg range= current_range ; actor new: data_actor modeller=draw ;

data_geometry new: dg_1 data_in= data_set

extent= (8,8,1,100,1,100) ; lookup_table new: default_table hue_range=(0.,0.67) saturation_range=(1,1) value_range=(1,1) build! ; display_all new: draw_1 data_in= dg_1 range= current_range lookup_table= default_table ; actor new: data_actor_1 modeller=draw_1 ;

data_geometry new: dg_2 data_in= data_set extent= (15,15,1,100,1,100) ; lookup_table new: bw_table hue_range=(0.,0.) saturation_range=(0,0) value_range=(.2,1) build! ; display_all new: draw_2 data_in= dg_2 range= current_range lookup_table= bw_table ; actor new: data_actor_2 modeller=draw_2 ;

/* * Renderer stuff */ environment new: _env variable="LYMB_RENDERER" ; string new: current_renderer = [_env value?];

vector new: bbox dimension=6; bbox = ([object# data_set bounds?]); camera new: acamera position=(1,1,1) x_range=([bbox @1 ?],[bbox @2 ?]) y_range=([bbox @3 ?],[bbox @4 ?]) z_range=([bbox @5 ?],[bbox @6 ?]) default! on! ;

light new: alight position=[acamera position?] on! ;

object# current_renderer new: main_renderer actors=([actor instances?]) lights=alight cameras=acamera render! ;

BUGS

The logic for clamping is incorrect. After specifying the clamping range and colors, the unclamped portion of the table is not built properly.

SEE ALSO

display_modeller, display_all, actor, light, camera


Please send comments and suggestions to
consult@rpi.edu