예제 #1
0
  /**
   * This is a callback to be executed before resampleSingle is executed. The bilinear interpolation
   * coefficients are computed here and vary with the single, active slice. The offset into the
   * intermediate image is also computed since this also varies with the active slice. If encoding
   * of transparent data has occurred in the renderer constructor, then the current slice of the
   * encoding table is initialized for use by resampleSingle.
   */
  protected void beforeResampleSingle() {

    // compute the 0-direction index ranges and weighting factors
    float fMin = (m_afShear[0] * m_iSlice) + m_afOffset[0];
    m_afA[0] = fMin - (float) Math.floor(fMin);
    m_afB[0] = 1.0f - m_afA[0];

    int iMin0 = (int) Math.ceil(fMin);

    // compute the 0-direction index ranges and weighting factors
    fMin = (m_afShear[1] * m_iSlice) + m_afOffset[1];
    m_afA[1] = fMin - (float) Math.floor(fMin);
    m_afB[1] = 1.0f - m_afA[1];

    int iMin1 = (int) Math.ceil(fMin);

    // offset into intermediate image of rendered voxel data
    m_iInterOffset = iMin0 + (m_iInterBound * iMin1);

    if (m_bDoEncodeSkip) {
      m_aasSliceEncode = m_aaasVolumeEncode[m_iSlice];
    }
  }
예제 #2
0
  /**
   * 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
  }
예제 #3
0
  /**
   * Rotate the oriented bounding box of the 3D image about the specified axis with the specified
   * angle.
   *
   * @param transform The transform and its matrix by which to rotate the image.
   */
  public void rotateFrameBy(Transform3D transform) {

    double rY, rX, rZ;
    double sinrX, sinrY, sinrZ, cosrX, cosrY, cosrZ;
    Matrix3d matrix = new Matrix3d();

    transform.get(matrix);

    rY = -Math.asin(matrix.m02);

    if (Math.cos(rY) != 0) {
      rX = -Math.atan2(matrix.m12, matrix.m22);
      rZ = Math.atan2(matrix.m01, matrix.m00);
    } else {
      rX = -Math.atan2(matrix.m10, matrix.m11);
      rZ = 0;
    }

    cosrX = Math.cos(rX);
    sinrX = Math.sin(rX);
    cosrY = Math.cos(rY);
    sinrY = Math.sin(rY);
    cosrZ = Math.cos(rZ);
    sinrZ = Math.sin(rZ);

    matrix.m00 = cosrZ * cosrY;
    matrix.m01 = -sinrZ * cosrY;
    matrix.m02 = sinrY;

    matrix.m10 = (cosrZ * sinrY * sinrX) + (sinrZ * cosrX);
    matrix.m11 = (-sinrZ * sinrY * sinrX) + (cosrZ * cosrX);
    matrix.m12 = -cosrY * sinrX;

    matrix.m20 = (-cosrZ * sinrY * cosrX) + (sinrZ * sinrX);
    matrix.m21 = (sinrZ * sinrY * cosrX) + (cosrZ * sinrX);
    matrix.m22 = cosrY * cosrX;

    m_kRotate.set(matrix);
    m_akAxis[0] = new Vector3f(1.0f, 0.0f, 0.0f);
    m_akAxis[1] = new Vector3f(0.0f, 1.0f, 0.0f);
    m_akAxis[2] = new Vector3f(0.0f, 0.0f, 1.0f);

    for (int i = 0; i < 3; i++) {
      m_kRotate.transform(m_akAxis[i]);
    }

    orthonormalize(m_akAxis);

    for (int i = 0; i < 3; i++) {
      setAxis(i, m_akAxis[i]);
    }
  }