From: <ha...@us...> - 2010-12-09 17:07:46
|
Revision: 14772 http://jmol.svn.sourceforge.net/jmol/?rev=14772&view=rev Author: hansonr Date: 2010-12-09 17:07:39 +0000 (Thu, 09 Dec 2010) Log Message: ----------- version=12.1.26_dev -- Brillouin zone preparations # new feature: plane(pt1, pt2) -- returns bisecting plane # new feature: draw SLAB $draw1 PLANE @{plane({...} {....})} # -- $draw1 must be a draw POLYGON definition # -- draw draw1 SLAB $draw1... is allowed Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java trunk/Jmol/src/org/jmol/util/MeshSurface.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-12-09 07:31:13 UTC (rev 14771) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-12-09 17:07:39 UTC (rev 14772) @@ -9416,6 +9416,7 @@ } if (endDegrees == 0 && points[0] != null) { // glide plane + rotAxis.normalize(); Measure.getPlaneThroughPoint(points[0], rotAxis, invPlane = new Point4f()); } @@ -14008,6 +14009,18 @@ propertyValue = vp; havePoints = true; break; + case Token.slab: + switch (getToken(++i).tok) { + case Token.dollarsign: + propertyName = "slab"; + propertyValue = objectNameParameter(++i); + i = iToken; + havePoints = true; + break; + default: + error(ERROR_invalidArgument); + } + break; case Token.intersection: switch (getToken(++i).tok) { case Token.unitcell: @@ -14021,7 +14034,7 @@ i = iToken; isIntersect = true; havePoints = true; - break; + break; default: error(ERROR_invalidArgument); } Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-12-09 07:31:13 UTC (rev 14771) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2010-12-09 17:07:39 UTC (rev 14772) @@ -1343,10 +1343,11 @@ private boolean evaluatePlane(ScriptVariable[] args, int tok) throws ScriptException { if (args.length != 3 && tok == Token.hkl || tok != Token.hkl - && args.length != 1 && args.length != 3 && args.length != 4) + && args.length == 0 || args.length > 4) return false; if (isSyntaxCheck) return addX(new Point4f(0, 0, 1, 0)); + Point3f pt1, pt2, pt3; switch (args.length) { case 1: @@ -1354,6 +1355,18 @@ if (pt instanceof Point4f) return addX(pt); return addX("" + pt); + case 2: + pt1 = ptValue(args[0], false); + pt2 = ptValue(args[1], false); + pt3 = new Point3f(pt1); + pt3.add(pt2); + pt3.scale(0.5f); + Vector3f v = new Vector3f(pt2); + v.sub(pt1); + v.normalize(); + Point4f plane = new Point4f(); + Measure.getPlaneThroughPoint(pt3, v, plane); + return addX(plane); case 3: if (tok == Token.hkl) { return addX(eval.getHklPlane(new Point3f( @@ -1364,9 +1377,9 @@ switch (args[0].tok) { case Token.bitset: case Token.point3f: - Point3f pt1 = ptValue(args[0], true); - Point3f pt2 = ptValue(args[1], true); - Point3f pt3 = ptValue(args[2], true); + pt1 = ptValue(args[0], false); + pt2 = ptValue(args[1], false); + pt3 = ptValue(args[2], false); Vector3f vAB = new Vector3f(); Vector3f vAC = new Vector3f(); Vector3f norm = new Vector3f(); Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2010-12-09 07:31:13 UTC (rev 14771) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2010-12-09 17:07:39 UTC (rev 14772) @@ -39,6 +39,7 @@ import org.jmol.util.BitSetUtil; import org.jmol.util.Escape; import org.jmol.util.Logger; +import org.jmol.util.MeshSurface; import org.jmol.util.Measure; import org.jmol.util.Point3fi; @@ -150,6 +151,7 @@ modelCount = viewer.getModelCount(); bsAllModels = null; intersectID = null; + slabData = null; boundBox = null; explicitID = false; setPropertySuper("thisID", JmolConstants.PREVIOUS_MESH_ID, null); @@ -175,6 +177,20 @@ return; } + if ("slab" == propertyName) { + int meshIndex = getIndexFromName((String) value); + if (meshIndex < 0) { + // could be isosurface? + return; + } + Mesh m = meshes[meshIndex]; + if (m.checkByteCount != 1) + return; + slabData = new MeshSurface(m.vertices, new float[m.vertexCount], m.vertexCount, + m.polygonIndexes, m.polygonCount, 1); + return; + } + if ("lineData" == propertyName) { lineData = new ArrayList<Point3f[]>(); if (indicatedModelIndex < 0) @@ -201,7 +217,7 @@ if ("planedef" == propertyName) { plane = (Point4f) value; - if (intersectID != null || boundBox != null) + if (intersectID != null || boundBox != null || slabData != null) return; if (isCircle || isArc) isPlane = true; @@ -506,6 +522,8 @@ thisMesh.width = width; if (intersectID != null || boundBox != null) setIntersectData(); + else if (slabData != null) + setSlabData(); if (polygon == null && (lineData != null ? lineData.size() == 0 : vData.size() == 0)) return false; if (polygon != null || lineData != null || indicatedModelIndex < 0 @@ -605,6 +623,17 @@ } } + MeshSurface slabData; + + private void setSlabData() { + if (plane != null) { + slabData.getIntersection(plane, null, false, true); + polygon = new ArrayList<Object>(); + polygon.add(slabData.vertices); + polygon.add(slabData.polygonIndexes); + } + } + private void addPoint(Point3f newPt, int iModel) { boolean isOK = (iModel < 0 || bsAllModels.get(iModel)); if (makePoints) { @@ -1331,7 +1360,10 @@ str.append(" ").append(Escape.escape(mesh.vertices[i])); str.append(" ").append(mesh.polygonCount); for (int i = 0; i < mesh.polygonCount; i++) - str.append(" ").append(Escape.escapeArray(mesh.polygonIndexes[i])); + if (mesh.polygonIndexes[i] == null) + str.append(" [0 0 0 0]"); + else + str.append(" ").append(Escape.escapeArray(mesh.polygonIndexes[i])); } else { str.append(getVertexList(mesh, iModel, nVertices)); } Modified: trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2010-12-09 07:31:13 UTC (rev 14771) +++ trunk/Jmol/src/org/jmol/shapesurface/Isosurface.java 2010-12-09 17:07:39 UTC (rev 14772) @@ -511,7 +511,7 @@ if (mesh == null) return false; data[3] = Integer.valueOf(mesh.modelIndex); - return mesh.getIntersection((Point4f) data[1], (List<Point3f[]>) data[2], false); + return mesh.getIntersection((Point4f) data[1], (List<Point3f[]>) data[2], false, false); } if (property == "getBoundingBox") { String id = (String) data[0]; Modified: trunk/Jmol/src/org/jmol/util/MeshSurface.java =================================================================== --- trunk/Jmol/src/org/jmol/util/MeshSurface.java 2010-12-09 07:31:13 UTC (rev 14771) +++ trunk/Jmol/src/org/jmol/util/MeshSurface.java 2010-12-09 17:07:39 UTC (rev 14772) @@ -28,9 +28,26 @@ public BitSet bsFaces; public Point3f ptOffset; public float scale3d; + public Point3f[] dots; + public float[] vertexValues; + public BitSet[] surfaceSet; + public int[] vertexSets; + public int nSets = 0; + public int checkCount = 2; + public MeshSurface() { } + + public MeshSurface(Point3f[] vertices, float[] vertexValues, int vertexCount, + int[][] polygonIndexes, int polygonCount, int checkCount) { + this.vertices = vertices; + this.vertexValues = vertexValues; + this.vertexCount = vertexCount; + this.polygonIndexes = polygonIndexes; + this.polygonCount = polygonCount; + this.checkCount = checkCount; + } public void setColix(short colix) { this.colix = colix; @@ -72,12 +89,6 @@ polygonIndexes = new int[polygonCount][]; } - public Point3f[] dots; - public float[] vertexValues; - public BitSet[] surfaceSet; - public int[] vertexSets; - public int nSets = 0; - public int addVertexCopy(Point3f vertex, float value) { if (vertexCount == 0) vertexValues = new float[SEED_COUNT]; @@ -98,8 +109,9 @@ || Float.isNaN(vertices[vertexB].x) || Float.isNaN(vertices[vertexC].x) ? -1 - : addPolygon(new int[] { vertexA, vertexB, vertexC, check, check2 }, - color)); + : checkCount == 2 ? addPolygon(new int[] { vertexA, vertexB, vertexC, check, check2 }, + color) + : addPolygon(new int[] { vertexA, vertexB, vertexC, check })); } private int lastColor; @@ -143,18 +155,18 @@ public void slabPolygons(Object slabbingObject, boolean andCap) { if (slabbingObject instanceof Point4f) { - getIntersection((Point4f) slabbingObject, null, andCap); + getIntersection((Point4f) slabbingObject, null, andCap, false); return; } if (slabbingObject instanceof Point3f[]) { Point4f[] faces = BoxInfo.getFacesFromCriticalPoints((Point3f[]) slabbingObject); for (int i = 0; i < faces.length; i++) - getIntersection(faces[i], null, andCap); + getIntersection(faces[i], null, andCap, false); return; } } - public boolean getIntersection(Point4f plane, List<Point3f[]> vData, boolean andCap) { + public boolean getIntersection(Point4f plane, List<Point3f[]> vData, boolean andCap, boolean doClean) { boolean isSlab = (vData == null); Point3f[] pts; int iD, iE; @@ -269,9 +281,49 @@ addTriangleCheck(iD, v0, iE, 0, 0, 0); } } + if (doClean) + clean(); return false; } + private void clean() { + // not perfect yet + BitSet bsv = new BitSet(); + BitSet bsp = new BitSet(); + for (int i = 0; i < polygonCount; i++) { + if (polygonIndexes[i] == null) + continue; + bsp.set(i); + for (int j = 0; j < 3; j++) + bsv.set(polygonIndexes[i][j]); + } + int n = 0; + int nPoly = bsp.cardinality(); + if (nPoly != polygonCount) { + int[] map = new int[vertexCount]; + for (int i = 0; i < vertexCount; i++) + if (bsv.get(i)) + map[i] = n++; + Point3f[] vTemp = new Point3f[n]; + n = 0; + for (int i = 0; i < vertexCount; i++) + if (bsv.get(i)) + vTemp[n++] = vertices[i]; + int[][] pTemp = new int[nPoly][]; + nPoly = 0; + for (int i = 0; i < polygonCount; i++) + if (polygonIndexes[i] != null) { + for (int j = 0; j < 3; j++) + polygonIndexes[i][j] = map[polygonIndexes[i][j]]; + pTemp[nPoly++] = polygonIndexes[i]; + } + vertices = vTemp; + vertexCount = n; + polygonIndexes = pTemp; + polygonCount = nPoly; + } + } + private static Point3f interpolatePoint(Point3f v1, Point3f v2, float d1, float d2) { float f = d1 / (d1 + d2); if (f < 0.0001) Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-12-09 07:31:13 UTC (rev 14771) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-12-09 17:07:39 UTC (rev 14772) @@ -3,6 +3,11 @@ version=12.1.26_dev +# new feature: plane(pt1, pt2) -- returns bisecting plane +# new feature: draw SLAB $draw1 PLANE @{plane({...} {....})} +# -- $draw1 must be a draw POLYGON definition +# -- draw draw1 SLAB $draw1... is allowed + # bug fix: pop-up menu after zap 1.1 in set of two models crashes Jmol # -------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |