Re: Java3D 1.3 Objects vanished AND resampling Irregular2DSet

> The lines will have to come from Data that makes lines, such
> as a Set with manifold dimension = 1 or a FlatField with a
> domain Set with manifold dimension = 1 (the lines don't look
> like iso-lines). 

1. In the attached test case (LineTest2) I added a line to my view. In
that example I
just put the height values in, but how could I calculate the real
values. In the example I would need the height values of the
Irregular2DSet set for example at a specific x or y position.
2. Additionaly I am not only interested in profiles parallel to x and y. I
am also interestes in profiles along a line through the x,y plane.
3. I tried to create a ConstantMap with a derivation of a xheight
Irregular2DSet. That one is giving me the shape of the layer from the
side. Thats unforetunately not what I want as well.
Sorry, I think I am still digging in the wrong direction.

Given such Data, you can make thick lines
> with ConstantMaps to LineWidth. You can put each set of lines
> on a different ZAxis level with ConstantMaps to ZAxis. 

Or if
> you want line z level to vary with terrain, you can resample
> your terrain FlatField to Sets over the (x, y) domain and with
> manifold dimension = 1. These resample() calls will produce
> FlatFields, and you can adjust their z level (to create distinct
> layers) by adding offsets to their getFloats() values, then
> passing back to their setSamples() methods.

Hm, I tried something:

        Linear1DSet set1D = new Linear1DSet(x,0,15,5);
        FlatField terrain_new
(FlatField) terrain.resample(set1D,Data.WEIGHTED_AVERAGE,Data.NO_ERRORS);

That gives me the following error:

Exception in thread "main" visad.SetException: FlatField.resample: bad Set
Dimen
sion
        at visad.FlatField.resample(FlatField.java:3260)
        at LineTest3.<init>(LineTest3.java:88)
        at LineTest3.main(LineTest3.java:166)

Is there an example somewhere, where something similar is done?
Can I resample a thing with 2 dimension to one with 1 dimension? See
LineTest3.java
I have still to create 2 dimensions, right? But where do I get the
manifold dimension 1?

Thank your very much for your help again.

Desiree

> 
> Good luck,
> Bill
> 
> 
// Import needed classes

import visad.*;
import visad.util.*;
import visad.java3d.DisplayImplJ3D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;




public class LineTest2{

    // Declare variables
    // The domain quantities longitude and latitude
    // and the dependent quantity rgbVal
    
    private RealType x,y,height;
    
    // Tuple to pack x and y together    
    private RealTupleType xy;
    
    // The function (domain_tuple -> rgbVal )    
    private FunctionType terrain_type;
        
    // Our Data values for the domain are represented by the Set    
    private Set set;
        
    // The Data class FlatField    
    private FlatField terrain;
    
    // The DataReference from data to display    
    private DataReferenceImpl data_ref;
    
    // The 2D display, and its the maps    
    private DisplayImpl display;
    private ScalarMap hoxmap,reymap,heightmap;
    
    public LineTest2(String []args)
        throws RemoteException, VisADException {
        
        // Create the quantities
        // Use RealType(String name, Unit unit, Set set);
        

        RealType x = RealType.getRealType("x");
        RealType y = RealType.getRealType("y");
        RealType height = RealType.getRealType("height");

        xy = new RealTupleType(x, y);
        RealTupleType xheight = new RealTupleType(x, height);
        
        terrain_type = new FunctionType( xy, height);
        
        FunctionType line_type = new FunctionType(x,height);

        FunctionType test_type = new FunctionType(xheight,y);

        Linear1DSet line_set = new Linear1DSet(x, 0.0, 15.0, 5); 

        float[] eastValues = {1,2,7,7,13};
        float[] northValues = {3,8,1,6,3};
        float[] heightValues = {1,2,3,2,1};

        set = new Irregular2DSet(xy,new float[][] {eastValues, northValues});
        Irregular2DSet settest = new Irregular2DSet(xheight,new float[][] 
{eastValues, heightValues});

        FlatField test_vals_ff = new FlatField(test_type, settest);
        test_vals_ff.setSamples(new float[][] {northValues});

        FlatField line_vals_ff = new FlatField(line_type, line_set);
        line_vals_ff.setSamples(new float[][] {heightValues});
        
        // Create a FlatField
        // Use FlatField(FunctionType type, Set domain_set)
        
        terrain = new FlatField( terrain_type, set);
        
        // ...and put the rgbVal values above into it
        
        // Note the argument false, meaning that the array won't be copied
        
        terrain.setSamples(new float[][] {heightValues});

        //slope
        FlatField slope_vals_ff;
        slope_vals_ff = (FlatField) test_vals_ff.derivative(height, 
Data.NO_ERRORS );
        // Get the funtionc from the FlatField for slope      
        FunctionType func_domain_slope = 
((FunctionType)slope_vals_ff.getType());
        
        // "slope" is a RealType;       
        RealType slope = (RealType) func_domain_slope.getRange();
        
        // Create Display and its maps
        
        // This is new: a 3D 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: latitude to XAxis, longitude to YAxis and
        // rgbVal to ZAxis and to RGB
        // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)
        
        hoxmap = new ScalarMap( x, Display.XAxis );
        reymap = new ScalarMap( y, Display.YAxis );
        heightmap = new ScalarMap( height, Display.ZAxis );
        
        // Add maps to display
        
        display.addMap( hoxmap );
        display.addMap( reymap );
        display.addMap( heightmap );

        heightmap.setRange(0,15);
        hoxmap.setRange(0,15);
        reymap.setRange(0,15);
        
        // Create a data reference and set the FlatField as our data
        
        data_ref = new DataReferenceImpl("data_ref");
        
        data_ref.setData( terrain );

        DataReferenceImpl data_ref3 = new DataReferenceImpl("data_ref3");
        data_ref3.setData( line_vals_ff );
        display.addReference(data_ref3);

        DataReferenceImpl data_ref2 = new DataReferenceImpl("data_ref2");
        data_ref2.setData( slope_vals_ff );
        display.addReference(data_ref2);

        //DataReferenceImpl data_ref4 = new DataReferenceImpl("data_ref4");
        //data_ref4.setData( test_vals_ff );
        //display.addReference(data_ref4);

        // Add reference to display

        display.addReference( data_ref );
        
        // Create application window and add display to window
        
        JFrame jframe = new JFrame("VolumeTest1");
        jframe.getContentPane().add(display.getComponent());
        
        // Set window size and make it visible
        
        jframe.setSize(300, 300);
        jframe.setVisible(true);
    }
    
    
    public static void main(String[] args)
        throws RemoteException, VisADException
    {
        new LineTest2(args);
    }
    
}
// Import needed classes

import visad.*;
import visad.util.*;
import visad.java3d.DisplayImplJ3D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;




public class LineTest3{

    // Declare variables
    // The domain quantities longitude and latitude
    // and the dependent quantity rgbVal
    
    private RealType x,y,height;
    
    // Tuple to pack x and y together    
    private RealTupleType xy;
    
    // The function (domain_tuple -> rgbVal )    
    private FunctionType terrain_type;
        
    // Our Data values for the domain are represented by the Set    
    private Set set;
        
    // The Data class FlatField    
    private FlatField terrain;
    
    // The DataReference from data to display    
    private DataReferenceImpl data_ref;
    
    // The 2D display, and its the maps    
    private DisplayImpl display;
    private ScalarMap hoxmap,reymap,heightmap;
    
    public LineTest3(String []args)
        throws RemoteException, VisADException {
        
        // Create the quantities
        // Use RealType(String name, Unit unit, Set set);
        

        RealType x = RealType.getRealType("x");
        RealType y = RealType.getRealType("y");
        RealType height = RealType.getRealType("height");

        xy = new RealTupleType(x, y);
        RealTupleType xheight = new RealTupleType(x, height);
        
        terrain_type = new FunctionType( xy, height);
        
        FunctionType line_type = new FunctionType(x,height);

        FunctionType test_type = new FunctionType(xheight,y);

        Linear1DSet line_set = new Linear1DSet(x, 0.0, 15.0, 5); 

        float[] eastValues = {1,2,7,7,13};
        float[] northValues = {3,8,1,6,3};
        float[] heightValues = {1,2,3,2,1};

        set = new Irregular2DSet(xy,new float[][] {eastValues, northValues});
        Irregular2DSet settest = new Irregular2DSet(xheight,new float[][] 
{eastValues, heightValues});

        FlatField test_vals_ff = new FlatField(test_type, settest);
        test_vals_ff.setSamples(new float[][] {northValues});

        FlatField line_vals_ff = new FlatField(line_type, line_set);
        line_vals_ff.setSamples(new float[][] {heightValues});
        
        // Create a FlatField
        // Use FlatField(FunctionType type, Set domain_set)
        
        terrain = new FlatField( terrain_type, set);
        
        // ...and put the rgbVal values above into it
        
        // Note the argument false, meaning that the array won't be copied
        
        terrain.setSamples(new float[][] {heightValues});

        Linear1DSet set1D = new Linear1DSet(x,0,15,5);
        FlatField terrain_new = (FlatField) 
terrain.resample(set1D,Data.WEIGHTED_AVERAGE,Data.NO_ERRORS);

        //slope
        FlatField slope_vals_ff;
        slope_vals_ff = (FlatField) test_vals_ff.derivative(height, 
Data.NO_ERRORS );
        // Get the funtionc from the FlatField for slope      
        FunctionType func_domain_slope = 
((FunctionType)slope_vals_ff.getType());
        
        // "slope" is a RealType;       
        RealType slope = (RealType) func_domain_slope.getRange();
        
        // Create Display and its maps
        
        // This is new: a 3D 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: latitude to XAxis, longitude to YAxis and
        // rgbVal to ZAxis and to RGB
        // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)
        
        hoxmap = new ScalarMap( x, Display.XAxis );
        reymap = new ScalarMap( y, Display.YAxis );
        heightmap = new ScalarMap( height, Display.ZAxis );
        
        // Add maps to display
        
        display.addMap( hoxmap );
        display.addMap( reymap );
        display.addMap( heightmap );

        heightmap.setRange(0,15);
        hoxmap.setRange(0,15);
        reymap.setRange(0,15);
        
        // Create a data reference and set the FlatField as our data
        
        data_ref = new DataReferenceImpl("data_ref");
        
        data_ref.setData( terrain );

        DataReferenceImpl data_ref3 = new DataReferenceImpl("data_ref3");
        data_ref3.setData( line_vals_ff );
        display.addReference(data_ref3);

        DataReferenceImpl data_ref2 = new DataReferenceImpl("data_ref2");
        data_ref2.setData( slope_vals_ff );
        display.addReference(data_ref2);

        //DataReferenceImpl data_ref4 = new DataReferenceImpl("data_ref4");
        //data_ref4.setData( test_vals_ff );
        //display.addReference(data_ref4);

        // Add reference to display

        display.addReference( data_ref );
        
        // Create application window and add display to window
        
        JFrame jframe = new JFrame("VolumeTest1");
        jframe.getContentPane().add(display.getComponent());
        
        // Set window size and make it visible
        
        jframe.setSize(300, 300);
        jframe.setVisible(true);
    }
    
    
    public static void main(String[] args)
        throws RemoteException, VisADException
    {
        new LineTest3(args);
    }
    
}
  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: