Changeset 175 for trunk/loci/visbio/view


Ignore:
Timestamp:
02/18/05 14:24:50 (15 years ago)
Author:
curtis
Message:

Improve volume rendering efficiency.

Location:
trunk/loci/visbio/view
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/view/StackLink.java

    r173 r175  
    5454  /** Data reference for volume rendered cube. */ 
    5555  protected DataReferenceImpl volumeRef; 
     56 
     57  /** Collapsed volume at current dimensional position. */ 
     58  protected FlatField collapse; 
    5659 
    5760  /** Whether volume rendering is currently enabled. */ 
     
    165168    if (this.volume == volume) return; 
    166169    this.volume = volume; 
    167     doTransform(TransformHandler.MINIMUM_BURN_DELAY); 
     170    doTransform(TransformHandler.MINIMUM_BURN_DELAY, true); 
    168171  } 
    169172 
     
    175178    if (volumeRes == res) return; 
    176179    volumeRes = res; 
    177     doTransform(TransformHandler.MINIMUM_BURN_DELAY); 
     180    if (volume) doTransform(TransformHandler.MINIMUM_BURN_DELAY, true); 
    178181  } 
    179182 
     
    321324      if (thumbs) setData(thumb, sliceRef); 
    322325      else { 
    323         setMessage("loading full-resolution data (" + 
    324           (s + 1) + "/" + len + ")"); 
    325         slices[s] = getImageData(pos); 
    326         if (th != null && thumb == null && !volume) { 
    327           // fill in missing thumbnail 
    328           th.setThumb(pos, th.makeThumb(slices[s])); 
     326        if (!volume || collapse == null) { 
     327          // load data from disk, unless collapsed volume is current 
     328          setMessage("loading full-resolution data (" + 
     329            (s + 1) + "/" + len + ")"); 
     330          slices[s] = getImageData(pos); 
     331          if (th != null && thumb == null && !volume) { 
     332            // fill in missing thumbnail 
     333            th.setThumb(pos, th.makeThumb(slices[s])); 
     334          } 
    329335        } 
    330336        if (volume) setData(DUMMY, sliceRef, false); 
     
    332338      } 
    333339    } 
    334     if (thumbs) setData(DUMMY, volumeRef, false); 
     340    if (thumbs) { 
     341      setData(DUMMY, volumeRef, false); 
     342      collapse = null; 
     343    } 
    335344    else { 
    336345      if (volume) { 
     
    342351        FunctionType imageType = it.getType(); 
    343352        try { 
    344           // convert slices to proper type 
    345           for (int i=0; i<len; i++) { 
    346             slices[i] = VisUtil.switchType((FlatField) slices[i], imageType); 
     353          if (collapse == null) { 
     354            // convert slices to proper type 
     355            for (int i=0; i<len; i++) { 
     356              slices[i] = VisUtil.switchType((FlatField) slices[i], imageType); 
     357            } 
     358            // compile slices into a single volume 
     359            FunctionType volumeType = new FunctionType(zType, imageType); 
     360            Linear1DSet volumeSet = new Linear1DSet(zType, -1, 1, len); 
     361            FieldImpl field = new FieldImpl(volumeType, volumeSet); 
     362            field.setSamples(slices, false); 
     363            // collapse volume 
     364            collapse = VisUtil.collapse(field); 
    347365          } 
    348           // compile slices into a single volume 
    349           FunctionType volumeType = new FunctionType(zType, imageType); 
    350           Linear1DSet volumeSet = new Linear1DSet(zType, -1, 1, len); 
    351           FieldImpl field = new FieldImpl(volumeType, volumeSet); 
    352           field.setSamples(slices, false); 
    353           // collapse volume 
    354           FlatField collapsed = VisUtil.collapse(field); 
    355366          // resample volume 
    356           setData(VisUtil.makeCube(collapsed, volumeRes), volumeRef, false); 
     367          setData(VisUtil.makeCube(collapse, volumeRes), volumeRef, false); 
    357368          setMessage("rendering " + res + " volume"); 
    358369        } 
     
    380391    int[] res = new int[len.length]; 
    381392    boolean same = true; 
    382     int maxRes = volume ? volumeRes : 
    383       ((StackHandler) handler).getStackResolution(); 
     393    int maxRes = ((StackHandler) handler).getStackResolution(); 
    384394    for (int i=0; i<len.length; i++) { 
    385395      if (len[i] > maxRes) { 
  • trunk/loci/visbio/view/TransformLink.java

    r173 r175  
    367367 
    368368  /** Updates displayed data based on current dimensional position. */ 
    369   protected void doTransform(long delay) { 
     369  protected void doTransform(long delay) { doTransform(delay, false); } 
     370 
     371  /** Updates displayed data based on current dimensional position. */ 
     372  protected void doTransform(long delay, boolean now) { 
    370373    String append = handler.getWindow().getName() + ":" + trans.getName(); 
     374    final boolean immediate = now || trans.isImmediate(); 
    371375    final long burnDelay = delay; 
    372376    new Thread("VisBio-ComputeDataThread-" + append) { 
    373377      public void run() { 
    374         if (trans.isImmediate()) computeData(false); 
     378        if (immediate) computeData(false); 
    375379        else { 
    376380          computeData(true); 
Note: See TracChangeset for help on using the changeset viewer.