NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

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

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: