Re-using the same elevation data in an animation

Hi Ugo,

I have taken the liberty of responding through visad-list, because the
issue you have raised will be useful to others.

> I'll take the opportunity to ask something else. One animation
> application I wrote takes a number n of attribute files and "glue" them
> on top of the same DEM (that is, we want to visualize the development of
> some attribute in time, in a given region). The DEM doesn't change, only
> the attributes.
>
> However, I have to have the DEM array as many times as the number of
> attributes (observe the function type ((time) -> ( (x,y) -> (z,
> attrib_1) ). Is it possible to arrange this so that I only have one
> single array for the elevation? (Therefore reducing the number of arrays
> altogether.)

I am happy to report that there is a way for you to do this.  Assume that
"FlatField[] flats" is the array of FlatFields in your animation sequence,
that "float[] elevations" is the array of elevations that get set in these
FlatFields, and that "float[][] attributes" is the array of attributes,
where the first index of the attributes array is over the animation
sequence.  Now, the FlatFields in the flats array have MathType
( (x,y) -> (z, attrib_1) ) so their input range array will be dimensioned 
[2][number_of_samples].  Here's how to put the data into the flats
array:

  for (int i=0; i<flats.length; i++) {
    float[][] range = new float[][] {elevations, attributes[i]};
    flats[i].setSamples(range, false); // "false" is the key
  }

Then of course something like:

  sequence_field.setSamples(flats, false);

where sequence_field is a FieldImpl with MathType
( (time) -> ( (x,y) -> (z, attrib_1) ) ).

Basically, the false argument to setSamples tells it not to copy the
range array.  The range arrays passed to each FlatField in the flats
array include references to the same copy of elevations.

Note that false is not the default in calls to setSamples because it
is a little dangerous - it gives the application a reference into the
internal data of Fields.

All the best,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html

  • 1999 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: