Re: Visualization and getting range values for functions with domain dimension > 2

  • To: Elin Sivertsen <elins@xxxxxx>
  • Subject: Re: Visualization and getting range values for functions with domain dimension > 2
  • From: Bill Hibbard <billh@xxxxxxxxxxxxx>
  • Date: Thu, 28 Aug 2003 05:25:23 -0500 (CDT)
Hi Elin,

Your program shows a real understanding of VisAD, which is
nice to see. Assuming that yuor arrays threeDSamples and
fi_Samples contain reasonable non-missing (i.e., not NaN)
values, you should see the values in your vals_ff FlatField
displayed as 7 colored points. This is what you get with
a FlatField of MathType ((x, y, z) -> w) and mappings
x -> XAxis, y -> YAxis, z -> ZAxis and w -> RGB. The colored
points will be small (single pixels). You can make them
larger by including a ConstantMap to PointSize in the call
to addReference for data_ref.

Also, have you tried dragging your large red cursor by
clicking on it with the right mouse button? It should
trigger your CellImpl to print its messages.

If this continues to be a probelm, you can add a few lines to
your program to set values in threeDSamples and fi_Samples,
and to add your DisplayImplJ3D to a JFrame, to make it into
a compilable and runnable program, and send it to us and I'll
run it.

Good luck,
Bill

On Thu, 28 Aug 2003, Elin Sivertsen wrote:

> Hello...
>
> I have some data values coming from a function of type (x, y, z) -> w. The
> domain values (R^3) are stored in an array of the form
> float[3][7]. The range values are stored in an array float[1][7]. My goals
> is to get the range value in each picked or chosen point, and
> view the surface as a 3d surface, w represented by color.
> The following program does not give me the range value, and all I see is the
> reference box and the colored cursor.
>
> Could anybody give a hint?
>
> Thanks,
>      Elin.
>
>
>  //Declarations
>        x = RealType.getRealType("gridx", SI.meter, null);
>        y = RealType.getRealType("gridy", SI.meter, null);
>        z = RealType.getRealType("gridz", SI.meter, null);
>        w = RealType.getRealType("gridw", SI.kelvin, null);
>
>        domain = new RealTupleType(x, y, z);
>
>        grid_type = new FunctionType(domain, w);
>
>        //Cursor
>        cursorCoords = new RealTuple(domain, new double[]{0.50, 0.50, 0.50});
>        cursorDataRef = new DataReferenceImpl("cursorDataRef");
>        cursorDataRef.setData(cursorCoords);
>
>
>
>        DelaunayWatson delan = new DelaunayWatson(threeDSamples);
>        domain_set = new Irregular3DSet(grid_type.getDomain(), threeDSamples,
> null, null, null, delan);
>
>
>        vals_ff = new FlatField(grid_type, domain_set);
>
>        vals_ff.setSamples(fi_Samples, false);
>
>       //Create a data reference and set the FlatField as our data
>        data_ref  = new DataReferenceImpl("data_ref");
>        data_ref.setData( vals_ff );
>
>
>        CellImpl cell = new CellImpl(){
>          public void doAction() throws RemoteException, VisADException{
>            RealTuple coords = (RealTuple) cursorDataRef.getData();
>
>            Real lon = (Real)coords.getComponent(0);
>            Real lat = (Real)coords.getComponent(1);
>            Real alt = (Real)coords.getComponent(2);
>
>            double x = lon.getValue();
>            double y = lat.getValue();
>            double z = alt.getValue();
>
>            System.out.println("Cursor at: (" + x + ", " +
>                                                y + ", " +
>                                                z +")");
>
>            Linear3DSet new3DSet = new Linear3DSet(-20.0, 13.0, 33, 0.0,
> 45.0, 45, -16.0, 16.0, 32);
>
>            int resampMode = Data.NEAREST_NEIGHBOR;
>            int errorMode = Data.NO_ERRORS;
>            FlatField temporField = (FlatField)vals_ff.resample(new3DSet,
> resampMode, errorMode);
>
>            double[][] tem1 = temporField.getValues();
>            System.out.println("TEM1 " + tem1[0][0]);
>
>            Real tem2 = (Real)vals_ff.evaluate(coords, resampMode,
> errorMode);
>            //System.out.println("RANGE " + tem2.getValue());
>            System.out.println("RANGE " + tem2);
>          }
>        };
>
>        cell.addReference(cursorDataRef);
>
>
>
>
>        // Create Display and its maps
>       // A 2D display
>        display = new DisplayImplJ3D("display1");
>
>         // Get display's graphics mode control and draw scales
>         GraphicsModeControl dispGMC
> (GraphicsModeControl)display.getGraphicsModeControl();
>         dispGMC.setScaleEnable(true);
>
>       // Create the ScalarMaps: y to YAxis, x to XAxis and
>     // z to ZAxis and temperature to RGB
>     // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)
>
>
>
>     xMap = new ScalarMap(x, Display.XAxis);
>     yMap = new ScalarMap(y, Display.YAxis);
>     zMap = new ScalarMap(z, Display.ZAxis);
>     wMap = new ScalarMap(w, Display.RGB);
>
>
>   // Add maps to display
>
>     display.addMap(xMap);
>     display.addMap(yMap);
>     display.addMap(zMap);
>
>     display.addMap(wMap);
>
>     ConstantMap[] cMaps = { new ConstantMap(1.0f, Display.Red),
>                             new ConstantMap(0.0f, Display.Green),
>                             new ConstantMap(0.0f, Display.Blue),
>                             new ConstantMap(5.0f, Display.PointSize) };
>
>
>
>     //Add reference to display
>        display.addReferences( new DirectManipulationRendererJ3D(),
> cursorDataRef, cMaps);
>        display.addReference( data_ref );
>
>
>
>
> ---------------------------------------------------------------------
> From: Elin R. Sivertsen---Elin.Sivertsen@xxxxxx
> Title: CandScient
> Place: IFE/OECD Halden Reactor Project
> Department: Halden VR Centre
>
>


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