animation - memory problem

Hi again,
        My problem is that I need to change the 'samples_sphere' array for the
Gridded3DSets for each 't' loop iteration (as the spheres are supposed to be
moving). IS there a method by which I can change the samples array without
having to call the constructor?
Thanks again for your help.
Ibrahim

Ibrahim Z Mohammad
*                                        *
RA - Dept. of Civil and Envt. Engineering
University of Illinois at Urbana-Champaign
*                                        *

-----Original Message-----
From: owner-visad-list@xxxxxxxxxxxxx
[mailto:owner-visad-list@xxxxxxxxxxxxx]On Behalf Of Bill Hibbard
Sent: Monday, July 15, 2002 3:51 PM
To: Ibrahim Z Mohammad
Subject: Re: animation - memory problem


Hi Ibrahim,

You don't have to construct different 'new Gridded3DSet' for each
iteration of the 'for(int t = 0; t < no_timesteps; t++)' loop.
Just pre-compute and save these Gridded3DSets for each "i" value
before your "t" loop. This may save a lot of memory.

However, you do need to construct a 'new FieldImpl' for
particles_field inside the "t" loop. I don't think this will
increase memory use much.

Good luck,
Bill

On Mon, 15 Jul 2002, Ibrahim Z Mohammad wrote:

> Hi,
>     I'm using VisAD to display an animation of many particles as spheres
> using Gridded3DSet. The code I'm using goes like this:
>
>
> Spheres particles[] = new Spheres [no_particles];
>
> timestep = new RealType("timestep", null, null);
> index = new RealType ("index", null, null);
> particles_set = new Integer1DSet(index, no_particles);
> timestep_set = new Integer1DSet(timestep, no_timesteps);
>
> x = new RealType("X", null, null);
> y = new RealType("Y", null, null);
> z = new RealType("Z", null, null);
> xyz = new RealTupleType(x, y, z);
> w = new RealType ("W", null, null);
>
> sphere_func = new FunctionType(xyz, w);
> particles_func = new FunctionType(index, sphere_func);
> timestep_func = new FunctionType(timestep, particles_func);
>
> particles_field = new FieldImpl(particles_func, particles_set);
> timestep_field = new FieldImpl(timestep_func, timestep_set);
>
> particles_ref = new DataReferenceImpl("Particles_ref");
>
> x_map = new ScalarMap(x, Display.XAxis);
> y_map = new ScalarMap(y, Display.YAxis);
> z_map = new ScalarMap(z, Display.ZAxis);
> anim_map = new ScalarMap(timestep, Display.Animation);
>
>
> for(int t = 0; t < no_timesteps; t++) {
>     for(int i = 0; i < no_particles; i++) {
>
>         particles[i] = new Spheres (a_sphere);
>
>         float samples_sphere[][] = particles[i].get_Coords();
>         float values_sphere[][] = particles[i].mapColors(samples_sphere);
>
>         particles[i].sphere_set = new Gridded3DSet(xyz, samples_sphere,
> particles[i].Mfold_sphere[0], particles[i].Mfold_sphere[1]);
>
>         particles[i].sphere_field = new FlatField(sphere_func,
> particles[i].sphere_set);
>         particles[i].sphere_field.setSamples(values_sphere, false);
>
>         particles[i].sphere_map = new ScalarMap(w, Display.Red);
>         display.addMap(particles[i].sphere_map);
>
>         particles_field.setSample(i, particles[i].sphere_field);
>
>    }
>
>    timestep_field.setSample(t, particles_field);
> }
>
> particles_ref.setData(timestep_field);
>
> display.addReference(particles_ref);
>
> When I run the code, it quickly runs into memory problems for not very
many
> frames (no_timesteps = around 40) and not too many particles (no_particles

> around 125). Is there a way I can make this code more efficient so as to
> decrease memory usage?
>
> Thanks,
> Ibrahim
> Ibrahim Z Mohammad
> *                                        *
> RA - Dept. of Civil and Envt. Engineering
> University of Illinois at Urbana-Champaign
> *                                        *
>
>