From: <ha...@us...> - 2012-02-01 23:04:39
|
Revision: 16710 http://jmol.svn.sourceforge.net/jmol/?rev=16710&view=rev Author: hansonr Date: 2012-02-01 23:04:32 +0000 (Wed, 01 Feb 2012) Log Message: ----------- version=12.3.15_dev # new feature: NFF neutral file format reader (http://paulbourke.net/dataformats/nff/nff1.html) # for electron microscopy data exported from IMOD Modified Paths: -------------- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java trunk/Jmol/src/org/jmol/util/SurfaceFileTyper.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Added Paths: ----------- trunk/Jmol/src/org/jmol/jvxl/readers/NffFileReader.java Added: trunk/Jmol/src/org/jmol/jvxl/readers/NffFileReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/NffFileReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/jvxl/readers/NffFileReader.java 2012-02-01 23:04:32 UTC (rev 16710) @@ -0,0 +1,125 @@ +/* $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: ha...@st... + * + * 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 java.util.Hashtable; +import java.util.Map; + +import javax.vecmath.Point3f; + +import org.jmol.g3d.Graphics3D; +import org.jmol.jvxl.data.JvxlCoder; +import org.jmol.util.Logger; + +/* simple Neutral File Format reader + * + * see: http://paulbourke.net/dataformats/nff/nff1.html + * + * for Eric Cole and tomography results from U. Colorado Boulder + * electron microscopy of cells. + * + * IMOD program write of objects http://bio3d.colorado.edu/imod/ + * + * The scale is probably huge -- you probably want to use + * + * isosurface... SCALE 0.1 .... + * + */ + + +class NffFileReader extends PolygonFileReader { + + protected int nPolygons; + + NffFileReader(SurfaceGenerator sg, BufferedReader br) { + super(sg, br); + } + + protected void setHeader() { + jvxlFileHeaderBuffer.append("NFF file format\nvertices and triangles only\n"); + JvxlCoder.jvxlCreateHeaderWithoutTitleOrAtoms(volumeData, + jvxlFileHeaderBuffer); + } + + @Override + void getSurfaceData() throws Exception { + if (readVerticesAndPolygons()) + Logger.info("NFF file contains " + nVertices + " vertices and " + + nTriangles + " triangles"); + else + Logger.error(params.fileName + ": Error reading Nff data "); + } + + protected boolean readVerticesAndPolygons() { + int color = 0xFF0000; + try { + while(readLine() != null) { + if (line.length() == 0) + continue; + String[] tokens = getTokens(); + switch (line.charAt(0)) { + case '#': + vertexMap.clear(); + continue; + case 'f': + color = Graphics3D.colorTriadToInt(parseFloat(tokens[1]), parseFloat(tokens[2]), parseFloat(tokens[3])); + continue; + case 'p': + if (line.equals("pp 3")) { + int i1 = getVertex(); + int i2 = getVertex(); + int i3 = getVertex(); + nTriangles++; + addTriangleCheck(i1, i2, i3, 7, 0, false, color); + } + continue; + } + } + } catch (Exception e) { + // end of file + } + return true; + } + + private final Map<String, Integer> vertexMap = new Hashtable<String, Integer>(); + + private final Point3f pt = new Point3f(); + + private int getVertex() throws Exception { + Integer i = vertexMap.get(readLine()); + if (i == null) { + String[] tokens = getTokens(); + pt.set(parseFloat(tokens[0]), parseFloat(tokens[1]), parseFloat(tokens[2])); + if (!Float.isNaN(params.scale)) + pt.scale(params.scale); + if (isAnisotropic) + setVertexAnisotropy(pt); + i = Integer.valueOf(addVertexCopy(pt, 0, nVertices++)); + vertexMap.put(line, i); + } + return i.intValue(); + } + +} Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2012-02-01 22:30:20 UTC (rev 16709) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2012-02-01 23:04:32 UTC (rev 16710) @@ -1281,6 +1281,8 @@ return new KinemageReader(this, br); if (fileType.equals("CastepDensity")) return new CastepDensityReader(this, br); + if (fileType.equals("Nff")) + return new NffFileReader(this, br); return null; } Modified: trunk/Jmol/src/org/jmol/util/SurfaceFileTyper.java =================================================================== --- trunk/Jmol/src/org/jmol/util/SurfaceFileTyper.java 2012-02-01 22:30:20 UTC (rev 16709) +++ trunk/Jmol/src/org/jmol/util/SurfaceFileTyper.java 2012-02-01 23:04:32 UTC (rev 16710) @@ -98,6 +98,8 @@ return "Efvet"; if (line.indexOf("usemtl") >= 0) return "Obj"; + if (line.indexOf("# object with") == 0) + return "Nff"; // binary formats: problem here is that the buffered reader // may be translating byte sequences into unicode // and thus shifting the offset Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2012-02-01 22:30:20 UTC (rev 16709) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2012-02-01 23:04:32 UTC (rev 16710) @@ -3,6 +3,8 @@ version=12.3.15_dev +# new feature: NFF neutral file format reader (http://paulbourke.net/dataformats/nff/nff1.html) +# for electron microscopy data exported from IMOD # new feature: preliminary JCAMP-DX file reader, where <models></models> is present # new feature: when picking struts or delete bond or measure, distance shows as per usual measurement # bug fix: Popup Menu item hbond calculate should not require PDB This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |