Class JvxlCoder


  • public class JvxlCoder
    extends Object
    • Constructor Detail

      • JvxlCoder

        public JvxlCoder()
    • Method Detail

      • jvxlGetFile

        public static String jvxlGetFile​(VolumeData volumeData,
                                         JvxlData jvxlData,
                                         String[] title)
        Parameters:
        volumeData -
        jvxlData -
        title -
        Returns:
        XML string
      • jvxlGetFile

        public static String jvxlGetFile​(JvxlData jvxlData,
                                         MeshData meshData,
                                         String[] title,
                                         String msg,
                                         boolean includeHeader,
                                         int nSurfaces,
                                         String state,
                                         String comment)
        Parameters:
        jvxlData -
        meshData -
        title -
        msg -
        includeHeader -
        nSurfaces -
        state -
        comment -
        Returns:
        JVXL file XML
      • checkHaveXMLUtil

        private static void checkHaveXMLUtil()
      • appendEncodedBitSetTag

        private static void appendEncodedBitSetTag​(javajs.util.SB sb,
                                                   String name,
                                                   javajs.util.BS bs,
                                                   int count,
                                                   Object[] attribs)
      • jvxlSetCompressionRatio

        private static String jvxlSetCompressionRatio​(javajs.util.SB data,
                                                      JvxlData jvxlData,
                                                      int len)
      • appendXmlEdgeData

        private static void appendXmlEdgeData​(javajs.util.SB sb,
                                              JvxlData jvxlData)
      • jvxlAppendCommandState

        private static void jvxlAppendCommandState​(javajs.util.SB data,
                                                   String cmd,
                                                   String state)
      • appendXmlColorData

        private static void appendXmlColorData​(javajs.util.SB sb,
                                               String data,
                                               boolean isEncoded,
                                               boolean isPrecisionColor,
                                               float value1,
                                               float value2)
      • jvxlGetInfo

        public static String jvxlGetInfo​(JvxlData jvxlData)
      • jvxlGetInfoData

        public static String jvxlGetInfoData​(JvxlData jvxlData,
                                             boolean vertexDataOnly)
      • addAttrib

        private static void addAttrib​(javajs.util.Lst<String[]> attribs,
                                      String name,
                                      String value)
      • jvxlEncodeContourData

        private static void jvxlEncodeContourData​(javajs.util.Lst<Object>[] contours,
                                                  javajs.util.SB sb)
        contour data are appended to a string buffer in the form of a <jmolContourData count="[nContours]"> <jmolContour index="0" value="-0.033" color="[xff0000]" encoding="base90iff1" data="fractional data">triangle bitset data</jmolContour> <jmolContour index="1" value=" 0.000" color="[xffff00]" encoding="base90iff1" data="fractional data">triangle bitset data</jmolContour> <jmolContour index="2" value=" 0.033" color="[x00ffff]" encoding="base90iff1" data="fractional data">triangle bitset data</jmolContour> ... </jmolContourData> One presumes an ordered set of triangles. The contour intersects these triangles along two edges or at two vertices. (see IsosurfaceMesh for details) Each contour is a Vector containing: 0 Integer number of polygons (length of BitSet) 1 BitSet of critical triangles 2 Float value 3 int[] [colorArgb] 4 StringXBuilder containing encoded data for each segment: char type ('3', '6', '5') indicating which two edges of the triangle are connected: '3' 0x011 AB-BC '5' 0x101 AB-CA '6' 0x110 BC-CA char fraction along first edge (jvxlFractionToCharacter) char fraction along second edge (jvxlFractionToCharacter) 5- stream of pairs of points for rendering (created
        Parameters:
        contours -
        sb -
      • set3dContourVector

        public static void set3dContourVector​(javajs.util.Lst<Object> v,
                                              int[][] polygonIndexes,
                                              javajs.util.T3[] vertices)
        Interpret fractional data in terms of actual vertex positions and create the elements of a Vector in Vector[] vContours starting at the CONTOUR_POINTS position.
        Parameters:
        v -
        polygonIndexes -
        vertices -
      • getContourPoint

        private static javajs.util.T3 getContourPoint​(javajs.util.T3[] vertices,
                                                      int i,
                                                      int j,
                                                      float f)
      • appendContourTriangleIntersection

        public static void appendContourTriangleIntersection​(int type,
                                                             float f1,
                                                             float f2,
                                                             javajs.util.SB fData)
        appends an integer (3, 5, or 6) representing two sides of a triangle ABC -- AB/BC(3), AB/CA(5), or BC/CA(6) -- along with two fractions along the edges for the intersection point base-90-encoded. This version is single precision. type f1 f2 3 AB BC 5 AB CA 6 BC CA
        Parameters:
        type -
        f1 - -- character-encoded fraction
        f2 - -- character-encoded fraction
        fData -
      • jvxlCreateColorData

        public static void jvxlCreateColorData​(JvxlData jvxlData,
                                               float[] vertexValues)
        Parameters:
        jvxlData -
        vertexValues -
      • appendXmlVertexOnlyData

        private static void appendXmlVertexOnlyData​(javajs.util.SB sb,
                                                    JvxlData jvxlData,
                                                    MeshData meshData,
                                                    boolean escapeXml)
      • appendXmlTriangleData

        private static boolean appendXmlTriangleData​(javajs.util.SB sb,
                                                     int[][] triangles,
                                                     int nData,
                                                     javajs.util.BS bsSlabDisplay,
                                                     int[] vertexIdNew,
                                                     boolean escapeXml)
        encode triangle data -- [ia ib ic] [ia ib ic] [ia ib ic] ... algorithm written by Bob Hanson, 11/2008. The principle is that not all vertices may be represented -- we only need the used vertices here. Capitalizing on the fact that triangle sets tend to have common edges and similar numbers for sequential triangles. a) Renumbering vertices as they appear in the triangle set [2456 2457 2458] [2456 2459 2458] becomes [ 1 2 3] [ 1 4 3] b) This allows efficient encoding of differences, not absolute numbers. 0 1 2 -2 3 -1 c) Which can then be represented often using a single ASCII character. I chose \ to be 0, and replace that with !. ASCII: -30 -20 -10 0 +10 +20 +30 <=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{| So the above sequence would simply be: !]^Z_[ When the range falls outside of +/-32, we simply use a number. When a positive number follows another number, we add a "+" to it. !]^Z_[-33+250]230-210]] Preliminary trials indicated that on average a triangle can be encoded in about 7 bytes, or roughly half the 12 bytes necessary for standard binary encoding of integers. The advantage here is that we have an ASCII-readable file and no little-/big-endian issue.
        Parameters:
        sb -
        triangles -
        nData -
        bsSlabDisplay -
        vertexIdNew -
        escapeXml -
        Returns:
        (triangles are present)
      • appendXmlVertexData

        private static void appendXmlVertexData​(javajs.util.SB sb,
                                                JvxlData jvxlData,
                                                int[] vertexIdNew,
                                                javajs.util.T3[] vertices,
                                                float[] vertexValues,
                                                int vertexCount,
                                                String polygonColorData,
                                                int polygonCount,
                                                javajs.util.BS bsSlabDisplay,
                                                int[] vertexColors,
                                                boolean addColorData,
                                                boolean escapeXml)
        encode the vertex data. This must be done AFTER encoding the triangles, because the triangles redefine the order of vertices. Bob Hanson 11/2008 If another program has created the triangles, we probably do not know the grid that was used for Marching Cubes, or quite possibly no grid was used. In that case, we just save the vertex/triangle/value data in a compact form. For the we use an extension of the way edge points are encoded. We simply identify the minimum and maximum x, y, and z coordinates and then express the point as a fraction along each of those directions. Thus, the x, y, and z coordinate are within the interval [0,1]. We opt for the two-byte double-precision JVXL character compression. This allows a 1 part in 8100 resolution, which is plenty for these purposes. The tag will indicate the minimum and maximum values: <jvxlVertexData count="150" min="(15.218472, -28.304049, 34.71112)" max="(97.8228, 54.011948, 109.95208)" data="...."> </jvxlVertexData> The resultant string is really two strings of length nData where the first string lists the "high" part of the positions, and the second string lists the "low" part of the positions.
        Parameters:
        sb -
        jvxlData -
        vertexIdNew -
        vertices -
        vertexValues -
        vertexCount -
        polygonColorData -
        polygonCount -
        bsSlabDisplay -
        vertexColors -
        addColorData -
        escapeXml -
      • jvxlFractionAsCharacter

        public static char jvxlFractionAsCharacter​(float fraction)
      • jvxlFractionAsCharacterRange

        public static char jvxlFractionAsCharacterRange​(float fraction,
                                                        int base,
                                                        int range)
      • jvxlAppendCharacter2

        private static void jvxlAppendCharacter2​(float value,
                                                 float min,
                                                 float max,
                                                 int base,
                                                 int range,
                                                 javajs.util.SB list1,
                                                 javajs.util.SB list2)
      • jvxlFractionFromCharacter

        public static float jvxlFractionFromCharacter​(int ich,
                                                      int base,
                                                      int range,
                                                      float fracOffset)
      • jvxlFractionFromCharacter2

        public static float jvxlFractionFromCharacter2​(int ich1,
                                                       int ich2,
                                                       int base,
                                                       int range)
      • jvxlValueAsCharacter

        public static char jvxlValueAsCharacter​(float value,
                                                float min,
                                                float max,
                                                int base,
                                                int range)
      • jvxlValueFromCharacter2

        protected static float jvxlValueFromCharacter2​(int ich,
                                                       int ich2,
                                                       float min,
                                                       float max,
                                                       int base,
                                                       int range)
      • jvxlEncodeBitSet0

        public static int jvxlEncodeBitSet0​(javajs.util.BS bs,
                                            int nPoints,
                                            javajs.util.SB sb)
      • jvxlEncodeBitSet

        public static String jvxlEncodeBitSet​(javajs.util.BS bs)
      • jvxlEncodeBitSetBuffer

        public static int jvxlEncodeBitSetBuffer​(javajs.util.BS bs,
                                                 int nPoints,
                                                 javajs.util.SB sb)
      • jvxlAppendEncodedNumber

        public static void jvxlAppendEncodedNumber​(javajs.util.SB sb,
                                                   int n,
                                                   int base,
                                                   int range)
      • jvxlDecodeBitSetRange

        public static javajs.util.BS jvxlDecodeBitSetRange​(String data,
                                                           int base,
                                                           int range)
      • jvxlParseEncodedInt

        public static int jvxlParseEncodedInt​(String str,
                                              int offset,
                                              int base,
                                              int[] next)
      • jvxlDecodeBitSet

        public static javajs.util.BS jvxlDecodeBitSet​(String data)
      • jvxlCompressString

        public static String jvxlCompressString​(String data,
                                                boolean escapeXml)
      • jvxlDecompressString

        public static String jvxlDecompressString​(String data)
      • jvxlCreateHeaderWithoutTitleOrAtoms

        public static void jvxlCreateHeaderWithoutTitleOrAtoms​(VolumeData v,
                                                               javajs.util.SB bs)
      • jvxlCreateHeader

        public static void jvxlCreateHeader​(VolumeData v,
                                            javajs.util.SB sb)
        Creates a two-line header for the XJVXL file. It is no longer necessary to create the atom set or generate the vectors here. Please leave the commented code for posterity.
        Parameters:
        v -
        sb -