Revision: 18433 http://sourceforge.net/p/jmol/code/18433 Author: hansonr Date: 2013-07-05 16:59:05 +0000 (Fri, 05 Jul 2013) Log Message: ----------- unitcell center {atomset} unitcell center {x y z} // assumed fractional
Modified Paths: -------------- trunk/Jmol/src/org/jmol/api/SymmetryInterface.java trunk/Jmol/src/org/jmol/io2/BinaryDocument.java trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java trunk/Jmol/src/org/jmol/modelset/AtomCollection.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/T.java trunk/Jmol/src/org/jmol/symmetry/Symmetry.java trunk/Jmol/src/org/jmol/util/Measure.java trunk/Jmol/src/org/jmol/util/Parser.java trunk/Jmol/src/org/jmol/viewer/ColorManager.java trunk/Jmol/src/org/jmol/viewer/DataManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/api/SymmetryInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/SymmetryInterface.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/api/SymmetryInterface.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -165,7 +165,9 @@ public Object getSymmetryInfo(ModelSet modelSet, int iModel, int iAtom, SymmetryInterface uc, String xyz, int op, P3 pt, P3 pt2, String id, int type); - public void setCentroid(ModelSet modelSet, int iAtom0, int iAtom1, + public BS notInCentroid(ModelSet modelSet, BS bsAtoms, int[] minmax); + public boolean checkUnitCell(SymmetryInterface uc, P3 cell, P3 ptTemp, boolean isAbsolute); + } Modified: trunk/Jmol/src/org/jmol/io2/BinaryDocument.java =================================================================== --- trunk/Jmol/src/org/jmol/io2/BinaryDocument.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/io2/BinaryDocument.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -394,7 +394,7 @@ fracIEEE = new float[270]; for (int i = 0; i < 270; i++) fracIEEE[i] = (float) Math.pow(2, i - 141); - // System.out.println(fracIEEE[0] + " " + Float.MIN_VALUE); + // System.out.println(fracIEEE[0] + " " + Parser.FLOAT_MIN_SAFE); // System.out.println(fracIEEE[269] + " " + Float.MAX_VALUE); } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/jvxl/readers/Parameters.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -129,6 +129,7 @@ import org.jmol.util.Matrix3f; import org.jmol.util.P3; import org.jmol.util.P4; +import org.jmol.util.Parser; import org.jmol.util.V3; import org.jmol.viewer.JC; @@ -421,7 +422,7 @@ dataType = (isGeodesic ? SURFACE_GEODESIC : SURFACE_SPHERE); distance = radius; setEccentricity(P4.new4(0, 0, 1, 1)); - cutoff = Float.MIN_VALUE; + cutoff = Parser.FLOAT_MIN_SAFE; isCutoffAbsolute = false; isSilent = !logMessages; script = getScriptParams() + " SPHERE " + radius + ";"; @@ -431,7 +432,7 @@ dataType = SURFACE_ELLIPSOID2; distance = 1f; setEccentricity(v); - cutoff = Float.MIN_VALUE; + cutoff = Parser.FLOAT_MIN_SAFE; isCutoffAbsolute = false; isSilent = !logMessages; //script = " center " + Escape.escape(center) @@ -445,7 +446,7 @@ //for (int i = 0; i < 6; i++)System.out.print(bList[i] + " ");System.out.println( " in Parameters setEllipsoid" + center); dataType = SURFACE_ELLIPSOID3; distance = 0.3f * (Float.isNaN(scale) ? 1f : scale); - cutoff = Float.MIN_VALUE; + cutoff = Parser.FLOAT_MIN_SAFE; isCutoffAbsolute = false; isSilent = !logMessages; if (center.x == Float.MAX_VALUE) @@ -574,7 +575,7 @@ void setFunctionXY(JmolList<Object> value) { dataType = SURFACE_FUNCTIONXY; functionInfo = value; - cutoff = Float.MIN_VALUE; + cutoff = Parser.FLOAT_MIN_SAFE; isEccentric = isAnisotropic = false; } @@ -582,7 +583,7 @@ dataType = SURFACE_FUNCTIONXYZ; functionInfo = value; if (cutoff == Float.MAX_VALUE) - cutoff = Float.MIN_VALUE; + cutoff = Parser.FLOAT_MIN_SAFE; isEccentric = isAnisotropic = false; } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -32,6 +32,8 @@ class XsfReader extends VolumeFileReader { + // from XCrysDen; see http://www.xcrysden.org/doc/XSF.html + XsfReader(){} @Override Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -301,12 +301,12 @@ // the maximum BondingRadius seen in this set of atoms // used in autobonding - protected float maxBondingRadius = Float.MIN_VALUE; - private float maxVanderwaalsRadius = Float.MIN_VALUE; + protected float maxBondingRadius = Parser.FLOAT_MIN_SAFE; + private float maxVanderwaalsRadius = Parser.FLOAT_MIN_SAFE; public float getMaxVanderwaalsRadius() { //Dots - if (maxVanderwaalsRadius == Float.MIN_VALUE) + if (maxVanderwaalsRadius == Parser.FLOAT_MIN_SAFE) findMaxRadii(); return maxVanderwaalsRadius; } Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -1654,19 +1654,25 @@ * deletes molecules based on: CENTROID -- molecular centroid is not in unit * cell CENTROID PACKED -- all molecule atoms are not in unit cell * - * @param iAtom0 - * @param iAtom1 + * @param bs * @param minmax * fractional [xmin, ymin, zmin, xmax, ymax, zmax, 1=packed] */ - public void setCentroid(int iAtom0, int iAtom1, int[] minmax) { + public void setCentroid(BS bs, int[] minmax) { + BS bsDelete = getNotInCentroid(bs, minmax); + if (bsDelete != null && bsDelete.nextSetBit(0) >= 0) + viewer.deleteAtoms(bsDelete, false); + } + + private BS getNotInCentroid(BS bs, int[] minmax) { + int iAtom0 = bs.nextSetBit(0); + if (iAtom0 < 0) + return null; SymmetryInterface uc = getUnitCell(atoms[iAtom0].modelIndex); - if (uc == null) - return; - uc.setCentroid((ModelSet) this, iAtom0, iAtom1, minmax); + return (uc == null ? null : uc.notInCentroid((ModelSet) this, bs, minmax)); } - public JmolMolecule[] getMolecules() { + public JmolMolecule[] getMolecules() { if (moleculeCount > 0) return molecules; if (molecules == null) @@ -1898,13 +1904,27 @@ // select cell=555 (an absolute quantity) bs = new BS(); info = (int[]) specInfo; - ptTemp1.set(info[0] / 1000f, info[1] / 1000f, - info[2] / 1000f); + ptTemp1.set(info[0] / 1000f, info[1] / 1000f, info[2] / 1000f); boolean isAbsolute = !viewer.getBoolean(T.fractionalrelative); for (int i = atomCount; --i >= 0;) if (isInLatticeCell(i, ptTemp1, ptTemp2, isAbsolute)) bs.set(i); return bs; + case T.centroid: + // select centroid=555 -- like cell=555 but for whole molecules + // if it is one full molecule, then return the EMPTY bitset + bs = BSUtil.newBitSet2(0, atomCount); + info = (int[]) specInfo; + int[] minmax = new int[] { info[0] / 1000 - 1, info[1] / 1000 - 1, info[2] / 1000 - 1, info[0] / 1000, info[1] / 1000, info[2] / 1000, 0 }; + for (int i = modelCount; --i >= 0;) { + SymmetryInterface uc = getUnitCell(i); + if (uc == null) { + BSUtil.andNot(bs, models[i].bsAtoms); + continue; + } + bs.andNot(uc.notInCentroid((ModelSet) this, models[i].bsAtoms, minmax)); + } + return bs; case T.molecule: return getMoleculeBitSet((BS) specInfo); case T.sequence: @@ -1953,8 +1973,8 @@ } return bs; case T.symmetry: - return BSUtil.copy(bsSymmetry == null ? bsSymmetry = BSUtil.newBitSet( - atomCount) : bsSymmetry); + return BSUtil.copy(bsSymmetry == null ? bsSymmetry = BSUtil + .newBitSet(atomCount) : bsSymmetry); case T.unitcell: // select UNITCELL (a relative quantity) bs = new BS(); @@ -1963,33 +1983,23 @@ return bs; ptTemp1.set(1, 1, 1); for (int i = atomCount; --i >= 0;) - if (isInLatticeCell(i, ptTemp1, ptTemp2, false)) + if (isInLatticeCell(i, ptTemp1, ptTemp2, false)) bs.set(i); return bs; } } - private boolean isInLatticeCell(int i, P3 cell, P3 pt, + private boolean isInLatticeCell(int i, P3 cell, P3 ptTemp, boolean isAbsolute) { // this is the one method that allows for an absolute fractional cell business // but it is always called with isAbsolute FALSE. // so then it is determining values for select UNITCELL and the like. + int iModel = atoms[i].modelIndex; SymmetryInterface uc = getUnitCell(iModel); - if (uc == null) - return false; - pt.setT(atoms[i]); - uc.toFractional(pt, isAbsolute); - float slop = 0.02f; - // {1 1 1} here is the original cell - if (pt.x < cell.x - 1f - slop || pt.x > cell.x + slop) - return false; - if (pt.y < cell.y - 1f - slop || pt.y > cell.y + slop) - return false; - if (pt.z < cell.z - 1f - slop || pt.z > cell.z + slop) - return false; - return true; + ptTemp.setT(atoms[i]); + return (uc != null && uc.checkUnitCell(uc, cell, ptTemp, isAbsolute)); } /** @@ -2274,7 +2284,7 @@ if (mad == 0) mad = 1; // null values for bitsets means "all" - if (maxBondingRadius == Float.MIN_VALUE) + if (maxBondingRadius == Parser.FLOAT_MIN_SAFE) findMaxRadii(); float bondTolerance = viewer.getFloat(T.bondtolerance); float minBondDistance = viewer.getFloat(T.minbonddistance); @@ -2365,7 +2375,7 @@ if (mad == 0) mad = 1; // null values for bitsets means "all" - if (maxBondingRadius == Float.MIN_VALUE) + if (maxBondingRadius == Parser.FLOAT_MIN_SAFE) findMaxRadii(); float bondTolerance = viewer.getFloat(T.bondtolerance); float minBondDistance = viewer.getFloat(T.minbonddistance); Modified: trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java =================================================================== --- trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/modelsetbio/BioPolymer.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -36,6 +36,7 @@ import org.jmol.util.BS; import org.jmol.util.Logger; import org.jmol.util.P3; +import org.jmol.util.Parser; import org.jmol.util.Quaternion; import org.jmol.util.SB; import org.jmol.util.TextFormat; @@ -267,7 +268,7 @@ leadMidpoints = new P3[monomerCount + 1]; leadPoints = new P3[monomerCount + 1]; wingVectors = new V3[monomerCount + 1]; - sheetSmoothing = Float.MIN_VALUE; + sheetSmoothing = Parser.FLOAT_MIN_SAFE; } if (reversed == null) reversed = BS.newN(monomerCount); Modified: trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/script/ScriptCompilationTokenParser.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -441,7 +441,8 @@ // create a file_model integer as part of the token return addTokenToPostfixInt(T.spec_model2, fixModelSpec(getToken()), theValue); case T.cell: - return clauseCell(); + case T.centroid: + return clauseCell(tok); case T.connected: return clauseConnected(); case T.search: @@ -932,7 +933,7 @@ return true; } - private boolean clauseCell() { + private boolean clauseCell(int tok) { P3 cell = new P3(); tokenNext(); // CELL if (!tokenNextTok(T.opEQ)) // = @@ -946,7 +947,7 @@ cell.x = nnn / 100 - 4; cell.y = (nnn % 100) / 10 - 4; cell.z = (nnn % 10) - 4; - return addTokenToPostfix(T.cell, cell); + return addTokenToPostfix(tok, cell); } if (!isToken(T.leftbrace) || !getNumericalToken()) return error(ERROR_coordinateExpected); // i @@ -961,7 +962,7 @@ if (!getNumericalToken() || !tokenNextTok(T.rightbrace)) return error(ERROR_coordinateExpected); // k cell.z = floatValue(); - return addTokenToPostfix(T.cell, cell); + return addTokenToPostfix(tok, cell); } private boolean clauseDefine(boolean haveToken, boolean forceString) { Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -3868,9 +3868,10 @@ if (chainID != -1) pc += 2; break; + case T.centroid: case T.cell: P3 pt = (P3) value; - rpn.addXBs(getAtomBits(T.cell, new int[] { (int) Math.floor(pt.x * 1000), + rpn.addXBs(getAtomBits(instruction.tok, new int[] { (int) Math.floor(pt.x * 1000), (int) Math.floor(pt.y * 1000), (int) Math.floor(pt.z * 1000) })); break; case T.thismodel: @@ -8208,7 +8209,7 @@ prefix = "atom"; } // don't allow isosurface partial translucency (yet) - //translucentLevel = Float.MIN_VALUE; + //translucentLevel = Parser.FLOAT_MIN_SAFE; getToken(index = iToken + 1); break; } @@ -8217,7 +8218,7 @@ return; boolean isTranslucent = (theTok == T.translucent); if (isTranslucent || theTok == T.opaque) { - if (translucentLevel == Float.MIN_VALUE) + if (translucentLevel == Parser.FLOAT_MIN_SAFE) error(ERROR_invalidArgument); translucency = parameterAsString(index++); if (isTranslucent && isFloatParameter(index)) @@ -8881,8 +8882,7 @@ // if it is just LOAD "xxxx.xxx" // so as to avoid the ZAP in case these // do not contain a full state script - if (modelName.endsWith(".spt") - || modelName.endsWith(".png") + if (modelName.endsWith(".spt") || modelName.endsWith(".png") || modelName.endsWith(".pngj")) { script(0, modelName); return; @@ -8936,9 +8936,9 @@ i++; loadScript.append(" " + modelName); tokType = (tok == T.identifier - && Parser.isOneOf(modelName.toLowerCase(), - JC.LOAD_ATOM_DATA_TYPES) ? T - .getTokFromName(modelName) : T.nada); + && Parser.isOneOf(modelName.toLowerCase(), JC.LOAD_ATOM_DATA_TYPES) ? T + .getTokFromName(modelName) + : T.nada); if (tokType != T.nada) { // loading just some data here // xyz vxyz vibration temperature occupancy partialcharge @@ -9024,7 +9024,7 @@ String filename = null; String appendedData = null; String appendedKey = null; - + if (slen == i + 1) { // end-of-command options: @@ -9050,15 +9050,14 @@ if (loadScript.indexOf(" files") < 0) error(ERROR_invalidArgument); for (int j = 0; j < filenames.length; j++) - loadScript.append(" /*file*/") - .append(Escape.eS(filenames[j])); + loadScript.append(" /*file*/").append(Escape.eS(filenames[j])); } } } } else if (getToken(i + 1).tok == T.manifest // model/vibration index or list of model indices - || theTok == T.integer || theTok == T.varray - || theTok == T.leftsquare || theTok == T.spacebeforesquare + || theTok == T.integer || theTok == T.varray || theTok == T.leftsquare + || theTok == T.spacebeforesquare // {i j k} (lattice) || theTok == T.leftbrace || theTok == T.point3f // PACKED/CENTROID, either order @@ -9324,7 +9323,6 @@ // .... APPEND DATA "appendedData" .... end "appendedData" // option here to designate other than "appendedData" // .... APPEND "appendedData" @x .... - if (tokAt(i) == T.append) { // for CIF reader -- experimental @@ -9357,7 +9355,7 @@ P3 pt = null; BS bs = null; - JmolList<String> fNames = new JmolList<String>(); + JmolList<String> fNames = new JmolList<String>(); while (i < slen) { switch (tokAt(i)) { case T.filter: @@ -9367,7 +9365,7 @@ case T.coord: htParams.remove("isTrajectory"); if (firstLastSteps == null) { - firstLastSteps = new JmolList<Object>(); + firstLastSteps = new JmolList<Object>(); pt = P3.new3(0, -1, 1); } if (isPoint3f(++i)) { @@ -9384,7 +9382,8 @@ } fNames.addLast(filename = parameterAsString(i++)); if (pt != null) { - firstLastSteps.addLast(new int[] { (int) pt.x, (int) pt.y, (int) pt.z }); + firstLastSteps + .addLast(new int[] { (int) pt.x, (int) pt.y, (int) pt.z }); loadScript.append(" COORD " + Escape.eP(pt)); } else if (bs != null) { firstLastSteps.addLast(bs); @@ -9410,8 +9409,9 @@ // get default filter if necessary if (appendedData != null) { - sOptions += " APPEND data \"" + appendedKey + "\"\n" + appendedData - + (appendedData.endsWith("\n") ? "" : "\n") + "end \"" + appendedKey + "\""; + sOptions += " APPEND data \"" + appendedKey + "\"\n" + appendedData + + (appendedData.endsWith("\n") ? "" : "\n") + "end \"" + appendedKey + + "\""; } if (filter == null) filter = viewer.getDefaultLoadFilter(); @@ -9434,9 +9434,9 @@ isVariable = true; String s = getStringParameter(filename.substring(1), false); htParams.put("fileData", s); - loadScript = new SB().append("{\n var ") - .append(filename.substring(1)).append(" = ") - .append(Escape.eS(s)).append(";\n ").appendSB(loadScript); + loadScript = new SB().append("{\n var ").append( + filename.substring(1)).append(" = ").append(Escape.eS(s)).append( + ";\n ").appendSB(loadScript); } } @@ -9499,8 +9499,7 @@ } if (errMsg != null && !isCmdLine_c_or_C_Option) { if (errMsg.indexOf(JC.NOTE_SCRIPT_FILE) == 0) { - filename = errMsg.substring(JC.NOTE_SCRIPT_FILE.length()) - .trim(); + filename = errMsg.substring(JC.NOTE_SCRIPT_FILE.length()).trim(); script(0, filename); return; } @@ -9517,9 +9516,10 @@ + (filenames == null ? htParams.get("fullPathName") : modelName)); Map<String, Object> info = viewer.getModelSetAuxiliaryInfo(); if (info != null && info.containsKey("centroidMinMax") - && viewer.getAtomCount() > 0) - viewer.setCentroid(isAppend ? atomCount0 : 0, viewer.getAtomCount() - 1, - (int[]) info.get("centroidMinMax")); + && viewer.getAtomCount() > 0) { + BS bs = BSUtil.newBitSet2(isAppend ? atomCount0 : 0, viewer.getAtomCount()); + viewer.setCentroid(bs, (int[]) info.get("centroidMinMax")); + } String script = viewer.getDefaultLoadScript(); String msg = ""; if (script.length() > 0) @@ -10388,7 +10388,7 @@ } BS bsAtoms = null; - float degreesPerSecond = Float.MIN_VALUE; + float degreesPerSecond = Parser.FLOAT_MIN_SAFE; int nPoints = 0; float endDegrees = Float.MAX_VALUE; boolean isMolecular = false; @@ -10456,7 +10456,7 @@ // rotate spin ... [degreesPerSecond] // rotate spin ... [endDegrees] [degreesPerSecond] // rotate spin BRANCH <DihedralList> [seconds] - if (degreesPerSecond == Float.MIN_VALUE) { + if (degreesPerSecond == Parser.FLOAT_MIN_SAFE) { degreesPerSecond = floatParameter(i); continue; } else if (endDegrees == Float.MAX_VALUE) { @@ -10470,7 +10470,7 @@ if (endDegrees == Float.MAX_VALUE) { endDegrees = floatParameter(i); continue; - } else if (degreesPerSecond == Float.MIN_VALUE) { + } else if (degreesPerSecond == Parser.FLOAT_MIN_SAFE) { degreesPerSecond = floatParameter(i); isSpin = true; continue; @@ -10630,7 +10630,7 @@ if (bsAtoms == null) bsAtoms = bsCompare; } - float rate = (degreesPerSecond == Float.MIN_VALUE ? 10 + float rate = (degreesPerSecond == Parser.FLOAT_MIN_SAFE ? 10 : endDegrees == Float.MAX_VALUE ? degreesPerSecond : (degreesPerSecond < 0) == (endDegrees > 0) ? // -n means number of seconds, not degreesPerSecond @@ -10712,7 +10712,7 @@ && (endDegrees == 0 || degreesPerSecond == 0)) { // need a token rotation endDegrees = 0.01f; - rate = (degreesPerSecond == Float.MIN_VALUE ? 0.01f + rate = (degreesPerSecond == Parser.FLOAT_MIN_SAFE ? 0.01f : degreesPerSecond < 0 ? // -n means number of seconds, not degreesPerSecond -endDegrees / degreesPerSecond @@ -11679,7 +11679,7 @@ break; case T.set: sm.loadShape(JC.SHAPE_ELLIPSOIDS); - setShapeProperty(JC.SHAPE_ELLIPSOIDS, "select", parameterAsString(2)); + setShapeProperty(JC.SHAPE_ELLIPSOIDS, "select", stringParameter(2)); i = iToken; checkMore = true; isSet = true; @@ -14430,11 +14430,32 @@ index++; id = objectNameParameter(++index); break; + case T.center: + ++index; + switch (tokAt(++index)) { + case T.bitset: + case T.expressionBegin: + pt = P3.newP(viewer.getAtomSetCenter(atomExpressionAt(index))); + viewer.toFractional(pt, true); + index = iToken; + break; + default: + if (isCenterParameter(index)) { + pt = centerParameter(index); + index = iToken; + break; + } + error(ERROR_invalidArgument); + } + pt.x -= 0.5f; + pt.y -= 0.5f; + pt.z -= 0.5f; + break; default: if (isArrayParameter(index + 1)) { points = getPointArray(++index, 4); index = iToken; - }else if (slen == index + 2) { + } else if (slen == index + 2) { if (getToken(index + 1).tok == T.integer && intParameter(index + 1) >= 111) icell = intParameter(++index); Modified: trunk/Jmol/src/org/jmol/script/T.java =================================================================== --- trunk/Jmol/src/org/jmol/script/T.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/script/T.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -580,6 +580,7 @@ public final static int atomindex = intproperty | 3; public final static int bondcount = intproperty | 4; public final static int cell = intproperty | 5; + public final static int centroid = intproperty | 6; public final static int configuration = intproperty | 6 | scriptCommand; //color: see xxx(a, b, c, d) public final static int elemisono = intproperty | 7; @@ -1098,7 +1099,6 @@ final static int cancel = misc | 50; public final static int cap = misc | 51 | expression; final static int cavity = misc | 52; - final static int centroid = misc | 53; final static int check = misc | 54; final static int chemical = misc | 55; final static int circle = misc | 56; Modified: trunk/Jmol/src/org/jmol/symmetry/Symmetry.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/Symmetry.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/symmetry/Symmetry.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -567,21 +567,20 @@ } } - public void setCentroid(ModelSet modelSet, int iAtom0, int iAtom1, + public BS notInCentroid(ModelSet modelSet, BS bsAtoms, int[] minmax) { try { BS bsDelete = new BS(); + int iAtom0 = bsAtoms.nextSetBit(0); JmolMolecule[] molecules = modelSet.getMolecules(); int moleculeCount = molecules.length; Atom[] atoms = modelSet.atoms; - boolean isOneMolecule = (molecules[moleculeCount - 1].firstAtomIndex == modelSet - .models[atoms[iAtom1].modelIndex].firstAtomIndex); + .models[atoms[iAtom0].modelIndex].firstAtomIndex); P3 center = new P3(); boolean centroidPacked = (minmax[6] == 1); nextMol: for (int i = moleculeCount; --i >= 0 - && molecules[i].firstAtomIndex >= iAtom0 - && molecules[i].firstAtomIndex < iAtom1;) { + && bsAtoms.get(molecules[i].firstAtomIndex);) { BS bs = molecules[i].atomList; center.set(0, 0, 0); int n = 0; @@ -602,10 +601,9 @@ if (centroidPacked || n > 0 && isNotCentroid(center, n, minmax, false)) bsDelete.or(bs); } - if (bsDelete.nextSetBit(0) >= 0) - modelSet.viewer.deleteAtoms(bsDelete, false); + return bsDelete; } catch (Exception e) { - // ignore + return null; } } @@ -619,10 +617,20 @@ return (center.x + 0.000005f <= minmax[0] || center.x - 0.000005f > minmax[3] || center.y + 0.000005f <= minmax[1] || center.y - 0.000005f > minmax[4] || center.z + 0.000005f <= minmax[2] || center.z - 0.000005f > minmax[5]); - return (center.x + 0.000005f <= minmax[0] || center.x + 0.00001f > minmax[3] - || center.y + 0.000005f <= minmax[1] || center.y + 0.00001f > minmax[4] - || center.z + 0.000005f <= minmax[2] || center.z + 0.00001f > minmax[5]); + + return (center.x + 0.000005f <= minmax[0] || center.x + 0.00005f > minmax[3] + || center.y + 0.000005f <= minmax[1] || center.y + 0.00005f > minmax[4] + || center.z + 0.000005f <= minmax[2] || center.z + 0.00005f > minmax[5]); } + public boolean checkUnitCell(SymmetryInterface uc, P3 cell, P3 ptTemp, + boolean isAbsolute) { + uc.toFractional(ptTemp, isAbsolute); + float slop = 0.02f; + // {1 1 1} here is the original cell + return (ptTemp.x >= cell.x - 1f - slop && ptTemp.x <= cell.x + slop + && ptTemp.y >= cell.y - 1f - slop && ptTemp.y <= cell.y + slop + && ptTemp.z >= cell.z - 1f - slop && ptTemp.z <= cell.z + slop); + } } Modified: trunk/Jmol/src/org/jmol/util/Measure.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Measure.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/util/Measure.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -134,7 +134,7 @@ V3 vda = new V3(); V3 vcb = V3.newV(n); if (v_dot_n == 0) - v_dot_n = Float.MIN_VALUE; // allow for perpendicular axis to vab + v_dot_n = Parser.FLOAT_MIN_SAFE; // allow for perpendicular axis to vab vcb.scale(v_dot_n); vda.sub2(vcb, vab); vda.scale(0.5f); @@ -150,7 +150,7 @@ if (tokType == T.point) { return pt_a_prime; } - if (v_dot_n != Float.MIN_VALUE) + if (v_dot_n != Parser.FLOAT_MIN_SAFE) n.scale(v_dot_n); // must calculate directed angle: P3 pt_b_prime = P3.newP(pt_a_prime); @@ -174,7 +174,7 @@ return "measure " + Escape.eP(a) + Escape.eP(pt_a_prime) + Escape.eP(pt_b_prime) + Escape.eP(b); // for now... array: float residuesPerTurn = Math.abs(theta == 0 ? 0 : 360f / theta); - float pitch = Math.abs(v_dot_n == Float.MIN_VALUE ? 0 : n.length() * (theta == 0 ? 1 : 360f / theta)); + float pitch = Math.abs(v_dot_n == Parser.FLOAT_MIN_SAFE ? 0 : n.length() * (theta == 0 ? 1 : 360f / theta)); switch (tokType) { case T.array: return new Object[] {pt_a_prime, n, r, P3.new3(theta, pitch, residuesPerTurn)}; Modified: trunk/Jmol/src/org/jmol/util/Parser.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Parser.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/util/Parser.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -29,6 +29,9 @@ public class Parser { + public final static float FLOAT_MIN_SAFE = 2E-45f; + // Float.MIN_ VALUE is not reliable with JavaScript because of the float/double difference there + /// general static string-parsing class /// // next[0] tracks the pointer within the string so these can all be static. Modified: trunk/Jmol/src/org/jmol/viewer/ColorManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -31,6 +31,7 @@ import org.jmol.util.Elements; import org.jmol.util.GData; import org.jmol.util.Logger; +import org.jmol.util.Parser; import org.jmol.constant.EnumPalette; import org.jmol.constant.StaticConstants; import org.jmol.modelset.Atom; @@ -311,7 +312,7 @@ colorData = data; propertyColorEncoder.currentPalette = propertyColorEncoder.createColorScheme( colorScheme, true, false); - propertyColorEncoder.hi = Float.MIN_VALUE; + propertyColorEncoder.hi = Parser.FLOAT_MIN_SAFE; propertyColorEncoder.lo = Float.MAX_VALUE; if (data == null) return; Modified: trunk/Jmol/src/org/jmol/viewer/DataManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/DataManager.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/viewer/DataManager.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -58,6 +58,15 @@ dataValues.clear(); } + private final static int DATA_TYPE_STRING = 0; + private final static int DATA_TYPE_AF = 1; + private final static int DATA_ARRAY_FF = 2; + private final static int DATA_ARRAY_FFF = 3; + //private final static int DATA_LABEL = 0; + private final static int DATA_VALUE = 1; + private final static int DATA_SELECTION_MAP = 2; + private final static int DATA_TYPE = 3; + void setData(String type, Object[] data, int arrayCount, int actualAtomCount, int matchField, int matchFieldColumnCount, int field, int fieldColumnCount) { @@ -80,7 +89,7 @@ } type = type.toLowerCase(); if (type.equals("element_vdw")) { - String stringData = ((String) data[1]).trim(); + String stringData = ((String) data[DATA_VALUE]).trim(); if (stringData.length() == 0) { userVdwMars = null; userVdws = null; @@ -90,12 +99,12 @@ if (bsUserVdws == null) setUserVdw(defaultVdw); Parser.parseFloatArrayFromMatchAndField(stringData, bsUserVdws, 1, 0, - (int[]) data[2], 2, 0, userVdws, 1); + (int[]) data[DATA_SELECTION_MAP], 2, 0, userVdws, 1); for (int i = userVdws.length; --i >= 0;) userVdwMars[i] = (int) Math.floor(userVdws[i] * 1000); return; } - if (data[2] != null && arrayCount > 0) { + if (data[DATA_SELECTION_MAP] != null && arrayCount > 0) { boolean createNew = (matchField != 0 || field != Integer.MIN_VALUE && field != Integer.MAX_VALUE); Object[] oldData = dataValues.get(type); @@ -106,9 +115,9 @@ // check to see if the data COULD be interpreted as a string of float values // and if so, do that. This pre-fetches the tokens in that case. - int depth = ((Integer)data[3]).intValue(); - String stringData = (depth == 0 ? (String) data[1] : null); - float[] floatData = (depth == 1 ? (float[]) data[1] : null); + int depth = ((Integer)data[DATA_TYPE]).intValue(); + String stringData = (depth == DATA_TYPE_STRING ? (String) data[DATA_VALUE] : null); + float[] floatData = (depth == DATA_TYPE_AF ? (float[]) data[DATA_VALUE] : null); String[] strData = null; if (field == Integer.MIN_VALUE && (strData = Parser.getTokens(stringData)).length > 1) @@ -116,11 +125,11 @@ if (field == Integer.MIN_VALUE) { // set the selected data elements to a single value - bs = (BS) data[2]; + bs = (BS) data[DATA_SELECTION_MAP]; Parser.setSelectedFloats(Parser.parseFloatStr(stringData), bs, f); } else if (field == 0 || field == Integer.MAX_VALUE) { // just get the selected token values - bs = (BS) data[2]; + bs = (BS) data[DATA_SELECTION_MAP]; if (floatData != null) { if (floatData.length == bs.cardinality()) for (int i = bs.nextSetBit(0), pt = 0; i >= 0; i = bs @@ -135,13 +144,13 @@ } } else if (matchField <= 0) { // get the specified field >= 1 for the selected atoms - bs = (BS) data[2]; + bs = (BS) data[DATA_SELECTION_MAP]; Parser.parseFloatArrayFromMatchAndField(stringData, bs, 0, 0, null, field, fieldColumnCount, f, 1); } else { // get the selected field, with an integer match in a specified field // in this case, bs is created and indicates which data points were set - int[] iData = (int[]) data[2]; + int[] iData = (int[]) data[DATA_SELECTION_MAP]; Parser.parseFloatArrayFromMatchAndField(stringData, null, matchField, matchFieldColumnCount, iData, field, fieldColumnCount, f, 1); bs = new BS(); @@ -149,11 +158,11 @@ if (iData[i] >= 0) bs.set(iData[i]); } - if (oldData != null && oldData[2] instanceof BS && !createNew) - bs.or((BS) (oldData[2])); - data[3] = Integer.valueOf(1); - data[2] = bs; - data[1] = f; + if (oldData != null && oldData[DATA_SELECTION_MAP] instanceof BS && !createNew) + bs.or((BS) (oldData[DATA_SELECTION_MAP])); + data[DATA_TYPE] = Integer.valueOf(DATA_TYPE_AF); + data[DATA_SELECTION_MAP] = bs; + data[DATA_VALUE] = f; if (type.indexOf("property_atom.") == 0) { int tok = T.getSettableTokFromString(type = type.substring(14)); if (tok == T.nada) { @@ -192,16 +201,16 @@ if (dataValues == null) return null; Object[] data = getData(label); - if (data == null || ((Integer)data[3]).intValue() != 1) + if (data == null || ((Integer)data[DATA_TYPE]).intValue() != DATA_TYPE_AF) return null; - return (float[]) data[1]; + return (float[]) data[DATA_VALUE]; } float getDataFloat(String label, int atomIndex) { if (dataValues != null) { Object[] data = getData(label); - if (data != null && ((Integer)data[3]).intValue() == 1) { - float[] f = (float[]) data[1]; + if (data != null && ((Integer)data[DATA_TYPE]).intValue() == DATA_TYPE_AF) { + float[] f = (float[]) data[DATA_VALUE]; if (atomIndex < f.length) return f[atomIndex]; } @@ -213,18 +222,18 @@ if (dataValues == null) return null; Object[] data = getData(label); - if (data == null || ((Integer)data[3]).intValue() != 2) + if (data == null || ((Integer)data[DATA_TYPE]).intValue() != DATA_ARRAY_FF) return null; - return (float[][]) data[1]; + return (float[][]) data[DATA_VALUE]; } float[][][] getDataFloat3D(String label) { if (dataValues == null) return null; Object[] data = getData(label); - if (data == null || ((Integer)data[3]).intValue() != 3) + if (data == null || ((Integer)data[DATA_TYPE]).intValue() != DATA_ARRAY_FFF) return null; - return (float[][][]) data[1]; + return (float[][][]) data[DATA_VALUE]; } void deleteModelAtoms(int firstAtomIndex, int nAtoms, BS bsDeleted) { @@ -237,10 +246,10 @@ Object[] obj = dataValues.get(name); BSUtil.deleteBits((BS) obj[2], bsDeleted); switch (((Integer)obj[3]).intValue()) { - case 1: + case DATA_TYPE_AF: obj[1] = ArrayUtil.deleteElements(obj[1], firstAtomIndex, nAtoms); break; - case 2: + case DATA_ARRAY_FF: obj[1] = ArrayUtil.deleteElements(obj[1], firstAtomIndex, nAtoms); break; default: @@ -326,4 +335,5 @@ .append(loadFilter == null || loadFilter.length() == 0 ? "" : " filter" + Escape.eS(loadFilter)) .append("\";"); } + } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-07-05 14:18:59 UTC (rev 18432) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-07-05 16:59:05 UTC (rev 18433) @@ -9769,8 +9769,8 @@ modelSet.setModelAuxiliaryInfo(modelIndex, "modelID", id); } - public void setCentroid(int iAtom0, int iAtom1, int[] minmax) { - modelSet.setCentroid(iAtom0, iAtom1, minmax); + public void setCentroid(BS bs, int[] minmax) { + modelSet.setCentroid(bs, minmax); } public String getPathForAllFiles() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits