Revision: 5160
Author: hansonr
Date: 2006-05-23 05:08:14 -0700 (Tue, 23 May 2006)
ViewCVS: http://svn.sourceforge.net/jmol/?rev=5160&view=rev
Log Message:
-----------
bob200306 isosurface JVXL Jmol Voxel File format Phase I complete (reading and
writing single-color JVXL files)
Modified Paths:
--------------
branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java
branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java
branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java
Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java
===================================================================
--- branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java 2006-05-22
21:30:32 UTC (rev 5159)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/Isosurface.java 2006-05-23
12:08:14 UTC (rev 5160)
@@ -198,23 +198,6 @@
voxelData = null;
}
- /*
- System.out.println("setProperty(" + propertyName + "," + value + ")");
- if ("load" == propertyName) {
- volumetricOrigin = new Point3f((float[])((Object[])value)[0]);
- float[][] vvectors = (float[][])((Object[])value)[1];
- for (int i = 3; --i >= 0; ) {
- volumetricVectors[i] = new Vector3f(vvectors[i]);
- }
- volumetricData = (float[][][])((Object[])value)[2];
-
- calcVoxelVertexVectors();
- constructTessellatedSurface();
- mesh.initialize();
- return;
- }
- */
-
////////////////////////////////////////////////////////////////
// default color stuff
int indexColorPositive;
@@ -263,10 +246,10 @@
}
}
- String JvxlHeader = "";
+ String jvxlHeader = "";
void readTitleLines() throws Exception {
- JvxlHeader = br.readLine() + "\n";
- JvxlHeader += br.readLine() + "\n";
+ jvxlHeader = br.readLine() + "\n";
+ jvxlHeader += br.readLine() + "\n";
}
int atomCount;
@@ -274,7 +257,7 @@
void readAtomCountAndOrigin() throws Exception {
line = br.readLine();
- JvxlHeader += line + "\n";
+ jvxlHeader += line + "\n";
atomCount = parseInt(line);
volumetricOrigin.x = parseFloat(line, ichNextParse);
volumetricOrigin.y = parseFloat(line, ichNextParse);
@@ -293,7 +276,7 @@
void readVoxelVector(int voxelVectorIndex) throws Exception {
line = br.readLine();
- JvxlHeader += line + "\n";
+ jvxlHeader += line + "\n";
Vector3f voxelVector = volumetricVectors[voxelVectorIndex];
voxelCounts[voxelVectorIndex] = parseInt(line);
voxelVector.x = parseFloat(line, ichNextParse);
@@ -306,7 +289,7 @@
void readAtoms() throws Exception {
for (int i = 0; i < atomCount; ++i) {
- JvxlHeader += br.readLine() + "\n";
+ jvxlHeader += br.readLine() + "\n";
/*
Atom atom = atomSetCollection.addNewAtom();
@@ -324,35 +307,35 @@
if (!negativeAtomCount)
return 1;
int nSurfaces = parseInt(line = br.readLine());
+ jvxlFileData = jvxlHeader;
isJvxl = (nSurfaces < 0);
- createJvxl = ! isJvxl;
if (isJvxl) {
nSurfaces = -nSurfaces;
edgeFractionBase = (char) parseInt(line, ichNextParse);
edgeFractionRange = parseFloat(line, ichNextParse);
System.out.println("JVXL reading base: " + edgeFractionBase + " range: "
+ edgeFractionRange);
- for (int i = 0; i < nSurfaces; i++)
- br.readLine(); // for now, skip definition line
}
+ jvxlFileData += "-1 " + (int) edgeFractionBase + " "
+ + (int) edgeFractionRange + " Jmol voxel format version 0.9a" + "\n";
return nSurfaces;
}
- boolean createJvxl = true; // for now
- String line = "";
- int nBytes = 0;
- int nDataPoints = 1;
- String data = "";
+ String line;
+ int nBytes;
+ int nDataPoints;
+ String surfaceData;
+ String edgeData;
void readVoxelData() throws Exception {
System.out.println("entering readVoxelData for fileIndex = " + fileIndex);
ichNextParse = 0;
- line = "";
thisValue = Integer.MIN_VALUE;
nThisValue = 0;
boolean inside = false;
int dataCount = 0;
- data = "";
+ surfaceData = "";
+ edgeData = "";
nBytes = 0;
thisInside = true;
nDataPoints = 1;
@@ -360,7 +343,13 @@
int voxelCountY = voxelCounts[1];
int voxelCountZ = voxelCounts[2];
voxelData = new float[voxelCountX][][];
- skipData((fileIndex - 1) * voxelCountX * voxelCountY * voxelCountZ);
+ skipData(fileIndex - 1);
+ if (isJvxl) {
+ br.readLine(); //skip definition line for now
+ System.out.println("jvxl data set: " + line);
+ cutoff = 0.5f; //just 0s and 1s here. detail is in the edgeFractions
+ }
+ line = "";
for (int x = 0; x < voxelCountX; ++x) {
float[][] plane = new float[voxelCountY][];
voxelData[x] = plane;
@@ -370,13 +359,12 @@
for (int z = 0; z < voxelCountZ; ++z) {
float voxelValue = getNextVoxelValue();
strip[z] = voxelValue;
- if (createJvxl) {
- boolean isInside = ((cutoff > 0 && voxelValue >= cutoff) ||
- (cutoff < 0 && voxelValue <= cutoff));
+ if (! isJvxl) {
+ boolean isInside = ((cutoff > 0 && voxelValue >= cutoff) ||
(cutoff < 0 && voxelValue <= cutoff));
if (inside == isInside) {
dataCount++;
} else {
- data += " " + dataCount;
+ surfaceData += " " + dataCount;
++nDataPoints;
dataCount = 1;
inside = !inside;
@@ -385,8 +373,8 @@
}
}
}
- if (createJvxl) {
- data += " " + dataCount;
+ if (! isJvxl) {
+ surfaceData += " " + dataCount + "\n";
}
System.out.println("Successfully read " + voxelCountX + " x " + voxelCountY
+ " x " + voxelCountZ + " voxels");
@@ -401,6 +389,7 @@
nThisValue = parseInt(line, ichNextParse);
if (nThisValue == Integer.MIN_VALUE) {
line = br.readLine();
+ surfaceData += line + "\n";
if (line == null || (nThisValue = parseInt(line)) ==
Integer.MIN_VALUE) {
System.out.println("end of file in JvxlReader? (x,y,z,line):"+
line);
throw new NullPointerException();
@@ -427,10 +416,14 @@
void skipData(int n) throws Exception {
if (n == 0)
return;
- System.out.println("skipping " + n + " datapoints");
+ System.out.println("skipping " + n + " data sets");
+ int nVertices = voxelCountX * voxelCountY * voxelCountZ;
+ for (int i = 0; i < n; i++)
+ if (isJvxl)
+ br.readLine(); //skip definition line
String line = "";
int i=0;
- while (i < n) {
+ while (i < nVertices) {
line = br.readLine();
int c = countData(line);
i += c;
@@ -475,7 +468,8 @@
final int[] surfacePointIndexes = new int[12];
int voxelCountX, voxelCountY, voxelCountZ;
-
+ String jvxlFileData;
+
void constructTessellatedSurface() {
voxelCountX = voxelData.length - 1;
voxelCountY = voxelData[0].length - 1;
@@ -534,34 +528,27 @@
}
}
}
- if (createJvxl)
- dumpJvxlData();
- System.out.println("volumetric=" +
- voxelCountX + "," +
- voxelCountY + "," +
- voxelCountZ + "," +
- " total=" +
- (voxelCountX*voxelCountY*voxelCountZ) +
- "\n" +
- " insideCount=" + insideCount +
- " outsideCount=" + outsideCount +
- " surfaceCount=" + surfaceCount +
- " total=" +
- (insideCount+
- outsideCount+surfaceCount));
- }
- void dumpJvxlData() {
- System.out.print(JvxlHeader);
- System.out.println("-1 " + (int)edgeFractionBase + " " + (int)
edgeFractionRange
- + " Jmol voxel format version 0.9"
- + "\n" + cutoff + " " + data.length() + " " + edgeFractions.length()
- + " compressionRatio="
- + (nBytes * 1f / (data.length() + edgeFractions.length()))
- + "\n" + data
- + "\n" + edgeFractions);
+ if (!isJvxl)
+ edgeData += "\n";
+ jvxlFileData += cutoff + " " + surfaceData.length() + " " +
edgeData.length();
+ if (!isJvxl) {
+ jvxlFileData += " compressionRatio="
+ + (nBytes * 1f / (surfaceData.length() + edgeData.length()));
+ }
+ jvxlFileData += "\n" + surfaceData + edgeData;
+ currentMesh.jvxlFileData = jvxlFileData;
+ System.out.println("volumetric=" + voxelCountX + "," + voxelCountY + ","
+ + voxelCountZ + "," + " total="
+ + (voxelCountX * voxelCountY * voxelCountZ) + "\n" + " insideCount="
+ + insideCount + " outsideCount=" + outsideCount + " surfaceCount="
+ + surfaceCount + " total="
+ + (insideCount + outsideCount + surfaceCount));
+ System.out.println("-------start of jvxl file data-------\n" + jvxlFileData
+ + "-------end of jvxl file data-------\n");
+
}
-
+
final int[] nullNeighbor = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
int[] propogateNeighborPointIndexes(int x, int y, int z,
@@ -655,6 +642,7 @@
return 0;
if (edgeFractionPtr >= edgeFractions.length()) {
edgeFractions = br.readLine();
+ edgeData += edgeFractions + "\n";
if (edgeFractions == null) {
System.out.println("end of file reading edgeFractions");
throw new NullPointerException();
@@ -678,13 +666,13 @@
} else {
float diff = valueB - valueA;
fraction = (cutoff - valueA) / diff;
- if (createJvxl) {
+ if (! isJvxl) {
int ich = (int)(fraction * edgeFractionRange + edgeFractionBase);
if (ich == 92)
ich = 33; // \ --> !
if (logMessages)
System.out.println(fraction +" --> " + ich + " " + (char)ich);
- edgeFractions += (char) (ich);
+ edgeData += (char) (ich);
}
if (Float.isNaN(fraction) || fraction < 0 || fraction > 1) {
System.out.println("fraction=" + fraction + " cutoff=" + cutoff + " A:"
Modified: branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java
===================================================================
--- branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java 2006-05-22
21:30:32 UTC (rev 5159)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/Mesh.java 2006-05-23
12:08:14 UTC (rev 5160)
@@ -34,6 +34,7 @@
Viewer viewer;
String meshID;
+ String jvxlFileData;
boolean visible = true;
short colix;
short[] vertexColixes;
Modified: branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java
===================================================================
--- branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java
2006-05-22 21:30:32 UTC (rev 5159)
+++ branches/bob200603/Jmol/src/org/jmol/viewer/MeshCollection.java
2006-05-23 12:08:14 UTC (rev 5160)
@@ -325,6 +325,11 @@
}
return V;
}
-
+
+ String getJvxlFileData() {
+ if (currentMesh == null)
+ return null;
+ return currentMesh.jvxlFileData;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jmol-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-commits