From: <ha...@us...> - 2010-08-30 20:17:26
|
Revision: 14197 http://jmol.svn.sourceforge.net/jmol/?rev=14197&view=rev Author: hansonr Date: 2010-08-30 20:17:18 +0000 (Mon, 30 Aug 2010) Log Message: ----------- version=12.1.9_dev # bug fix: isosurface "t.jvxl" map property temperature nonfunctional Modified Paths: -------------- trunk/Jmol/src/org/jmol/atomdata/AtomDataServer.java trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java trunk/Jmol/src/org/jmol/jvxl/data/VolumeData.java trunk/Jmol/src/org/jmol/jvxl/readers/AtomDataReader.java trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java trunk/Jmol/src/org/jmol/modelset/Model.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/jvxl/readers/AtomPropertyMapper.java Modified: trunk/Jmol/src/org/jmol/atomdata/AtomDataServer.java =================================================================== --- trunk/Jmol/src/org/jmol/atomdata/AtomDataServer.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/atomdata/AtomDataServer.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -3,6 +3,8 @@ import java.io.BufferedInputStream; import java.util.BitSet; +import javax.vecmath.Point3f; + import org.jmol.api.AtomIndexIterator; @@ -14,6 +16,9 @@ public void setIteratorForAtom(AtomIndexIterator iterator, int atomIndex, float distance); + public void setIteratorForPoint(AtomIndexIterator iter, int modelIndex, Point3f pt, + float maxDistance); + public void fillAtomData(AtomData atomData, int mode); public BufferedInputStream getBufferedInputStream(String fullPathName); Modified: trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/calc/MarchingSquares.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -103,7 +103,7 @@ this.valueMax = valueMax; } - private int contourVertexCount; + public int contourVertexCount; ContourVertex[] contourVertexes = new ContourVertex[1000]; private static class ContourVertex extends Point3f { @@ -263,7 +263,7 @@ } void setValidity(float min, float max) { - isValid = (contourVertexes[pts[0]].value <= max + isValid &= (contourVertexes[pts[0]].value <= max && contourVertexes[pts[1]].value <= max && contourVertexes[pts[2]].value <= max && contourVertexes[pts[0]].value >= min Modified: trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/data/JvxlCoder.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -507,7 +507,8 @@ int colorFractionRange = jvxlData.colorFractionRange; float valueBlue = jvxlData.valueMappedToBlue; float valueRed = jvxlData.valueMappedToRed; - int vertexCount = jvxlData.vertexCount; + int vertexCount = (jvxlData.saveVertexCount > 0 ? jvxlData.saveVertexCount + : jvxlData.vertexCount); float min = jvxlData.mappedDataMin; float max = jvxlData.mappedDataMax; StringBuffer list1 = new StringBuffer(); Modified: trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/data/JvxlData.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -146,6 +146,7 @@ public boolean colorDensity; public String moleculeXml; public float dataMin, dataMax; + public int saveVertexCount; public void setSurfaceInfo(Point4f thePlane, int nSurfaceInts, String surfaceData) { jvxlSurfaceData = surfaceData; Modified: trunk/Jmol/src/org/jmol/jvxl/data/VolumeData.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/data/VolumeData.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/data/VolumeData.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -128,6 +128,9 @@ public class VolumeData implements VolumeDataInterface { + public SurfaceReader sr; + public boolean doIterate = true; + public final Point3f volumetricOrigin = new Point3f(); public final float[] origin = new float[3]; public final Vector3f[] volumetricVectors = new Vector3f[3]; @@ -284,8 +287,6 @@ pt3i.set((int) ptXyzTemp.x, (int) ptXyzTemp.y, (int) ptXyzTemp.z); } - public SurfaceReader sr; - public float lookupInterpolatedVoxelValue(Point3f point) { if (sr != null) return sr.getValueAtPoint(point); @@ -427,7 +428,7 @@ edgeVector.sub(pointB, pointA); contourPoint.scaleAdd(fraction, edgeVector, pointA); float dist; - if (sr == null || valueB == valueA + if (sr == null || !doIterate || valueB == valueA || fraction < 0.01f || fraction > 0.99f || (dist = edgeVector.length()) < 0.01f) return fraction; @@ -440,10 +441,8 @@ - sr.getValueAtPoint(contourPoint)) / (valueB - valueA))) > 0.005f) { contourPoint.scaleAdd(diff, edgeVector, contourPoint); } - fraction = contourPoint.distance(pointA) / dist; - if (fraction > 1) - System.out.println("volumeData ohoh"); - return fraction; + dist = contourPoint.distance(pointA) / dist; + return (dist > 1 || dist < 0 ? fraction : dist); } } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/AtomDataReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/AtomDataReader.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/readers/AtomDataReader.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -44,6 +44,7 @@ abstract class AtomDataReader extends VolumeDataReader { protected AtomDataServer atomDataServer; + protected float maxDistance; AtomDataReader(SurfaceGenerator sg) { super(sg); @@ -67,7 +68,7 @@ protected int myAtomCount; protected int nearbyAtomCount; protected int firstNearbyAtom; - protected BitSet bsMySelected, bsMyIgnored; + protected BitSet bsMySelected, bsMyIgnored, bsNearby; protected boolean doAddHydrogens; protected boolean doUsePlane; @@ -136,6 +137,7 @@ BitSet atomSet = BitSetUtil.copy(bsMySelected); int nH = 0; atomProp = null; + float[] props = params.theProperty; if (myAtomCount > 0) { Point3f[] hAtoms = null; if (doAddHydrogens) { @@ -172,7 +174,6 @@ // + hAtoms[i].z + "};"); } myAtomCount = nH; - float[] props = params.theProperty; for (int i = atomSet.nextSetBit(0); i >= 0; i = atomSet.nextSetBit(i + 1)) { if (atomProp != null) atomProp[myAtomCount] = (props != null && i < props.length ? props[i] @@ -208,7 +209,7 @@ return; Point3f pt = new Point3f(); - BitSet bsNearby = new BitSet(); + bsNearby = new BitSet(); for (int i = 0; i < atomCount; i++) { if (atomSet.get(i) || bsMyIgnored.get(i)) continue; @@ -216,6 +217,8 @@ if (params.thePlane != null && Math.abs(volumeData.distancePointToPlane(atomData.atomXyz[i])) > 2 * rA) continue; + if (params.theProperty != null) + rA += maxDistance; pt = atomData.atomXyz[i]; if (pt.x + rA > xyzMin.x && pt.x - rA < xyzMax.x && pt.y + rA > xyzMin.y && pt.y - rA < xyzMax.y && pt.z + rA > xyzMin.z @@ -229,8 +232,14 @@ nAtoms += nearbyAtomCount; atomRadius = ArrayUtil.setLength(atomRadius, nAtoms); atomXyz = (Point3f[]) ArrayUtil.setLength(atomXyz, nAtoms); + if (props != null) + atomProp = ArrayUtil.setLength(atomProp, nAtoms); for (int i = bsNearby.nextSetBit(0); i >= 0; i = bsNearby .nextSetBit(i + 1)) { + if (props != null) { + atomProp[myAtomCount] = props[i]; + myIndex[i] = myAtomCount; + } atomXyz[myAtomCount] = atomData.atomXyz[i]; atomRadius[myAtomCount++] = atomData.atomRadius[i]; } Added: trunk/Jmol/src/org/jmol/jvxl/readers/AtomPropertyMapper.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/AtomPropertyMapper.java (rev 0) +++ trunk/Jmol/src/org/jmol/jvxl/readers/AtomPropertyMapper.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -0,0 +1,119 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2007-03-30 11:40:16 -0500 (Fri, 30 Mar 2007) $ + * $Revision: 7273 $ + * + * Copyright (C) 2007 Miguel, Bob, Jmol Development + * + * Contact: ha...@st... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jmol.jvxl.readers; + +import javax.vecmath.Point3f; + +import org.jmol.util.Logger; + +import org.jmol.api.AtomIndexIterator; + +class AtomPropertyMapper extends AtomDataReader { + + AtomPropertyMapper(SurfaceGenerator sg) { + super(sg); + } + //// maps property data //// + + private boolean doSmoothProperty; + private AtomIndexIterator iter; + + + @Override + protected void setup() { + super.setup(); + // MAP only + volumeData.sr = this; + volumeData.doIterate = false; + point = params.point; + doSmoothProperty = params.propertySmoothing; + doUseIterator = true; + maxDistance = 4; + getAtoms(Float.NaN, false, doSmoothProperty); + setHeader("property", params.calculationType); + // for plane mapping + setRangesAndAddAtoms(params.solvent_ptsPerAngstrom, params.solvent_gridMax, 0); + params.cutoff = 0; + } + + @Override + protected void initializeMapping() { + if (Logger.debugging) + Logger.startTimer(); + bsMySelected.or(bsNearby); + iter = atomDataServer.getSelectedAtomIterator(bsMySelected, false, true); + } + + @Override + protected void finalizeMapping() { + iter.release(); + iter = null; + if (Logger.debugging) + Logger.checkTimer("property mapping time"); + } + + //////////// meshData extensions //////////// + + /////////////// calculation methods ////////////// + + @Override + protected void generateCube() { + // not applicable + } + + @Override + public float getValueAtPoint(Point3f pt) { + float value = (doSmoothProperty ? 0 : Float.NaN); + float dmin = Float.MAX_VALUE; + float dminNearby = Float.MAX_VALUE; + float vdiv = 0; + atomDataServer.setIteratorForPoint(iter, modelIndex, pt, maxDistance); + while (iter.hasNext()) { + int iAtom = myIndex[iter.next()]; + boolean isNearby = (iAtom >= firstNearbyAtom); + Point3f ptA = atomXyz[iAtom]; + float p = atomProp[iAtom]; + if (Float.isNaN(p)) + continue; + float d = pt.distance(ptA); + if (isNearby) { + if (d < dminNearby) + dminNearby = d; + } else if (d < dmin) { + dmin = d; + if (!doSmoothProperty) + value = p; + } + if (doSmoothProperty) { // fourth-power smoothing + d = 1 / d; + d *= d; + d *= d; + vdiv += d; + value += d * p; + } + } + return (doSmoothProperty ? (vdiv == 0 || dminNearby < dmin ? Float.NaN : value / vdiv) : value); + } + +} Modified: trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -42,8 +42,6 @@ ///// solvent-accessible, solvent-excluded surface ////// - //// also creates a map for properties //// - /* * The surface fragment idea: * @@ -69,8 +67,6 @@ private boolean doCalculateTroughs; private boolean isCavity, isPocket; private float solventRadius; - private boolean isProperty; - private boolean doSmoothProperty; @Override protected void setup() { @@ -83,9 +79,6 @@ isCavity = (params.isCavity && meshDataServer != null); // Jvxl cannot do this calculation on its own. isPocket = (params.pocket != null && meshDataServer != null); - isProperty = (dataType == Parameters.SURFACE_PROPERTY); - doSmoothProperty = isProperty && params.propertySmoothing; - doCalculateTroughs = (atomDataServer != null && !isCavity // Jvxl needs an atom iterator to do this. && solventRadius > 0 && (dataType == Parameters.SURFACE_SOLVENT || dataType == Parameters.SURFACE_MOLECULAR)); doUseIterator = doCalculateTroughs; @@ -275,7 +268,7 @@ Point3f ptA; Point3f ptY0 = new Point3f(), ptZ0 = new Point3f(); Point3i pt0 = new Point3i(), pt1 = new Point3i(); - float value = (doSmoothProperty ? Float.NaN : Float.MAX_VALUE); + float value = Float.MAX_VALUE; if (Logger.debugging) Logger.startTimer(); for (int x = 0; x < nPointsX; ++x) @@ -285,16 +278,6 @@ if (dataType == Parameters.SURFACE_NOMAP) return; int atomCount = myAtomCount; - float property[][][] = null; - if (isProperty) { - atomCount = firstNearbyAtom; - property = new float[nPointsX][nPointsY][nPointsZ]; - value = (doSmoothProperty ? 0 : Float.NaN); - for (int x = 0; x < nPointsX; ++x) - for (int y = 0; y < nPointsY; ++y) - for (int z = 0; z < nPointsZ; ++z) - property[x][y][z] = value; - } float maxRadius = 0; float r0 = (isFirstPass && isCavity ? cavityRadius : 0); boolean isWithin = (isFirstPass && distance != Float.MAX_VALUE && point != null); @@ -316,20 +299,9 @@ ptZ0.set(ptXyzTemp); for (int k = pt0.z; k < pt1.z; k++) { float v = ptXyzTemp.distance(ptA) - rA; - if (doSmoothProperty) { - v = 1 / (v + rA); - v *= v; - v *= v; - if (Float.isNaN(voxelData[i][j][k])) - voxelData[i][j][k] = 0; - if (!Float.isNaN(atomProp[iAtom])) - property[i][j][k] += atomProp[iAtom] * v; - voxelData[i][j][k] += v; - } else if (v < voxelData[i][j][k]) { + if (v < voxelData[i][j][k]) { voxelData[i][j][k] = (isNearby || isWithin && ptXyzTemp.distance(point) > distance ? Float.NaN : v); - if (isProperty) - property[i][j][k] = atomProp[iAtom]; } ptXyzTemp.add(volumetricVectors[2]); } @@ -407,18 +379,6 @@ iter.release(); iter = null; } - if (doSmoothProperty) { - for (int x = 0; x < nPointsX; ++x) - for (int y = 0; y < nPointsY; ++y) - for (int z = 0; z < nPointsZ; ++z) - if (!Float.isNaN(voxelData[x][y][z])) - voxelData[x][y][z] = property[x][y][z] / voxelData[x][y][z]; - return; - } else if (isProperty) { - volumeData.voxelData = property; - setVolumeData(volumeData); - initializeVolumetricData(); - } if (params.thePlane == null) { for (int x = 0; x < nPointsX; ++x) for (int y = 0; y < nPointsY; ++y) @@ -441,7 +401,7 @@ } void setGridLimitsForAtom(Point3f ptA, float rA, Point3i pt0, Point3i pt1) { - int n = (isProperty ? 4 : 1); + int n = 1; volumeData.xyzToVoxelPt(ptA.x - rA, ptA.y - rA, ptA.z - rA, pt0); pt0.x -= n; pt0.y -= n; Modified: trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -246,6 +246,7 @@ title = null; atomRadiusData = null; rangeAll = false; + rangeSelected = false; } String calculationType = ""; @@ -713,6 +714,7 @@ boolean isPositiveOnly; boolean rangeAll; + boolean rangeSelected; public boolean rangeDefined; float valueMappedToRed, valueMappedToBlue; float mappedDataMin; @@ -747,8 +749,9 @@ mappedDataMax = 1; } if (mappedDataMin == Float.MAX_VALUE || mappedDataMin == mappedDataMax) { - mappedDataMin = surfaceReader.getMinMappedValue(); - mappedDataMax = surfaceReader.getMaxMappedValue(); + float[] minMax = surfaceReader.getMinMaxMappedValues(); + mappedDataMin = minMax[0]; + mappedDataMax = minMax[1]; } if (mappedDataMin == 0 && mappedDataMax == 0) { //just set default -1/1 if there is no obvious data Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -557,6 +557,11 @@ return true; } + if ("rangeSelected" == propertyName) { + params.rangeSelected = true; + return true; + } + if ("red" == propertyName) { params.valueMappedToRed = ((Float) value).floatValue(); return true; @@ -959,10 +964,12 @@ case Parameters.SURFACE_NOMAP: surfaceReader = new IsoPlaneReader(this); break; + case Parameters.SURFACE_PROPERTY: + surfaceReader = new AtomPropertyMapper(this); + break; case Parameters.SURFACE_SOLVENT: case Parameters.SURFACE_MOLECULAR: case Parameters.SURFACE_SASURFACE: - case Parameters.SURFACE_PROPERTY: surfaceReader = new IsoSolventReader(this); break; case Parameters.SURFACE_MOLECULARORBITAL: Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -308,9 +308,13 @@ } boolean readAndSetVolumeParameters() { - return (readVolumeParameters() && (vertexDataOnly || volumeData.setUnitVectors())); + return (readVolumeParameters() && (vertexDataOnly || setUnitVectors())); } + protected boolean setUnitVectors() { + return volumeData.setUnitVectors(); + } + boolean createIsosurface(boolean justForPlane) { resetIsosurface(); jvxlData.cutoff = Float.NaN; @@ -342,7 +346,8 @@ meshDataServer.fillMeshData(meshData, MeshData.MODE_GET_VERTICES, null); params.setMapRanges(this); generateSurfaceData(); - volumeData.voxelData = voxelDataTemp; + if (volumeData != null) + volumeData.voxelData = voxelDataTemp; } else { if (!readVolumeData(false)) return false; @@ -603,7 +608,7 @@ //////////////////////////////////////////////////////////////// void colorIsosurface() { - if (params.isSquared) + if (params.isSquared && volumeData != null) volumeData.filterData(true, Float.NaN); /* if (params.isContoured && marchingSquares == null) { // if (params.isContoured && !(jvxlDataIs2dContour || params.thePlane != null)) { @@ -616,14 +621,17 @@ } if (params.isContoured && marchingSquares != null) { + initializeMapping(); params.setMapRanges(this); marchingSquares.setMinMax(params.valueMappedToRed, params.valueMappedToBlue); + jvxlData.saveVertexCount = marchingSquares.contourVertexCount; contourVertexCount = marchingSquares - .generateContourData(jvxlDataIs2dContour); + .generateContourData(jvxlDataIs2dContour); jvxlData.contourValuesUsed = marchingSquares.getContourValues(); if (meshDataServer != null) meshDataServer.notifySurfaceGenerationCompleted(); + finalizeMapping(); } applyColorScale(); @@ -644,16 +652,11 @@ meshDataServer.fillMeshData(meshData, MeshData.MODE_GET_VERTICES, null); meshDataServer.fillMeshData(meshData, MeshData.MODE_GET_COLOR_INDEXES, null); } - params.setMapRanges(this); //colorBySign is true when colorByPhase is true, but not vice-versa //old: boolean saveColorData = !(params.colorByPhase && !params.isBicolorMap && !params.colorBySign); //sorry! boolean saveColorData = (params.colorDensity || params.isBicolorMap || params.colorBySign || !params.colorByPhase); // colors mappable always now jvxlData.isJvxlPrecisionColor = true;//(jvxlDataIsPrecisionColor || params.isContoured || params.remappable); - jvxlData.valueMappedToRed = params.valueMappedToRed; - jvxlData.valueMappedToBlue = params.valueMappedToBlue; - jvxlData.mappedDataMin = params.mappedDataMin; - jvxlData.mappedDataMax = params.mappedDataMax; jvxlData.vertexCount = (contourVertexCount > 0 ? contourVertexCount : meshData.vertexCount); jvxlData.minColorIndex = -1; @@ -671,15 +674,19 @@ boolean useMeshDataValues = jvxlDataIs2dContour || // !jvxlDataIs2dContour && (params.isContoured && jvxlData.jvxlPlane != null || vertexDataOnly || params.colorDensity || params.isBicolorMap && !params.isContoured; - float value; - if (!useMeshDataValues) + if (!useMeshDataValues) { + + float min = Float.MAX_VALUE; + float max = -Float.MAX_VALUE; + float value; + initializeMapping(); for (int i = meshData.vertexCount; --i >= 0;) { /* right, so what we are doing here is setting a range within the * data for which we want red-->blue, but returning the actual * number so it can be encoded more precisely. This turned out to be * the key to making the JVXL contours work. * - */ + */ if (params.colorBySets) value = meshData.vertexSets[i]; else if (params.colorByPhase) @@ -687,10 +694,25 @@ //else if (jvxlDataIs2dContour) //marchingSquares // .getInterpolatedPixelValue(meshData.vertices[i]); + else if (volumeData == null) + value = getValueAtPoint(meshData.vertices[i]); else value = volumeData.lookupInterpolatedVoxelValue(meshData.vertices[i]); + if (value < min) + min = value; + if (value > max && value != Float.MAX_VALUE) + max = value; meshData.vertexValues[i] = value; } + if (params.rangeSelected && minMax == null) + minMax = new float[] { min, max }; + finalizeMapping(); + } + params.setMapRanges(this); + jvxlData.mappedDataMin = params.mappedDataMin; + jvxlData.mappedDataMax = params.mappedDataMax; + jvxlData.valueMappedToRed = params.valueMappedToRed; + jvxlData.valueMappedToBlue = params.valueMappedToBlue; colorData(); JvxlCoder.jvxlCreateColorData(jvxlData, @@ -789,46 +811,45 @@ return 1; } - float getMinMappedValue() { + protected float[] minMax; + + public float[] getMinMaxMappedValues() { + if (minMax != null && minMax[0] != Float.MAX_VALUE) + return minMax; if (params.colorBySets) - return 0; - int vertexCount = (contourVertexCount > 0 ? contourVertexCount - : meshData.vertexCount); - Point3f[] vertexes = meshData.vertices; + return (minMax = new float[] { 0, Math.max(meshData.nSets - 1, 0) }); float min = Float.MAX_VALUE; - boolean useVertexValue = (jvxlDataIs2dContour || vertexDataOnly || params.colorDensity); - for (int i = 0; i < vertexCount; i++) { - float challenger; - if (useVertexValue) - challenger = meshData.vertexValues[i]; - else - challenger = volumeData.lookupInterpolatedVoxelValue(vertexes[i]); - if (challenger < min) - min = challenger; + float max = -Float.MAX_VALUE; + if (params.theProperty != null) { + for (int i = 0; i < params.theProperty.length; i++) { + if (params.rangeSelected && !params.bsSelected.get(i)) + continue; + float p = params.theProperty[i]; + if (Float.isNaN(p)) + continue; + if (p < min) + min = p; + if (p > max) + max = p; + } + return (minMax = new float[] { min, max }); } - return min; - } - - float getMaxMappedValue() { - if (params.colorBySets) - return Math.max(meshData.nSets - 1, 0); int vertexCount = (contourVertexCount > 0 ? contourVertexCount : meshData.vertexCount); Point3f[] vertexes = meshData.vertices; - float max = -Float.MAX_VALUE; boolean useVertexValue = (jvxlDataIs2dContour || vertexDataOnly || params.colorDensity); for (int i = 0; i < vertexCount; i++) { - float challenger; + float v; if (useVertexValue) - challenger = meshData.vertexValues[i]; + v = meshData.vertexValues[i]; else - challenger = volumeData.lookupInterpolatedVoxelValue(vertexes[i]); - if (challenger == Float.MAX_VALUE) - challenger = 0; //for now TESTING ONLY - if (challenger > max && challenger != Float.MAX_VALUE) - max = challenger; + v = volumeData.lookupInterpolatedVoxelValue(vertexes[i]); + if (v < min) + min = v; + if (v > max && v != Float.MAX_VALUE) + max = v; } - return max; + return (minMax = new float[] { min, max }); } void updateTriangles() { @@ -960,8 +981,16 @@ * @return value */ public float getValueAtPoint(Point3f pt) { - // only for readers that can support it (isoShapeReader) + // only for readers that can support it (IsoShapeReader, AtomPropertyMapper) return 0; } + protected void initializeMapping() { + // initiate any iterators + } + + protected void finalizeMapping() { + // release any iterators + } + } Modified: trunk/Jmol/src/org/jmol/modelset/Model.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Model.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/modelset/Model.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -98,9 +98,6 @@ int hydrogenCount; boolean isPDB; - public boolean isPDB() { - return isPDB; - } String loadState = ""; StringBuffer loadScript = new StringBuffer(); Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -1955,6 +1955,12 @@ bspf.initialize(modelIndex, atoms, viewer.getModelUndeletedAtomsBitSet(modelIndex)); } + public void setIteratorForPoint(AtomIndexIterator iterator, int modelIndex, + Point3f pt, float distance) { + initializeBspt(modelIndex); + iterator.set(modelIndex, models[modelIndex].firstAtomIndex, Integer.MAX_VALUE, pt, distance); + } + public void setIteratorForAtom(AtomIndexIterator iterator, int modelIndex, int atomIndex, float distance) { if (modelIndex < 0) Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -14997,17 +14997,43 @@ error(ERROR_invalidArgument); continue; case Token.property: - if (dataUse == null) { // mlp or mep + case Token.variable: + if (modelIndex < 0) + error(ERROR_multipleModelsDisplayedNotOK, "ISOSURFACE " + + theToken.value); + if (isCavity) + error(ERROR_invalidArgument); + boolean isVariable = (theTok == Token.variable); + if (dataUse == null) { // not mlp or mep + if (bsSelect == null) { + bsSelect = viewer.getSelectionSet(false); + bsSelect.and(viewer.getModelUndeletedAtomsBitSet(modelIndex)); + addShapeProperty(propertyList, "select", bsSelect); + } + if (surfaceObjectSeen) { + // not for overall surface, just this mapping + sbCommand.append(" select " + Escape.escape(bsSelect)); + bsSelect = null; + } else { + surfaceObjectSeen = true; + addShapeProperty(propertyList, "sasurface", new Float(0)); + sbCommand.append(" vdw"); + } + propertyName = "property"; if (smoothing == null) smoothing = viewer.getIsosurfacePropertySmoothing() ? Boolean.TRUE : Boolean.FALSE; addShapeProperty(propertyList, "propertySmoothing", smoothing); sbCommand.append(" isosurfacePropertySmoothing " + smoothing); + if (viewer.isRangeSelected()) + addShapeProperty(propertyList, "rangeSelected", Boolean.TRUE); + } else { + propertyName = dataUse; } str = parameterAsString(i); sbCommand.append(" ").append(str); - propertyName = (dataUse == null ? "property" : dataUse); - if (!isCavity && str.toLowerCase().indexOf("property_") == 0) { + + if (str.toLowerCase().indexOf("property_") == 0) { data = new float[viewer.getAtomCount()]; if (isSyntaxCheck) continue; @@ -15017,23 +15043,35 @@ addShapeProperty(propertyList, propertyName, data); continue; } - int tokProperty = getToken(++i).tok; - sbCommand.append(" " + theToken.value); + int atomCount = viewer.getAtomCount(); - data = (isCavity ? new float[0] : new float[atomCount]); - if (isCavity)// not implemented: && tokProperty != - // Token.surfacedistance) - error(ERROR_invalidArgument); - if (!isSyntaxCheck && !isCavity) { - Atom[] atoms = viewer.getModelSet().atoms; - viewer.autoCalculate(tokProperty); - for (int iAtom = atomCount; --iAtom >= 0;) { - data[iAtom] = Atom.atomPropertyFloat(viewer, atoms[iAtom], - tokProperty); + data = new float[atomCount]; + + if (isVariable) { + String vname = parameterAsString(++i); + if (vname.length() == 0) { + data = floatParameterSet(i, atomCount, atomCount); + } else { + data = new float[atomCount]; + if (!isSyntaxCheck) + Parser.parseStringInfestedFloatArray("" + + getParameter(vname, false), null, data); } + if (!isSyntaxCheck) + sbCommand.append(" \"\" ").append(Escape.escape(data)); + } else { + int tokProperty = getToken(++i).tok; + if (!isSyntaxCheck) { + sbCommand.append(" " + theToken.value); + Atom[] atoms = viewer.getModelSet().atoms; + viewer.autoCalculate(tokProperty); + for (int iAtom = atomCount; --iAtom >= 0;) + data[iAtom] = Atom.atomPropertyFloat(viewer, atoms[iAtom], + tokProperty); + } + if (tokProperty == Token.color) + colorScheme = "colorRGB"; } - if (tokProperty == Token.color) - colorScheme = "colorRGB"; propertyValue = data; break; case Token.model: @@ -15211,8 +15249,7 @@ propertyName = "ellipsoid"; propertyValue = floatParameterSet(i, 6, 6); i = iToken; - sbCommand.append(" ellipsoid ").append( - Escape.escape(propertyValue)); + sbCommand.append(" ellipsoid ").append(Escape.escape(propertyValue)); break; } catch (ScriptException e) { } @@ -15261,12 +15298,14 @@ modelIndex = viewer.getAtomModelIndex(atomIndex); pt = viewer.getAtomPoint3f(atomIndex); } - addShapeProperty(propertyList, "modelIndex", Integer.valueOf(modelIndex)); + addShapeProperty(propertyList, "modelIndex", Integer + .valueOf(modelIndex)); Vector3f[] axes = { new Vector3f(), new Vector3f(), new Vector3f(pt), new Vector3f() }; - if (!isSyntaxCheck && !lcaoType.equalsIgnoreCase("s") - && viewer.getHybridizationAndAxes(atomIndex, axes[0], axes[1], lcaoType) - == null) + if (!isSyntaxCheck + && !lcaoType.equalsIgnoreCase("s") + && viewer.getHybridizationAndAxes(atomIndex, axes[0], axes[1], + lcaoType) == null) return; propertyValue = axes; break; @@ -15311,7 +15350,8 @@ if (tokAt(i + 1) == Token.integer) { calcType = intParameter(++i); sbCommand.append(" " + calcType); - addShapeProperty(propertyList, "mepCalcType", Integer.valueOf(calcType)); + addShapeProperty(propertyList, "mepCalcType", Integer + .valueOf(calcType)); } if (tokAt(i + 1) == Token.string) { fname = stringParameter(++i); @@ -15331,18 +15371,6 @@ error(ERROR_noPartialCharges); propertyValue = data; break; - case Token.sasurface: - case Token.solvent: - surfaceObjectSeen = true; - addShapeProperty(propertyList, "bsSolvent", - lookupIdentifierValue("solvent")); - propertyName = (theTok == Token.sasurface ? "sasurface" : "solvent"); - sbCommand.append(" ").append(theToken.value); - float radius = (isFloatParameter(i + 1) ? floatParameter(++i) : viewer - .getSolventProbeRadius()); - propertyValue = new Float(radius); - sbCommand.append(" ").append(radius); - break; case Token.volume: doCalcVolume = !isSyntaxCheck; sbCommand.append(" volume"); @@ -15453,8 +15481,8 @@ sbCommand.append(" increment ").append(Escape.escape(pt)); break; default: - propertyValue = Integer.valueOf( - tokAt(i + 1) == Token.integer ? intParameter(++i) : 0); + propertyValue = Integer + .valueOf(tokAt(i + 1) == Token.integer ? intParameter(++i) : 0); sbCommand.append(" ").append(propertyValue); } break; @@ -15690,10 +15718,32 @@ sbCommand.append(" modelBased"); break; case Token.molecular: + case Token.sasurface: + case Token.solvent: + if (modelIndex < 0) + error(ERROR_multipleModelsDisplayedNotOK, "ISOSURFACE " + + theToken.value); + if (bsSelect == null) { + bsSelect = viewer.getSelectionSet(false); + bsSelect.and(viewer.getModelUndeletedAtomsBitSet(modelIndex)); + addShapeProperty(propertyList, "select", bsSelect); + } surfaceObjectSeen = true; - propertyName = "molecular"; - propertyValue = Float.valueOf((float) 1.4); - sbCommand.append(" molecular"); + float radius; + if (theTok == Token.molecular) { + propertyName = "molecular"; + sbCommand.append(" molecular"); + radius = 1.4f; + } else { + addShapeProperty(propertyList, "bsSolvent", + lookupIdentifierValue("solvent")); + propertyName = (theTok == Token.sasurface ? "sasurface" : "solvent"); + sbCommand.append(" ").append(theToken.value); + radius = (isFloatParameter(i + 1) ? floatParameter(++i) : viewer + .getSolventProbeRadius()); + sbCommand.append(" ").append(radius); + } + propertyValue = Float.valueOf(radius); break; case Token.object: case Token.obj: @@ -15736,21 +15786,6 @@ propertyValue = Boolean.TRUE; sbCommand.append(" squared"); break; - case Token.variable: - propertyName = (dataUse == null ? "property" : dataUse); - String vname = parameterAsString(++i); - int nAtoms = viewer.getAtomCount(); - if (vname.length() == 0) { - data = floatParameterSet(i, nAtoms, nAtoms); - } else { - data = new float[nAtoms]; - if (!isSyntaxCheck) - Parser.parseStringInfestedFloatArray("" - + getParameter(vname, false), null, data); - } - propertyValue = data; - sbCommand.append(" variable \"\" ").append(Escape.escape(data)); - break; case Token.string: String filename = parameterAsString(i); boolean firstPass = (!surfaceObjectSeen && !planeSeen); @@ -15822,8 +15857,8 @@ surfaceObjectSeen = true; int fileIndex = -1; if (tokAt(i + 1) == Token.integer) - addShapeProperty(propertyList, "fileIndex", Integer.valueOf( - fileIndex = intParameter(++i))); + addShapeProperty(propertyList, "fileIndex", Integer + .valueOf(fileIndex = intParameter(++i))); if (filename.equalsIgnoreCase("INLINE")) { // inline PMESH data if (tokAt(i + 1) != Token.string) @@ -15927,8 +15962,8 @@ surfaceObjectSeen = true; } if (thisSetNumber > 0) - addShapeProperty(propertyList, "getSurfaceSets", Integer.valueOf( - thisSetNumber - 1)); + addShapeProperty(propertyList, "getSurfaceSets", Integer + .valueOf(thisSetNumber - 1)); if (discreteColixes != null) { addShapeProperty(propertyList, "colorDiscrete", discreteColixes); } else if (colorScheme != null) { Modified: trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -1208,6 +1208,8 @@ Point3f[] centers = m.getCenters(); for (int j = centers.length; --j >= 0; ) { Point3f v = centers[j]; + if (v == null) + continue; int d2 = coordinateInRange(x, y, v, dmin2, ptXY); if (d2 >= 0) { if (ptXY.z < minz) { Modified: trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/shapesurface/IsosurfaceMesh.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -225,10 +225,13 @@ return centers; centers = new Point3f[polygonCount]; for (int i = 0; i < polygonCount; i++) { + int[] pi = polygonIndexes[i]; + if (pi == null) + continue; Point3f pt = centers[i] = new Point3f(); - pt.add(vertices[polygonIndexes[i][0]]); - pt.add(vertices[polygonIndexes[i][1]]); - pt.add(vertices[polygonIndexes[i][2]]); + pt.add(vertices[pi[0]]); + pt.add(vertices[pi[1]]); + pt.add(vertices[pi[2]]); pt.scale(1/3f); } return centers; @@ -475,6 +478,8 @@ polygonColixes = new short[polygonCount]; for (int i = 0; i < polygonCount; i++) { int[] pi = polygonIndexes[i]; + if (pi == null) + continue; polygonColixes[i] = defaultColix; float v = (vertexValues[pi[0]] + vertexValues[pi[1]] + vertexValues[pi[2]])/3; //System.out.println(i + " " + v); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-08-30 20:17:18 UTC (rev 14197) @@ -3,6 +3,8 @@ version=12.1.9_dev +# bug fix: isosurface "t.jvxl" map property temperature nonfunctional +# bug fix: isosurface PROPERTY ("VDW 100%" implied) not working # code: rewrite of calculateHydrogen/hybridization code # bug fix: WRITE xxx should do SHOW not clipboard for application # bug fix: % at end of line acts as a line continuation Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-08-30 19:57:46 UTC (rev 14196) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2010-08-30 20:17:18 UTC (rev 14197) @@ -2476,6 +2476,11 @@ modelSet.setIteratorForAtom(iterator, -1, atomIndex, distance); } + public void setIteratorForPoint(AtomIndexIterator iterator, int modelIndex, Point3f pt, + float distance) { + modelSet.setIteratorForPoint(iterator, modelIndex, pt, distance); + } + public void fillAtomData(AtomData atomData, int mode) { atomData.programInfo = "Jmol Version " + getJmolVersion(); atomData.fileName = getFileName(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |