Revision: 20817 http://sourceforge.net/p/jmol/code/20817 Author: hansonr Date: 2015-10-11 15:41:18 +0000 (Sun, 11 Oct 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.16_2015.10.11"
new feature: unitcell() function -- returns unitcell as an array in the form [origin, va, vb, vc] -- first parameter is optional unitcell itself; absence uses current model's unit cell. -- optional last parameter: scale -- signatures: unitcell() // uses current unit cell unitcell(uc) // copies unit cell unitcell(uc, "reciprocal") // reciprocal lattice for specied unit cell unitcell("reciprocal") // reciprocal lattice for current model's unit cell unitcell(ucconv, "primitive","BCC"|"FCC") // convert primitive to conventional unitcell("primitive","BCC"|"FCC") unitcell(ucprim, "conventional","BCC"|"FCC") // convert primitive to conventional unitcell("conventional","BCC"|"FCC") unitcell(origin, [va, vb, vc]) unitcell(origin, pta, ptb, ptc) new feature: point(unitcell, {i, j, k}) -- unitcell is an array of the form [origin, va, vb, vc] -- {i j k} is a point in the unitcell Modified Paths: -------------- trunk/Jmol/src/org/jmol/api/SymmetryInterface.java trunk/Jmol/src/org/jmol/script/ScriptEval.java trunk/Jmol/src/org/jmol/scriptext/MathExt.java trunk/Jmol/src/org/jmol/symmetry/SpaceGroup.java trunk/Jmol/src/org/jmol/symmetry/Symmetry.java trunk/Jmol/src/org/jmol/symmetry/SymmetryDesc.java trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/api/SymmetryInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/SymmetryInterface.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/api/SymmetryInterface.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -38,7 +38,7 @@ public boolean createSpaceGroup(int desiredSpaceGroupIndex, String name, - Object object); + Object data); public String fcoord(T3 p); Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -8626,7 +8626,8 @@ float angstroms = floatParameterRange(index, 0, 2); return (Float.isNaN(angstroms) ? Integer.MAX_VALUE : (int) Math.floor(angstroms * 1000 * 2)); } - errorStr(ERROR_booleanOrWhateverExpected, "\"DOTTED\""); + if (!chk) + errorStr(ERROR_booleanOrWhateverExpected, "\"DOTTED\""); return 0; } Modified: trunk/Jmol/src/org/jmol/scriptext/MathExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/scriptext/MathExt.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -227,7 +227,7 @@ // unitcell(uc) // unitcell(uc, "reciprocal") // unitcell(ucconv, "primitive","BCC"|"FCC") - // unitcell(ucprim, "conventional","BCC"|"FCC"|...?) //not yet implemented + // unitcell(ucprim, "conventional","BCC"|"FCC") // unitcell(origin, [va, vb, vc]) // unitcell(origin, pta, ptb, ptc) int lastParam = args.length - 1; @@ -280,27 +280,13 @@ } } } - String op = (ptParam <= lastParam ? args[ptParam++].asString() : null); - if ("reciprocal".equalsIgnoreCase(op)) { + String op = (ptParam <= lastParam ? args[ptParam].asString() : null); + boolean isPrimitive = "primitive".equalsIgnoreCase(op); + if (isPrimitive || "conventional".equalsIgnoreCase(op)) { + if (!SimpleUnitCell.transformCubic(isPrimitive, args[++ptParam].asString(), ucnew)) + return false; + } else if ("reciprocal".equalsIgnoreCase(op)) { ucnew = SimpleUnitCell.getReciprocal(ucnew); - } else if ("primitive".equalsIgnoreCase(op)) { - String type = args[ptParam].asString(); - float[] f = null; - if (type.equalsIgnoreCase("BCC")) - f = new float[] { .5f, .5f, -.5f, -.5f, .5f, .5f, .5f, -.5f, .5f }; - else if (type.equalsIgnoreCase("FCC")) - f = new float[] { .5f, .5f, 0, 0, .5f, .5f, .5f, 0, .5f }; - if (f == null) - return false; - P3[] b = new P3[3]; - for (int i = 0, p = 0; i < 3; i++) { - b[i] = new P3(); - for (int j = 1; j < 4; j++) - b[i].scaleAdd2(f[p++], ucnew[j], b[i]); - } - for (int i = 0; i < 3; i++) - ucnew[i + 1] = b[i]; - } if (scale != 1) for (int i = 1; i < 4; i++) @@ -2268,6 +2254,12 @@ } private boolean evaluatePoint(ScriptMathProcessor mp, SV[] args) { + // point(1.3) // rounds toward 0 + // point(pt, true) // to screen coord + // point(pt, false) // from screen coord + // point(x, y, z) + // point(x, y, z, w) + switch (args.length) { default: return false; @@ -2281,15 +2273,33 @@ return (pt instanceof P3 ? mp.addXPt((P3) pt) : mp.addXStr("" + pt)); case 2: // to/from screen coordinates - P3 pt3 = SV.ptValue(args[0]); - if (pt3 == null) - return false; - if (args[1].tok == T.off) { + P3 pt3; + switch (args[1].tok) { + case T.off: + if ((pt3 = SV.ptValue(args[0])) == null) + return false; // these are screen coordinates vwr.tm.unTransformPoint(pt3, pt3); - } else { + break; + case T.on: + if ((pt3 = SV.ptValue(args[0])) == null) + return false; // this is TO screen coordinates vwr.tm.transformPt3f(pt3, pt3); + break; + case T.point3f: + // unitcell transform + Lst<SV> sv = args[0].getList(); + if (sv == null || sv.size() != 4) + return false; + P3 pt1 = SV.ptValue(args[1]); + pt3 = P3.newP(SV.ptValue(sv.get(0))); + pt3.scaleAdd2(pt1.x, SV.ptValue(sv.get(1)), pt3); + pt3.scaleAdd2(pt1.y, SV.ptValue(sv.get(2)), pt3); + pt3.scaleAdd2(pt1.z, SV.ptValue(sv.get(3)), pt3); + break; + default: + return false; } return mp.addXPt(pt3); case 3: Modified: trunk/Jmol/src/org/jmol/symmetry/SpaceGroup.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/SpaceGroup.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/symmetry/SpaceGroup.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -116,9 +116,13 @@ boolean isBilbao; - static SpaceGroup getNull(boolean doInit) { + static SpaceGroup getNull(boolean doInit, boolean doNormalize, boolean doFinalize) { getSpaceGroups(); - return new SpaceGroup(null, doInit); + SpaceGroup sg = new SpaceGroup(null, doInit); + sg.doNormalize = doNormalize; + if (doFinalize) + sg.setFinalOperations(null, 0, 0, false); + return sg; } private SpaceGroup(String cifLine, boolean doInit) { @@ -128,11 +132,6 @@ buildSpaceGroup(cifLine); } - SpaceGroup set(boolean doNormalize) { - this.doNormalize = doNormalize; - return this; - } - private void init(boolean addXYZ) { xyzList = new Hashtable<String, Integer>(); operationCount = 0; @@ -159,6 +158,12 @@ return sg; } + /** + * + * @param name + * @param data Lst<SymmetryOperation> or Lst<M4> + * @return a new SpaceGroup if successful or null + */ private static SpaceGroup createSGFromList(String name, Lst<?> data) { // try unconventional Hall symbol SpaceGroup sg = new SpaceGroup("0;--;--;--", true); @@ -352,7 +357,7 @@ /** * - * @return valid space group or null + * @return a known space group or null */ SpaceGroup getDerivedSpaceGroup() { if (index >= 0 && index < SG.length Modified: trunk/Jmol/src/org/jmol/symmetry/Symmetry.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/Symmetry.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/symmetry/Symmetry.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -130,7 +130,7 @@ @Override public void setSpaceGroup(boolean doNormalize) { if (spaceGroup == null) - spaceGroup = (SpaceGroup.getNull(true)).set(doNormalize); + spaceGroup = SpaceGroup.getNull(true, doNormalize, false); } @Override @@ -160,11 +160,18 @@ spaceGroup = (SpaceGroup) symmetry.getSpaceGroup(); } + /** + * + * @param desiredSpaceGroupIndex + * @param name + * @param data a Lst<SymmetryOperation> or Lst<M4> + * @return true if a known space group + */ @Override public boolean createSpaceGroup(int desiredSpaceGroupIndex, String name, - Object object) { + Object data) { spaceGroup = SpaceGroup.createSpaceGroup(desiredSpaceGroupIndex, name, - object); + data); if (spaceGroup != null && Logger.debugging) Logger.debug("using generated space group " + spaceGroup.dumpInfo(null)); return spaceGroup != null; @@ -321,8 +328,11 @@ @Override public M4[] getSymmetryOperations() { - return symmetryInfo == null ? spaceGroup.finalOperations - : symmetryInfo.symmetryOperations; + if (symmetryInfo != null) + return symmetryInfo.symmetryOperations; + if (spaceGroup == null) + spaceGroup = SpaceGroup.getNull(true, false, true); + return spaceGroup.finalOperations; } @Override Modified: trunk/Jmol/src/org/jmol/symmetry/SymmetryDesc.java =================================================================== --- trunk/Jmol/src/org/jmol/symmetry/SymmetryDesc.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/symmetry/SymmetryDesc.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -1007,7 +1007,7 @@ } else { isStandard = !isBio; if (isBio) - sym.spaceGroup = (SpaceGroup.getNull(false)).set(false); + sym.spaceGroup = SpaceGroup.getNull(false, false, false); else sym.setSpaceGroup(false); strOperations = "\n" + ops.length + " symmetry operations:"; Modified: trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java =================================================================== --- trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java 2015-10-11 15:41:18 UTC (rev 20817) @@ -400,4 +400,31 @@ } return rabc; } + + /** + * + * @param isPrimitive or assumed conventional + * @param type FCC or BCC + * @param uc either [origin, va, vb, vc] or just [va, vb, vc] + * @return true if successful + */ + public static boolean transformCubic(boolean isPrimitive, String type, + T3[] uc) { + int offset = uc.length - 3; + float[] f = (type.equalsIgnoreCase("BCC") ? (isPrimitive ? new float[] { .5f, .5f, -.5f, -.5f, .5f, .5f, .5f, -.5f, .5f } + : new float[] { 1, 0, 1, 1, 1, 0, 0, 1, 1 }) + : type.equalsIgnoreCase("FCC") ? (isPrimitive ? new float[] { .5f, .5f, 0, 0, .5f, .5f, .5f, 0, .5f } + : new float[] { 1, -1, 1, 1, 1, -1, -1, 1, 1 }) : null); + if (f == null) + return false; + P3[] b = new P3[3]; + for (int i = 0, p = 0; i < 3; i++) { + b[i] = new P3(); + for (int j = offset; j < 3 + offset; j++) + b[i].scaleAdd2(f[p++], uc[j], b[i]); + } + for (int i = 0; i < 3; i++) + uc[i + offset] = b[i]; + return true; + } } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-10-10 16:49:59 UTC (rev 20816) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-10-11 15:41:18 UTC (rev 20817) @@ -63,17 +63,28 @@ -Jmol.___JmolVersion="14.3.16_2015.10.09" +Jmol.___JmolVersion="14.3.16_2015.10.11" new feature: unitcell() function - // optional last parameter: scale - // unitcell() - // unitcell(uc) - // unitcell(uc, "reciprocal") - // unitcell(ucconv, "primitive","BCC"|"FCC") - // unitcell(ucprim, "conventional","BCC"|"FCC"|...?) //not yet implemented - // unitcell(origin, [va, vb, vc]) - // unitcell(origin, pta, ptb, ptc) + -- returns unitcell as an array in the form [origin, va, vb, vc] + -- first parameter is optional unitcell itself; absence uses current model's unit cell. + -- optional last parameter: scale + -- signatures: + unitcell() // uses current unit cell + unitcell(uc) // copies unit cell + unitcell(uc, "reciprocal") // reciprocal lattice for specied unit cell + unitcell("reciprocal") // reciprocal lattice for current model's unit cell + unitcell(ucconv, "primitive","BCC"|"FCC") // convert primitive to conventional + unitcell("primitive","BCC"|"FCC") + unitcell(ucprim, "conventional","BCC"|"FCC") // convert primitive to conventional + unitcell("conventional","BCC"|"FCC") + + unitcell(origin, [va, vb, vc]) + unitcell(origin, pta, ptb, ptc) + +new feature: point(unitcell, {i, j, k}) + -- unitcell is an array of the form [origin, va, vb, vc] + -- {i j k} is a point in the unitcell JmolVersion="14.3.16_2015.10.09" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits