Revision: 20109 http://sourceforge.net/p/jmol/code/20109 Author: hansonr Date: 2014-11-15 17:15:05 +0000 (Sat, 15 Nov 2014) Log Message: ----------- Jmol.___JmolVersion="14.3.9_2014.11.15"
new feature: VASP CHGCAR reader new feature: VASP CHGCAR isosurface reader Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java trunk/Jmol/src/org/jmol/io/JmolUtil.java trunk/Jmol/src/org/jmol/jvxl/readers/ApbsReader.java trunk/Jmol/src/org/jmol/jvxl/readers/CastepDensityReader.java trunk/Jmol/src/org/jmol/jvxl/readers/CubeReader.java trunk/Jmol/src/org/jmol/jvxl/readers/EfvetReader.java trunk/Jmol/src/org/jmol/jvxl/readers/JaguarReader.java trunk/Jmol/src/org/jmol/jvxl/readers/JvxlReader.java trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java trunk/Jmol/src/org/jmol/jvxl/readers/KinemageReader.java trunk/Jmol/src/org/jmol/jvxl/readers/MsmsReader.java trunk/Jmol/src/org/jmol/jvxl/readers/NffReader.java trunk/Jmol/src/org/jmol/jvxl/readers/ObjReader.java trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java trunk/Jmol/src/org/jmol/jvxl/readers/Pmesh4Reader.java trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceFileReader.java trunk/Jmol/src/org/jmol/jvxl/readers/UhbdReader.java trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java trunk/Jmol/src/org/jmol/jvxl/readers/XplorReader.java trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Added Paths: ----------- trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java trunk/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java trunk/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java Added: trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -0,0 +1,96 @@ +/* $RCSfile$ + * $Author: hansonr $ + * + * Copyright (C) 2003-2005 Miguel, Jmol Development, www.jmol.org + * + * Contact: jmol-develop...@lists.sf.net + * + * Copyright (C) 2009 Piero Canepa, University of Kent, UK + * + * Contact: pc...@kent.ac.uk or pieremanuele.can...@gmail.com + * + * 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 Public 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.adapter.readers.xtal; + +import org.jmol.adapter.smarter.AtomSetCollectionReader; + +/** + * http://cms.mpi.univie.ac.at/vasp/vasp/CHGCAR_file.html + * + * very simple reader of just the header information. + * + */ + +public class VaspChgcarReader extends AtomSetCollectionReader { + + @Override + protected void initializeReader() { + setSpaceGroupName("P1"); + setFractionalCoordinates(true); + } + +// Na Cl +// 5.68452685100000 +// 1.000000 0.000000 0.000000 +// 0.000000 1.000000 0.000000 +// 0.000000 0.000000 1.000000 +// 4 4 +//Direct +// 0.750000 0.250000 0.250000 +// 0.250000 0.750000 0.250000 +// 0.250000 0.250000 0.750000 +// 0.750000 0.750000 0.750000 +// 0.250000 0.250000 0.250000 +// 0.750000 0.750000 0.250000 +// 0.750000 0.250000 0.750000 +// 0.250000 0.750000 0.750000 +// + + @Override + protected boolean checkLine() throws Exception { + String[] atomSym = getTokens(); + float scale = parseFloatStr(rd()); + float[] unitCellData = new float[9]; + fillFloatArray(null, 0, unitCellData); + for (int i = 0; i < 9; i++) + unitCellData[i] *= scale; + addPrimitiveLatticeVector(0, unitCellData, 0); + addPrimitiveLatticeVector(1, unitCellData, 3); + addPrimitiveLatticeVector(2, unitCellData, 6); + String[] tokens = getTokensStr(rd()); + int[] atomCounts = new int[tokens.length]; + for (int i = tokens.length; --i >= 0;) + atomCounts[i] = parseIntStr(tokens[i]); + if (atomSym.length != atomCounts.length) + atomSym = null; + /*String type = */ rd(); + // type should be "direct" + for (int i = 0; i < atomCounts.length; i++) + for (int j = atomCounts[i]; --j >= 0;) + addAtomXYZSymName(getTokensStr(rd()), 0, (atomSym == null ? "Xx" : atomSym[i]), null); + continuing = false; + return false; + } + + @Override + protected void finalizeSubclassReader() throws Exception { + applySymmetryAndSetTrajectory(); + } + + +} Property changes on: trunk/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -54,7 +54,7 @@ "pymol.", ";PyMOL;", "simple.", ";Alchemy;Ampac;Cube;FoldingXyz;GhemicalMM;HyperChem;Jme;JSON;Mopac;MopacArchive;Tinker;ZMatrix;", "xtal.", ";Abinit;Aims;Bilbao;Castep;Cgd;Crystal;Dmol;Espresso;Gulp;Jana;Magres;Shelx;Siesta;VaspOutcar;" + - "VaspPoscar;Wien2k;Xcrysden;", + "VaspPoscar;VaspChgcar;Wien2k;Xcrysden;", "xml.", ";XmlArgus;XmlCml;XmlChem3d;XmlMolpro;XmlOdyssey;XmlXsd;XmlVasp;XmlQE;", }; @@ -364,8 +364,10 @@ return "Crystal"; if (checkCastep(lines)) return "Castep"; - if (checkVaspposcar(lines)) + if (checkVasp(lines, true)) return "VaspPoscar"; + if (checkVasp(lines, false)) + return "VaspChgcar"; } else { if (nLines == 1 && lines[0].length() > 0 && PT.isDigit(lines[0].charAt(0))) @@ -456,17 +458,13 @@ return false; } - private static boolean checkVaspposcar(String[] lines) { - String select = lines[8].trim().toLowerCase(); - if (select.contains("direct") || select.contains("cartesian") - || select.contains("selective")) - return true; - String normal = lines[7].trim().toLowerCase(); - if (normal.contains("direct") || normal.contains("cartesian")) - return true; - return false; + private static boolean checkVasp(String[] lines, boolean isPoscar) { + String line = lines[isPoscar ? 7 : 6].toLowerCase(); + if (isPoscar && line.contains("selective")) + line = lines[7].toLowerCase(); + return (line.contains("direct") || line.contains("cartesian")); } - + private static boolean checkCrystal(String[] lines) { String s = lines[1].trim(); if (s.equals("SLAB") ||s.equals("MOLECULE") Modified: trunk/Jmol/src/org/jmol/io/JmolUtil.java =================================================================== --- trunk/Jmol/src/org/jmol/io/JmolUtil.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/io/JmolUtil.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -367,7 +367,8 @@ if (nAtoms == Integer.MIN_VALUE) return (line3.indexOf("+") == 0 ? "Jvxl+" : null); if (nAtoms >= 0) - return (line3.length() < 60 ? "Cube": null); //Can't be a Jvxl file; M40 files are > 60 char + return (line3.length() >= 60 ? null + : line3.indexOf(".") > 0 ? "VaspChgcar" : "Cube"); //Can't be a Jvxl file; M40 files are > 60 char nAtoms = -nAtoms; for (int i = 4 + nAtoms; --i >= 0;) if ((line = br.readLineWithNewline()) == null) Modified: trunk/Jmol/src/org/jmol/jvxl/readers/ApbsReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/ApbsReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/ApbsReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -52,10 +52,10 @@ protected void readParameters() throws Exception { jvxlFileHeaderBuffer = SB.newS(skipComments(false)); while (line != null && line.length() == 0) - readLine(); + rd(); jvxlFileHeaderBuffer.append("APBS OpenDx DATA ").append(line).append("\n"); jvxlFileHeaderBuffer.append("see http://apbs.sourceforge.net\n"); - String atomLine = readLine(); + String atomLine = rd(); String[] tokens = PT.getTokens(atomLine); if (tokens.length >= 4) { volumetricOrigin.set(parseFloatStr(tokens[1]), parseFloatStr(tokens[2]), @@ -66,7 +66,7 @@ readVoxelVector(0); readVoxelVector(1); readVoxelVector(2); - readLine(); + rd(); tokens = getTokens(); /* see http://apbs.sourceforge.net/doc/user-guide/index.html#opendx-format object 2 class gridconnections counts nx ny nz @@ -75,6 +75,6 @@ */ for (int i = 0; i < 3; i++) voxelCounts[i] = parseIntStr(tokens[i + 5]); - readLine(); + rd(); } } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/CastepDensityReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/CastepDensityReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/CastepDensityReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -25,12 +25,11 @@ import java.io.BufferedReader; - import javajs.util.PT; import javajs.util.SB; import javajs.util.V3; -class CastepDensityReader extends VolumeFileReader { +class CastepDensityReader extends PeriodicVolumeFileReader { private int nFilePoints; @@ -43,6 +42,13 @@ isAngstroms = true; } + private int nSkip; + + @Override + protected void gotoData(int n, int nPoints) throws Exception { + nSkip = n; + } + /* * BEGIN header @@ -62,16 +68,16 @@ @Override protected void readParameters() throws Exception { jvxlFileHeaderBuffer = new SB(); - while (readLine() != null && line.indexOf(".") < 0) { + while (rd() != null && line.indexOf(".") < 0) { // skip front stuff } for (int i = 0; i < 3; ++i) { V3 voxelVector = volumetricVectors[i]; voxelVector.set(parseFloatStr(line), parseFloat(), parseFloat()); - readLine(); + rd(); } - nSurfaces = parseIntStr(readLine()); - readLine(); + nSurfaces = parseIntStr(rd()); + rd(); voxelCounts[0] = (nPointsX = parseIntStr(line)) + 1; voxelCounts[1] = (nPointsY = parseInt()) + 1; voxelCounts[2] = (nPointsZ = parseInt()) + 1; @@ -82,30 +88,13 @@ if (isAnisotropic) setVectorAnisotropy(volumetricVectors[i]); } - while (readLine().trim().length() > 0) { + while (rd().trim().length() > 0) { // } } - private int nSkip; - @Override - protected void gotoData(int n, int nPoints) throws Exception { - nSkip = n; - } - - @Override - protected void readSurfaceData(boolean isMapData) throws Exception { - initializeSurfaceData(); - voxelData = new float[nPointsX][nPointsY][nPointsZ]; - readLine(); - String[] tokens = getTokens(); - if (nSkip > 0 && tokens.length < 3 + nSurfaces) { - for (int j = 0; j < nSkip; j++) - for (int i = 0; i < nFilePoints; i++) - readLine(); - nSkip = 0; - } + protected void getPeriodicVoxels() throws Exception { for (int i = 0; i < nFilePoints; i++) { int x = parseIntStr(line) - 1; int y = parseInt() - 1; @@ -113,43 +102,9 @@ if (nSkip > 0) skipPoints(nSkip); voxelData[x][y][z] = recordData(parseFloat()); - readLine(); + rd(); } - // add in periodic face data - - int n; - n = nPointsX - 1; - for (int i = 0; i < nPointsY; ++i) - for (int j = 0; j < nPointsZ; ++j) - voxelData[n][i][j] = voxelData[0][i][j]; - n = nPointsY - 1; - for (int i = 0; i < nPointsX; ++i) - for (int j = 0; j < nPointsZ; ++j) - voxelData[i][n][j] = voxelData[i][0][j]; - n = nPointsZ - 1; - for (int i = 0; i < nPointsX; ++i) - for (int j = 0; j < nPointsY; ++j) - voxelData[i][j][n] = voxelData[i][j][0]; - - // for map data, just pick out near points and get rid of voxelData - - if (isMapData && volumeData.hasPlane()) { - volumeData.setVoxelMap(); - for (int x = 0; x < nPointsX; ++x) { - for (int y = 0; y < nPointsY; ++y) { - for (int z = 0; z < nPointsZ; ++z) { - float f = volumeData.getToPlaneParameter(); - if (volumeData.isNearPlane(x, y, z, f)) - volumeData.setVoxelMapValue(x, y, z, voxelData[x][y][z]); - } - } - } - voxelData = null; - } - volumeData.setVoxelDataAsArray(voxelData); - if (dataMin > params.cutoff) - params.cutoff = 2 * dataMin; } private void skipPoints(int n) { @@ -166,5 +121,17 @@ } + @Override + protected void readSkip() throws Exception { + rd(); + String[] tokens = getTokens(); + if (nSkip > 0 && tokens.length < 3 + nSurfaces) { + for (int j = 0; j < nSkip; j++) + for (int i = 0; i < nFilePoints; i++) + rd(); + nSkip = 0; + } + } + } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/CubeReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/CubeReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/CubeReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -43,9 +43,9 @@ @Override protected void readParameters() throws Exception { jvxlFileHeaderBuffer = new SB(); - jvxlFileHeaderBuffer.append(readLine()).appendC('\n'); - jvxlFileHeaderBuffer.append(readLine()).appendC('\n'); - String atomLine = readLine(); + jvxlFileHeaderBuffer.append(rd()).appendC('\n'); + jvxlFileHeaderBuffer.append(rd()).appendC('\n'); + String atomLine = rd(); String[] tokens = PT.getTokensAt(atomLine, 0); ac = parseIntStr(tokens[0]); negativeAtomCount = (ac < 0); // MO list @@ -60,12 +60,12 @@ for (int i = 0; i < 3; ++i) readVoxelVector(i); for (int i = 0; i < ac; ++i) - jvxlFileHeaderBuffer.append(readLine() + "\n"); + jvxlFileHeaderBuffer.append(rd() + "\n"); if (!negativeAtomCount) { nSurfaces = 1; } else { - readLine(); + rd(); Logger.info("Reading extra CUBE information line: " + line); nSurfaces = parseIntStr(line); } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/EfvetReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/EfvetReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/EfvetReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -107,7 +107,7 @@ private void getHeader() throws Exception { skipTo("<efvet", null); - while(readLine().length() > 0 && line.indexOf(">") < 0) + while(rd().length() > 0 && line.indexOf(">") < 0) jvxlFileHeaderBuffer.append("# " + line + "\n"); Logger.info(jvxlFileHeaderBuffer.toString()); } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/JaguarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/JaguarReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/JaguarReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -89,7 +89,7 @@ jvxlFileHeaderBuffer.append("Jaguar data\n"); jvxlFileHeaderBuffer.append("\n"); String atomLine; - while ((atomLine = readLine()) != null + while ((atomLine = rd()) != null && atomLine.indexOf("origin=") < 0) { } String[] tokens = PT.getTokensAt(atomLine, 0); @@ -107,7 +107,7 @@ readExtents(1); readExtents(2); - tokens = PT.getTokens(readLine()); + tokens = PT.getTokens(rd()); voxelCounts[0] = parseIntStr(tokens[1]); voxelCounts[1] = parseIntStr(tokens[2]); voxelCounts[2] = parseIntStr(tokens[3]); @@ -129,7 +129,7 @@ // I think, because if you don't use -1 here, then the grid // distances are the same, but the surface is in the wrong place! - readLine(); + rd(); } @@ -143,7 +143,7 @@ * @exception Exception -- generally a reader issue */ private void readExtents(int voxelVectorIndex) throws Exception { - String[] tokens = PT.getTokens(readLine()); + String[] tokens = PT.getTokens(rd()); extents[voxelVectorIndex] = parseFloatStr(tokens[voxelVectorIndex + 1]); } } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/JvxlReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/JvxlReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/JvxlReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -61,7 +61,7 @@ if (line == null || line.length() == 0) line = "Line 1"; jvxlFileHeaderBuffer.append(line).appendC('\n'); - if (readLine() == null || line.length() == 0) + if (rd() == null || line.length() == 0) line = "Line 2"; jvxlFileHeaderBuffer.append(line).appendC('\n'); jvxlFileHeaderBuffer.append(skipComments(false)); @@ -89,7 +89,7 @@ readVoxelVector(1); readVoxelVector(2); for (int i = 0; i < ac; ++i) - jvxlFileHeaderBuffer.append(readLine() + "\n"); + jvxlFileHeaderBuffer.append(rd() + "\n"); skipComments(true); Logger.info("Reading extra JVXL information line: " + line); nSurfaces = parseIntStr(line); @@ -119,7 +119,7 @@ String str = ""; try { while (str.length() < nPoints) { - readLine(); + rd(); str += JvxlCoder.jvxlDecompressString(line); } } catch (Exception e) { @@ -286,7 +286,7 @@ private void jvxlSkipDataBlock(int nPoints, boolean isInt) throws Exception { int n = 0; while (n < nPoints) { - readLine(); + rd(); n += (isInt ? countData(line) : JvxlCoder.jvxlDecompressString(line).length()); } } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/JvxlXmlReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -201,7 +201,7 @@ protected void jvxlSkipData(@SuppressWarnings("unused") int nPoints, @SuppressWarnings("unused") boolean doSkipColorData) throws Exception { - readLine(); + rd(); xr.skipTag("jvxlSurface"); } @@ -480,7 +480,7 @@ while (bsVoxelPtr < nPoints) { nThisValue = parseInt(); if (nThisValue == Integer.MIN_VALUE) { - readLine(); + rd(); // note -- does not allow for empty lines; // must be a continuous block of numbers. if (line == null || (nThisValue = parseIntStr(line)) == Integer.MIN_VALUE) { Modified: trunk/Jmol/src/org/jmol/jvxl/readers/KinemageReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/KinemageReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/KinemageReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -84,7 +84,7 @@ @Override protected boolean readVertices() throws Exception { // also reads polygons - readLine(); + rd(); int n0; while (line != null) { if (line.length() != 0 && line.charAt(0) == '@') { @@ -107,7 +107,7 @@ } } } - readLine(); + rd(); } return true; } @@ -120,7 +120,7 @@ private void readDots() throws Exception { int[] color = new int[1]; - while (readLine() != null && line.indexOf('@') < 0) { + while (rd() != null && line.indexOf('@') < 0) { int i = getPoint(line, 2, color, true); if (i < 0) continue; @@ -135,7 +135,7 @@ */ private void readVectors() throws Exception { int[] color = new int[1]; - while (readLine() != null && line.indexOf('@') < 0) { + while (rd() != null && line.indexOf('@') < 0) { int ia = getPoint(line, 3, color, true); int ib = getPoint(line.substring(line.lastIndexOf('{')), 2, color, false); if (ia < 0 || ib < 0) Modified: trunk/Jmol/src/org/jmol/jvxl/readers/MsmsReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/MsmsReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/MsmsReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -81,7 +81,7 @@ } private void skipHeader() throws Exception { - while (readLine() != null && line.indexOf("#") >= 0) { + while (rd() != null && line.indexOf("#") >= 0) { // skip header } tokens = getTokens(); Modified: trunk/Jmol/src/org/jmol/jvxl/readers/NffReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/NffReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/NffReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -79,7 +79,7 @@ protected boolean readVerticesAndPolygons() { int color = 0xFF0000; try { - while(readLine() != null) { + while(rd() != null) { if (line.length() == 0) continue; String[] tokens = getTokens(); @@ -112,7 +112,7 @@ private final P3 pt = new P3(); private int getVertex() throws Exception { - Integer i = vertexMap.get(readLine()); + Integer i = vertexMap.get(rd()); if (i == null) { String[] tokens = getTokens(); pt.set(parseFloatStr(tokens[0]), parseFloatStr(tokens[1]), parseFloatStr(tokens[2])); Modified: trunk/Jmol/src/org/jmol/jvxl/readers/ObjReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/ObjReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/ObjReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -100,7 +100,7 @@ // pymol writes a crude file with much re-writing of vertices BS bsOK = new BS(); - while (readLine() != null) { + while (rd() != null) { if (line.length() < 2 || line.charAt(1) != ' ') { if (params.readAllData && line.startsWith("usemtl")) // usemtl k00FF00 Added: trunk/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -0,0 +1,52 @@ +package org.jmol.jvxl.readers; + +public abstract class PeriodicVolumeFileReader extends VolumeFileReader { + + @Override + protected void readSurfaceData(boolean isMapData) throws Exception { + initializeSurfaceData(); + voxelData = new float[nPointsX][nPointsY][nPointsZ]; + readSkip(); + getPeriodicVoxels(); + + // add in periodic face data + + int n; + n = nPointsX - 1; + for (int i = 0; i < nPointsY; ++i) + for (int j = 0; j < nPointsZ; ++j) + voxelData[n][i][j] = voxelData[0][i][j]; + n = nPointsY - 1; + for (int i = 0; i < nPointsX; ++i) + for (int j = 0; j < nPointsZ; ++j) + voxelData[i][n][j] = voxelData[i][0][j]; + n = nPointsZ - 1; + for (int i = 0; i < nPointsX; ++i) + for (int j = 0; j < nPointsY; ++j) + voxelData[i][j][n] = voxelData[i][j][0]; + + // for map data, just pick out near points and get rid of voxelData + + if (isMapData && volumeData.hasPlane()) { + volumeData.setVoxelMap(); + for (int x = 0; x < nPointsX; ++x) { + for (int y = 0; y < nPointsY; ++y) { + for (int z = 0; z < nPointsZ; ++z) { + float f = volumeData.getToPlaneParameter(); + if (volumeData.isNearPlane(x, y, z, f)) + volumeData.setVoxelMapValue(x, y, z, voxelData[x][y][z]); + } + } + } + voxelData = null; + } + volumeData.setVoxelDataAsArray(voxelData); + + if (dataMin > params.cutoff) + params.cutoff = 2 * dataMin; + } + + protected abstract void getPeriodicVoxels() throws Exception; + protected abstract void readSkip() throws Exception; + +} Property changes on: trunk/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/PltFormattedReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -62,10 +62,10 @@ @Override protected void readParameters() throws Exception { - int n1 = parseIntStr(readLine()); + int n1 = parseIntStr(rd()); int n2 = parseInt(); //yes, it's "Z Y X", but that doesn't matter. Our loop will be (X (Y (Z))) - nPointsX = parseIntStr(readLine()); + nPointsX = parseIntStr(rd()); nPointsY = parseInt(); nPointsZ = parseInt(); jvxlFileHeaderBuffer.append("Plt formatted data (" + n1 + "," + n2 + ") " @@ -77,7 +77,7 @@ -0.41532E+01 0.78468E+01-0.40155E+01 0.79845E+01-0.38912E+01 0.71088E+01 */ - float xmin = parseFloatStr(readLine().substring(0, 12)); + float xmin = parseFloatStr(rd().substring(0, 12)); float xmax = parseFloatRange(line, 12, 24); float ymin = parseFloatRange(line, 24, 36); float ymax = parseFloatRange(line, 36, 48); Modified: trunk/Jmol/src/org/jmol/jvxl/readers/Pmesh4Reader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/Pmesh4Reader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/Pmesh4Reader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -101,7 +101,7 @@ @Override void getSurfaceData() throws Exception { - readLine(); + rd(); if (readVerticesAndPolygons()) Logger.info(type + " file contains " + nVertices + " 4D vertices and " + nPolygons + " polygons for " @@ -168,7 +168,7 @@ private String nextToken() throws Exception { while (iToken >= tokens.length) { iToken = 0; - readLine(); + rd(); tokens = getTokens(); } return tokens[iToken++]; Modified: trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -309,7 +309,7 @@ private String nextToken() throws Exception { while (iToken >= tokens.length) { iToken = 0; - readLine(); + rd(); tokens = getTokens(); } return tokens[iToken++]; Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceFileReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceFileReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceFileReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -151,13 +151,13 @@ protected void skipTo(String info, String what) throws Exception { if (info != null) - while (readLine().indexOf(info) < 0) { + while (rd().indexOf(info) < 0) { } if (what != null) next[0] = line.indexOf(what) + what.length() + 2; } - protected String readLine() throws Exception { + protected String rd() throws Exception { line = br.readLine(); if (line != null) { nBytes += line.length(); Modified: trunk/Jmol/src/org/jmol/jvxl/readers/UhbdReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/UhbdReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/UhbdReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -81,14 +81,14 @@ @Override protected void readParameters() throws Exception { - readLine(); + rd(); // POTENTIAL (kT/e) jvxlFileHeaderBuffer = SB.newS(line); jvxlFileHeaderBuffer.append("UHBD format ").append(line).append("\n"); jvxlFileHeaderBuffer.append("see http://sourceforge.net/p/apbs/code/ci/9527462a39126fb6cd880924b3cc4880ec4b78a9/tree/src/mg/vgrid.c\n"); - readLine(); // ignored + rd(); // ignored // 1.00000e+00 0.00000e+00 -1 0 161 1 161 - readLine(); + rd(); // 161 161 161 1.56250e+00-8.79940e+01-6.20705e+01-7.07875e+01 voxelCounts[0] = parseIntStr(line.substring(0, 7)); voxelCounts[1] = parseIntStr(line.substring(7,14)); @@ -101,9 +101,9 @@ volumetricVectors[1].set(0, dx, 0); volumetricVectors[2].set(dx, 0, 0); planeCount = voxelCounts[0]*voxelCounts[1]; - readLine(); // ignored + rd(); // ignored // 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 - readLine(); // ignored + rd(); // ignored // 0.00000e+00 0.00000e+00 0 0 } @@ -112,12 +112,12 @@ @Override protected float nextVoxel() throws Exception { if (voxelCount % planeCount == 0) { - readLine(); + rd(); // 1 161 161 pt = 0; } if (pt%78 == 0) { - readLine(); + rd(); // -4.19027e-06 -4.40880e-06 -4.63681e-06 -4.87457e-06 -5.12234e-06 -5.38038e-06 pt = 0; } Added: trunk/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -0,0 +1,128 @@ +/* $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: hans...@stolaf.edu + * + * 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 java.io.BufferedReader; + +import org.jmol.util.SimpleUnitCell; + +import javajs.util.SB; + +class VaspChgcarReader extends PeriodicVolumeFileReader { + + private float volume; + + VaspChgcarReader(){ + } + + @Override + void init2(SurfaceGenerator sg, BufferedReader br) { + init2VFR(sg, br); + isAngstroms = true; + nSurfaces = 1; + canDownsample = isProgressive = false; // for now + } + + // pt + // 10.0000000000000 + // 1.000000 0.000000 0.000000 + // 0.000000 1.000000 0.000000 + // 0.000000 0.000000 1.000000 + // 2 4 + //Direct + // 0.080067 0.160200 0.131800 + // 0.213232 0.160200 0.131800 + // 0.022723 0.101273 0.060100 + // 0.022724 0.219127 0.203500 + // 0.270578 0.101273 0.060100 + // 0.270577 0.219127 0.203499 + // + // 140 140 140 + //0.12994340141E+02 0.13765428641E+02 0.14355609008E+02 0.14732384059E+02 0.14873912610E+02 + +// WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC) +// +// The x index is the fastest index, and the z index the slowest index. +// The file can be read format-free, because at least in new versions, +// it is guaranteed that spaces separate each number. Please do not forget +// to divide by the volume before visualizing the file! + + @Override + protected void readParameters() throws Exception { + jvxlFileHeaderBuffer = new SB(); + jvxlFileHeaderBuffer.append("Vasp CHGCAR format\n"); + rd(); // atoms + float scale = parseFloatStr(rd()); + float[] data = new float[15]; + data[0] = -1; + for (int i = 0, pt = 6; i < 3; ++i) + volumetricVectors[i].set(data[pt++] = parseFloatStr(rd()) * scale, + data[pt++] = parseFloat() * scale, data[pt++] = parseFloat() * scale); + volume = (float) SimpleUnitCell.newA(data).volume; + // v0 here will be the slowest, not the fastest + while (rd().length() > 2) { + } + rd(); + String[] counts = getTokens(); + for (int i = 0; i < 3; ++i) { + volumetricVectors[i] + .scale(1f / ((voxelCounts[i] = parseIntStr(counts[i]) + 1) - 1)); + if (isAnisotropic) + setVectorAnisotropy(volumetricVectors[i]); + } + swapXZ(); + volumetricOrigin.set(0, 0, 0); + } + + private int pt; + + @Override + protected float nextVoxel() throws Exception { + if ((pt++)%5 == 0) { + rd(); + next[0] = 0; + } + return parseFloat() / volume; + } + + @Override + protected void getPeriodicVoxels() throws Exception { + int ni = voxelCounts[0] - 1; + int nj = voxelCounts[1] - 1; + int nk = voxelCounts[2] - 1; + for (int i = 0; i < ni; i++) + for (int j = 0; j < nj; j++) + for (int k = 0; k < nk; k++) + voxelData[i][j][k] = recordData(nextVoxel()); + } + + @Override + protected void readSkip() throws Exception { + // n/a + } + + +} + + Property changes on: trunk/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -174,14 +174,14 @@ protected String skipComments(boolean allowBlankLines) throws Exception { SB sb = new SB(); - while (readLine() != null + while (rd() != null && (allowBlankLines && line.length() == 0 || line.indexOf("#") == 0)) sb.append(line).appendC('\n'); return sb.toString(); } protected void readVoxelVector(int voxelVectorIndex) throws Exception { - readLine(); + rd(); V3 voxelVector = volumetricVectors[voxelVectorIndex]; if ((voxelCounts[voxelVectorIndex] = parseIntStr(line)) == Integer.MIN_VALUE) //unreadable next[0] = line.indexOf(" "); @@ -469,7 +469,7 @@ protected float nextVoxel() throws Exception { float voxelValue = parseFloat(); if (Float.isNaN(voxelValue)) { - while (readLine() != null && Float.isNaN(voxelValue = parseFloatStr(line))) { + while (rd() != null && Float.isNaN(voxelValue = parseFloatStr(line))) { } if (line == null) { if (!endOfData) @@ -500,7 +500,7 @@ protected void skipDataVFR(int nPoints) throws Exception { int iV = 0; while (iV < nPoints) - iV += countData(readLine()); + iV += countData(rd()); } private int countData(String str) { @@ -612,4 +612,14 @@ volumetricVectors[2].scale(scale); } + protected void swapXZ() { + V3 v = volumetricVectors[0]; + volumetricVectors[0] = volumetricVectors[2]; + volumetricVectors[2] = v; + int n = voxelCounts[0]; + voxelCounts[0] = voxelCounts[2]; + voxelCounts[2] = n; + params.insideOut = !params.insideOut; + } + } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/XplorReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/XplorReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/XplorReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -155,9 +155,9 @@ private String getLine() throws Exception { - readLine(); + rd(); while (line != null && (line.length() == 0 || line.indexOf("REMARKS") >= 0 || line.indexOf("XPLOR:") >= 0)) - readLine(); + rd(); return line; } @@ -167,14 +167,14 @@ @Override protected float nextVoxel() throws Exception { if (linePt >= line.length()) { - readLine(); + rd(); //System.out.println(nRead + " " + line); linePt = 0; if ((nRead % nBlock) == 0) { //if (Logger.debugging) //Logger.info("XplorReader: block " + line + " min/max " //+ dataMin + "/" + dataMax); - readLine(); + rd(); } } if (line == null) Modified: trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/jvxl/readers/XsfReader.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -54,7 +54,7 @@ isAngstroms = true; String beginKey = "BEGIN_DATAGRID_3D"; nSurfaces = 1; - while (readLine() != null && line.indexOf(beginKey) < 0) { + while (rd() != null && line.indexOf(beginKey) < 0) { Logger.info(line); if (line.indexOf("Fermi Energy:") >= 0) { isBXSF = true; @@ -69,14 +69,14 @@ if (needCutoff) params.cutoff = 0.05f; if (isBXSF) - nSurfaces = parseIntStr(readLine()); - voxelCounts[0] = parseIntStr(readLine()); + nSurfaces = parseIntStr(rd()); + voxelCounts[0] = parseIntStr(rd()); voxelCounts[1] = parseInt(); voxelCounts[2] = parseInt(); - volumetricOrigin.set(parseFloatStr(readLine()), parseFloat(), parseFloat()); + volumetricOrigin.set(parseFloatStr(rd()), parseFloat(), parseFloat()); // SPANNING vectors here. for (int i = 0; i < 3; ++i) { - volumetricVectors[i].set(parseFloatStr(readLine()), parseFloat(), + volumetricVectors[i].set(parseFloatStr(rd()), parseFloat(), parseFloat()); volumetricVectors[i].scale(1.0f / (voxelCounts[i] - 1)); } @@ -92,13 +92,7 @@ } else { // data are slowest-z // reversed order -- so we just reverse the vectors - V3 v = volumetricVectors[0]; - volumetricVectors[0] = volumetricVectors[2]; - volumetricVectors[2] = v; - int n = voxelCounts[0]; - voxelCounts[0] = voxelCounts[2]; - voxelCounts[2] = n; - params.insideOut = !params.insideOut; + swapXZ(); } } @@ -109,7 +103,7 @@ if (n > 0) Logger.info("skipping " + n + " data sets, " + nPoints + " points each"); if (isBXSF) - Logger.info(readLine()); //"BAND: <n>" line + Logger.info(rd()); //"BAND: <n>" line for (int i = 0; i < n; i++) skipData(nPoints); } @@ -118,7 +112,7 @@ protected void skipData(int nPoints) throws Exception { skipDataVFR(nPoints); if (isBXSF) - Logger.info(readLine()); //"BAND: <n>" line + Logger.info(rd()); //"BAND: <n>" line } } Modified: trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java =================================================================== --- trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/util/SimpleUnitCell.java 2014-11-15 17:15:05 UTC (rev 20109) @@ -46,6 +46,7 @@ protected float[] notionalUnitcell; //6 parameters + optional 16 matrix items public M4 matrixCartesianToFractional; public M4 matrixFractionalToCartesian; + public double volume; protected final static float toRadians = (float) Math.PI * 2 / 360; @@ -58,7 +59,6 @@ protected double cosAlpha, sinAlpha; protected double cosBeta, sinBeta; protected double cosGamma, sinGamma; - protected double volume; protected double cA_, cB_; protected double a_; protected double b_, c_; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-11-12 19:46:49 UTC (rev 20108) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2014-11-15 17:15:05 UTC (rev 20109) @@ -15,8 +15,13 @@ TODO: design and implement sidechain mutation -- MUTATE command ? TODO: remove HTML5 dependency on synchronous file loading (check SCRIPT command for problems) -Jmol.___JmolVersion="14.3.9_2014.11.12" +Jmol.___JmolVersion="14.3.9_2014.11.15" +new feature: VASP CHGCAR reader +new feature: VASP CHGCAR isosurface reader + +JmolVersion="14.3.9_2014.11.12" + bug fix: Molden reader fails to read orbitals if [GEOCONV] is present JmolVersion="14.3.9_2014.11.11" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits