From: <ha...@us...> - 2010-07-07 20:39:14
|
Revision: 13519 http://jmol.svn.sourceforge.net/jmol/?rev=13519&view=rev Author: hansonr Date: 2010-07-07 20:39:08 +0000 (Wed, 07 Jul 2010) Log Message: ----------- version=12.0.RC24_dev # bug fix: much speedier mapProperty when all three properties are numeric Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/viewer/DataManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-07-07 19:33:13 UTC (rev 13518) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-07-07 20:39:08 UTC (rev 13519) @@ -7262,29 +7262,35 @@ BitSet bsOut = null; showString("mapping " + property1.toUpperCase() + " for " + bsFrom.cardinality() + " atoms to " + property2.toUpperCase() - + " using " + mapKey.toUpperCase()); - if (Token.tokAttrOr(tokProp1, Token.intproperty, Token.floatparam) - && Token.tokAttrOr(tokProp2, Token.intproperty, Token.floatparam) - && Token.tokAttrOr(tokKey, Token.intproperty, Token.floatparam)) { + + " for " + bsTo.cardinality() + " atoms using " + mapKey.toUpperCase()); + if (Token.tokAttrOr(tokProp1, Token.intproperty, Token.floatproperty) + && Token.tokAttrOr(tokProp2, Token.intproperty, Token.floatproperty) + && Token.tokAttrOr(tokKey, Token.intproperty, Token.floatproperty)) { float[] data1 = getBitsetPropertyFloat(bsFrom, tokProp1); float[] data2 = getBitsetPropertyFloat(bsFrom, tokKey); float[] data3 = getBitsetPropertyFloat(bsTo, tokKey); + boolean isProperty = (tokProp2 == Token.property); + float[] dataOut = new float[isProperty ? viewer.getAtomCount() : data3.length]; bsOut = new BitSet(); if (data1.length == data2.length) { Hashtable ht = new Hashtable(); for (int i = 0; i < data1.length; i++) ht.put(new Float(data2[i]), new Float(data1[i])); - int pt = 0; + int pt = -1; int nOut = 0; for (int i = 0; i < data3.length; i++) { + pt = bsTo.nextSetBit(pt + 1); Float F = (Float) ht.get(new Float(data3[i])); if (F == null) continue; - bsOut.set(bsTo.nextSetBit(pt++)); - data3[nOut] = F.floatValue(); + bsOut.set(pt); + dataOut[(isProperty ? pt : nOut)] = F.floatValue(); nOut++; } - viewer.setAtomProperty(bsOut, tokProp2, 0, 0, null, data3, null); + if (isProperty) + viewer.setData(property2, new Object[] {property2, dataOut, bsOut}, viewer.getAtomCount(), 0, 0, Integer.MAX_VALUE, 0); + else + viewer.setAtomProperty(bsOut, tokProp2, 0, 0, null, dataOut, null); } } if (bsOut == null) { Modified: trunk/Jmol/src/org/jmol/viewer/DataManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/DataManager.java 2010-07-07 19:33:13 UTC (rev 13518) +++ trunk/Jmol/src/org/jmol/viewer/DataManager.java 2010-07-07 20:39:08 UTC (rev 13519) @@ -92,7 +92,6 @@ return; } if (data[2] != null && atomCount > 0) { - String stringData = (String) data[1]; boolean createNew = (matchField != 0 || field != Integer.MIN_VALUE && field != Integer.MAX_VALUE); Object[] oldData = (Object[]) dataValues.get(type); @@ -103,6 +102,8 @@ // 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. + String stringData = (data[1] instanceof String ? (String) data[1] : null); + float[] floatData = (data[1] instanceof float[] ? (float[]) data[1] : null); String[] strData = null; if (field == Integer.MIN_VALUE && (strData = Parser.getTokens(stringData)).length > 1) @@ -115,8 +116,13 @@ } else if (field == 0 || field == Integer.MAX_VALUE) { // just get the selected token values bs = (BitSet) data[2]; - Parser.parseFloatArray(strData == null ? Parser.getTokens(stringData) + if (floatData != null) { + for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) + f[i] = floatData[i]; + } else { + Parser.parseFloatArray(strData == null ? Parser.getTokens(stringData) : strData, bs, f); + } } else if (matchField <= 0) { // get the specified field >= 1 for the selected atoms bs = (BitSet) data[2]; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-07-07 19:33:13 UTC (rev 13518) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-07-07 20:39:08 UTC (rev 13519) @@ -3,6 +3,7 @@ version=12.0.RC24_dev +# bug fix: much speedier mapProperty when all three properties are numeric # bug fix: 3D-SMARTS search combining variable number of atoms [$(...)m-n] and distance # check (.d:min-max)...(.d) fails # bug fix: load FILES does not properly set full path name to files. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |