Irregular2Dsets and Irregular3Dsets



Hello all,

 Until now i've being using Irregular2dSets to creat small "rectangles"
where a flatfield shows the color behaviour, but now i've to introduce
Altitude to the system and instead of rectangles i must have cubes or
Irregular3dsets i thought.
 For a Irregualr2dset you define 4 points and 4 color values in each
point and you have a "solid" rectangle, but i create a irregular3dset
with 8 points with eight color values in for the flatfield i get 4
points in space instead of a cube with color variation.
 How can i get a cube?

Cheers,
Tiago Simoes

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import visad.*;
import visad.java3d.*;
import visad.util.*;

public class tester
{
  private DisplayImpl display;

  public tester()
  {
    try {
      display = new DisplayImplJ3D("display");

      RealType rgb = new RealType("rgb");

      ScalarMap latMap = new ScalarMap(RealType.Latitude, Display.XAxis);
      ScalarMap lonMap = new ScalarMap(RealType.Longitude, Display.YAxis);
      ScalarMap hgtMap = new ScalarMap(RealType.Radius, Display.ZAxis);
      ScalarMap clrMap = new ScalarMap(rgb, Display.RGB);

      display.addMap(latMap);
      display.addMap(lonMap);
      display.addMap(hgtMap);
      display.addMap(clrMap);

      latMap.setRange(-90.0, 90.0);
      lonMap.setRange(-180.0, 180.0);
      hgtMap.setRange(0.0f, 100.0f);

      RealTupleType lt = new RealTupleType(RealType.Latitude, 
RealType.Longitude);

      LinearLatLonSet land = new 
LinearLatLonSet(lt,90.0,-90.0,100,180.0,-180.0,100);

      DataReference land_ref = new DataReferenceImpl("land");
      land_ref.setData(land);

      ConstantMap[] landConstantMap = new ConstantMap[3];
      landConstantMap[0] = new ConstantMap(1.0f, Display.Blue);
      landConstantMap[1] = new ConstantMap(0.0f, Display.Red);
      landConstantMap[2] = new ConstantMap(0.0f, Display.Green);

      RealTupleType fieldtuple = new RealTupleType(RealType.Latitude, 
RealType.Longitude, RealType.Radius);

      FunctionType funccolor = new FunctionType(fieldtuple, rgb);

      Irregular3DSet dataSystem[] = new Irregular3DSet[1];

      float[][] pol = new float[3][8];

      pol[0][0] = 32.0f;
      pol[1][0] = 50.0f;
      pol[2][0] = 20.0f;

      pol[0][1] = 40.0f;
      pol[1][1] = 60.0f;
      pol[2][1] = 20.0f;

      pol[0][2] = 35.5f;
      pol[1][2] = 53.0f;
      pol[2][2] = 20.0f;

      pol[0][3] = 33.0f;
      pol[1][3] = 60.0f;
      pol[2][3] = 20.0f;

      pol[0][4] = 32.0f;
      pol[1][4] = 50.0f;
      pol[2][4] = 60.0f;

      pol[0][5] = 40.0f;
      pol[1][5] = 60.0f;
      pol[2][5] = 60.0f;

      pol[0][6] = 35.5f;
      pol[1][6] = 53.0f;
      pol[2][6] = 60.0f;

      pol[0][7] = 33.0f;
      pol[1][7] = 60.0f;
      pol[2][7] = 60.0f;

      dataSystem[0] = new Irregular3DSet(fieldtuple,pol);

      UnionSet layerLines = new UnionSet(fieldtuple, dataSystem);

      FlatField color_ff = new FlatField(funccolor, layerLines);

      float[][] color_Vals = new float[1][8];

      color_Vals[0][0] = 0.0f;
      color_Vals[0][1] = 1.0f;
      color_Vals[0][2] = 0.0f;
      color_Vals[0][3] = 1.0f;
      color_Vals[0][4] = 0.5f;
      color_Vals[0][5] = 0.0f;
      color_Vals[0][6] = 0.5f;
      color_Vals[0][7] = 1.0f;

      color_ff.setSamples(color_Vals, false);

      DataReferenceImpl layerLinesRef = new DataReferenceImpl("layerLines");
      layerLinesRef.setData(color_ff);

      display.addReference(layerLinesRef);

      JFrame frame = new JFrame("Tester");
      frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) { System.exit(0); }
      });

      frame.getContentPane().setLayout(new BorderLayout());
      frame.getContentPane().add(display.getComponent(), BorderLayout.CENTER);
      //frame.getContentPane().add(vs, BorderLayout.SOUTH);
      frame.setSize(1000, 900);
      frame.setVisible(true);

      GraphicsModeControl dispGMC = display.getGraphicsModeControl();
      dispGMC.setScaleEnable(true);

    } catch (Exception ne) {
      ne.printStackTrace();
      System.exit(1);
    }
  }

  public static void main(String[] args)
  {
    tester satDisplay = new tester();
  }

}

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