[vtkusers] Read Scalar in a VTK File with JAVA
gehin pierre-alexandre
pagehin at hotmail.com
Thu Jan 5 10:02:21 EST 2006
Hello,
I am trying to read scalar Data in a VTK File (with extension ".VTK")
This file contain a Structured Grid with different scalars. I already read
the grid Data and the the scalar name, but i don't find how to read scalar.
public class ImportVTKLoad {
private String filetoload = null;
private String header = null;
static {
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkRenderingJava");
}
public ImportVTKLoad(String filetoload) {
this.filetoload = filetoload;
}
void LoadFile() {
String[] PropertieName = new String[15];
double[][] GridPoint = new double[800][3];
vtkStructuredGridReader asciiReader = new vtkStructuredGridReader();
asciiReader.SetFileName(this.filetoload);
asciiReader.Update();
int j = -1;
while (!asciiReader.GetScalarsNameInFile(j+1).equals("")){
j=j+1;
PropertieName[j] = asciiReader.GetScalarsNameInFile(j);
}
for (int i = 0;i<asciiReader.GetOutput().GetNumberOfPoints()-1;i++) {
double[] tempGridPoint = asciiReader.GetOutput().GetPoint(i);
for (int k = 0;k<3;k++){
GridPoint[i][k] = tempGridPoint [k];
}
}
}
# vtk DataFile Version 2.0
Dump SimpleGrid3D
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS 11 11 6
POINTS 726 float
1.0 2.0 3.0
5.0 0.0 0.0
..............
CELL_DATA 500
SCALARS Porosity float 1
LOOKUP_TABLE default
7.84207296371
13.507144928
............
Thanks.
More information about the vtkusers
mailing list