Sorry Bill,
I saw, that the mailer had send my reply to your private email address.
Here is the answer to your question at the mailing list.
-------- Original Message --------
Subject: Re: Problem with DelaunayCustom
Date: Thu, 18 Jul 2002 01:46:05 +0200
From: Olav Rybatzki <o.rybatzki@xxxxxx>
To: Bill Hibbard <billh@xxxxxxxxxxxxx>
References: <Pine.GSO.4.44.0207171806310.8736-100000@xxxxxxxxxxxxxxxxxx>
Bill Hibbard wrote:
> On Thu, 18 Jul 2002, Olav Rybatzki wrote:
>
>
>>I have a problem with the DelaunayCustom. The data I get are
>>unstructured with a connectivity list of 8 points per node (a
hexahedron).
>>
>>
>>
7-------------6
>> . | . |
>> 4 | 5 |
>> | | | |
>> | | | |
>> | 3---------|---2
>> | . | .
>> 0--------------1
>>
>>
>>To get my data into the DelaunayCustom I split the hexahedron into 5
>>tetrahedron. The 5 tetrahedrons have the following points,
>>
>>tetra_1 (0,5,7,4)
>>tetra_2 (0,5,7,2)
>>tetra_3 (0,2,5,1)
>>tetra_4 (0,2,7,3)
>>tetra_5 (7,5,2,6)
>>
>>Now when I create the DelaunayCustom with the new connectivity list I
>>get the following exception
>>
>>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
>> at visad.Delaunay.finish_triang(Delaunay.java:510)
>> at visad.DelaunayCustom.<init>(DelaunayCustom.java:115)
>> at visad.DelaunayCustom.<init>(DelaunayCustom.java:43)
>
>
> Thanks for the stack dump, but I cannot determine the
> problem from it. Can you send me a simple program that
> generates this Exception?
>
> Thanks, Bill
>
>
Hi Bill,
thank you for your answer. Here comes the code.
RealType tempType = reader.getTemperatureType();
RealTupleType domainTuple = reader.getCoordinateTuple();
FunctionType funcDomainTemperature = new
FunctionType(domainTuple, tempType);
Vector axis = reader.getAxisValues();
RealType xaxisType = reader.getXAxisType();
RealType yaxisType = reader.getYAxisType();
RealType zaxisType = reader.getZAxisType();
Vector variable = reader.getVariableValues();
DisplayImplJ3D display3D = new DisplayImplJ3D("3D Display" +
reader.getTitle());
GraphicsModeControl dispGMC = (GraphicsModeControl)
display3D.getGraphicsModeControl();
ScalarMap colMap = new ScalarMap(xaxisType, Display.XAxis);
ScalarMap rowMap = new ScalarMap(yaxisType, Display.YAxis);
ScalarMap zMap = new ScalarMap(zaxisType, Display.ZAxis);
ScalarMap tempMap = new ScalarMap(tempType, Display.RGB);
ScalarMap tempIsoMap = new ScalarMap(tempType,
Display.IsoContour);
display3D.addMap(colMap);
display3D.addMap(rowMap);
display3D.addMap(zMap);
//display3D.addMap (tempIsoMap);
display3D.addMap(tempMap);
float[][] pointValues = (float[][])axis.get(0);
int[][] connect =
Tools.hexaedronToTretrahedron(reader.getConnectingList());
System.gc();
DelaunayCustom tri = new DelaunayCustom(pointValues, connect);
Irregular3DSet domainSet = new Irregular3DSet(domainTuple,
pointValues,
null,
null,
null,
tri);
FlatField val_ff = new FlatField(funcDomainTemperature,
domainSet);
float[][] var = (float[][]) variable.get(0);
System.gc();
float[][] data = new float[1][var[0].length];
for(i=0; i<var[0].length; i++)
{
data[0][i] = var[1][i];
}
System.out.println("Array of Temp values is now ready for use");
System.gc();
val_ff.setSamples(data);
DataReferenceImpl data_ref = new DataReferenceImpl("data_ref");
data_ref.setData(val_ff);
display3D.addReference( data_ref );
JFrame frame = new JFrame("First VisAD Test" + reader.getTitle());
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.getContentPane().add(display3D.getComponent());
frame.setSize(400, 300);
frame.setVisible(true);
The algoritm to split a hexahedron to 5 tetrahedrons, placed in the
class Tools, is shown below.
public static int[][] hexaedronToTretrahedron(int[][] hex)
{
int[][] hexa = hex;
int[][] tetra = new int[hexa.length*5][4];
for(int i=0; i<hexa.length; i++)
{
tetra[i*5][0] = hexa[i][0];
tetra[i*5][1] = hexa[i][5];
tetra[i*5][2] = hexa[i][7];
tetra[i*5][3] = hexa[i][4];
tetra[i*5+1][0] = hexa[i][0];
tetra[i*5+1][1] = hexa[i][5];
tetra[i*5+1][2] = hexa[i][7];
tetra[i*5+1][3] = hexa[i][2];
tetra[i*5+2][0] = hexa[i][0];
tetra[i*5+2][1] = hexa[i][2];
tetra[i*5+2][2] = hexa[i][5];
tetra[i*5+2][3] = hexa[i][7];
tetra[i*5+3][0] = hexa[i][0];
tetra[i*5+3][1] = hexa[i][2];
tetra[i*5+3][2] = hexa[i][7];
tetra[i*5+3][3] = hexa[i][3];
tetra[i*5+4][0] = hexa[i][7];
tetra[i*5+4][1] = hexa[i][5];
tetra[i*5+4][2] = hexa[i][2];
tetra[i*5+4][3] = hexa[i][6];
}
return tetra;
}
Thanks, Olav