protected void jvxlDecodeContourData(JvxlData jvxlData, String data) throws Exception { List<List<Object>> vs = new List<List<Object>>(); SB values = new SB(); SB colors = new SB(); int pt = -1; jvxlData.vContours = null; if (data == null) return; while ((pt = data.indexOf("<jvxlContour", pt + 1)) >= 0) { List<Object> v = new List<Object>(); String s = xr.getXmlData("jvxlContour", data.substring(pt), true, false); float value = parseFloatStr(XmlReader.getXmlAttrib(s, "value")); values.append(" ").appendF(value); int color = getColor(XmlReader.getXmlAttrib(s, "color")); short colix = C.getColix(color); colors.append(" ").append(Escape.escapeColor(color)); String fData = JvxlCoder.jvxlDecompressString(XmlReader.getXmlAttrib(s, "data")); BS bs = JvxlCoder.jvxlDecodeBitSet(xr.getXmlData("jvxlContour", s, false, false)); int n = bs.length(); IsosurfaceMesh.setContourVector(v, n, bs, value, colix, color, SB.newS(fData)); vs.addLast(v); } int n = vs.size(); if (n > 0) { jvxlData.vContours = AU.createArrayOfArrayList(n); // 3D contour values and colors jvxlData.contourColixes = params.contourColixes = new short[n]; jvxlData.contourValues = params.contoursDiscrete = new float[n]; for (int i = 0; i < n; i++) { jvxlData.vContours[i] = vs.get(i); jvxlData.contourValues[i] = ((Float) jvxlData.vContours[i].get(2)).floatValue(); jvxlData.contourColixes[i] = ((short[]) jvxlData.vContours[i].get(3))[0]; } jvxlData.contourColors = C.getHexCodes(jvxlData.contourColixes); Logger.info("JVXL read: " + n + " discrete contours"); Logger.info("JVXL read: contour values: " + values); Logger.info("JVXL read: contour colors: " + colors); } }
void applyColorScale() { colorFractionBase = jvxlData.colorFractionBase = JvxlCoder.defaultColorFractionBase; colorFractionRange = jvxlData.colorFractionRange = JvxlCoder.defaultColorFractionRange; if (params.colorPhase == 0) params.colorPhase = 1; if (meshDataServer == null) { meshData.vertexColixes = new short[meshData.vertexCount]; } else { meshDataServer.fillMeshData(meshData, MeshData.MODE_GET_VERTICES, null); if (params.contactPair == null) meshDataServer.fillMeshData(meshData, MeshData.MODE_GET_COLOR_INDEXES, null); } // colorBySign is true when colorByPhase is true, but not vice-versa // old: boolean saveColorData = !(params.colorByPhase && !params.isBicolorMap && // !params.colorBySign); //sorry! boolean saveColorData = (params.colorDensity || params.isBicolorMap || params.colorBySign || !params.colorByPhase); if (params.contactPair != null) saveColorData = false; // colors mappable always now jvxlData.isJvxlPrecisionColor = true; jvxlData.vertexCount = (contourVertexCount > 0 ? contourVertexCount : meshData.vertexCount); jvxlData.minColorIndex = -1; jvxlData.maxColorIndex = 0; jvxlData.contourValues = params.contoursDiscrete; jvxlData.isColorReversed = params.isColorReversed; if (!params.colorDensity) if (params.isBicolorMap && !params.isContoured || params.colorBySign) { jvxlData.minColorIndex = Graphics3D.getColixTranslucent( Graphics3D.getColix(params.isColorReversed ? params.colorPos : params.colorNeg), jvxlData.translucency != 0, jvxlData.translucency); jvxlData.maxColorIndex = Graphics3D.getColixTranslucent( Graphics3D.getColix(params.isColorReversed ? params.colorNeg : params.colorPos), jvxlData.translucency != 0, jvxlData.translucency); } jvxlData.isTruncated = (jvxlData.minColorIndex >= 0 && !params.isContoured); boolean useMeshDataValues = jvxlDataIs2dContour || // !jvxlDataIs2dContour && (params.isContoured && jvxlData.jvxlPlane != null || hasColorData || vertexDataOnly || params.colorDensity || params.isBicolorMap && !params.isContoured; if (!useMeshDataValues) { if (haveSurfaceAtoms && meshData.vertexSource == null) meshData.vertexSource = new int[meshData.vertexCount]; float min = Float.MAX_VALUE; float max = -Float.MAX_VALUE; float value; initializeMapping(); for (int i = meshData.vertexCount; --i >= meshData.mergeVertexCount0; ) { /* right, so what we are doing here is setting a range within the * data for which we want red-->blue, but returning the actual * number so it can be encoded more precisely. This turned out to be * the key to making the JVXL contours work. * */ if (params.colorBySets) { value = meshData.vertexSets[i]; } else if (params.colorByPhase) { value = getPhase(meshData.vertices[i]); // else if (jvxlDataIs2dContour) // marchingSquares // .getInterpolatedPixelValue(meshData.vertices[i]); } else { value = volumeData.lookupInterpolatedVoxelValue(meshData.vertices[i]); if (haveSurfaceAtoms) meshData.vertexSource[i] = getSurfaceAtomIndex(); } if (value < min) min = value; if (value > max && value != Float.MAX_VALUE) max = value; meshData.vertexValues[i] = value; } if (params.rangeSelected && minMax == null) minMax = new float[] {min, max}; finalizeMapping(); } params.setMapRanges(this, true); jvxlData.mappedDataMin = params.mappedDataMin; jvxlData.mappedDataMax = params.mappedDataMax; jvxlData.valueMappedToRed = params.valueMappedToRed; jvxlData.valueMappedToBlue = params.valueMappedToBlue; if (params.contactPair == null) colorData(); JvxlCoder.jvxlCreateColorData(jvxlData, (saveColorData ? meshData.vertexValues : null)); if (haveSurfaceAtoms && meshDataServer != null) meshDataServer.fillMeshData(meshData, MeshData.MODE_PUT_VERTICES, null); if (meshDataServer != null && params.colorBySets) meshDataServer.fillMeshData(meshData, MeshData.MODE_PUT_SETS, null); }