/** * @param colors A color buffer * @param i The index in this buffer where to put the 12 components of this quad */ public void updateColors(float[] colors, int i) { float[] baseColor = getColorForOrder(groupIdx, 6); System.arraycopy(baseColor, 0, colors, i, 3); System.arraycopy(baseColor, 0, colors, i + 3, 3); System.arraycopy(baseColor, 0, colors, i + 6, 3); System.arraycopy(baseColor, 0, colors, i + 9, 3); }
/** Disposes of image memory and associated objects. */ public void disposeLocal() { m_aafBox = null; m_aafM = null; m_afShear = null; m_afOffset = null; m_afA = null; m_afB = null; m_aiSliceBound = null; m_aiBound = null; m_aiSliceMin = null; m_aiSliceMax = null; m_aiClipMin = null; m_aiClipMax = null; m_aaaasEncode = null; m_aaasVolumeEncode = null; m_aasSliceEncode = null; m_aaiIndex = null; m_asSkip = null; m_aiCurrentI = null; m_aiInterC = null; m_kP00 = null; m_kP01 = null; m_kP10 = null; m_kP11 = null; m_kPosition = null; super.disposeLocal(); System.gc(); }
/** * The top level rendering call. This function calls beforeResampleAll, resampleAll, and * mapIntermediateToFinal, all virtual functions that are implemented in derived classes. * * @param iDS The number of slices to increment during the resampling phase. The value should be * one or larger. If one, all slices of the volume data are resampled. If two, only every * other slice is resampled. An input larger than one is used to allow fast rendering during * rotation of the volume data. Once the rotation terminates, a composite with input of one * should be called. */ public synchronized void composite(int iDS) { long startTime = 0, now = 0; double elapsedTime = 0d; // compute maximum component of the box direction vector float fMax = 0.0f; int i, iMax = -1; for (i = 0; i < 3; i++) { float fAbs = Math.abs(m_aafBox[2][i]); if (fAbs > fMax) { fMax = fAbs; iMax = i; } } startTime = System.currentTimeMillis(); traceInit(); // composite in the appropriate direction if (iMax == 0) { beforeResampleAll(1, 2, 0); } else if (iMax == 1) { beforeResampleAll(2, 0, 1); } else { beforeResampleAll(0, 1, 2); } resampleAll(iDS); mapIntermediateToFinal(); now = System.currentTimeMillis(); elapsedTime = (double) (now - startTime); if (elapsedTime <= 0) { elapsedTime = (double) 0.0; } Preferences.debug( "Shear elapse time = " + (double) (elapsedTime / 1000.0) + "\n"); // in seconds }
/** Handles highlighting for edges */ public void highlight(boolean on, Object parameter) { // Should always be a pick result since those Shape3D do not appear in // the JTree if (parameter instanceof PickResult) { PickResult result = (PickResult) parameter; result.setFirstIntersectOnly(true); PickIntersection pi = result.getIntersection(0); // indices of the picked line // should always be line at this point // Indices are set to vertex indices, as this is not an Index // Geometry object int[] idx = pi.getPrimitiveCoordinateIndices(); Point3d point3d = pi.getPointCoordinates(); double[] point = new double[3]; point3d.get(point); FloatBuffer coords = (FloatBuffer) (pi.getGeometryArray()).getCoordRefBuffer().getBuffer(); float[] pt1 = new float[3]; float[] pt2 = new float[3]; coords.position(idx[0] * 3); coords.get(pt1); coords.position(idx[1] * 3); coords.get(pt2); int[] gpt1 = getGridCoordinate(pt1); int[] gpt2 = getGridCoordinate(pt2); int dim = 0; // lines are parallel to one of the axis => only one coordinate // changes if (gpt1[0] != gpt2[0]) dim = 0; else if (gpt1[1] != gpt2[1]) dim = 1; else if (gpt1[2] != gpt2[2]) dim = 2; else System.err.println("Error: edge is not parallel to one of the axis"); // use gpt1 and gpt2 as a variables for the new point => destroy // previous content gpt1[dim] = (int) Math.floor( gpt1[dim] + (point[dim] - pt1[dim]) * (gpt2[dim] - gpt1[dim]) / (pt2[dim] - pt1[dim])); System.out.println( "Edge end 0 vertex grid coordinates = (" + gpt1[0] + ", " + gpt1[1] + ", " + gpt1[2] + ")"); gpt2[dim] = gpt1[dim] + 1; System.out.println( "Edge end 1 vertex grid coordinates = (" + gpt2[0] + ", " + gpt2[1] + ", " + gpt2[2] + ")"); System.out.println("pi.getGeometryArray()=" + pi.getGeometryArray()); System.out.println( "pi.getGeometryArray().getUserData()=" + pi.getGeometryArray().getUserData()); // handle wire case Object userData = pi.getGeometryArray().getUserData(); if (userData != null && userData instanceof int[]) { int[] info = (int[]) userData; if (info[0] < 0) { float[] color = getColorForOrder(info[0], on ? 2 : 0); idx = pi.getPrimitiveColorIndices(); FloatBuffer colors = (FloatBuffer) (pi.getGeometryArray()).getColorRefBuffer().getBuffer(); colors.position(idx[0] * 3); colors.put(color); colors.position(idx[1] * 3); colors.put(color); } toggleSelectedEdge(on, new SelectionEdge(gpt1, gpt2, info[0], info[1])); } } // event propagation System.out.println(System.currentTimeMillis() + " end of highlight"); }
/** * @param coords A coordinate buffer * @param i The index in this buffer where to put the 12 components of this quad */ public void updateCoords(float[][] grid, float[] coords, int i) { System.arraycopy(p.getCoordinates(grid, u, v), 0, coords, i, 3); System.arraycopy(p.getCoordinates(grid, u, v + 1), 0, coords, i + 3, 3); System.arraycopy(p.getCoordinates(grid, u + 1, v + 1), 0, coords, i + 6, 3); System.arraycopy(p.getCoordinates(grid, u + 1, v), 0, coords, i + 9, 3); }
/* * (non-Javadoc) * * @see syn3d.base.ActiveNode#highlight(boolean, java.lang.Object) */ public void highlight(boolean on, Object parameter) { System.out.println("Total memory: " + Runtime.getRuntime().totalMemory()); System.out.println("Free memory: " + Runtime.getRuntime().freeMemory()); System.out.println(System.currentTimeMillis() + " starting highlight with " + parameter); if (parameter instanceof PickResult) { PickResult result = (PickResult) parameter; result.setFirstIntersectOnly(true); PickIntersection pi = result.getIntersection(0); // indices of the picked quad // Indices are set to vertex indices, as this is not an Index // Geometry object // => easy to find the plate index from this int[] idx = pi.getPrimitiveCoordinateIndices(); int plateNum = idx[0] / 4; Plate p = plates[plateNum]; Point3d point3d = pi.getPointCoordinates(); point3d.get(point); FloatBuffer coords = (FloatBuffer) ((NioQuadArray) (shape.getGeometry())).getCoordRefBuffer().getBuffer(); for (int i = 0; i < idx.length; ++i) { coords.position(idx[i] * 3); coords.get(vertices[i]); } int d1 = 0, d2 = 0; if (p instanceof PlateX) { d1 = 1; d2 = 2; } else if (p instanceof PlateY) { d1 = 0; d2 = 2; } else if (p instanceof PlateZ) { d1 = 0; d2 = 1; } int u = (int) Math.floor( (point[d1] - vertices[0][d1]) * (p.max1 - p.min1) / (vertices[3][d1] - vertices[0][d1])); int v = (int) Math.floor( (point[d2] - vertices[0][d2]) * (p.max2 - p.min2) / (vertices[1][d2] - vertices[0][d2])); int quadIdx = v * (p.max1 - p.min1) + u; u += p.min1; v += p.min2; System.out.println( (on ? "" : "de") + "selected quad " + quadIdx + " in plate " + plateNum + " in group "); System.out.println("Grid positions for the quad (x,y,z) indices:"); int[] pos = p.getXYZGridIndices(u, v); System.out.println("vertex1 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")"); pos = p.getXYZGridIndices(u, v + 1); System.out.println("vertex2 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")"); pos = p.getXYZGridIndices(u + 1, v + 1); System.out.println("vertex3 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")"); pos = p.getXYZGridIndices(u + 1, v); System.out.println("vertex4 = (" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")"); float[] color = getColorForOrder(groupIdx, on ? 1 : 0); for (int i = 0; i < idx.length; ++i) { colors.position(idx[i] * 3); colors.put(color); } toggleSelectedQuad(on, new SelectionQuad(p, u, v, groupIdx)); // Use event propagation, but don't call // setAppearanceForHighlight FloatBuffer tmp = colors; colors = null; colors = tmp; } System.out.println(System.currentTimeMillis() + " end of highlight"); }
public static void main(String[] args) { System.out.print(System.getProperty("java.version")); }
// Override Behavior's initialize method to setup wakeup criteria public void initialize() { alpha.setStartTime(System.currentTimeMillis()); // Establish initial wakeup criteria wakeupOn(w); }