Hi Bill and others,
sometime last year you helped me creating a Delaunay-Triangulation with
Visad and catching the Java3D-Shape3D.
In the meantime I used a similar way to construct a terrain out of a
Linear2DSet:
public void makeSurface() {
eastValues = RealType.getRealType("eastValues");
northValues = RealType.getRealType("northValues");
heightValues = RealType.getRealType("heightValues");
try {
domain_tuple = new RealTupleType(northValues,eastValues);
// Create a FunctionType (domain_tuple -> range_tuple);
func_en_h = new FunctionType(domain_tuple, heightValues);
//System.out.println("nCols "+nCols);
//System.out.println("nRows "+nRows);
//System.out.println(northMin+" "+northMax+" "+eastMin+" "+eastMax);
domain_set = new
Linear2DSet(domain_tuple,northMin,northMax,nRows,eastMin, eastMax, nCols);
// Get the Set samples to facilitate the calculations
float[][] set_samples = domain_set.getSamples( true );
// We create another array, with the same number of elements
of
// altitude and temperature, but organized as
// float[2][ number_of_samples ]
float[][] flat_samples = new float[1][nCols * nRows];
// ...and then we fill our 'flat' array with the generated
values
// by looping over NCOLS and NROWS
// specifiy height
for(int c = 0; c < nCols; c++){
for(int r = 0; r < nRows; r++){
flat_samples[0][c*nRows+r] = height[c*nRows+r];
}
}
// Create a FlatField
// Use FlatField(FunctionType type, Set domain_set)
vals_ff = new FlatField( func_en_h, domain_set);
// ...and put the values above into it
// Note the argument false, meaning that the array won't be
copied
vals_ff.setSamples( flat_samples , false );
// Create Display and its maps
// A 2D display
display = new DisplayImplJ3D("display1");
// Create the ScalarMaps: latitude to XAxis, longitude to
YAxis and
// altitude to RGB and temperature to IsoContour
// Use ScalarMap(ScalarType scalar, DisplayRealType
display_scalar)
eastMap = new ScalarMap( eastValues, Display.YAxis );
northMap = new ScalarMap( northValues, Display.XAxis );
heightMap = new ScalarMap(heightValues,Display.ZAxis);
eastMap.setRange(-1.0, 1.0);
northMap.setRange(-1.0, 1.0);
heightMap.setRange(-1.0, 1.0);
// Add maps to display
display.addMap( eastMap );
display.addMap( northMap );
display.addMap( heightMap );
// Create a data reference and set the FlatField as our data
data_ref = new DataReferenceImpl("data_ref");
data_ref.setData( vals_ff );
renderer = new DefaultRendererJ3D();
// Add reference to display
display.addReferences(renderer,data_ref);
//display.addReference( data_ref );
display.addDisplayListener(listener);
}
catch (VisADException ve) {
System.out.println("VisADException");
System.out.println(ve.getMessage());
}
catch (RemoteException re) {
System.out.println("RemoteExcpetion");
System.out.println(re.getMessage());
}
}
This is working for data samples with a rectangle layout.
. . . . .
. . . . .
. . . . .
. . . . .
My new kind of data samples is still a grid like structure, with the same
space value between my coordinates, but it is not filled to an recangle.
It looks more like this:
. .
. . .
. . .
. . . .
. . . . . .
. . . .
. .
Is there a possibility to fill the not defined points with a kind of hole
value, or is it possible to create a not rectangle Linear2DSet? Or is
there another solution, I am not aware of?
Thanks for your help in advance.
Desiree
oooooooooooooooooooooooooooooooooooooooooooooooo
Desiree Hilbring
Institut fuer Photogrammetrie und Fernerkundung
Universitaet Karlsruhe, Germany
email: hilbring@xxxxxxxxxxxxxxxxxxxx
# 0721 6083676
oooooooooooooooooooooooooooooooooooooooooooooooo
On Mon, 16 Oct 2000, Bill Hibbard wrote:
> Hi Desiree,
>
> > I did manage to include the with VisAD created Delaunay Shape3D Object in
> > my application.
>
> Great.
>
> > /**
> > * Triangulation of given set of points with delaunay. This method
> > * throws an event, when 3D-Objects are ready. See displayChanged.
> > */
> > public void makeSurface() {
> > //System.out.println("Hallo Delaunay!");
> > RealType x = RealType.getRealType("x");
> > RealType y = RealType.getRealType("y");
> > RealType height = RealType.getRealType("height");
> > try {
> > RealTupleType xy = new RealTupleType(x, y);
> > FunctionType terrain_type = new FunctionType(xy, height);
> > Irregular2DSet set = new Irregular2DSet(xy,new float[][]
> > {eastValues,northValues});
> > FlatField terrain = new FlatField(terrain_type, set);
> > terrain.setSamples(new float[][] {heightValues});
> >
> > display = new DisplayImplJ3D("display1");
> > ScalarMap hoxmap = new ScalarMap(x, Display.XAxis);
> > ScalarMap reymap = new ScalarMap(y, Display.YAxis);
> > ScalarMap heightmap = new ScalarMap(height, Display.ZAxis);
> >
> > display.addMap(hoxmap);
> > display.addMap(reymap);
> > display.addMap(heightmap);
> >
> > hoxmap.setRange(-1.0, 1.0);
> > reymap.setRange(-1.0, 1.0);
> > heightmap.setRange(-1.0, 1.0);
> >
> > DataReferenceImpl data_ref = new
> > DataReferenceImpl("data_ref");
> > data_ref.setData( terrain );
> > renderer = new DefaultRendererJ3D();
> > display.addReferences(renderer,data_ref);
> > display.addDisplayListener(listener);
> > }
> > catch (VisADException ve) {
> > System.out.println("VisAd TupleType Exception");
> > }
> > catch (RemoteException re) {
> > System.out.println("RemoteExcpetion");
> > }
> > //System.out.println("Delaunay ende!");
> > }
> >
> > Is it possible with visad to get a shap3d of a part of this triangulation?
> > Say, I do have coordinates of a point and want to clip the parts of the
> > object, which are more far away, than 10m, or something similar?
>
> Yes, if you want to clip in x, y and/or height. Just add
> ScalarMaps from any of them to Display.SelectRange, then
> do something like:
>
> RangeControl control = (RangeControl) range_map.getControl();
> control.setRange(low, hi); // set low and hi clip values
>
> Note this is different from ScalarMap.setRange(). It should
> give you the part of the irregular syrface within the clip range(s).
>
> Cheers,
> Bill
> ----------------------------------------------------------
> Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
> hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
> http://www.ssec.wisc.edu/~billh/vis.html
>