From: Miguel <mig...@us...> - 2005-05-17 12:09:36
|
Update of /cvsroot/jmol/Jmol/src/org/jmol/viewer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30765/src/org/jmol/viewer Modified Files: Surface.java SurfaceRenderer.java Log Message: cavities are painted Index: Surface.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/jmol/viewer/Surface.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Surface.java 16 May 2005 18:41:12 -0000 1.27 +++ Surface.java 17 May 2005 12:09:19 -0000 1.28 @@ -88,6 +88,7 @@ int surfaceConvexMax; // the Max == the highest atomIndex with surface + 1 int[][] convexVertexMaps; + int[][] convexEdgeVertexMaps; int[][] convexFaceMaps; short[] colixesConvex; Vector3f[] geodesicVertexVectors; @@ -149,13 +150,17 @@ int atomCount = frame.atomCount; if (convexVertexMaps == null) { convexVertexMaps = new int[atomCount][]; + convexEdgeVertexMaps = new int[atomCount][]; convexFaceMaps = new int[atomCount][]; colixesConvex = new short[atomCount]; } // always delete old surfaces for selected atoms for (int i = atomCount; --i >= 0; ) - if (bsSelected.get(i)) + if (bsSelected.get(i)) { convexVertexMaps[i] = null; + convexEdgeVertexMaps[i] = null; + convexFaceMaps[i] = null; + } deleteUnusedToruses(); deleteUnusedCavities(); @@ -171,9 +176,12 @@ calcCavitiesI(); if (convexVertexMaps[i] == calculateMyConvexSurfaceMap) { convexVertexMaps[i] = calcVertexBitmapI(); + convexEdgeVertexMaps[i] = calcEdgeVertexes(convexVertexMaps[i]); convexFaceMaps[i] = calcFaceBitmap(); } } + for (int i = cavityCount; --i >= 0; ) + cavities[i].calcNearestGeodesicVertexes(); saveToruses(); long timeElapsed = System.currentTimeMillis() - timeBegin; System.out.println("atomCount=" + atomCount); @@ -1175,18 +1183,6 @@ // plus use vectorPI and vectorPJ from above; final Vector3f vectorPK = new Vector3f(); - final static byte[] gcSplits = { - 1, 2, 4, - 2, 3, 5, - 3, 1, 6, - 1, 4, 7, - 2, 4, 8, - 2, 5, 9, - 3, 5, 10, - 3, 6, 11, - 1, 6, 12 - }; - class Cavity { final int ixI, ixJ, ixK; final Atom atI, atJ, atK; @@ -1196,6 +1192,10 @@ final float radiansIJ; final float radiansJK; final float radiansKI; + final Point3f pointPI = new Point3f(); + final Point3f pointPJ = new Point3f(); + final Point3f pointPK = new Point3f(); + short vertexI, vertexJ, vertexK; short colixI, colixJ, colixK; byte segmentsIJ, segmentsJK, segmentsKI; @@ -1212,10 +1212,16 @@ vectorPI.sub(centerI, probeCenter); vectorPI.normalize(); + pointPI.scaleAdd(radiusP, vectorPI, probeCenter); + vectorPJ.sub(centerJ, probeCenter); vectorPJ.normalize(); + pointPJ.scaleAdd(radiusP, vectorPJ, probeCenter); + vectorPK.sub(centerK, probeCenter); vectorPK.normalize(); + pointPK.scaleAdd(radiusP, vectorPK, probeCenter); + radiansIJ = vectorPI.angle(vectorPJ); segmentsIJ = (byte)(radiansIJ / radiansPerSegment); if (segmentsIJ == 0) @@ -1249,6 +1255,26 @@ points, normixes, 1 + segmentsIJ + segmentsJK); } + void calcNearestGeodesicVertexes() { + vectorT.sub(probeCenter, atI.point3f); + vertexI = + g3d.getClosestVisibleGeodesicVertexIndex(vectorT, + convexEdgeVertexMaps[ixI], + geodesicRenderingLevel); + vectorT.sub(probeCenter, atJ.point3f); + vertexJ = + g3d.getClosestVisibleGeodesicVertexIndex(vectorT, + convexEdgeVertexMaps[ixJ], + geodesicRenderingLevel); + vectorT.sub(probeCenter, atK.point3f); + vertexK = + g3d.getClosestVisibleGeodesicVertexIndex(vectorT, + convexEdgeVertexMaps[ixK], + geodesicRenderingLevel); + System.out.println("calcNearestGeodesicVertexes vertexI=" + vertexI + + " vertexJ=" + vertexJ + " vertexK=" + vertexK); + } + Point3f getPoint(int atomIndex) { if (atomIndex == ixI) return points[1]; @@ -1292,11 +1318,6 @@ } } - void tellMeAboutYourself() { - System.out.println(" cavity i,j,k:" + ixI + "," + ixJ + "," + ixK + - " -> " + points[0]); - } - } @@ -1408,6 +1429,8 @@ } int[] calcEdgeVertexes(int[] visibilityBitmap) { + if (visibilityBitmap == null) + return null; int[] edgeVertexes = new int[visibilityBitmap.length]; for (int vertex = Bmp.getMaxMappedBit(visibilityBitmap), neighborIndex = 6 * (vertex - 1); Index: SurfaceRenderer.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/jmol/viewer/SurfaceRenderer.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- SurfaceRenderer.java 16 May 2005 18:41:12 -0000 1.22 +++ SurfaceRenderer.java 17 May 2005 12:09:19 -0000 1.23 @@ -88,11 +88,12 @@ } Surface.Cavity[] cavities = surface.cavities; for (int i = surface.cavityCount; --i >= 0; ) - renderCavity(cavities[i]); + renderCavity(cavities[i], convexVertexMaps); screensCache.free(); } - private final static boolean CONVEX_DOTS = true; + private final static boolean CONVEX_DOTS = false; + private final static boolean CAVITY_DOTS = false; void renderConvex(Atom atom, short colix, int[] vertexMap, int[] faceMap) { Point3i[] screens = screensCache.lookup(atom, vertexMap); @@ -144,18 +145,53 @@ renderingLevel); Point3i screenMaxJ = screensJ[lastVertexJ]; - g3d.fillCylinder(Graphics3D.PINK, Graphics3D.ENDCAPS_FLAT, 4, - atomI.getScreenX(),atomI.getScreenY(),atomI.getScreenZ(), - screenMaxJ.x, screenMaxJ.y, screenMaxJ.z); - - g3d.fillCylinder(Graphics3D.GREEN, Graphics3D.ENDCAPS_FLAT, 4, - atomJ.getScreenX(),atomJ.getScreenY(),atomJ.getScreenZ(), - screenMaxI.x, screenMaxI.y, screenMaxI.z); + if (CONVEX_DOTS) { + g3d.fillCylinder(Graphics3D.PINK, Graphics3D.ENDCAPS_FLAT, 4, + atomI.getScreenX(), + atomI.getScreenY(),atomI.getScreenZ(), + screenMaxJ.x, screenMaxJ.y, screenMaxJ.z); + + g3d.fillCylinder(Graphics3D.GREEN, Graphics3D.ENDCAPS_FLAT, 4, + atomJ.getScreenX(), + atomJ.getScreenY(),atomJ.getScreenZ(), + screenMaxI.x, screenMaxI.y, screenMaxI.z); + } } - void renderCavity(Surface.Cavity cavity) { - } + void renderCavity(Surface.Cavity cavity, int[][] convexVertexMaps) { + short vertexI = cavity.vertexI; if (vertexI < 0) return; + short vertexJ = cavity.vertexJ; if (vertexJ < 0) return; + short vertexK = cavity.vertexK; if (vertexK < 0) return; + + if (CAVITY_DOTS) { + Point3i screen; + screen = viewer.transformPoint(cavity.pointPI); + g3d.fillSphereCentered(Graphics3D.RED, 4, screen); + + screen = viewer.transformPoint(cavity.pointPJ); + g3d.fillSphereCentered(Graphics3D.GREEN, 4, screen); + + screen = viewer.transformPoint(cavity.pointPK); + g3d.fillSphereCentered(Graphics3D.BLUE, 4, screen); + } + Point3i[] screensI = screensCache.lookup(cavity.atI, + convexVertexMaps[cavity.ixI]); + Point3i[] screensJ = screensCache.lookup(cavity.atJ, + convexVertexMaps[cavity.ixJ]); + Point3i[] screensK = screensCache.lookup(cavity.atK, + convexVertexMaps[cavity.ixK]); + if (CAVITY_DOTS) { + g3d.fillSphereCentered(Graphics3D.RED, 8, screensI[vertexI]); + g3d.fillSphereCentered(Graphics3D.GREEN, 8, screensJ[vertexJ]); + g3d.fillSphereCentered(Graphics3D.BLUE, 8, screensK[vertexK]); + } + + g3d.fillTriangle(false, + screensI[vertexI], cavity.atI.colixAtom, vertexI, + screensJ[vertexJ], cavity.atJ.colixAtom, vertexJ, + screensK[vertexK], cavity.atK.colixAtom, vertexK); + } } class ScreensCache { @@ -246,5 +282,4 @@ screen.z = atomZ - (int)(scaledRadius * tv.z); // smaller z comes to me } } - } |