From: Miguel <mig...@us...> - 2005-09-24 20:20:20
|
Update of /cvsroot/jmol/Jmol/src/org/jmol/viewer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28380/src/org/jmol/viewer Modified Files: SasGem.java Sasurface1.java Added Files: SasFlattenedPointList.java Log Message: added SasFlattenedPointList --- NEW FILE: SasFlattenedPointList.java --- /* $RCSfile: SasFlattenedPointList.java,v $ * $Author: migueljmol $ * $Date: 2005/09/24 20:20:09 $ * $Revision: 1.1 $ * * Copyright (C) 2005 Miguel, Jmol Development, www.jmol.org * * Contact: mi...@jm... * * 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., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. */ package org.jmol.viewer; class SasFlattenedPointList { int count; short[] vertexes = new short[32]; float[] angles = new float[32]; float[] distances = new float[32]; void reset() { count = 0; } void add(short vertex, float angle, float distance) { if (count == vertexes.length) { vertexes = Util.doubleLength(vertexes); angles = Util.doubleLength(angles); distances = Util.doubleLength(distances); } vertexes[count] = vertex; angles[count] = angle; distances[count] = distance; ++count; } void duplicateFirstPointPlus2Pi() { add(vertexes[0], angles[0] + (float)(2*Math.PI), distances[0]); } void sort() { for (int i = count; --i > 0; ) for (int j = i; --j >= 0; ) if (angles[j] > angles[i]) { Util.swap(angles, i, j); Util.swap(distances, i, j); Util.swap(vertexes, i, j); } } int find(float angle) { int i; for (i = 0; i < count; ++i) if (angles[i] >= angle) return i; return -1; } int findGE(float angle) { int min = 0; int max = count; while (min != max) { int mid = (min + max) / 2; float midAngle = angles[mid]; if (midAngle < angle) min = mid + 1; else max = mid; } return min; } int findGT(float angle) { int min = 0; int max = count; while (min != max) { int mid = (min + max) / 2; float midAngle = angles[mid]; if (midAngle <= angle) min = mid + 1; else max = mid; } return min; } } Index: SasGem.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/jmol/viewer/SasGem.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SasGem.java 24 Sep 2005 19:47:48 -0000 1.5 +++ SasGem.java 24 Sep 2005 20:20:09 -0000 1.6 @@ -42,7 +42,7 @@ final Frame frame; final int geodesicLevel; - FlattenedPointList fpl = new FlattenedPointList(); + SasFlattenedPointList fpl = new SasFlattenedPointList(); int projectedCount = 0; short[] projectedVertexes = new short[64]; @@ -515,63 +515,9 @@ return Bmp.allocMinimalCopy(faceMapT); } - static class FlattenedPointList { - int count; - short[] vertexes = new short[32]; - float[] angles = new float[32]; - float[] distances = new float[32]; - - void reset() { - count = 0; - } - - void add(short vertex, float angle, float distance) { - if (count == vertexes.length) { - vertexes = Util.doubleLength(vertexes); - angles = Util.doubleLength(angles); - distances = Util.doubleLength(distances); - } - vertexes[count] = vertex; - angles[count] = angle; - distances[count] = distance; - ++count; - } - - void duplicateFirstPointPlus2Pi() { - add(vertexes[0], angles[0] + 2*PI, distances[0]); - } - - void sort() { - for (int i = count; --i > 0; ) - for (int j = i; --j >= 0; ) - if (angles[j] > angles[i]) { - Util.swap(angles, i, j); - Util.swap(distances, i, j); - Util.swap(vertexes, i, j); - } - } - - int find(float angle) { - int i; - for (i = 0; i < count; ++i) - if (angles[i] >= angle) - return i; - return -1; - } - - int find2(float angle) { - int min = 0; - int max = count; - while (min != max) { - int mid = (min + max) / 2; - float midAngle = angles[mid]; - if (midAngle < angle) - min = mid + 1; - else - max = mid; - } - return (min == count) ? -1 : min; - } + SasFlattenedPointList getFlattenedPointList() { + return fpl; } + } Index: Sasurface1.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/jmol/viewer/Sasurface1.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- Sasurface1.java 24 Sep 2005 19:47:48 -0000 1.45 +++ Sasurface1.java 24 Sep 2005 20:20:09 -0000 1.46 @@ -955,20 +955,11 @@ } } - void stitchWithSortedProjectedVertexes(int projectedCount, - short[] projectedVertexes, - float[] projectedAngles, - float[] projectedDistances, + void stitchWithSortedProjectedVertexes(SasFlattenedPointList geodesicFpl, boolean isEdgeA) { - int minProjectedIndex = 0; - while (minProjectedIndex < projectedCount && - projectedAngles[minProjectedIndex] < startAngle) - ++minProjectedIndex; + int minProjectedIndex = geodesicFpl.findGE(startAngle); float endAngle = startAngle + (stepAngle * stepCount); - int maxProjectedIndex = minProjectedIndex; - while (maxProjectedIndex < projectedCount && - projectedAngles[maxProjectedIndex] <= endAngle) - ++maxProjectedIndex; + int maxProjectedIndex = geodesicFpl.findGT(endAngle); int vertexCount = maxProjectedIndex - minProjectedIndex; if (vertexCount == 0) { System.out.println("no vertexes for this torus segment"); @@ -985,17 +976,17 @@ */ fillSegmentVertexAngles(isEdgeA); stitchEm(stepCount, segmentVertexesT, segmentVertexAnglesT, - minProjectedIndex, maxProjectedIndex, - projectedVertexes, - projectedAngles, projectedDistances); + minProjectedIndex, maxProjectedIndex, geodesicFpl); } void stitchEm(int torusCount, short[] torusVertexes, float[] torusAngles, int geodesicMin, int geodesicMax, - short[] geodesicVertexes, float[] geodesicAngles, - float[] geodesicDistances) { + SasFlattenedPointList geodesicFpl) { if (geodesicMin == geodesicMax) return; + short[] geodesicVertexes = geodesicFpl.vertexes; + float[] geodesicAngles = geodesicFpl.angles; + float[] geodesicDistances = geodesicFpl.distances; int tLast = torusCount - 1; int gLast = geodesicMax - 1; oneStitch(torusVertexes[0], geodesicVertexes[geodesicMin]); @@ -1126,7 +1117,6 @@ Atom atom = frame.atoms[ix]; float atomRadius = atom.getVanderwaalsRadiusFloat(); Point3f atomCenter = atom.point3f; - boolean dump = (ixA == 0 && (ixB == 1 || ixB == 3)); int edgeCount = gem.findGeodesicEdge(convexVertexMaps[ix], edgeVertexesT); if (edgeCount > 0) { @@ -1135,27 +1125,17 @@ atomCenter, atomRadius, centerPointT, axisUnitVector, zeroPointT, (torusCavities == null), - edgeVertexesT, dump); - stitchSegmentsWithSortedProjectedVertexes(gem.projectedCount, - gem.projectedVertexes, - gem.projectedAngles, - gem.projectedDistances, - isEdgeA); + edgeVertexesT, false); + SasFlattenedPointList geodesicFpl = gem.getFlattenedPointList(); + stitchSegmentsWithSortedProjectedVertexes(geodesicFpl, isEdgeA); } } - void stitchSegmentsWithSortedProjectedVertexes(int projectedCount, - short[] projectedVertexes, - float[] projectedAngles, - float[] projectedDistances, + void stitchSegmentsWithSortedProjectedVertexes(SasFlattenedPointList gfpl, boolean isEdgeA) { countStitchesT = 0; for (int i = torusSegmentCount; --i >= 0; ) - torusSegments[i].stitchWithSortedProjectedVertexes(projectedCount, - projectedVertexes, - projectedAngles, - projectedDistances, - isEdgeA); + torusSegments[i].stitchWithSortedProjectedVertexes(gfpl, isEdgeA); short[] geodesicStitches = new short[countStitchesT]; for (int i = countStitchesT; --i >= 0; ) geodesicStitches[i] = stitchesT[i]; |