Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

vp_compAC11B.c

Go to the documentation of this file.
00001 /*
00002  * DO NOT EDIT THIS FILE! It was created automatically by m4.
00003  */
00004 
00005 /*
00006  * Copyright (c) 1994 The Board of Trustees of The Leland Stanford
00007  * Junior University.  All rights reserved.
00008  * 
00009  * Permission to use, copy, modify and distribute this software and its
00010  * documentation for any purpose is hereby granted without fee, provided
00011  * that the above copyright notice and this permission notice appear in
00012  * all copies of this software and that you do not sell the software.
00013  * Commercial licensing is available by contacting the author.
00014  * 
00015  * THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
00016  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
00017  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00018  * 
00019  * Author:
00020  *    Phil Lacroute
00021  *    Computer Systems Laboratory
00022  *    Electrical Engineering Dept.
00023  *    Stanford University
00024  */
00025 /*
00026  * vp_compA.m4
00027  *
00028  * Compositing routine for affine viewing transformations.
00029  *
00030  * Copyright (c) 1994 The Board of Trustees of The Leland Stanford
00031  * Junior University.  All rights reserved.
00032  *
00033  * Permission to use, copy, modify and distribute this software and its
00034  * documentation for any purpose is hereby granted without fee, provided
00035  * that the above copyright notice and this permission notice appear in
00036  * all copies of this software and that you do not sell the software.
00037  * Commercial licensing is available by contacting the author.
00038  * 
00039  * THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
00040  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
00041  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00042  *
00043  * Author:
00044  *    Phil Lacroute
00045  *    Computer Systems Laboratory
00046  *    Electrical Engineering Dept.
00047  *    Stanford University
00048  */
00049 
00050 /*
00051  * $Date: 2001/12/17 16:16:20 $
00052  * $Revision: 1.1 $
00053  */
00054 
00055 #include "vp_global.h"
00056 
00057 
00058 
00059     
00060     
00061     
00062     
00063     
00064 
00065     
00066     
00067     
00068     
00069     
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 #define GRAYSCALE
00123     
00124     
00125     
00126     
00127 
00128 
00129 
00130 
00131 
00132 #define RLEVOLUME
00133         
00134         
00135         
00136         
00137         
00138         
00139         
00140 
00141 
00142 
00143 
00144 #undef INDEX_VOLUME
00145 
00146 
00147 
00148     
00149     
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 /* codes indicating the types of a pair of runs in adjacent scanlines */
00159 #define ALL_ZERO        0       /* both runs are runs of zeros */
00160 #define TOP_NONZERO     1       /* run for top scanline has nonzero data */
00161 #define BOT_NONZERO     2       /* run for bottom scanline has nonzero data */
00162 #define ALL_NONZERO     3       /* both runs have nonzero data */
00163 
00164 /* codes indicating the types for the current left and right voxel pairs */
00165 #define ALL_ZERO__ALL_ZERO              ((ALL_ZERO << 2) | ALL_ZERO)
00166 #define ALL_ZERO__TOP_NONZERO           ((ALL_ZERO << 2) | TOP_NONZERO)
00167 #define ALL_ZERO__BOT_NONZERO           ((ALL_ZERO << 2) | BOT_NONZERO)
00168 #define ALL_ZERO__ALL_NONZERO           ((ALL_ZERO << 2) | ALL_NONZERO)
00169 #define TOP_NONZERO__ALL_ZERO           ((TOP_NONZERO << 2) | ALL_ZERO)
00170 #define TOP_NONZERO__TOP_NONZERO        ((TOP_NONZERO << 2) | TOP_NONZERO)
00171 #define TOP_NONZERO__BOT_NONZERO        ((TOP_NONZERO << 2) | BOT_NONZERO)
00172 #define TOP_NONZERO__ALL_NONZERO        ((TOP_NONZERO << 2) | ALL_NONZERO)
00173 #define BOT_NONZERO__ALL_ZERO           ((BOT_NONZERO << 2) | ALL_ZERO)
00174 #define BOT_NONZERO__TOP_NONZERO        ((BOT_NONZERO << 2) | TOP_NONZERO)
00175 #define BOT_NONZERO__BOT_NONZERO        ((BOT_NONZERO << 2) | BOT_NONZERO)
00176 #define BOT_NONZERO__ALL_NONZERO        ((BOT_NONZERO << 2) | ALL_NONZERO)
00177 #define ALL_NONZERO__ALL_ZERO           ((ALL_NONZERO << 2) | ALL_ZERO)
00178 #define ALL_NONZERO__TOP_NONZERO        ((ALL_NONZERO << 2) | TOP_NONZERO)
00179 #define ALL_NONZERO__BOT_NONZERO        ((ALL_NONZERO << 2) | BOT_NONZERO)
00180 #define ALL_NONZERO__ALL_NONZERO        ((ALL_NONZERO << 2) | ALL_NONZERO)
00181 
00182 #ifdef SKIP_ERT
00183 #define PIXEL_IS_OPAQUE(ipixel) 0
00184 #else
00185 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00186 #endif
00187 
00188 #ifdef STATISTICS
00189 extern int vpResampleCount;
00190 extern int vpCompositeCount;
00191 extern int vpERTSkipCount;
00192 extern int vpERTSkipAgainCount;
00193 extern int vpERTUpdateCount;
00194 extern int vpSpecialZeroSkipCount;
00195 extern int vpRunFragmentCount;
00196 #define COUNT_RESAMPLE          vpResampleCount++
00197 #define COUNT_COMPOSITE         vpCompositeCount++
00198 #define COUNT_ERT_SKIP          vpERTSkipCount++
00199 #define COUNT_ERT_SKIP_AGAIN    vpERTSkipAgainCount++
00200 #define COUNT_ERT_UPDATE        vpERTUpdateCount++
00201 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00202 #define COUNT_RUN_FRAGMENT      vpRunFragmentCount++
00203 #else
00204 #define COUNT_RESAMPLE
00205 #define COUNT_COMPOSITE
00206 #define COUNT_ERT_SKIP
00207 #define COUNT_ERT_SKIP_AGAIN
00208 #define COUNT_ERT_UPDATE
00209 #define COUNT_SPECIAL_ZERO_SKIP
00210 #define COUNT_RUN_FRAGMENT
00211 #endif /* STATISTICS */
00212 
00213 /*
00214  * VPCompAC11B
00215  *
00216  * Compositing routine for run-length encoded volume data slices.
00217  * Decode and resample one slice of volume data, and composite
00218  * it into the intermediate image.  The resampling filter is a bilirp.
00219  */
00220 
00221 void
00222 VPCompAC11B (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00223           weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00224           run_lengths, voxel_data )
00225 vpContext *vpc;                 /* context */
00226 int icount;                     /* slice size */
00227 int jcount;
00228 int k;                          /* slice number */
00229 double slice_depth_cueing_dbl;  /* depth cueing factor for slice */
00230 GrayIntPixel *intimage;         /* intermediate image pixels */
00231 double weightTLdbl;             /* resampling weights */
00232 double weightBLdbl;
00233 double weightTRdbl;
00234 double weightBRdbl;
00235 
00236                 unsigned char *run_lengths;     /* run lengths for slice */
00237                 void *voxel_data;               /* voxel data for slice */
00238 
00239 {
00240     int i, j;                   /* voxel index in rotated object space */
00241     GrayIntPixel *ipixel;       /* current intermediate image pixel */
00242     GrayIntPixel *ipixel2;      /* another intermediate image pixel */
00243     int update_interval;        /* # of pixels to skip when updating links */
00244     float iopc;                 /* intermediate pixel opacity (0-1) */
00245     float iopc_inv;             /* 1-iopc */
00246     float acc_opc;              /* accumulator for resampled voxel opacity */
00247     float top_opc, bot_opc;     /* voxel opacity (top and bottom scanlines) */
00248 #ifdef NO_REUSE_VOXEL
00249 #define voxels_loaded   0
00250 #define CLEAR_VOXELS_LOADED
00251 #define SET_VOXELS_LOADED
00252 #else
00253     int voxels_loaded;          /* if true, top/bot_opc contain valid
00254                                    data loaded during the last resample */
00255 #define CLEAR_VOXELS_LOADED     voxels_loaded = 0
00256 #define SET_VOXELS_LOADED       voxels_loaded = 1
00257 #endif
00258     float wgtTL, wgtBL,         /* weights in the range 0..1 which give the */
00259           wgtTR, wgtBR;         /*   fractional contribution of the */
00260                                 /*   neighboring voxels to the current */
00261                                 /*   intermediate image pixel */
00262     unsigned char *topRLElen;   /* length of current run in top scanline */
00263     unsigned char *botRLElen;   /* length of current run in bottom scanline */
00264     char *topRLEdata;           /* data for current run in top scanline */
00265     char *botRLEdata;           /* data for current run in bottom scanline */
00266     int toprun_count;           /* number of voxels left in top run */
00267     int botrun_count;           /* number of voxels left in bottom run */
00268     int last_run_state;         /* run state code for last resample */
00269     int run_state;              /* run state code for this resample */
00270     int final_run_state;        /* run state code for end of scanline */
00271     float min_opacity;          /* low opacity threshold */
00272     float max_opacity;          /* high opacity threshold */
00273     float slice_depth_cueing;   /* depth cueing factor for slice */
00274     float *opac_correct;        /* opacity correction table */
00275     int ert_skip_count;         /* number of pixels to skip for ERT */
00276     int intermediate_width;     /* width of intermediate image in pixels */
00277     int count;                  /* voxels left in current run */
00278     float *shade_table;         /* shade lookup table */
00279     int norm_offset;            /* byte offset to shade table index in voxel */
00280     int shade_index;            /* shade index */
00281     float shade_factor;         /* attenuation factor for color
00282                                    (voxel opacity * depth cueing) */
00283 
00284 #ifdef MULTIPLE_MATERIALS
00285     float *weight_table;        /* weight lookup table */
00286     int wgt_offset;             /* byte offset to weight table index */
00287     int weight_index;           /* weight index */
00288     int m, num_materials;
00289     float weight1, weight2;
00290 #endif /* MULTIPLE_MATERIALS */
00291 
00292 #ifdef GRAYSCALE
00293     float acc_clr;              /* accumulator for resampled color */
00294     float top_clr, bot_clr;     /* voxel color (top and bottom scanlines) */
00295 #endif /* GRAYSCALE */
00296 
00297 #ifdef RGB
00298     float acc_rclr;             /* accumulator for resampled color */
00299     float acc_gclr;
00300     float acc_bclr;
00301     float top_rclr;             /* voxel color (top and bottom scanlines) */
00302     float bot_rclr;
00303     float top_gclr;
00304     float bot_gclr;
00305     float top_bclr;
00306     float bot_bclr;
00307 #endif
00308 
00309 #ifdef RLEVOLUME
00310     int voxel_istride;          /* size of a voxel in bytes */
00311 #endif
00312 
00313 #ifdef RAWVOLUME
00314     int use_octree;             /* if true then use the min-max octree */
00315     MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00316                                 /* stack for traversal of min-max octree */
00317     int scans_left;             /* scanlines until next octree traversal */
00318     int best_view_axis;         /* viewing axis */
00319     unsigned char runlen_buf1[VP_MAX_VOLUME_DIM]; /* buffers for run lengths */
00320     unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00321     unsigned char *top_len_base;/* first run length for top scanline */
00322     unsigned char *bot_len_base;/* first run length for bottom scanline */
00323     int opac_param;             /* parameter to opacity transfer function */
00324     float opacity;              /* voxel opacity */
00325     int opacity_int;            /* voxel opacity truncated to an integer */
00326     int param0_offset;          /* offset to first parameter in voxel */
00327     int param0_size;            /* size of first parameter in bytes */
00328     float *param0_table;        /* lookup table for first parameter */
00329     int param1_offset;          /* offset to second parameter in voxel */
00330     int param1_size;            /* size of second parameter in bytes */
00331     float *param1_table;        /* lookup table for second parameter */
00332     int param2_offset;          /* offset to third parameter in voxel */
00333     int param2_size;            /* size of third parameter in bytes */
00334     float *param2_table;        /* lookup table for third parameter */
00335 #endif /* RAWVOLUME */
00336 
00337 #ifdef INDEX_VOLUME
00338     unsigned char *scanline_topRLElen; /* first topRLElen in scanline */
00339     unsigned char *scanline_botRLElen; /* first botRLElen in scanline */
00340     char *scanline_topRLEdata;  /* first topRLEdata in scanline */
00341     char *scanline_botRLEdata;  /* first botRLEdata in scanline */
00342     VoxelLocation *top_voxel_index; /* voxel indexes for top scanline */
00343     VoxelLocation *bot_voxel_index; /* voxel indexes for bot scanline */
00344     VoxelLocation *vindex;
00345     int next_i;                 /* i coordinate of voxel to skip to */
00346     int next_scan;              /* true if skipped to next scanline */
00347 #endif /* INDEX_VOLUME */
00348 
00349 #ifdef CALLBACK
00350                                 /* shading callback function */
00351 #ifdef GRAYSCALE
00352     void (*shade_func) ANSI_ARGS((void *, float *, void *));
00353 #endif
00354 #ifdef RGB
00355     void (*shade_func) ANSI_ARGS((void *, float *, float *, float *, void *));
00356 #endif
00357     void *client_data;          /* client data handle */
00358 #endif /* CALLBACK */
00359 
00360 #ifdef USE_SHADOW_BUFFER
00361     float *shadow_table;        /* color lookup table for shadows */
00362     int shadow_width;           /* width of shadow buffer */
00363     GrayIntPixel *shadow_pixel; /* current shadow buffer pixel */
00364 #ifdef GRAYSCALE
00365     float top_sclr, bot_sclr;   /* shadow color (top and bottom scanlines) */
00366 #endif /* GRAYSCALE */
00367 #ifdef RGB
00368     float top_rsclr;            /* shadow color (top and bottom scanlines) */
00369     float bot_rsclr;
00370     float top_gsclr;
00371     float bot_gsclr;
00372     float top_bsclr;
00373     float bot_bsclr;
00374 #endif
00375 #endif /* SHADOW_BUFFER */
00376 
00377 #ifdef DEBUG
00378     float trace_opcTL, trace_opcBL, trace_opcTR, trace_opcBR;
00379     float trace_rsclrTL, trace_rsclrBL, trace_rsclrTR, trace_rsclrBR;
00380     float trace_rclrTL, trace_rclrBL, trace_rclrTR, trace_rclrBR;
00381     float trace_gclrTL, trace_gclrBL, trace_gclrTR, trace_gclrBR;
00382     float trace_bclrTL, trace_bclrBL, trace_bclrTR, trace_bclrBR;
00383     GrayIntPixel *trace_pixel_ptr;
00384 
00385 #ifdef COMPUTE_SHADOW_BUFFER
00386     int slice_u_int, shadow_slice_u_int;
00387     int slice_v_int, shadow_slice_v_int;
00388 #endif
00389 #endif /* DEBUG */
00390 
00391     DECLARE_HIRES_TIME(t0);
00392     DECLARE_HIRES_TIME(t1);
00393 
00394     /*******************************************************************
00395      * Copy parameters from the rendering context into local variables.
00396      *******************************************************************/
00397 
00398     GET_HIRES_TIME(vpc, t0);
00399 
00400     wgtTL = weightTLdbl;
00401     wgtBL = weightBLdbl;
00402     wgtTR = weightTRdbl;
00403     wgtBR = weightBRdbl;
00404     slice_depth_cueing = slice_depth_cueing_dbl;
00405     min_opacity = vpc->min_opacity;
00406     max_opacity = vpc->max_opacity;
00407 #ifdef USE_SHADOW_BUFFER
00408     opac_correct = vpc->shadow_opac_correct;
00409 #else
00410     opac_correct = vpc->affine_opac_correct;
00411 #endif
00412 #ifdef COMPUTE_SHADOW_BUFFER
00413     intermediate_width = vpc->shadow_width;
00414 #else
00415     intermediate_width = vpc->intermediate_width;
00416 #endif
00417 #ifdef USE_SHADOW_BUFFER
00418     shadow_table = vpc->shadow_color_table;
00419     shadow_width = vpc->shadow_width;
00420     shadow_pixel = shadow_buffer;
00421 #endif
00422     ipixel = intimage;
00423     shade_table = vpc->shade_color_table;
00424     norm_offset = vpc->field_offset[vpc->color_field];
00425 
00426 #ifdef MULTIPLE_MATERIALS
00427     weight_table = vpc->shade_weight_table;
00428     wgt_offset = vpc->field_offset[vpc->weight_field];
00429     num_materials = vpc->num_materials;
00430 #endif /* MULTIPLE_MATERIALS */
00431 
00432 #ifdef RLEVOLUME
00433     topRLEdata = voxel_data;
00434     botRLEdata = voxel_data;
00435     topRLElen = run_lengths;
00436     botRLElen = run_lengths;
00437     voxel_istride = vpc->rle_bytes_per_voxel;
00438 #endif /* RLEVOLUME */
00439 
00440 #ifdef RAWVOLUME
00441     ASSERT(vpc->num_clsfy_params > 0);
00442     ASSERT(vpc->num_clsfy_params < 3);
00443     param0_offset = vpc->field_offset[vpc->param_field[0]];
00444     param0_size = vpc->field_size[vpc->param_field[0]];
00445     param0_table = vpc->clsfy_table[0];
00446     if (vpc->num_clsfy_params > 1) {
00447         param1_offset = vpc->field_offset[vpc->param_field[1]];
00448         param1_size = vpc->field_size[vpc->param_field[1]];
00449         param1_table = vpc->clsfy_table[1];
00450     } else {
00451         param1_offset = 0;
00452         param1_size = 0;
00453         param1_table = NULL;
00454     }
00455     if (vpc->num_clsfy_params > 2) {
00456         param2_offset = vpc->field_offset[vpc->param_field[2]];
00457         param2_size = vpc->field_size[vpc->param_field[2]];
00458         param2_table = vpc->clsfy_table[2];
00459     } else {
00460         param2_offset = 0;
00461         param2_size = 0;
00462         param2_table = NULL;
00463     }
00464     if (vpc->mm_octree == NULL) {
00465         use_octree = 0;
00466     } else {
00467         use_octree = 1;
00468         best_view_axis = vpc->best_view_axis;
00469         VPInitOctreeLevelStack(vpc, level_stack, best_view_axis, k);
00470         scans_left = 0;
00471         bot_len_base = runlen_buf1;
00472     }
00473 #endif /* RAWVOLUME */
00474 
00475 #ifdef CALLBACK
00476     shade_func = vpc->shade_func;
00477     client_data = vpc->client_data;
00478     ASSERT(shade_func != NULL);
00479 #endif
00480 
00481 #ifdef DEBUG
00482     trace_pixel_ptr = 0;
00483     if (vpc->trace_u >= 0 && vpc->trace_v >= 0) {
00484 #ifdef GRAYSCALE
00485         trace_pixel_ptr = &vpc->int_image.gray_intim[vpc->trace_u + 
00486                       vpc->trace_v*vpc->intermediate_width];
00487 #endif
00488 #ifdef RGB
00489         trace_pixel_ptr = &vpc->int_image.rgb_intim[vpc->trace_u + 
00490                       vpc->trace_v*vpc->intermediate_width];
00491 #endif
00492 #ifdef COMPUTE_SHADOW_BUFFER
00493         slice_u_int = (int)ceil(vpc->shear_i * vpc->trace_shadow_k +
00494                                 vpc->trans_i) - 1;
00495         shadow_slice_u_int = (int)ceil(vpc->shadow_shear_i * 
00496                              vpc->trace_shadow_k + vpc->shadow_trans_i) - 1;
00497         slice_v_int = (int)ceil(vpc->shear_j * vpc->trace_shadow_k
00498                                 + vpc->trans_j) - 1;
00499         shadow_slice_v_int = (int)ceil(vpc->shadow_shear_j *
00500                              vpc->trace_shadow_k + vpc->shadow_trans_j) - 1;
00501         trace_pixel_ptr = &vpc->shadow_buffer[vpc->trace_u +
00502                 shadow_slice_u_int - slice_u_int + 
00503                 (vpc->trace_v + shadow_slice_v_int -
00504                 slice_v_int)*vpc->shadow_width];
00505 #endif
00506     }
00507 #endif /* DEBUG */
00508 
00509     /*******************************************************************
00510      * Loop over voxel scanlines.
00511      *******************************************************************/
00512 
00513     for (j = 0; j <= jcount; j++) {
00514 
00515         /***************************************************************
00516          * Initialize counters and flags.
00517          ***************************************************************/
00518 
00519         i = icount;
00520         CLEAR_VOXELS_LOADED;
00521         last_run_state = ALL_ZERO;
00522 
00523 #ifdef RAWVOLUME
00524         botRLEdata = (char *)voxel_data + j*voxel_jstride;
00525         topRLEdata = botRLEdata - voxel_jstride;
00526         if (!use_octree) {
00527             if (j == 0) {
00528                 run_state = BOT_NONZERO;
00529                 toprun_count = icount+2;
00530                 botrun_count = icount;
00531             } else if (j == jcount) {
00532                 run_state = TOP_NONZERO;
00533                 toprun_count = icount;
00534                 botrun_count = icount+2;
00535             } else {
00536                 run_state = ALL_NONZERO;
00537                 toprun_count = icount;
00538                 botrun_count = icount;
00539             }
00540         } else
00541 #endif /* RAWVOLUME */
00542         if (j == 0) {
00543             run_state = BOT_NONZERO;
00544             toprun_count = icount+2;
00545             botrun_count = 0;
00546         } else if (j == jcount) {
00547             run_state = TOP_NONZERO;
00548             toprun_count = 0;
00549             botrun_count = icount+2;
00550         } else {
00551             run_state = ALL_NONZERO;
00552             toprun_count = 0;
00553             botrun_count = 0;
00554         }
00555 
00556 #ifdef INDEX_VOLUME
00557         scanline_topRLElen = topRLElen;
00558         scanline_botRLElen = botRLElen;
00559         scanline_topRLEdata = topRLEdata;
00560         scanline_botRLEdata = botRLEdata;
00561         if (j == 0) {
00562             top_voxel_index = voxel_index;
00563             bot_voxel_index = voxel_index;
00564         } else {
00565             top_voxel_index = bot_voxel_index;
00566             bot_voxel_index += icount;
00567         }
00568 #endif /* INDEX_VOLUME */
00569 
00570         /***************************************************************
00571          * If the volume is not run-length encoded, use the min-max
00572          * to find run lengths for the current voxel scanline.
00573          ***************************************************************/
00574 
00575 #ifdef RAWVOLUME
00576         if (use_octree) {
00577             top_len_base = bot_len_base;
00578             if (scans_left == 0) {
00579                 if (bot_len_base == runlen_buf1)
00580                     bot_len_base = runlen_buf2;
00581                 else
00582                     bot_len_base = runlen_buf1;
00583 
00584                 GET_HIRES_TIME(vpc, t1);
00585                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00586                 COPY_HIRES_TIME(t0, t1);
00587 
00588                 scans_left = VPComputeScanRuns(vpc, level_stack, bot_len_base,
00589                                                best_view_axis, j, icount);
00590 
00591                 GET_HIRES_TIME(vpc, t1);
00592                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_OCTREE, t0, t1);
00593                 COPY_HIRES_TIME(t0, t1);
00594             }
00595 #ifdef DEBUG
00596             if (j > 0)
00597                 VPCheckRuns(vpc, top_len_base, best_view_axis, k, j-1);
00598             if (j < jcount)
00599                 VPCheckRuns(vpc, bot_len_base, best_view_axis, k, j);
00600 #endif
00601             scans_left--;
00602             topRLElen = top_len_base;
00603             botRLElen = bot_len_base;
00604         }
00605 #endif /* RAWVOLUME */
00606 
00607         /***************************************************************
00608          * Loop over runs in the voxel scanline.
00609          ***************************************************************/
00610 
00611         Debug((vpc, VPDEBUG_COMPOSITE, "StartIScan(u=%d,v=%d)\n",
00612                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00613                 sizeof(GrayIntPixel)) % vpc->intermediate_width,
00614                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00615                 sizeof(GrayIntPixel)) / vpc->intermediate_width));
00616 
00617 #ifdef UNROLL_RUN_LOOP
00618         while (i > 0) {
00619 #else
00620         while (i >= 0) {
00621 #endif
00622             /***********************************************************
00623              * Skip over any empty runs at beginning of scanline.
00624              ***********************************************************/
00625 
00626             if (last_run_state == ALL_ZERO) {
00627 #ifndef UNROLL_RUN_LOOP
00628                 if (i == 0) {
00629                     Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00630                     ipixel += 1;
00631                     final_run_state = ALL_ZERO;
00632                     i = -1;
00633                     break;      /* scanline is done */
00634                 }
00635 #endif
00636 
00637                 /* check if this is the start of a new run */
00638                 while (toprun_count == 0) {
00639                     toprun_count = *topRLElen++;
00640                     run_state ^= 1;
00641                 }
00642                 while (botrun_count == 0) {
00643                     botrun_count = *botRLElen++;
00644                     run_state ^= 2;
00645                 }
00646                 if (run_state == ALL_ZERO) {
00647                     COUNT_SPECIAL_ZERO_SKIP;
00648 
00649                     /* find the union of the two runs of voxels */
00650                     count = MIN(toprun_count, botrun_count);
00651                     toprun_count -= count;
00652                     botrun_count -= count;
00653                     ipixel += count;
00654                     ;
00655                     ;
00656                     i -= count;
00657                     ASSERT(i >= 0);
00658                     Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(%d)\n", count));
00659                     continue;
00660                 }
00661             }
00662 
00663 #ifndef SKIP_ERT
00664             /***********************************************************
00665              * Skip over opaque pixels (early-ray termination).
00666              ***********************************************************/
00667 
00668             if ((ert_skip_count = ipixel->lnk) != 0) {
00669 
00670                 GET_HIRES_TIME(vpc, t1);
00671                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00672                 COPY_HIRES_TIME(t0, t1);
00673 
00674                 COUNT_ERT_SKIP;
00675 
00676 #ifndef UNROLL_RUN_LOOP
00677                 if (i == 0) {
00678                     ipixel += 1;
00679                     final_run_state = last_run_state;
00680                     i = -1;
00681                     Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00682                     break;      /* scanline is done */
00683                 }
00684 #endif
00685 
00686                 /* find out how many pixels to skip */
00687                 if (ert_skip_count < i &&
00688                                 (count = ipixel[ert_skip_count].lnk) != 0) {
00689                     /* follow pointer chain */
00690                     do {
00691                         COUNT_ERT_SKIP_AGAIN;
00692                         ert_skip_count += count;
00693                     } while (ert_skip_count < i &&
00694                                  (count = ipixel[ert_skip_count].lnk) != 0);
00695 
00696                     /* update some of the lnk pointers in the run of opaque
00697                        pixels; the more links we update the longer it will
00698                        take to perform the update, but we will potentially
00699                        save time in future slices by not having to follow
00700                        long pointer chains */
00701                     ipixel2 = ipixel;
00702                     update_interval = 1;
00703                     count = ert_skip_count - 1;
00704                     while (count > 0) {
00705                         COUNT_ERT_UPDATE;
00706                         ipixel2 += update_interval;
00707                         if (count > 255)
00708                             ipixel2->lnk = 255;
00709                         else
00710                             ipixel2->lnk = count;
00711                         update_interval *= 2;
00712                         count -= update_interval;
00713                     }
00714 
00715                     /* update the current link */
00716                     COUNT_ERT_UPDATE;
00717                     if (ert_skip_count > 255)
00718                         ert_skip_count = 255;
00719                     ipixel->lnk = ert_skip_count;
00720                 }
00721 
00722                 /* skip over the opaque pixels */
00723                 if (ert_skip_count > i)
00724                     ert_skip_count = i;
00725                 Debug((vpc, VPDEBUG_COMPOSITE,"ERTSkip(%d)\n",ert_skip_count));
00726                 ipixel += ert_skip_count;
00727                 CLEAR_VOXELS_LOADED;
00728 
00729 #ifdef INDEX_VOLUME
00730                 /* compute i coordinate of voxel to skip to */
00731                 next_i = icount - i + ert_skip_count;
00732                 if (next_i == icount) {
00733                     next_i--;
00734                     next_scan = 1;
00735                 } else {
00736                     next_scan = 0;
00737                 }
00738 
00739                 /* skip over voxels in top scanline */
00740                 vindex = &top_voxel_index[next_i];
00741                 toprun_count = vindex->run_count;
00742                 topRLElen = scanline_topRLElen + vindex->len_offset;
00743                 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00744                     run_state &= ~1;
00745                     topRLEdata = scanline_topRLEdata +
00746                         (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00747                 } else {
00748                     run_state |= 1;
00749                     topRLEdata = scanline_topRLEdata + vindex->data_offset;
00750                 }
00751 
00752                 /* skip over voxels in bottom scanline */
00753                 vindex = &bot_voxel_index[next_i];
00754                 botrun_count = vindex->run_count;
00755                 botRLElen = scanline_botRLElen + vindex->len_offset;
00756                 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00757                     run_state &= ~2;
00758                     botRLEdata = scanline_botRLEdata +
00759                         (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00760                 } else {
00761                     run_state |= 2;
00762                     botRLEdata = scanline_botRLEdata + vindex->data_offset;
00763                 }
00764 
00765                 /* special case to skip over last voxel in scanline */
00766                 if (next_scan) {
00767                     /* advance to beginning of next top scanline */
00768                     while (toprun_count == 0) {
00769                         toprun_count = *topRLElen++;
00770                         run_state ^= 1;
00771                     }
00772                     toprun_count--;
00773                     if (run_state & 1) {
00774                         topRLEdata += 1 * voxel_istride;
00775                     } else {
00776                         ;
00777                     }
00778 
00779                     /* advance to beginning of next bottom scanline */
00780                     while (botrun_count == 0) {
00781                         botrun_count = *botRLElen++;
00782                         run_state ^= 2;
00783                     }
00784                     botrun_count--;
00785                     if (run_state & 2) {
00786                         botRLEdata += 1 * voxel_istride;
00787                     } else {
00788                         ;
00789                     }
00790                 }
00791 
00792 #else /* !INDEX_VOLUME */
00793                 /* skip over voxels in top scanline */
00794                 count = ert_skip_count;
00795                 for (;;) {
00796                     if (toprun_count >= count) {
00797                         toprun_count -= count;
00798                         if (run_state & 1) {
00799                             topRLEdata += count * voxel_istride;
00800                         } else {
00801                             ;
00802                         }
00803                         break;
00804                     } else {
00805                         count -= toprun_count;
00806                         if (run_state & 1) {
00807                             topRLEdata += toprun_count * voxel_istride;
00808                         } else {
00809                             ;
00810                         }
00811                         toprun_count = *topRLElen++;
00812                         if (toprun_count == 0)
00813                             toprun_count = *topRLElen++;
00814                         else
00815                             run_state ^= 1;
00816                     }
00817                 }
00818 
00819                 /* skip over voxels in bottom scanline */
00820                 count = ert_skip_count;
00821                 for (;;) {
00822                     if (botrun_count >= count) {
00823                         botrun_count -= count;
00824                         if (run_state & 2) {
00825                             botRLEdata += count * voxel_istride;
00826                         } else {
00827                             ;
00828                         }
00829                         break;
00830                     } else {
00831                         count -= botrun_count;
00832                         if (run_state & 2) {
00833                             botRLEdata += botrun_count * voxel_istride;
00834                         } else {
00835                             ;
00836                         }
00837                         botrun_count = *botRLElen++;
00838                         if (botrun_count == 0)
00839                             botrun_count = *botRLElen++;
00840                         else
00841                             run_state ^= 2;
00842                     }
00843                 }
00844 #endif /* INDEX_VOLUME */
00845                 i -= ert_skip_count;
00846                 last_run_state = run_state;
00847                 if (i == 0) {
00848 #ifdef UNROLL_RUN_LOOP
00849                     break;
00850 #else
00851                     if (last_run_state == ALL_ZERO) {
00852                         ipixel += 1;
00853                         final_run_state = ALL_ZERO;
00854                         i = -1;
00855                         Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00856                         break;  /* scanline is done */
00857                     }
00858                     if (ipixel->lnk != 0) {
00859                         ipixel += 1;
00860                         final_run_state = last_run_state;
00861                         i = -1;
00862                         Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00863                         break;  /* scanline is done */
00864                     }
00865 #endif /* UNROLL_RUN_LOOP */
00866                 }
00867 
00868                 GET_HIRES_TIME(vpc, t1);
00869                 STORE_HIRES_TIME(vpc, VPTIMER_ERT, t0, t1);
00870                 COPY_HIRES_TIME(t0, t1);
00871             }
00872             ASSERT(ipixel->opcflt < max_opacity);
00873 #endif /* SKIP_ERT */
00874 
00875             /***********************************************************
00876              * Compute the length of the current run.
00877              ***********************************************************/
00878 
00879 #ifndef UNROLL_RUN_LOOP
00880             if (i == 0) {
00881                 final_run_state = last_run_state;
00882                 run_state = ALL_ZERO;
00883                 i = -1;
00884                 count = 1;
00885                 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
00886             } else {
00887 #endif
00888                 /* check if this is the start of a new run */
00889                 while (toprun_count == 0) {
00890                     toprun_count = *topRLElen++;
00891                     run_state ^= 1;
00892                 }
00893                 while (botrun_count == 0) {
00894                     botrun_count = *botRLElen++;
00895                     run_state ^= 2;
00896                 }
00897 
00898                 /* find the union of the two runs of voxels */
00899                 count = MIN(toprun_count, botrun_count);
00900                 toprun_count -= count;
00901                 botrun_count -= count;
00902                 i -= count;
00903                 Debug((vpc, VPDEBUG_COMPOSITE, "Run(%d)\n", count));
00904                 ASSERT(i >= 0);
00905 #ifndef UNROLL_RUN_LOOP
00906             }
00907 #endif
00908             COUNT_RUN_FRAGMENT;
00909 
00910             /***********************************************************
00911              * composite the voxels in the current run.
00912              ***********************************************************/
00913 
00914             GET_HIRES_TIME(vpc, t1);
00915             STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00916             COPY_HIRES_TIME(t0, t1);
00917 
00918 #ifdef SKIP_COMPOSITE
00919             switch (run_state) {
00920             case ALL_ZERO:
00921                 ipixel += count;
00922                 ;
00923                 ;
00924                 count = 0;
00925                 break;
00926             case TOP_NONZERO:
00927                 ipixel += count;
00928                 topRLEdata += count * voxel_istride;
00929                 ;
00930                 count = 0;
00931                 break;
00932             case BOT_NONZERO:
00933                 ipixel += count;
00934                 ;
00935                 botRLEdata += count * voxel_istride;
00936                 count = 0;
00937                 break;
00938             case ALL_NONZERO:
00939                 ipixel += count;
00940                 topRLEdata += count * voxel_istride;
00941                 botRLEdata += count * voxel_istride;
00942                 count = 0;
00943                 break;
00944             }
00945 #else /* !SKIP_COMPOSITE */
00946 #ifdef UNROLL_RUN_LOOP
00947             /* this run contains pixels, so process them */
00948             switch ((last_run_state << 2) | run_state) {
00949             case ALL_ZERO__ALL_ZERO:
00950                 /* no voxels contribute to the pixels in this run */
00951                 ipixel += count;
00952                 ;
00953                 ;
00954                 count = 0;
00955                 break;
00956             case TOP_NONZERO__ALL_ZERO:
00957                 /* only the top-left voxel contributes to the first
00958                    pixel of the run, and the rest are zero */
00959                 if (!voxels_loaded) {
00960                     
00961     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
00962     
00963     
00964     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
00965     ;
00966     
00967         
00968     top_clr = 
00969     shade_table[shade_index + 1*0 + 0] * (float)1.0;
00970         ;
00971     shade_factor = top_opc * slice_depth_cueing;
00972     
00973         top_clr *= shade_factor;
00974     ;
00975                 }
00976                 
00977 #ifdef DEBUG
00978     if (ipixel == trace_pixel_ptr) {
00979         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
00980         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
00981         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
00982         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
00983         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
00984     }
00985 #endif
00986 ;
00987                 
00988        acc_opc = top_opc * wgtTL;
00989        acc_clr = top_clr * wgtTL;
00990        
00991 #ifdef DEBUG
00992     if (ipixel == trace_pixel_ptr) {
00993         trace_opcTL = top_opc;
00994         trace_rclrTL = top_clr;
00995         
00996     }
00997 #endif
00998 ;
00999                 
01000         COUNT_RESAMPLE;
01001         if (acc_opc > min_opacity) {
01002             COUNT_COMPOSITE;
01003             iopc = ipixel->opcflt;
01004 #           ifndef SKIP_ERT
01005                 ASSERT(iopc < max_opacity);
01006 #           endif
01007             iopc_inv = (float)1. - iopc;
01008             ipixel->clrflt += acc_clr * iopc_inv;
01009             iopc += acc_opc * iopc_inv;
01010             ipixel->opcflt = iopc;
01011             
01012 #ifdef DEBUG
01013     if (ipixel == trace_pixel_ptr) {
01014 #ifdef COMPUTE_SHADOW_BUFFER
01015         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01016 #else
01017         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01018 #endif
01019         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01020         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01021         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01022         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01023         printf("  %3.0f %3.0f\n", iopc*255., 
01024                ipixel->clrflt);
01025         
01026         
01027     }
01028 #endif /* DEBUG */
01029 ;
01030 #           ifndef SKIP_ERT
01031                 if (iopc >= max_opacity) {
01032                     ASSERT(ipixel->lnk == 0);
01033                     ipixel->lnk = 1;
01034                 }
01035 #           endif
01036         };
01037                 ipixel += count;
01038                 ;
01039                 ;
01040                 count = 0;
01041                 break;
01042             case BOT_NONZERO__ALL_ZERO:
01043                 /* only the bottom left voxel contributes to the first
01044                    pixel of the run, and the rest are zero */
01045                 if (!voxels_loaded) {
01046                     
01047     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01048     
01049     
01050     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01051     ;
01052     
01053         
01054     bot_clr = 
01055     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01056         ;
01057     shade_factor = bot_opc * slice_depth_cueing;
01058     
01059         bot_clr *= shade_factor;
01060     ;
01061                 }
01062                 
01063 #ifdef DEBUG
01064     if (ipixel == trace_pixel_ptr) {
01065         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01066         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01067         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01068         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01069         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01070     }
01071 #endif
01072 ;
01073                 
01074        acc_opc = bot_opc * wgtBL;
01075        acc_clr = bot_clr * wgtBL;
01076        
01077 #ifdef DEBUG
01078     if (ipixel == trace_pixel_ptr) {
01079         trace_opcBL = bot_opc;
01080         trace_rclrBL = bot_clr;
01081         
01082     }
01083 #endif
01084 ;
01085                 
01086         COUNT_RESAMPLE;
01087         if (acc_opc > min_opacity) {
01088             COUNT_COMPOSITE;
01089             iopc = ipixel->opcflt;
01090 #           ifndef SKIP_ERT
01091                 ASSERT(iopc < max_opacity);
01092 #           endif
01093             iopc_inv = (float)1. - iopc;
01094             ipixel->clrflt += acc_clr * iopc_inv;
01095             iopc += acc_opc * iopc_inv;
01096             ipixel->opcflt = iopc;
01097             
01098 #ifdef DEBUG
01099     if (ipixel == trace_pixel_ptr) {
01100 #ifdef COMPUTE_SHADOW_BUFFER
01101         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01102 #else
01103         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01104 #endif
01105         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01106         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01107         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01108         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01109         printf("  %3.0f %3.0f\n", iopc*255., 
01110                ipixel->clrflt);
01111         
01112         
01113     }
01114 #endif /* DEBUG */
01115 ;
01116 #           ifndef SKIP_ERT
01117                 if (iopc >= max_opacity) {
01118                     ASSERT(ipixel->lnk == 0);
01119                     ipixel->lnk = 1;
01120                 }
01121 #           endif
01122         };
01123                 ipixel += count;
01124                 ;
01125                 ;
01126                 count = 0;
01127                 break;
01128             case ALL_NONZERO__ALL_ZERO:
01129                 /* the top and bottom left voxels contribute to the
01130                    first pixel of the run, and the rest are zero */
01131                 if (!voxels_loaded) {
01132                     
01133     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01134     
01135     
01136     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01137     ;
01138     
01139         
01140     top_clr = 
01141     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01142         ;
01143     shade_factor = top_opc * slice_depth_cueing;
01144     
01145         top_clr *= shade_factor;
01146     ;
01147                     
01148     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01149     
01150     
01151     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01152     ;
01153     
01154         
01155     bot_clr = 
01156     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01157         ;
01158     shade_factor = bot_opc * slice_depth_cueing;
01159     
01160         bot_clr *= shade_factor;
01161     ;
01162                 }
01163                 
01164 #ifdef DEBUG
01165     if (ipixel == trace_pixel_ptr) {
01166         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01167         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01168         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01169         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01170         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01171     }
01172 #endif
01173 ;
01174                 
01175        acc_opc = top_opc * wgtTL;
01176        acc_clr = top_clr * wgtTL;
01177        
01178 #ifdef DEBUG
01179     if (ipixel == trace_pixel_ptr) {
01180         trace_opcTL = top_opc;
01181         trace_rclrTL = top_clr;
01182         
01183     }
01184 #endif
01185 ;
01186                 
01187        acc_opc += bot_opc * wgtBL;
01188        acc_clr += bot_clr * wgtBL;
01189        
01190 #ifdef DEBUG
01191     if (ipixel == trace_pixel_ptr) {
01192         trace_opcBL = bot_opc;
01193         trace_rclrBL = bot_clr;
01194         
01195     }
01196 #endif
01197 ;
01198                 
01199         COUNT_RESAMPLE;
01200         if (acc_opc > min_opacity) {
01201             COUNT_COMPOSITE;
01202             iopc = ipixel->opcflt;
01203 #           ifndef SKIP_ERT
01204                 ASSERT(iopc < max_opacity);
01205 #           endif
01206             iopc_inv = (float)1. - iopc;
01207             ipixel->clrflt += acc_clr * iopc_inv;
01208             iopc += acc_opc * iopc_inv;
01209             ipixel->opcflt = iopc;
01210             
01211 #ifdef DEBUG
01212     if (ipixel == trace_pixel_ptr) {
01213 #ifdef COMPUTE_SHADOW_BUFFER
01214         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01215 #else
01216         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01217 #endif
01218         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01219         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01220         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01221         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01222         printf("  %3.0f %3.0f\n", iopc*255., 
01223                ipixel->clrflt);
01224         
01225         
01226     }
01227 #endif /* DEBUG */
01228 ;
01229 #           ifndef SKIP_ERT
01230                 if (iopc >= max_opacity) {
01231                     ASSERT(ipixel->lnk == 0);
01232                     ipixel->lnk = 1;
01233                 }
01234 #           endif
01235         };
01236                 ipixel += count;
01237                 ;
01238                 ;
01239                 count = 0;
01240                 break;
01241             case ALL_ZERO__TOP_NONZERO:
01242                 /* first pixel: only the top-right voxel contributes */
01243                 
01244     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01245     
01246     
01247     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01248     ;
01249     
01250         
01251     top_clr = 
01252     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01253         ;
01254     shade_factor = top_opc * slice_depth_cueing;
01255     
01256         top_clr *= shade_factor;
01257     ;
01258                 
01259 #ifdef DEBUG
01260     if (ipixel == trace_pixel_ptr) {
01261         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01262         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01263         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01264         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01265         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01266     }
01267 #endif
01268 ;
01269                 
01270        acc_opc = top_opc * wgtTR;
01271        acc_clr = top_clr * wgtTR;
01272        
01273 #ifdef DEBUG
01274     if (ipixel == trace_pixel_ptr) {
01275         trace_opcTR = top_opc;
01276         trace_rclrTR = top_clr;
01277         
01278     }
01279 #endif
01280 ;
01281                 
01282         COUNT_RESAMPLE;
01283         if (acc_opc > min_opacity) {
01284             COUNT_COMPOSITE;
01285             iopc = ipixel->opcflt;
01286 #           ifndef SKIP_ERT
01287                 ASSERT(iopc < max_opacity);
01288 #           endif
01289             iopc_inv = (float)1. - iopc;
01290             ipixel->clrflt += acc_clr * iopc_inv;
01291             iopc += acc_opc * iopc_inv;
01292             ipixel->opcflt = iopc;
01293             
01294 #ifdef DEBUG
01295     if (ipixel == trace_pixel_ptr) {
01296 #ifdef COMPUTE_SHADOW_BUFFER
01297         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01298 #else
01299         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01300 #endif
01301         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01302         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01303         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01304         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01305         printf("  %3.0f %3.0f\n", iopc*255., 
01306                ipixel->clrflt);
01307         
01308         
01309     }
01310 #endif /* DEBUG */
01311 ;
01312 #           ifndef SKIP_ERT
01313                 if (iopc >= max_opacity) {
01314                     ASSERT(ipixel->lnk == 0);
01315                     ipixel->lnk = 1;
01316                 }
01317 #           endif
01318         };
01319                 ipixel += 1;
01320                 topRLEdata += 1 * voxel_istride;
01321                 ;
01322                 count--;
01323                 SET_VOXELS_LOADED;
01324 
01325                 /* do the rest of the pixels in this run;
01326                    the top-left and top-right voxels contribute */
01327                 while (count > 0) {
01328                     if (PIXEL_IS_OPAQUE(ipixel))
01329                         break;
01330                     if (!voxels_loaded) {
01331                         
01332     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01333     
01334     
01335     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01336     ;
01337     
01338         
01339     top_clr = 
01340     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01341         ;
01342     shade_factor = top_opc * slice_depth_cueing;
01343     
01344         top_clr *= shade_factor;
01345     ;
01346                     }
01347                     
01348 #ifdef DEBUG
01349     if (ipixel == trace_pixel_ptr) {
01350         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01351         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01352         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01353         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01354         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01355     }
01356 #endif
01357 ;
01358                     
01359        acc_opc = top_opc * wgtTL;
01360        acc_clr = top_clr * wgtTL;
01361        
01362 #ifdef DEBUG
01363     if (ipixel == trace_pixel_ptr) {
01364         trace_opcTL = top_opc;
01365         trace_rclrTL = top_clr;
01366         
01367     }
01368 #endif
01369 ;
01370                     
01371     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01372     
01373     
01374     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01375     ;
01376     
01377         
01378     top_clr = 
01379     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01380         ;
01381     shade_factor = top_opc * slice_depth_cueing;
01382     
01383         top_clr *= shade_factor;
01384     ;
01385                     
01386        acc_opc += top_opc * wgtTR;
01387        acc_clr += top_clr * wgtTR;
01388        
01389 #ifdef DEBUG
01390     if (ipixel == trace_pixel_ptr) {
01391         trace_opcTR = top_opc;
01392         trace_rclrTR = top_clr;
01393         
01394     }
01395 #endif
01396 ;
01397                     
01398         COUNT_RESAMPLE;
01399         if (acc_opc > min_opacity) {
01400             COUNT_COMPOSITE;
01401             iopc = ipixel->opcflt;
01402 #           ifndef SKIP_ERT
01403                 ASSERT(iopc < max_opacity);
01404 #           endif
01405             iopc_inv = (float)1. - iopc;
01406             ipixel->clrflt += acc_clr * iopc_inv;
01407             iopc += acc_opc * iopc_inv;
01408             ipixel->opcflt = iopc;
01409             
01410 #ifdef DEBUG
01411     if (ipixel == trace_pixel_ptr) {
01412 #ifdef COMPUTE_SHADOW_BUFFER
01413         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01414 #else
01415         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01416 #endif
01417         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01418         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01419         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01420         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01421         printf("  %3.0f %3.0f\n", iopc*255., 
01422                ipixel->clrflt);
01423         
01424         
01425     }
01426 #endif /* DEBUG */
01427 ;
01428 #           ifndef SKIP_ERT
01429                 if (iopc >= max_opacity) {
01430                     ASSERT(ipixel->lnk == 0);
01431                     ipixel->lnk = 1;
01432                 }
01433 #           endif
01434         };
01435                     ipixel += 1;
01436                     topRLEdata += 1 * voxel_istride;
01437                     ;
01438                     count--;
01439                     SET_VOXELS_LOADED;
01440                 }
01441                 break;
01442             case TOP_NONZERO__TOP_NONZERO:
01443                 /* do the pixels in this run; the top-left and
01444                    top-right voxels contribute */
01445                 while (count > 0) {
01446                     if (PIXEL_IS_OPAQUE(ipixel))
01447                         break;
01448                     if (!voxels_loaded) {
01449                         
01450     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01451     
01452     
01453     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01454     ;
01455     
01456         
01457     top_clr = 
01458     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01459         ;
01460     shade_factor = top_opc * slice_depth_cueing;
01461     
01462         top_clr *= shade_factor;
01463     ;
01464                     }
01465                     
01466 #ifdef DEBUG
01467     if (ipixel == trace_pixel_ptr) {
01468         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01469         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01470         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01471         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01472         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01473     }
01474 #endif
01475 ;
01476                     
01477        acc_opc = top_opc * wgtTL;
01478        acc_clr = top_clr * wgtTL;
01479        
01480 #ifdef DEBUG
01481     if (ipixel == trace_pixel_ptr) {
01482         trace_opcTL = top_opc;
01483         trace_rclrTL = top_clr;
01484         
01485     }
01486 #endif
01487 ;
01488                     
01489     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01490     
01491     
01492     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01493     ;
01494     
01495         
01496     top_clr = 
01497     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01498         ;
01499     shade_factor = top_opc * slice_depth_cueing;
01500     
01501         top_clr *= shade_factor;
01502     ;
01503                     
01504        acc_opc += top_opc * wgtTR;
01505        acc_clr += top_clr * wgtTR;
01506        
01507 #ifdef DEBUG
01508     if (ipixel == trace_pixel_ptr) {
01509         trace_opcTR = top_opc;
01510         trace_rclrTR = top_clr;
01511         
01512     }
01513 #endif
01514 ;
01515                     
01516         COUNT_RESAMPLE;
01517         if (acc_opc > min_opacity) {
01518             COUNT_COMPOSITE;
01519             iopc = ipixel->opcflt;
01520 #           ifndef SKIP_ERT
01521                 ASSERT(iopc < max_opacity);
01522 #           endif
01523             iopc_inv = (float)1. - iopc;
01524             ipixel->clrflt += acc_clr * iopc_inv;
01525             iopc += acc_opc * iopc_inv;
01526             ipixel->opcflt = iopc;
01527             
01528 #ifdef DEBUG
01529     if (ipixel == trace_pixel_ptr) {
01530 #ifdef COMPUTE_SHADOW_BUFFER
01531         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01532 #else
01533         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01534 #endif
01535         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01536         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01537         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01538         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01539         printf("  %3.0f %3.0f\n", iopc*255., 
01540                ipixel->clrflt);
01541         
01542         
01543     }
01544 #endif /* DEBUG */
01545 ;
01546 #           ifndef SKIP_ERT
01547                 if (iopc >= max_opacity) {
01548                     ASSERT(ipixel->lnk == 0);
01549                     ipixel->lnk = 1;
01550                 }
01551 #           endif
01552         };
01553                     ipixel += 1;
01554                     topRLEdata += 1 * voxel_istride;
01555                     ;
01556                     count--;
01557                     SET_VOXELS_LOADED;
01558                 }
01559                 break;
01560             case BOT_NONZERO__TOP_NONZERO:
01561                 /* first pixel: bottom-left and top-right voxels
01562                    contribute */
01563                 if (!voxels_loaded) {
01564                     
01565     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01566     
01567     
01568     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01569     ;
01570     
01571         
01572     bot_clr = 
01573     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01574         ;
01575     shade_factor = bot_opc * slice_depth_cueing;
01576     
01577         bot_clr *= shade_factor;
01578     ;
01579                 }
01580                 
01581 #ifdef DEBUG
01582     if (ipixel == trace_pixel_ptr) {
01583         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01584         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01585         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01586         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01587         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01588     }
01589 #endif
01590 ;
01591                 
01592        acc_opc = bot_opc * wgtBL;
01593        acc_clr = bot_clr * wgtBL;
01594        
01595 #ifdef DEBUG
01596     if (ipixel == trace_pixel_ptr) {
01597         trace_opcBL = bot_opc;
01598         trace_rclrBL = bot_clr;
01599         
01600     }
01601 #endif
01602 ;
01603                 
01604     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01605     
01606     
01607     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01608     ;
01609     
01610         
01611     top_clr = 
01612     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01613         ;
01614     shade_factor = top_opc * slice_depth_cueing;
01615     
01616         top_clr *= shade_factor;
01617     ;
01618                 
01619        acc_opc += top_opc * wgtTR;
01620        acc_clr += top_clr * wgtTR;
01621        
01622 #ifdef DEBUG
01623     if (ipixel == trace_pixel_ptr) {
01624         trace_opcTR = top_opc;
01625         trace_rclrTR = top_clr;
01626         
01627     }
01628 #endif
01629 ;
01630                 
01631         COUNT_RESAMPLE;
01632         if (acc_opc > min_opacity) {
01633             COUNT_COMPOSITE;
01634             iopc = ipixel->opcflt;
01635 #           ifndef SKIP_ERT
01636                 ASSERT(iopc < max_opacity);
01637 #           endif
01638             iopc_inv = (float)1. - iopc;
01639             ipixel->clrflt += acc_clr * iopc_inv;
01640             iopc += acc_opc * iopc_inv;
01641             ipixel->opcflt = iopc;
01642             
01643 #ifdef DEBUG
01644     if (ipixel == trace_pixel_ptr) {
01645 #ifdef COMPUTE_SHADOW_BUFFER
01646         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01647 #else
01648         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01649 #endif
01650         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01651         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01652         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01653         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01654         printf("  %3.0f %3.0f\n", iopc*255., 
01655                ipixel->clrflt);
01656         
01657         
01658     }
01659 #endif /* DEBUG */
01660 ;
01661 #           ifndef SKIP_ERT
01662                 if (iopc >= max_opacity) {
01663                     ASSERT(ipixel->lnk == 0);
01664                     ipixel->lnk = 1;
01665                 }
01666 #           endif
01667         };
01668                 ipixel += 1;
01669                 topRLEdata += 1 * voxel_istride;
01670                 ;
01671                 count--;
01672                 SET_VOXELS_LOADED;
01673 
01674                 /* do the rest of the pixels in this run;
01675                    the top-left and top-right voxels contribute */
01676                 while (count > 0) {
01677                     if (PIXEL_IS_OPAQUE(ipixel))
01678                         break;
01679                     if (!voxels_loaded) {
01680                         
01681     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01682     
01683     
01684     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01685     ;
01686     
01687         
01688     top_clr = 
01689     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01690         ;
01691     shade_factor = top_opc * slice_depth_cueing;
01692     
01693         top_clr *= shade_factor;
01694     ;
01695                     }
01696                     
01697 #ifdef DEBUG
01698     if (ipixel == trace_pixel_ptr) {
01699         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01700         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01701         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01702         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01703         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01704     }
01705 #endif
01706 ;
01707                     
01708        acc_opc = top_opc * wgtTL;
01709        acc_clr = top_clr * wgtTL;
01710        
01711 #ifdef DEBUG
01712     if (ipixel == trace_pixel_ptr) {
01713         trace_opcTL = top_opc;
01714         trace_rclrTL = top_clr;
01715         
01716     }
01717 #endif
01718 ;
01719                     
01720     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01721     
01722     
01723     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01724     ;
01725     
01726         
01727     top_clr = 
01728     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01729         ;
01730     shade_factor = top_opc * slice_depth_cueing;
01731     
01732         top_clr *= shade_factor;
01733     ;
01734                     
01735        acc_opc += top_opc * wgtTR;
01736        acc_clr += top_clr * wgtTR;
01737        
01738 #ifdef DEBUG
01739     if (ipixel == trace_pixel_ptr) {
01740         trace_opcTR = top_opc;
01741         trace_rclrTR = top_clr;
01742         
01743     }
01744 #endif
01745 ;
01746                     
01747         COUNT_RESAMPLE;
01748         if (acc_opc > min_opacity) {
01749             COUNT_COMPOSITE;
01750             iopc = ipixel->opcflt;
01751 #           ifndef SKIP_ERT
01752                 ASSERT(iopc < max_opacity);
01753 #           endif
01754             iopc_inv = (float)1. - iopc;
01755             ipixel->clrflt += acc_clr * iopc_inv;
01756             iopc += acc_opc * iopc_inv;
01757             ipixel->opcflt = iopc;
01758             
01759 #ifdef DEBUG
01760     if (ipixel == trace_pixel_ptr) {
01761 #ifdef COMPUTE_SHADOW_BUFFER
01762         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01763 #else
01764         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01765 #endif
01766         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01767         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01768         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01769         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01770         printf("  %3.0f %3.0f\n", iopc*255., 
01771                ipixel->clrflt);
01772         
01773         
01774     }
01775 #endif /* DEBUG */
01776 ;
01777 #           ifndef SKIP_ERT
01778                 if (iopc >= max_opacity) {
01779                     ASSERT(ipixel->lnk == 0);
01780                     ipixel->lnk = 1;
01781                 }
01782 #           endif
01783         };
01784                     ipixel += 1;
01785                     topRLEdata += 1 * voxel_istride;
01786                     ;
01787                     count--;
01788                     SET_VOXELS_LOADED;
01789                 }
01790                 break;
01791             case ALL_NONZERO__TOP_NONZERO:
01792                 /* first pixel: top-left, bottom-left and top-right voxels
01793                    contribute */
01794                 if (!voxels_loaded) {
01795                     
01796     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01797     
01798     
01799     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01800     ;
01801     
01802         
01803     top_clr = 
01804     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01805         ;
01806     shade_factor = top_opc * slice_depth_cueing;
01807     
01808         top_clr *= shade_factor;
01809     ;
01810                     
01811     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01812     
01813     
01814     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01815     ;
01816     
01817         
01818     bot_clr = 
01819     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01820         ;
01821     shade_factor = bot_opc * slice_depth_cueing;
01822     
01823         bot_clr *= shade_factor;
01824     ;
01825                 }
01826                 
01827 #ifdef DEBUG
01828     if (ipixel == trace_pixel_ptr) {
01829         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01830         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01831         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01832         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01833         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01834     }
01835 #endif
01836 ;
01837                 
01838        acc_opc = top_opc * wgtTL;
01839        acc_clr = top_clr * wgtTL;
01840        
01841 #ifdef DEBUG
01842     if (ipixel == trace_pixel_ptr) {
01843         trace_opcTL = top_opc;
01844         trace_rclrTL = top_clr;
01845         
01846     }
01847 #endif
01848 ;
01849                 
01850        acc_opc += bot_opc * wgtBL;
01851        acc_clr += bot_clr * wgtBL;
01852        
01853 #ifdef DEBUG
01854     if (ipixel == trace_pixel_ptr) {
01855         trace_opcBL = bot_opc;
01856         trace_rclrBL = bot_clr;
01857         
01858     }
01859 #endif
01860 ;
01861                 
01862     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01863     
01864     
01865     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01866     ;
01867     
01868         
01869     top_clr = 
01870     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01871         ;
01872     shade_factor = top_opc * slice_depth_cueing;
01873     
01874         top_clr *= shade_factor;
01875     ;
01876                 
01877        acc_opc += top_opc * wgtTR;
01878        acc_clr += top_clr * wgtTR;
01879        
01880 #ifdef DEBUG
01881     if (ipixel == trace_pixel_ptr) {
01882         trace_opcTR = top_opc;
01883         trace_rclrTR = top_clr;
01884         
01885     }
01886 #endif
01887 ;
01888                 
01889         COUNT_RESAMPLE;
01890         if (acc_opc > min_opacity) {
01891             COUNT_COMPOSITE;
01892             iopc = ipixel->opcflt;
01893 #           ifndef SKIP_ERT
01894                 ASSERT(iopc < max_opacity);
01895 #           endif
01896             iopc_inv = (float)1. - iopc;
01897             ipixel->clrflt += acc_clr * iopc_inv;
01898             iopc += acc_opc * iopc_inv;
01899             ipixel->opcflt = iopc;
01900             
01901 #ifdef DEBUG
01902     if (ipixel == trace_pixel_ptr) {
01903 #ifdef COMPUTE_SHADOW_BUFFER
01904         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01905 #else
01906         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01907 #endif
01908         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01909         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01910         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01911         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01912         printf("  %3.0f %3.0f\n", iopc*255., 
01913                ipixel->clrflt);
01914         
01915         
01916     }
01917 #endif /* DEBUG */
01918 ;
01919 #           ifndef SKIP_ERT
01920                 if (iopc >= max_opacity) {
01921                     ASSERT(ipixel->lnk == 0);
01922                     ipixel->lnk = 1;
01923                 }
01924 #           endif
01925         };
01926                 ipixel += 1;
01927                 topRLEdata += 1 * voxel_istride;
01928                 ;
01929                 count--;
01930                 SET_VOXELS_LOADED;
01931 
01932                 /* do the rest of the pixels in this run;
01933                    the top-left and top-right voxels contribute */
01934                 while (count > 0) {
01935                     if (PIXEL_IS_OPAQUE(ipixel))
01936                         break;
01937                     if (!voxels_loaded) {
01938                         
01939     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01940     
01941     
01942     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01943     ;
01944     
01945         
01946     top_clr = 
01947     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01948         ;
01949     shade_factor = top_opc * slice_depth_cueing;
01950     
01951         top_clr *= shade_factor;
01952     ;
01953                     }
01954                     
01955 #ifdef DEBUG
01956     if (ipixel == trace_pixel_ptr) {
01957         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01958         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01959         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01960         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01961         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01962     }
01963 #endif
01964 ;
01965                     
01966        acc_opc = top_opc * wgtTL;
01967        acc_clr = top_clr * wgtTL;
01968        
01969 #ifdef DEBUG
01970     if (ipixel == trace_pixel_ptr) {
01971         trace_opcTL = top_opc;
01972         trace_rclrTL = top_clr;
01973         
01974     }
01975 #endif
01976 ;
01977                     
01978     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01979     
01980     
01981     shade_index=1*1*ShortField(topRLEdata,norm_offset);
01982     ;
01983     
01984         
01985     top_clr = 
01986     shade_table[shade_index + 1*0 + 0] * (float)1.0;
01987         ;
01988     shade_factor = top_opc * slice_depth_cueing;
01989     
01990         top_clr *= shade_factor;
01991     ;
01992                     
01993        acc_opc += top_opc * wgtTR;
01994        acc_clr += top_clr * wgtTR;
01995        
01996 #ifdef DEBUG
01997     if (ipixel == trace_pixel_ptr) {
01998         trace_opcTR = top_opc;
01999         trace_rclrTR = top_clr;
02000         
02001     }
02002 #endif
02003 ;
02004                     
02005         COUNT_RESAMPLE;
02006         if (acc_opc > min_opacity) {
02007             COUNT_COMPOSITE;
02008             iopc = ipixel->opcflt;
02009 #           ifndef SKIP_ERT
02010                 ASSERT(iopc < max_opacity);
02011 #           endif
02012             iopc_inv = (float)1. - iopc;
02013             ipixel->clrflt += acc_clr * iopc_inv;
02014             iopc += acc_opc * iopc_inv;
02015             ipixel->opcflt = iopc;
02016             
02017 #ifdef DEBUG
02018     if (ipixel == trace_pixel_ptr) {
02019 #ifdef COMPUTE_SHADOW_BUFFER
02020         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02021 #else
02022         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02023 #endif
02024         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02025         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02026         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02027         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02028         printf("  %3.0f %3.0f\n", iopc*255., 
02029                ipixel->clrflt);
02030         
02031         
02032     }
02033 #endif /* DEBUG */
02034 ;
02035 #           ifndef SKIP_ERT
02036                 if (iopc >= max_opacity) {
02037                     ASSERT(ipixel->lnk == 0);
02038                     ipixel->lnk = 1;
02039                 }
02040 #           endif
02041         };
02042                     ipixel += 1;
02043                     topRLEdata += 1 * voxel_istride;
02044                     ;
02045                     count--;
02046                     SET_VOXELS_LOADED;
02047                 }
02048                 break;
02049             case ALL_ZERO__BOT_NONZERO:
02050                 /* first pixel: only the bottom-right voxel contributes */
02051                 
02052     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02053     
02054     
02055     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02056     ;
02057     
02058         
02059     bot_clr = 
02060     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02061         ;
02062     shade_factor = bot_opc * slice_depth_cueing;
02063     
02064         bot_clr *= shade_factor;
02065     ;
02066                 
02067 #ifdef DEBUG
02068     if (ipixel == trace_pixel_ptr) {
02069         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02070         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02071         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02072         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02073         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02074     }
02075 #endif
02076 ;
02077                 
02078        acc_opc = bot_opc * wgtBR;
02079        acc_clr = bot_clr * wgtBR;
02080        
02081 #ifdef DEBUG
02082     if (ipixel == trace_pixel_ptr) {
02083         trace_opcBR = bot_opc;
02084         trace_rclrBR = bot_clr;
02085         
02086     }
02087 #endif
02088 ;
02089                 
02090         COUNT_RESAMPLE;
02091         if (acc_opc > min_opacity) {
02092             COUNT_COMPOSITE;
02093             iopc = ipixel->opcflt;
02094 #           ifndef SKIP_ERT
02095                 ASSERT(iopc < max_opacity);
02096 #           endif
02097             iopc_inv = (float)1. - iopc;
02098             ipixel->clrflt += acc_clr * iopc_inv;
02099             iopc += acc_opc * iopc_inv;
02100             ipixel->opcflt = iopc;
02101             
02102 #ifdef DEBUG
02103     if (ipixel == trace_pixel_ptr) {
02104 #ifdef COMPUTE_SHADOW_BUFFER
02105         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02106 #else
02107         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02108 #endif
02109         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02110         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02111         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02112         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02113         printf("  %3.0f %3.0f\n", iopc*255., 
02114                ipixel->clrflt);
02115         
02116         
02117     }
02118 #endif /* DEBUG */
02119 ;
02120 #           ifndef SKIP_ERT
02121                 if (iopc >= max_opacity) {
02122                     ASSERT(ipixel->lnk == 0);
02123                     ipixel->lnk = 1;
02124                 }
02125 #           endif
02126         };      
02127                 ipixel += 1;
02128                 ;
02129                 botRLEdata += 1 * voxel_istride;
02130                 count--;
02131                 SET_VOXELS_LOADED;
02132 
02133                 /* do the rest of the pixels in this run;
02134                    bottom-left and bottom-right voxels contribute */
02135                 while (count > 0) {
02136                     if (PIXEL_IS_OPAQUE(ipixel))
02137                         break;
02138                     if (!voxels_loaded) {
02139                         
02140     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02141     
02142     
02143     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02144     ;
02145     
02146         
02147     bot_clr = 
02148     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02149         ;
02150     shade_factor = bot_opc * slice_depth_cueing;
02151     
02152         bot_clr *= shade_factor;
02153     ;
02154                     }
02155                     
02156 #ifdef DEBUG
02157     if (ipixel == trace_pixel_ptr) {
02158         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02159         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02160         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02161         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02162         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02163     }
02164 #endif
02165 ;
02166                     
02167        acc_opc = bot_opc * wgtBL;
02168        acc_clr = bot_clr * wgtBL;
02169        
02170 #ifdef DEBUG
02171     if (ipixel == trace_pixel_ptr) {
02172         trace_opcBL = bot_opc;
02173         trace_rclrBL = bot_clr;
02174         
02175     }
02176 #endif
02177 ;
02178                     
02179     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02180     
02181     
02182     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02183     ;
02184     
02185         
02186     bot_clr = 
02187     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02188         ;
02189     shade_factor = bot_opc * slice_depth_cueing;
02190     
02191         bot_clr *= shade_factor;
02192     ;
02193                     
02194        acc_opc += bot_opc * wgtBR;
02195        acc_clr += bot_clr * wgtBR;
02196        
02197 #ifdef DEBUG
02198     if (ipixel == trace_pixel_ptr) {
02199         trace_opcBR = bot_opc;
02200         trace_rclrBR = bot_clr;
02201         
02202     }
02203 #endif
02204 ;
02205                     
02206         COUNT_RESAMPLE;
02207         if (acc_opc > min_opacity) {
02208             COUNT_COMPOSITE;
02209             iopc = ipixel->opcflt;
02210 #           ifndef SKIP_ERT
02211                 ASSERT(iopc < max_opacity);
02212 #           endif
02213             iopc_inv = (float)1. - iopc;
02214             ipixel->clrflt += acc_clr * iopc_inv;
02215             iopc += acc_opc * iopc_inv;
02216             ipixel->opcflt = iopc;
02217             
02218 #ifdef DEBUG
02219     if (ipixel == trace_pixel_ptr) {
02220 #ifdef COMPUTE_SHADOW_BUFFER
02221         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02222 #else
02223         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02224 #endif
02225         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02226         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02227         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02228         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02229         printf("  %3.0f %3.0f\n", iopc*255., 
02230                ipixel->clrflt);
02231         
02232         
02233     }
02234 #endif /* DEBUG */
02235 ;
02236 #           ifndef SKIP_ERT
02237                 if (iopc >= max_opacity) {
02238                     ASSERT(ipixel->lnk == 0);
02239                     ipixel->lnk = 1;
02240                 }
02241 #           endif
02242         };
02243                     ipixel += 1;
02244                     ;
02245                     botRLEdata += 1 * voxel_istride;
02246                     count--;
02247                     SET_VOXELS_LOADED;
02248                 }
02249                 break;
02250             case TOP_NONZERO__BOT_NONZERO:
02251                 /* first pixel: top-left and bottom-right voxels contribute */
02252                 if (!voxels_loaded) {
02253                     
02254     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02255     
02256     
02257     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02258     ;
02259     
02260         
02261     top_clr = 
02262     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02263         ;
02264     shade_factor = top_opc * slice_depth_cueing;
02265     
02266         top_clr *= shade_factor;
02267     ;
02268                 }
02269                 
02270 #ifdef DEBUG
02271     if (ipixel == trace_pixel_ptr) {
02272         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02273         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02274         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02275         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02276         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02277     }
02278 #endif
02279 ;
02280                 
02281        acc_opc = top_opc * wgtTL;
02282        acc_clr = top_clr * wgtTL;
02283        
02284 #ifdef DEBUG
02285     if (ipixel == trace_pixel_ptr) {
02286         trace_opcTL = top_opc;
02287         trace_rclrTL = top_clr;
02288         
02289     }
02290 #endif
02291 ;
02292                 
02293     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02294     
02295     
02296     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02297     ;
02298     
02299         
02300     bot_clr = 
02301     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02302         ;
02303     shade_factor = bot_opc * slice_depth_cueing;
02304     
02305         bot_clr *= shade_factor;
02306     ;
02307                 
02308        acc_opc += bot_opc * wgtBR;
02309        acc_clr += bot_clr * wgtBR;
02310        
02311 #ifdef DEBUG
02312     if (ipixel == trace_pixel_ptr) {
02313         trace_opcBR = bot_opc;
02314         trace_rclrBR = bot_clr;
02315         
02316     }
02317 #endif
02318 ;
02319                 
02320         COUNT_RESAMPLE;
02321         if (acc_opc > min_opacity) {
02322             COUNT_COMPOSITE;
02323             iopc = ipixel->opcflt;
02324 #           ifndef SKIP_ERT
02325                 ASSERT(iopc < max_opacity);
02326 #           endif
02327             iopc_inv = (float)1. - iopc;
02328             ipixel->clrflt += acc_clr * iopc_inv;
02329             iopc += acc_opc * iopc_inv;
02330             ipixel->opcflt = iopc;
02331             
02332 #ifdef DEBUG
02333     if (ipixel == trace_pixel_ptr) {
02334 #ifdef COMPUTE_SHADOW_BUFFER
02335         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02336 #else
02337         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02338 #endif
02339         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02340         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02341         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02342         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02343         printf("  %3.0f %3.0f\n", iopc*255., 
02344                ipixel->clrflt);
02345         
02346         
02347     }
02348 #endif /* DEBUG */
02349 ;
02350 #           ifndef SKIP_ERT
02351                 if (iopc >= max_opacity) {
02352                     ASSERT(ipixel->lnk == 0);
02353                     ipixel->lnk = 1;
02354                 }
02355 #           endif
02356         };
02357                 ipixel += 1;
02358                 ;
02359                 botRLEdata += 1 * voxel_istride;
02360                 count--;
02361                 SET_VOXELS_LOADED;
02362 
02363                 /* do the rest of the pixels in this run;
02364                    bottom-left and bottom-right voxels contribute */
02365                 while (count > 0) {
02366                     if (PIXEL_IS_OPAQUE(ipixel))
02367                         break;
02368                     if (!voxels_loaded) {
02369                         
02370     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02371     
02372     
02373     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02374     ;
02375     
02376         
02377     bot_clr = 
02378     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02379         ;
02380     shade_factor = bot_opc * slice_depth_cueing;
02381     
02382         bot_clr *= shade_factor;
02383     ;
02384                     }
02385                     
02386 #ifdef DEBUG
02387     if (ipixel == trace_pixel_ptr) {
02388         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02389         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02390         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02391         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02392         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02393     }
02394 #endif
02395 ;
02396                     
02397        acc_opc = bot_opc * wgtBL;
02398        acc_clr = bot_clr * wgtBL;
02399        
02400 #ifdef DEBUG
02401     if (ipixel == trace_pixel_ptr) {
02402         trace_opcBL = bot_opc;
02403         trace_rclrBL = bot_clr;
02404         
02405     }
02406 #endif
02407 ;
02408                     
02409     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02410     
02411     
02412     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02413     ;
02414     
02415         
02416     bot_clr = 
02417     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02418         ;
02419     shade_factor = bot_opc * slice_depth_cueing;
02420     
02421         bot_clr *= shade_factor;
02422     ;
02423                     
02424        acc_opc += bot_opc * wgtBR;
02425        acc_clr += bot_clr * wgtBR;
02426        
02427 #ifdef DEBUG
02428     if (ipixel == trace_pixel_ptr) {
02429         trace_opcBR = bot_opc;
02430         trace_rclrBR = bot_clr;
02431         
02432     }
02433 #endif
02434 ;
02435                     
02436         COUNT_RESAMPLE;
02437         if (acc_opc > min_opacity) {
02438             COUNT_COMPOSITE;
02439             iopc = ipixel->opcflt;
02440 #           ifndef SKIP_ERT
02441                 ASSERT(iopc < max_opacity);
02442 #           endif
02443             iopc_inv = (float)1. - iopc;
02444             ipixel->clrflt += acc_clr * iopc_inv;
02445             iopc += acc_opc * iopc_inv;
02446             ipixel->opcflt = iopc;
02447             
02448 #ifdef DEBUG
02449     if (ipixel == trace_pixel_ptr) {
02450 #ifdef COMPUTE_SHADOW_BUFFER
02451         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02452 #else
02453         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02454 #endif
02455         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02456         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02457         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02458         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02459         printf("  %3.0f %3.0f\n", iopc*255., 
02460                ipixel->clrflt);
02461         
02462         
02463     }
02464 #endif /* DEBUG */
02465 ;
02466 #           ifndef SKIP_ERT
02467                 if (iopc >= max_opacity) {
02468                     ASSERT(ipixel->lnk == 0);
02469                     ipixel->lnk = 1;
02470                 }
02471 #           endif
02472         };
02473                     ipixel += 1;
02474                     ;
02475                     botRLEdata += 1 * voxel_istride;
02476                     count--;
02477                     SET_VOXELS_LOADED;
02478                 }
02479                 break;
02480             case BOT_NONZERO__BOT_NONZERO:
02481                 /* do the pixels in this run; bottom-left and
02482                    bottom-right voxels contribute */
02483                 while (count > 0) {
02484                     if (PIXEL_IS_OPAQUE(ipixel))
02485                         break;
02486                     if (!voxels_loaded) {
02487                         
02488     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02489     
02490     
02491     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02492     ;
02493     
02494         
02495     bot_clr = 
02496     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02497         ;
02498     shade_factor = bot_opc * slice_depth_cueing;
02499     
02500         bot_clr *= shade_factor;
02501     ;
02502                     }
02503                     
02504 #ifdef DEBUG
02505     if (ipixel == trace_pixel_ptr) {
02506         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02507         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02508         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02509         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02510         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02511     }
02512 #endif
02513 ;
02514                     
02515        acc_opc = bot_opc * wgtBL;
02516        acc_clr = bot_clr * wgtBL;
02517        
02518 #ifdef DEBUG
02519     if (ipixel == trace_pixel_ptr) {
02520         trace_opcBL = bot_opc;
02521         trace_rclrBL = bot_clr;
02522         
02523     }
02524 #endif
02525 ;
02526                     
02527     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02528     
02529     
02530     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02531     ;
02532     
02533         
02534     bot_clr = 
02535     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02536         ;
02537     shade_factor = bot_opc * slice_depth_cueing;
02538     
02539         bot_clr *= shade_factor;
02540     ;
02541                     
02542        acc_opc += bot_opc * wgtBR;
02543        acc_clr += bot_clr * wgtBR;
02544        
02545 #ifdef DEBUG
02546     if (ipixel == trace_pixel_ptr) {
02547         trace_opcBR = bot_opc;
02548         trace_rclrBR = bot_clr;
02549         
02550     }
02551 #endif
02552 ;
02553                     
02554         COUNT_RESAMPLE;
02555         if (acc_opc > min_opacity) {
02556             COUNT_COMPOSITE;
02557             iopc = ipixel->opcflt;
02558 #           ifndef SKIP_ERT
02559                 ASSERT(iopc < max_opacity);
02560 #           endif
02561             iopc_inv = (float)1. - iopc;
02562             ipixel->clrflt += acc_clr * iopc_inv;
02563             iopc += acc_opc * iopc_inv;
02564             ipixel->opcflt = iopc;
02565             
02566 #ifdef DEBUG
02567     if (ipixel == trace_pixel_ptr) {
02568 #ifdef COMPUTE_SHADOW_BUFFER
02569         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02570 #else
02571         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02572 #endif
02573         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02574         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02575         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02576         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02577         printf("  %3.0f %3.0f\n", iopc*255., 
02578                ipixel->clrflt);
02579         
02580         
02581     }
02582 #endif /* DEBUG */
02583 ;
02584 #           ifndef SKIP_ERT
02585                 if (iopc >= max_opacity) {
02586                     ASSERT(ipixel->lnk == 0);
02587                     ipixel->lnk = 1;
02588                 }
02589 #           endif
02590         };
02591                     ipixel += 1;
02592                     ;
02593                     botRLEdata += 1 * voxel_istride;
02594                     count--;
02595                     SET_VOXELS_LOADED;
02596                 }
02597                 break;
02598             case ALL_NONZERO__BOT_NONZERO:
02599                 /* first pixel: top-left, bottom-left and bottom-right
02600                    voxels contribute */
02601                 if (!voxels_loaded) {
02602                     
02603     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02604     
02605     
02606     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02607     ;
02608     
02609         
02610     top_clr = 
02611     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02612         ;
02613     shade_factor = top_opc * slice_depth_cueing;
02614     
02615         top_clr *= shade_factor;
02616     ;
02617                     
02618     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02619     
02620     
02621     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02622     ;
02623     
02624         
02625     bot_clr = 
02626     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02627         ;
02628     shade_factor = bot_opc * slice_depth_cueing;
02629     
02630         bot_clr *= shade_factor;
02631     ;
02632                 }
02633                 
02634 #ifdef DEBUG
02635     if (ipixel == trace_pixel_ptr) {
02636         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02637         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02638         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02639         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02640         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02641     }
02642 #endif
02643 ;
02644                 
02645        acc_opc = top_opc * wgtTL;
02646        acc_clr = top_clr * wgtTL;
02647        
02648 #ifdef DEBUG
02649     if (ipixel == trace_pixel_ptr) {
02650         trace_opcTL = top_opc;
02651         trace_rclrTL = top_clr;
02652         
02653     }
02654 #endif
02655 ;
02656                 
02657        acc_opc += bot_opc * wgtBL;
02658        acc_clr += bot_clr * wgtBL;
02659        
02660 #ifdef DEBUG
02661     if (ipixel == trace_pixel_ptr) {
02662         trace_opcBL = bot_opc;
02663         trace_rclrBL = bot_clr;
02664         
02665     }
02666 #endif
02667 ;
02668                 
02669     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02670     
02671     
02672     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02673     ;
02674     
02675         
02676     bot_clr = 
02677     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02678         ;
02679     shade_factor = bot_opc * slice_depth_cueing;
02680     
02681         bot_clr *= shade_factor;
02682     ;
02683                 
02684        acc_opc += bot_opc * wgtBR;
02685        acc_clr += bot_clr * wgtBR;
02686        
02687 #ifdef DEBUG
02688     if (ipixel == trace_pixel_ptr) {
02689         trace_opcBR = bot_opc;
02690         trace_rclrBR = bot_clr;
02691         
02692     }
02693 #endif
02694 ;
02695                 
02696         COUNT_RESAMPLE;
02697         if (acc_opc > min_opacity) {
02698             COUNT_COMPOSITE;
02699             iopc = ipixel->opcflt;
02700 #           ifndef SKIP_ERT
02701                 ASSERT(iopc < max_opacity);
02702 #           endif
02703             iopc_inv = (float)1. - iopc;
02704             ipixel->clrflt += acc_clr * iopc_inv;
02705             iopc += acc_opc * iopc_inv;
02706             ipixel->opcflt = iopc;
02707             
02708 #ifdef DEBUG
02709     if (ipixel == trace_pixel_ptr) {
02710 #ifdef COMPUTE_SHADOW_BUFFER
02711         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02712 #else
02713         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02714 #endif
02715         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02716         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02717         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02718         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02719         printf("  %3.0f %3.0f\n", iopc*255., 
02720                ipixel->clrflt);
02721         
02722         
02723     }
02724 #endif /* DEBUG */
02725 ;
02726 #           ifndef SKIP_ERT
02727                 if (iopc >= max_opacity) {
02728                     ASSERT(ipixel->lnk == 0);
02729                     ipixel->lnk = 1;
02730                 }
02731 #           endif
02732         };
02733                 ipixel += 1;
02734                 ;
02735                 botRLEdata += 1 * voxel_istride;
02736                 count--;
02737                 SET_VOXELS_LOADED;
02738 
02739                 /* do the rest of the pixels in this run;
02740                    bottom-left and bottom-right voxels contribute */
02741                 while (count > 0) {
02742                     if (PIXEL_IS_OPAQUE(ipixel))
02743                         break;
02744                     if (!voxels_loaded) {
02745                         
02746     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02747     
02748     
02749     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02750     ;
02751     
02752         
02753     bot_clr = 
02754     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02755         ;
02756     shade_factor = bot_opc * slice_depth_cueing;
02757     
02758         bot_clr *= shade_factor;
02759     ;
02760                     }
02761                     
02762 #ifdef DEBUG
02763     if (ipixel == trace_pixel_ptr) {
02764         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02765         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02766         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02767         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02768         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02769     }
02770 #endif
02771 ;
02772                     
02773        acc_opc = bot_opc * wgtBL;
02774        acc_clr = bot_clr * wgtBL;
02775        
02776 #ifdef DEBUG
02777     if (ipixel == trace_pixel_ptr) {
02778         trace_opcBL = bot_opc;
02779         trace_rclrBL = bot_clr;
02780         
02781     }
02782 #endif
02783 ;
02784                     
02785     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02786     
02787     
02788     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02789     ;
02790     
02791         
02792     bot_clr = 
02793     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02794         ;
02795     shade_factor = bot_opc * slice_depth_cueing;
02796     
02797         bot_clr *= shade_factor;
02798     ;
02799                     
02800        acc_opc += bot_opc * wgtBR;
02801        acc_clr += bot_clr * wgtBR;
02802        
02803 #ifdef DEBUG
02804     if (ipixel == trace_pixel_ptr) {
02805         trace_opcBR = bot_opc;
02806         trace_rclrBR = bot_clr;
02807         
02808     }
02809 #endif
02810 ;
02811                     
02812         COUNT_RESAMPLE;
02813         if (acc_opc > min_opacity) {
02814             COUNT_COMPOSITE;
02815             iopc = ipixel->opcflt;
02816 #           ifndef SKIP_ERT
02817                 ASSERT(iopc < max_opacity);
02818 #           endif
02819             iopc_inv = (float)1. - iopc;
02820             ipixel->clrflt += acc_clr * iopc_inv;
02821             iopc += acc_opc * iopc_inv;
02822             ipixel->opcflt = iopc;
02823             
02824 #ifdef DEBUG
02825     if (ipixel == trace_pixel_ptr) {
02826 #ifdef COMPUTE_SHADOW_BUFFER
02827         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02828 #else
02829         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02830 #endif
02831         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02832         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02833         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02834         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02835         printf("  %3.0f %3.0f\n", iopc*255., 
02836                ipixel->clrflt);
02837         
02838         
02839     }
02840 #endif /* DEBUG */
02841 ;
02842 #           ifndef SKIP_ERT
02843                 if (iopc >= max_opacity) {
02844                     ASSERT(ipixel->lnk == 0);
02845                     ipixel->lnk = 1;
02846                 }
02847 #           endif
02848         };
02849                     ipixel += 1;
02850                     ;
02851                     botRLEdata += 1 * voxel_istride;
02852                     count--;
02853                     SET_VOXELS_LOADED;
02854                 }
02855                 break;
02856             case ALL_ZERO__ALL_NONZERO:
02857                 /* first pixel: top-right and bottom-right voxels contribute */
02858                 
02859     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02860     
02861     
02862     shade_index=1*1*ShortField(topRLEdata,norm_offset);
02863     ;
02864     
02865         
02866     top_clr = 
02867     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02868         ;
02869     shade_factor = top_opc * slice_depth_cueing;
02870     
02871         top_clr *= shade_factor;
02872     ;
02873                 
02874     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02875     
02876     
02877     shade_index=1*1*ShortField(botRLEdata,norm_offset);
02878     ;
02879     
02880         
02881     bot_clr = 
02882     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02883         ;
02884     shade_factor = bot_opc * slice_depth_cueing;
02885     
02886         bot_clr *= shade_factor;
02887     ;
02888                 
02889 #ifdef DEBUG
02890     if (ipixel == trace_pixel_ptr) {
02891         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02892         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02893         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02894         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02895         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02896     }
02897 #endif
02898 ;
02899                 
02900        acc_opc = top_opc * wgtTR;
02901        acc_clr = top_clr * wgtTR;
02902        
02903 #ifdef DEBUG
02904     if (ipixel == trace_pixel_ptr) {
02905         trace_opcTR = top_opc;
02906         trace_rclrTR = top_clr;
02907         
02908     }
02909 #endif
02910 ;
02911                 
02912        acc_opc += bot_opc * wgtBR;
02913        acc_clr += bot_clr * wgtBR;
02914        
02915 #ifdef DEBUG
02916     if (ipixel == trace_pixel_ptr) {
02917         trace_opcBR = bot_opc;
02918         trace_rclrBR = bot_clr;
02919         
02920     }
02921 #endif
02922 ;
02923                 
02924         COUNT_RESAMPLE;
02925         if (acc_opc > min_opacity) {
02926             COUNT_COMPOSITE;
02927             iopc = ipixel->opcflt;
02928 #           ifndef SKIP_ERT
02929                 ASSERT(iopc < max_opacity);
02930 #           endif
02931             iopc_inv = (float)1. - iopc;
02932             ipixel->clrflt += acc_clr * iopc_inv;
02933             iopc += acc_opc * iopc_inv;
02934             ipixel->opcflt = iopc;
02935             
02936 #ifdef DEBUG
02937     if (ipixel == trace_pixel_ptr) {
02938 #ifdef COMPUTE_SHADOW_BUFFER
02939         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02940 #else
02941         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02942 #endif
02943         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02944         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02945         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02946         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02947         printf("  %3.0f %3.0f\n", iopc*255., 
02948                ipixel->clrflt);
02949         
02950         
02951     }
02952 #endif /* DEBUG */
02953 ;
02954 #           ifndef SKIP_ERT
02955                 if (iopc >= max_opacity) {
02956                     ASSERT(ipixel->lnk == 0);
02957                     ipixel->lnk = 1;
02958                 }
02959 #           endif
02960         };
02961                 ipixel += 1;
02962                 topRLEdata += 1 * voxel_istride;
02963                 botRLEdata += 1 * voxel_istride;
02964                 count--;
02965                 SET_VOXELS_LOADED;
02966 
02967                 /* do the rest of the pixels in this run;
02968                    all four voxels contribute */
02969                 while (count > 0) {
02970                     if (PIXEL_IS_OPAQUE(ipixel))
02971                         break;
02972                     if (!voxels_loaded) {
02973                         
02974     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02975     
02976     
02977     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02978     ;
02979     
02980         
02981     top_clr = 
02982     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02983         ;
02984     shade_factor = top_opc * slice_depth_cueing;
02985     
02986         top_clr *= shade_factor;
02987     ;
02988                         
02989     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02990     
02991     
02992     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02993     ;
02994     
02995         
02996     bot_clr = 
02997     shade_table[shade_index + 1*0 + 0] * (float)1.0;
02998         ;
02999     shade_factor = bot_opc * slice_depth_cueing;
03000     
03001         bot_clr *= shade_factor;
03002     ;
03003                     }
03004                     
03005 #ifdef DEBUG
03006     if (ipixel == trace_pixel_ptr) {
03007         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03008         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03009         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03010         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03011         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03012     }
03013 #endif
03014 ;
03015                     
03016        acc_opc = top_opc * wgtTL;
03017        acc_clr = top_clr * wgtTL;
03018        
03019 #ifdef DEBUG
03020     if (ipixel == trace_pixel_ptr) {
03021         trace_opcTL = top_opc;
03022         trace_rclrTL = top_clr;
03023         
03024     }
03025 #endif
03026 ;
03027                     
03028        acc_opc += bot_opc * wgtBL;
03029        acc_clr += bot_clr * wgtBL;
03030        
03031 #ifdef DEBUG
03032     if (ipixel == trace_pixel_ptr) {
03033         trace_opcBL = bot_opc;
03034         trace_rclrBL = bot_clr;
03035         
03036     }
03037 #endif
03038 ;
03039                     
03040     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03041     
03042     
03043     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03044     ;
03045     
03046         
03047     top_clr = 
03048     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03049         ;
03050     shade_factor = top_opc * slice_depth_cueing;
03051     
03052         top_clr *= shade_factor;
03053     ;
03054                     
03055     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03056     
03057     
03058     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03059     ;
03060     
03061         
03062     bot_clr = 
03063     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03064         ;
03065     shade_factor = bot_opc * slice_depth_cueing;
03066     
03067         bot_clr *= shade_factor;
03068     ;
03069                     
03070        acc_opc += top_opc * wgtTR;
03071        acc_clr += top_clr * wgtTR;
03072        
03073 #ifdef DEBUG
03074     if (ipixel == trace_pixel_ptr) {
03075         trace_opcTR = top_opc;
03076         trace_rclrTR = top_clr;
03077         
03078     }
03079 #endif
03080 ;
03081                     
03082        acc_opc += bot_opc * wgtBR;
03083        acc_clr += bot_clr * wgtBR;
03084        
03085 #ifdef DEBUG
03086     if (ipixel == trace_pixel_ptr) {
03087         trace_opcBR = bot_opc;
03088         trace_rclrBR = bot_clr;
03089         
03090     }
03091 #endif
03092 ;
03093                     
03094         COUNT_RESAMPLE;
03095         if (acc_opc > min_opacity) {
03096             COUNT_COMPOSITE;
03097             iopc = ipixel->opcflt;
03098 #           ifndef SKIP_ERT
03099                 ASSERT(iopc < max_opacity);
03100 #           endif
03101             iopc_inv = (float)1. - iopc;
03102             ipixel->clrflt += acc_clr * iopc_inv;
03103             iopc += acc_opc * iopc_inv;
03104             ipixel->opcflt = iopc;
03105             
03106 #ifdef DEBUG
03107     if (ipixel == trace_pixel_ptr) {
03108 #ifdef COMPUTE_SHADOW_BUFFER
03109         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03110 #else
03111         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03112 #endif
03113         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03114         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03115         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03116         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03117         printf("  %3.0f %3.0f\n", iopc*255., 
03118                ipixel->clrflt);
03119         
03120         
03121     }
03122 #endif /* DEBUG */
03123 ;
03124 #           ifndef SKIP_ERT
03125                 if (iopc >= max_opacity) {
03126                     ASSERT(ipixel->lnk == 0);
03127                     ipixel->lnk = 1;
03128                 }
03129 #           endif
03130         };
03131                     ipixel += 1;
03132                     topRLEdata += 1 * voxel_istride;
03133                     botRLEdata += 1 * voxel_istride;
03134                     count--;
03135                     SET_VOXELS_LOADED;
03136                 }
03137                 break;
03138             case TOP_NONZERO__ALL_NONZERO:
03139                 /* first pixel: top-left, top-right and bottom-right
03140                    voxels contribute */
03141                 if (!voxels_loaded) {
03142                     
03143     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03144     
03145     
03146     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03147     ;
03148     
03149         
03150     top_clr = 
03151     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03152         ;
03153     shade_factor = top_opc * slice_depth_cueing;
03154     
03155         top_clr *= shade_factor;
03156     ;
03157                 }
03158                 
03159 #ifdef DEBUG
03160     if (ipixel == trace_pixel_ptr) {
03161         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03162         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03163         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03164         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03165         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03166     }
03167 #endif
03168 ;
03169                 
03170        acc_opc = top_opc * wgtTL;
03171        acc_clr = top_clr * wgtTL;
03172        
03173 #ifdef DEBUG
03174     if (ipixel == trace_pixel_ptr) {
03175         trace_opcTL = top_opc;
03176         trace_rclrTL = top_clr;
03177         
03178     }
03179 #endif
03180 ;
03181                 
03182     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03183     
03184     
03185     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03186     ;
03187     
03188         
03189     top_clr = 
03190     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03191         ;
03192     shade_factor = top_opc * slice_depth_cueing;
03193     
03194         top_clr *= shade_factor;
03195     ;
03196                 
03197     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03198     
03199     
03200     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03201     ;
03202     
03203         
03204     bot_clr = 
03205     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03206         ;
03207     shade_factor = bot_opc * slice_depth_cueing;
03208     
03209         bot_clr *= shade_factor;
03210     ;
03211                 
03212        acc_opc += top_opc * wgtTR;
03213        acc_clr += top_clr * wgtTR;
03214        
03215 #ifdef DEBUG
03216     if (ipixel == trace_pixel_ptr) {
03217         trace_opcTR = top_opc;
03218         trace_rclrTR = top_clr;
03219         
03220     }
03221 #endif
03222 ;
03223                 
03224        acc_opc += bot_opc * wgtBR;
03225        acc_clr += bot_clr * wgtBR;
03226        
03227 #ifdef DEBUG
03228     if (ipixel == trace_pixel_ptr) {
03229         trace_opcBR = bot_opc;
03230         trace_rclrBR = bot_clr;
03231         
03232     }
03233 #endif
03234 ;
03235                 
03236         COUNT_RESAMPLE;
03237         if (acc_opc > min_opacity) {
03238             COUNT_COMPOSITE;
03239             iopc = ipixel->opcflt;
03240 #           ifndef SKIP_ERT
03241                 ASSERT(iopc < max_opacity);
03242 #           endif
03243             iopc_inv = (float)1. - iopc;
03244             ipixel->clrflt += acc_clr * iopc_inv;
03245             iopc += acc_opc * iopc_inv;
03246             ipixel->opcflt = iopc;
03247             
03248 #ifdef DEBUG
03249     if (ipixel == trace_pixel_ptr) {
03250 #ifdef COMPUTE_SHADOW_BUFFER
03251         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03252 #else
03253         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03254 #endif
03255         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03256         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03257         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03258         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03259         printf("  %3.0f %3.0f\n", iopc*255., 
03260                ipixel->clrflt);
03261         
03262         
03263     }
03264 #endif /* DEBUG */
03265 ;
03266 #           ifndef SKIP_ERT
03267                 if (iopc >= max_opacity) {
03268                     ASSERT(ipixel->lnk == 0);
03269                     ipixel->lnk = 1;
03270                 }
03271 #           endif
03272         };
03273                 ipixel += 1;
03274                 topRLEdata += 1 * voxel_istride;
03275                 botRLEdata += 1 * voxel_istride;
03276                 count--;
03277                 SET_VOXELS_LOADED;
03278                     
03279                 /* do the rest of the pixels in this run;
03280                    all four voxels contribute */
03281                 while (count > 0) {
03282                     if (PIXEL_IS_OPAQUE(ipixel))
03283                         break;
03284                     if (!voxels_loaded) {
03285                         
03286     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03287     
03288     
03289     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03290     ;
03291     
03292         
03293     top_clr = 
03294     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03295         ;
03296     shade_factor = top_opc * slice_depth_cueing;
03297     
03298         top_clr *= shade_factor;
03299     ;
03300                         
03301     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03302     
03303     
03304     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03305     ;
03306     
03307         
03308     bot_clr = 
03309     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03310         ;
03311     shade_factor = bot_opc * slice_depth_cueing;
03312     
03313         bot_clr *= shade_factor;
03314     ;
03315                     }
03316                     
03317 #ifdef DEBUG
03318     if (ipixel == trace_pixel_ptr) {
03319         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03320         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03321         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03322         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03323         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03324     }
03325 #endif
03326 ;
03327                     
03328        acc_opc = top_opc * wgtTL;
03329        acc_clr = top_clr * wgtTL;
03330        
03331 #ifdef DEBUG
03332     if (ipixel == trace_pixel_ptr) {
03333         trace_opcTL = top_opc;
03334         trace_rclrTL = top_clr;
03335         
03336     }
03337 #endif
03338 ;
03339                     
03340        acc_opc += bot_opc * wgtBL;
03341        acc_clr += bot_clr * wgtBL;
03342        
03343 #ifdef DEBUG
03344     if (ipixel == trace_pixel_ptr) {
03345         trace_opcBL = bot_opc;
03346         trace_rclrBL = bot_clr;
03347         
03348     }
03349 #endif
03350 ;
03351                     
03352     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03353     
03354     
03355     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03356     ;
03357     
03358         
03359     top_clr = 
03360     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03361         ;
03362     shade_factor = top_opc * slice_depth_cueing;
03363     
03364         top_clr *= shade_factor;
03365     ;
03366                     
03367     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03368     
03369     
03370     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03371     ;
03372     
03373         
03374     bot_clr = 
03375     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03376         ;
03377     shade_factor = bot_opc * slice_depth_cueing;
03378     
03379         bot_clr *= shade_factor;
03380     ;
03381                     
03382        acc_opc += top_opc * wgtTR;
03383        acc_clr += top_clr * wgtTR;
03384        
03385 #ifdef DEBUG
03386     if (ipixel == trace_pixel_ptr) {
03387         trace_opcTR = top_opc;
03388         trace_rclrTR = top_clr;
03389         
03390     }
03391 #endif
03392 ;
03393                     
03394        acc_opc += bot_opc * wgtBR;
03395        acc_clr += bot_clr * wgtBR;
03396        
03397 #ifdef DEBUG
03398     if (ipixel == trace_pixel_ptr) {
03399         trace_opcBR = bot_opc;
03400         trace_rclrBR = bot_clr;
03401         
03402     }
03403 #endif
03404 ;
03405                     
03406         COUNT_RESAMPLE;
03407         if (acc_opc > min_opacity) {
03408             COUNT_COMPOSITE;
03409             iopc = ipixel->opcflt;
03410 #           ifndef SKIP_ERT
03411                 ASSERT(iopc < max_opacity);
03412 #           endif
03413             iopc_inv = (float)1. - iopc;
03414             ipixel->clrflt += acc_clr * iopc_inv;
03415             iopc += acc_opc * iopc_inv;
03416             ipixel->opcflt = iopc;
03417             
03418 #ifdef DEBUG
03419     if (ipixel == trace_pixel_ptr) {
03420 #ifdef COMPUTE_SHADOW_BUFFER
03421         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03422 #else
03423         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03424 #endif
03425         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03426         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03427         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03428         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03429         printf("  %3.0f %3.0f\n", iopc*255., 
03430                ipixel->clrflt);
03431         
03432         
03433     }
03434 #endif /* DEBUG */
03435 ;
03436 #           ifndef SKIP_ERT
03437                 if (iopc >= max_opacity) {
03438                     ASSERT(ipixel->lnk == 0);
03439                     ipixel->lnk = 1;
03440                 }
03441 #           endif
03442         };
03443                     ipixel += 1;
03444                     topRLEdata += 1 * voxel_istride;
03445                     botRLEdata += 1 * voxel_istride;
03446                     count--;
03447                     SET_VOXELS_LOADED;
03448                 }
03449                 break;
03450             case BOT_NONZERO__ALL_NONZERO:
03451                 /* first pixel: bottom-left, top-right and bottom-right
03452                    voxels contribute */
03453                 if (!voxels_loaded) {
03454                     
03455     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03456     
03457     
03458     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03459     ;
03460     
03461         
03462     bot_clr = 
03463     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03464         ;
03465     shade_factor = bot_opc * slice_depth_cueing;
03466     
03467         bot_clr *= shade_factor;
03468     ;
03469                 }
03470                 
03471 #ifdef DEBUG
03472     if (ipixel == trace_pixel_ptr) {
03473         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03474         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03475         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03476         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03477         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03478     }
03479 #endif
03480 ;
03481                 
03482        acc_opc = bot_opc * wgtBL;
03483        acc_clr = bot_clr * wgtBL;
03484        
03485 #ifdef DEBUG
03486     if (ipixel == trace_pixel_ptr) {
03487         trace_opcBL = bot_opc;
03488         trace_rclrBL = bot_clr;
03489         
03490     }
03491 #endif
03492 ;
03493                 
03494     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03495     
03496     
03497     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03498     ;
03499     
03500         
03501     top_clr = 
03502     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03503         ;
03504     shade_factor = top_opc * slice_depth_cueing;
03505     
03506         top_clr *= shade_factor;
03507     ;
03508                 
03509     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03510     
03511     
03512     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03513     ;
03514     
03515         
03516     bot_clr = 
03517     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03518         ;
03519     shade_factor = bot_opc * slice_depth_cueing;
03520     
03521         bot_clr *= shade_factor;
03522     ;
03523                 
03524        acc_opc += top_opc * wgtTR;
03525        acc_clr += top_clr * wgtTR;
03526        
03527 #ifdef DEBUG
03528     if (ipixel == trace_pixel_ptr) {
03529         trace_opcTR = top_opc;
03530         trace_rclrTR = top_clr;
03531         
03532     }
03533 #endif
03534 ;
03535                 
03536        acc_opc += bot_opc * wgtBR;
03537        acc_clr += bot_clr * wgtBR;
03538        
03539 #ifdef DEBUG
03540     if (ipixel == trace_pixel_ptr) {
03541         trace_opcBR = bot_opc;
03542         trace_rclrBR = bot_clr;
03543         
03544     }
03545 #endif
03546 ;
03547                 
03548         COUNT_RESAMPLE;
03549         if (acc_opc > min_opacity) {
03550             COUNT_COMPOSITE;
03551             iopc = ipixel->opcflt;
03552 #           ifndef SKIP_ERT
03553                 ASSERT(iopc < max_opacity);
03554 #           endif
03555             iopc_inv = (float)1. - iopc;
03556             ipixel->clrflt += acc_clr * iopc_inv;
03557             iopc += acc_opc * iopc_inv;
03558             ipixel->opcflt = iopc;
03559             
03560 #ifdef DEBUG
03561     if (ipixel == trace_pixel_ptr) {
03562 #ifdef COMPUTE_SHADOW_BUFFER
03563         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03564 #else
03565         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03566 #endif
03567         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03568         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03569         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03570         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03571         printf("  %3.0f %3.0f\n", iopc*255., 
03572                ipixel->clrflt);
03573         
03574         
03575     }
03576 #endif /* DEBUG */
03577 ;
03578 #           ifndef SKIP_ERT
03579                 if (iopc >= max_opacity) {
03580                     ASSERT(ipixel->lnk == 0);
03581                     ipixel->lnk = 1;
03582                 }
03583 #           endif
03584         };
03585                 ipixel += 1;
03586                 topRLEdata += 1 * voxel_istride;
03587                 botRLEdata += 1 * voxel_istride;
03588                 count--;
03589                 SET_VOXELS_LOADED;
03590                     
03591                 /* do the rest of the pixels in this run;
03592                    all four voxels contribute */
03593                 while (count > 0) {
03594                     if (PIXEL_IS_OPAQUE(ipixel))
03595                         break;
03596                     if (!voxels_loaded) {
03597                         
03598     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03599     
03600     
03601     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03602     ;
03603     
03604         
03605     top_clr = 
03606     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03607         ;
03608     shade_factor = top_opc * slice_depth_cueing;
03609     
03610         top_clr *= shade_factor;
03611     ;
03612                         
03613     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03614     
03615     
03616     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03617     ;
03618     
03619         
03620     bot_clr = 
03621     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03622         ;
03623     shade_factor = bot_opc * slice_depth_cueing;
03624     
03625         bot_clr *= shade_factor;
03626     ;
03627                     }
03628                     
03629 #ifdef DEBUG
03630     if (ipixel == trace_pixel_ptr) {
03631         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03632         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03633         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03634         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03635         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03636     }
03637 #endif
03638 ;
03639                     
03640        acc_opc = top_opc * wgtTL;
03641        acc_clr = top_clr * wgtTL;
03642        
03643 #ifdef DEBUG
03644     if (ipixel == trace_pixel_ptr) {
03645         trace_opcTL = top_opc;
03646         trace_rclrTL = top_clr;
03647         
03648     }
03649 #endif
03650 ;
03651                     
03652        acc_opc += bot_opc * wgtBL;
03653        acc_clr += bot_clr * wgtBL;
03654        
03655 #ifdef DEBUG
03656     if (ipixel == trace_pixel_ptr) {
03657         trace_opcBL = bot_opc;
03658         trace_rclrBL = bot_clr;
03659         
03660     }
03661 #endif
03662 ;
03663                     
03664     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03665     
03666     
03667     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03668     ;
03669     
03670         
03671     top_clr = 
03672     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03673         ;
03674     shade_factor = top_opc * slice_depth_cueing;
03675     
03676         top_clr *= shade_factor;
03677     ;
03678                     
03679     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03680     
03681     
03682     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03683     ;
03684     
03685         
03686     bot_clr = 
03687     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03688         ;
03689     shade_factor = bot_opc * slice_depth_cueing;
03690     
03691         bot_clr *= shade_factor;
03692     ;
03693                     
03694        acc_opc += top_opc * wgtTR;
03695        acc_clr += top_clr * wgtTR;
03696        
03697 #ifdef DEBUG
03698     if (ipixel == trace_pixel_ptr) {
03699         trace_opcTR = top_opc;
03700         trace_rclrTR = top_clr;
03701         
03702     }
03703 #endif
03704 ;
03705                     
03706        acc_opc += bot_opc * wgtBR;
03707        acc_clr += bot_clr * wgtBR;
03708        
03709 #ifdef DEBUG
03710     if (ipixel == trace_pixel_ptr) {
03711         trace_opcBR = bot_opc;
03712         trace_rclrBR = bot_clr;
03713         
03714     }
03715 #endif
03716 ;
03717                     
03718         COUNT_RESAMPLE;
03719         if (acc_opc > min_opacity) {
03720             COUNT_COMPOSITE;
03721             iopc = ipixel->opcflt;
03722 #           ifndef SKIP_ERT
03723                 ASSERT(iopc < max_opacity);
03724 #           endif
03725             iopc_inv = (float)1. - iopc;
03726             ipixel->clrflt += acc_clr * iopc_inv;
03727             iopc += acc_opc * iopc_inv;
03728             ipixel->opcflt = iopc;
03729             
03730 #ifdef DEBUG
03731     if (ipixel == trace_pixel_ptr) {
03732 #ifdef COMPUTE_SHADOW_BUFFER
03733         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03734 #else
03735         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03736 #endif
03737         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03738         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03739         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03740         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03741         printf("  %3.0f %3.0f\n", iopc*255., 
03742                ipixel->clrflt);
03743         
03744         
03745     }
03746 #endif /* DEBUG */
03747 ;
03748 #           ifndef SKIP_ERT
03749                 if (iopc >= max_opacity) {
03750                     ASSERT(ipixel->lnk == 0);
03751                     ipixel->lnk = 1;
03752                 }
03753 #           endif
03754         };
03755                     ipixel += 1;
03756                     topRLEdata += 1 * voxel_istride;
03757                     botRLEdata += 1 * voxel_istride;
03758                     count--;
03759                     SET_VOXELS_LOADED;
03760                 }
03761                 break;
03762             case ALL_NONZERO__ALL_NONZERO:
03763                 /* do the pixels in this run; all four voxels contribute */
03764                 while (count > 0) {
03765                     if (PIXEL_IS_OPAQUE(ipixel))
03766                         break;
03767                     if (!voxels_loaded) {
03768                         
03769     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03770     
03771     
03772     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03773     ;
03774     
03775         
03776     top_clr = 
03777     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03778         ;
03779     shade_factor = top_opc * slice_depth_cueing;
03780     
03781         top_clr *= shade_factor;
03782     ;
03783                         
03784     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03785     
03786     
03787     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03788     ;
03789     
03790         
03791     bot_clr = 
03792     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03793         ;
03794     shade_factor = bot_opc * slice_depth_cueing;
03795     
03796         bot_clr *= shade_factor;
03797     ;
03798                     }
03799                     
03800 #ifdef DEBUG
03801     if (ipixel == trace_pixel_ptr) {
03802         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03803         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03804         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03805         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03806         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03807     }
03808 #endif
03809 ;
03810                     
03811        acc_opc = top_opc * wgtTL;
03812        acc_clr = top_clr * wgtTL;
03813        
03814 #ifdef DEBUG
03815     if (ipixel == trace_pixel_ptr) {
03816         trace_opcTL = top_opc;
03817         trace_rclrTL = top_clr;
03818         
03819     }
03820 #endif
03821 ;
03822                     
03823        acc_opc += bot_opc * wgtBL;
03824        acc_clr += bot_clr * wgtBL;
03825        
03826 #ifdef DEBUG
03827     if (ipixel == trace_pixel_ptr) {
03828         trace_opcBL = bot_opc;
03829         trace_rclrBL = bot_clr;
03830         
03831     }
03832 #endif
03833 ;
03834                     
03835     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03836     
03837     
03838     shade_index=1*1*ShortField(topRLEdata,norm_offset);
03839     ;
03840     
03841         
03842     top_clr = 
03843     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03844         ;
03845     shade_factor = top_opc * slice_depth_cueing;
03846     
03847         top_clr *= shade_factor;
03848     ;
03849                     
03850     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03851     
03852     
03853     shade_index=1*1*ShortField(botRLEdata,norm_offset);
03854     ;
03855     
03856         
03857     bot_clr = 
03858     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03859         ;
03860     shade_factor = bot_opc * slice_depth_cueing;
03861     
03862         bot_clr *= shade_factor;
03863     ;
03864                     
03865        acc_opc += top_opc * wgtTR;
03866        acc_clr += top_clr * wgtTR;
03867        
03868 #ifdef DEBUG
03869     if (ipixel == trace_pixel_ptr) {
03870         trace_opcTR = top_opc;
03871         trace_rclrTR = top_clr;
03872         
03873     }
03874 #endif
03875 ;
03876                     
03877        acc_opc += bot_opc * wgtBR;
03878        acc_clr += bot_clr * wgtBR;
03879        
03880 #ifdef DEBUG
03881     if (ipixel == trace_pixel_ptr) {
03882         trace_opcBR = bot_opc;
03883         trace_rclrBR = bot_clr;
03884         
03885     }
03886 #endif
03887 ;
03888                     
03889         COUNT_RESAMPLE;
03890         if (acc_opc > min_opacity) {
03891             COUNT_COMPOSITE;
03892             iopc = ipixel->opcflt;
03893 #           ifndef SKIP_ERT
03894                 ASSERT(iopc < max_opacity);
03895 #           endif
03896             iopc_inv = (float)1. - iopc;
03897             ipixel->clrflt += acc_clr * iopc_inv;
03898             iopc += acc_opc * iopc_inv;
03899             ipixel->opcflt = iopc;
03900             
03901 #ifdef DEBUG
03902     if (ipixel == trace_pixel_ptr) {
03903 #ifdef COMPUTE_SHADOW_BUFFER
03904         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03905 #else
03906         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03907 #endif
03908         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03909         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03910         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03911         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03912         printf("  %3.0f %3.0f\n", iopc*255., 
03913                ipixel->clrflt);
03914         
03915         
03916     }
03917 #endif /* DEBUG */
03918 ;
03919 #           ifndef SKIP_ERT
03920                 if (iopc >= max_opacity) {
03921                     ASSERT(ipixel->lnk == 0);
03922                     ipixel->lnk = 1;
03923                 }
03924 #           endif
03925         };
03926                     ipixel += 1;
03927                     topRLEdata += 1 * voxel_istride;
03928                     botRLEdata += 1 * voxel_istride;
03929                     count--;
03930                     SET_VOXELS_LOADED;
03931                 }
03932                 break;
03933             default:
03934                 VPBug("illegal value for run states in compositing loop");
03935             }
03936 #else /* UNROLL_RUN_LOOP */
03937             /* this run contains pixels, so process them */
03938             while (count > 0) {
03939                 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
03940                     ipixel += count;
03941                     if (i != -1) {
03942                         ;
03943                         ;
03944                     }
03945                     count = 0;
03946                     break;
03947                 }
03948                 if (ipixel->lnk != 0)
03949                     break;
03950                 
03951 #ifdef DEBUG
03952     if (ipixel == trace_pixel_ptr) {
03953         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03954         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03955         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03956         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03957         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03958     }
03959 #endif
03960 ;
03961                 
03962        acc_opc = 0;
03963        acc_clr = 0;
03964                 if (last_run_state & TOP_NONZERO) {
03965                     if (!voxels_loaded) {
03966                         
03967     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03968     
03969     
03970     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03971     ;
03972     
03973         
03974     top_clr = 
03975     shade_table[shade_index + 1*0 + 0] * (float)1.0;
03976         ;
03977     shade_factor = top_opc * slice_depth_cueing;
03978     
03979         top_clr *= shade_factor;
03980     ;
03981                     }
03982                     
03983        acc_opc += top_opc * wgtTL;
03984        acc_clr += top_clr * wgtTL;
03985        
03986 #ifdef DEBUG
03987     if (ipixel == trace_pixel_ptr) {
03988         trace_opcTL = top_opc;
03989         trace_rclrTL = top_clr;
03990         
03991     }
03992 #endif
03993 ;
03994                 }
03995                 if (last_run_state & BOT_NONZERO) {
03996                     if (!voxels_loaded) {
03997                         
03998     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03999     
04000     
04001     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04002     ;
04003     
04004         
04005     bot_clr = 
04006     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04007         ;
04008     shade_factor = bot_opc * slice_depth_cueing;
04009     
04010         bot_clr *= shade_factor;
04011     ;
04012                     }
04013                     
04014        acc_opc += bot_opc * wgtBL;
04015        acc_clr += bot_clr * wgtBL;
04016        
04017 #ifdef DEBUG
04018     if (ipixel == trace_pixel_ptr) {
04019         trace_opcBL = bot_opc;
04020         trace_rclrBL = bot_clr;
04021         
04022     }
04023 #endif
04024 ;
04025                 }
04026                 if (run_state & TOP_NONZERO) {
04027                     
04028     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04029     
04030     
04031     shade_index=1*1*ShortField(topRLEdata,norm_offset);
04032     ;
04033     
04034         
04035     top_clr = 
04036     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04037         ;
04038     shade_factor = top_opc * slice_depth_cueing;
04039     
04040         top_clr *= shade_factor;
04041     ;
04042                     
04043        acc_opc += top_opc * wgtTR;
04044        acc_clr += top_clr * wgtTR;
04045        
04046 #ifdef DEBUG
04047     if (ipixel == trace_pixel_ptr) {
04048         trace_opcTR = top_opc;
04049         trace_rclrTR = top_clr;
04050         
04051     }
04052 #endif
04053 ;
04054                     topRLEdata += 1 * voxel_istride;
04055                 } else {
04056                     if (i != -1) {
04057                         ;
04058                     }
04059                 }
04060                 if (run_state & BOT_NONZERO) {
04061                     
04062     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04063     
04064     
04065     shade_index=1*1*ShortField(botRLEdata,norm_offset);
04066     ;
04067     
04068         
04069     bot_clr = 
04070     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04071         ;
04072     shade_factor = bot_opc * slice_depth_cueing;
04073     
04074         bot_clr *= shade_factor;
04075     ;
04076                     
04077        acc_opc += bot_opc * wgtBR;
04078        acc_clr += bot_clr * wgtBR;
04079        
04080 #ifdef DEBUG
04081     if (ipixel == trace_pixel_ptr) {
04082         trace_opcBR = bot_opc;
04083         trace_rclrBR = bot_clr;
04084         
04085     }
04086 #endif
04087 ;
04088                     botRLEdata += 1 * voxel_istride;
04089                 } else {
04090                     if (i != -1) {
04091                         ;
04092                     }
04093                 }
04094                 
04095         COUNT_RESAMPLE;
04096         if (acc_opc > min_opacity) {
04097             COUNT_COMPOSITE;
04098             iopc = ipixel->opcflt;
04099 #           ifndef SKIP_ERT
04100                 ASSERT(iopc < max_opacity);
04101 #           endif
04102             iopc_inv = (float)1. - iopc;
04103             ipixel->clrflt += acc_clr * iopc_inv;
04104             iopc += acc_opc * iopc_inv;
04105             ipixel->opcflt = iopc;
04106             
04107 #ifdef DEBUG
04108     if (ipixel == trace_pixel_ptr) {
04109 #ifdef COMPUTE_SHADOW_BUFFER
04110         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04111 #else
04112         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04113 #endif
04114         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04115         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04116         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04117         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04118         printf("  %3.0f %3.0f\n", iopc*255., 
04119                ipixel->clrflt);
04120         
04121         
04122     }
04123 #endif /* DEBUG */
04124 ;
04125 #           ifndef SKIP_ERT
04126                 if (iopc >= max_opacity) {
04127                     ASSERT(ipixel->lnk == 0);
04128                     ipixel->lnk = 1;
04129                 }
04130 #           endif
04131         };
04132                 ipixel += 1;
04133                 count--;
04134                 SET_VOXELS_LOADED;
04135                 last_run_state = run_state;
04136             }
04137 #endif /* UNROLL_RUN_LOOP */
04138 
04139             GET_HIRES_TIME(vpc, t1);
04140             STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
04141             COPY_HIRES_TIME(t0, t1);
04142 
04143             if (count > 0) {
04144                 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
04145                 toprun_count += count;
04146                 botrun_count += count;
04147                 i += count;
04148             }
04149 #endif /* SKIP_COMPOSITE */
04150 
04151             /***********************************************************
04152              * Go on to next voxel run.
04153              ***********************************************************/
04154 
04155             last_run_state = run_state;
04156         } /* while (i > 0) */
04157 
04158         /***************************************************************
04159          * Finish processing voxel scanline and go on to next one.
04160          ***************************************************************/
04161 
04162 #ifdef UNROLL_RUN_LOOP
04163         ASSERT(i == 0);
04164 #else
04165         ASSERT(i == -1);
04166 #endif
04167 
04168 #ifndef SKIP_COMPOSITE
04169 #ifdef UNROLL_RUN_LOOP
04170         /* do the last pixel (to the right of the last voxel) */
04171         if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
04172             /* last voxels are nonzero and the pixel is not opaque yet
04173                so there is work to be done */
04174             Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
04175             switch (last_run_state) {
04176             case TOP_NONZERO:
04177                 /* only the top-left voxel contributes */
04178                 if (!voxels_loaded) {
04179                     
04180     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04181     
04182     
04183     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04184     ;
04185     
04186         
04187     top_clr = 
04188     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04189         ;
04190     shade_factor = top_opc * slice_depth_cueing;
04191     
04192         top_clr *= shade_factor;
04193     ;
04194                 }
04195                 
04196 #ifdef DEBUG
04197     if (ipixel == trace_pixel_ptr) {
04198         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04199         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04200         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04201         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04202         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04203     }
04204 #endif
04205 ;
04206                 
04207        acc_opc = top_opc * wgtTL;
04208        acc_clr = top_clr * wgtTL;
04209        
04210 #ifdef DEBUG
04211     if (ipixel == trace_pixel_ptr) {
04212         trace_opcTL = top_opc;
04213         trace_rclrTL = top_clr;
04214         
04215     }
04216 #endif
04217 ;
04218                 
04219         COUNT_RESAMPLE;
04220         if (acc_opc > min_opacity) {
04221             COUNT_COMPOSITE;
04222             iopc = ipixel->opcflt;
04223 #           ifndef SKIP_ERT
04224                 ASSERT(iopc < max_opacity);
04225 #           endif
04226             iopc_inv = (float)1. - iopc;
04227             ipixel->clrflt += acc_clr * iopc_inv;
04228             iopc += acc_opc * iopc_inv;
04229             ipixel->opcflt = iopc;
04230             
04231 #ifdef DEBUG
04232     if (ipixel == trace_pixel_ptr) {
04233 #ifdef COMPUTE_SHADOW_BUFFER
04234         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04235 #else
04236         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04237 #endif
04238         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04239         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04240         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04241         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04242         printf("  %3.0f %3.0f\n", iopc*255., 
04243                ipixel->clrflt);
04244         
04245         
04246     }
04247 #endif /* DEBUG */
04248 ;
04249 #           ifndef SKIP_ERT
04250                 if (iopc >= max_opacity) {
04251                     ASSERT(ipixel->lnk == 0);
04252                     ipixel->lnk = 1;
04253                 }
04254 #           endif
04255         };
04256                 break;
04257             case BOT_NONZERO:
04258                 /* only the bottom left voxel contributes */
04259                 if (!voxels_loaded) {
04260                     
04261     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04262     
04263     
04264     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04265     ;
04266     
04267         
04268     bot_clr = 
04269     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04270         ;
04271     shade_factor = bot_opc * slice_depth_cueing;
04272     
04273         bot_clr *= shade_factor;
04274     ;
04275                 }
04276                 
04277 #ifdef DEBUG
04278     if (ipixel == trace_pixel_ptr) {
04279         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04280         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04281         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04282         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04283         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04284     }
04285 #endif
04286 ;
04287                 
04288        acc_opc = bot_opc * wgtBL;
04289        acc_clr = bot_clr * wgtBL;
04290        
04291 #ifdef DEBUG
04292     if (ipixel == trace_pixel_ptr) {
04293         trace_opcBL = bot_opc;
04294         trace_rclrBL = bot_clr;
04295         
04296     }
04297 #endif
04298 ;
04299                 
04300         COUNT_RESAMPLE;
04301         if (acc_opc > min_opacity) {
04302             COUNT_COMPOSITE;
04303             iopc = ipixel->opcflt;
04304 #           ifndef SKIP_ERT
04305                 ASSERT(iopc < max_opacity);
04306 #           endif
04307             iopc_inv = (float)1. - iopc;
04308             ipixel->clrflt += acc_clr * iopc_inv;
04309             iopc += acc_opc * iopc_inv;
04310             ipixel->opcflt = iopc;
04311             
04312 #ifdef DEBUG
04313     if (ipixel == trace_pixel_ptr) {
04314 #ifdef COMPUTE_SHADOW_BUFFER
04315         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04316 #else
04317         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04318 #endif
04319         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04320         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04321         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04322         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04323         printf("  %3.0f %3.0f\n", iopc*255., 
04324                ipixel->clrflt);
04325         
04326         
04327     }
04328 #endif /* DEBUG */
04329 ;
04330 #           ifndef SKIP_ERT
04331                 if (iopc >= max_opacity) {
04332                     ASSERT(ipixel->lnk == 0);
04333                     ipixel->lnk = 1;
04334                 }
04335 #           endif
04336         };
04337                 break;
04338             case ALL_NONZERO:
04339                 /* the top and bottom left voxels contribute */
04340                 if (!voxels_loaded) {
04341                     
04342     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04343     
04344     
04345     shade_index=1*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04346     ;
04347     
04348         
04349     top_clr = 
04350     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04351         ;
04352     shade_factor = top_opc * slice_depth_cueing;
04353     
04354         top_clr *= shade_factor;
04355     ;
04356                     
04357     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04358     
04359     
04360     shade_index=1*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04361     ;
04362     
04363         
04364     bot_clr = 
04365     shade_table[shade_index + 1*0 + 0] * (float)1.0;
04366         ;
04367     shade_factor = bot_opc * slice_depth_cueing;
04368     
04369         bot_clr *= shade_factor;
04370     ;
04371                 }
04372                 
04373 #ifdef DEBUG
04374     if (ipixel == trace_pixel_ptr) {
04375         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04376         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04377         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04378         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04379         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04380     }
04381 #endif
04382 ;
04383                 
04384        acc_opc = top_opc * wgtTL;
04385        acc_clr = top_clr * wgtTL;
04386        
04387 #ifdef DEBUG
04388     if (ipixel == trace_pixel_ptr) {
04389         trace_opcTL = top_opc;
04390         trace_rclrTL = top_clr;
04391         
04392     }
04393 #endif
04394 ;
04395                 
04396        acc_opc += bot_opc * wgtBL;
04397        acc_clr += bot_clr * wgtBL;
04398        
04399 #ifdef DEBUG
04400     if (ipixel == trace_pixel_ptr) {
04401         trace_opcBL = bot_opc;
04402         trace_rclrBL = bot_clr;
04403         
04404     }
04405 #endif
04406 ;
04407                 
04408         COUNT_RESAMPLE;
04409         if (acc_opc > min_opacity) {
04410             COUNT_COMPOSITE;
04411             iopc = ipixel->opcflt;
04412 #           ifndef SKIP_ERT
04413                 ASSERT(iopc < max_opacity);
04414 #           endif
04415             iopc_inv = (float)1. - iopc;
04416             ipixel->clrflt += acc_clr * iopc_inv;
04417             iopc += acc_opc * iopc_inv;
04418             ipixel->opcflt = iopc;
04419             
04420 #ifdef DEBUG
04421     if (ipixel == trace_pixel_ptr) {
04422 #ifdef COMPUTE_SHADOW_BUFFER
04423         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04424 #else
04425         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04426 #endif
04427         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04428         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04429         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04430         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04431         printf("  %3.0f %3.0f\n", iopc*255., 
04432                ipixel->clrflt);
04433         
04434         
04435     }
04436 #endif /* DEBUG */
04437 ;
04438 #           ifndef SKIP_ERT
04439                 if (iopc >= max_opacity) {
04440                     ASSERT(ipixel->lnk == 0);
04441                     ipixel->lnk = 1;
04442                 }
04443 #           endif
04444         };
04445                 break;
04446             default:
04447                 VPBug("illegal value for run state at end of scanline");
04448             }
04449         } else if (last_run_state == ALL_ZERO) {
04450             Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
04451         } else {
04452             Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
04453         }
04454 #endif /* UNROLL_RUN_LOOP */
04455 #endif /* SKIP_COMPOSITE */
04456 
04457 #ifndef UNROLL_RUN_LOOP
04458         run_state = final_run_state;
04459 #endif
04460         /* skip over any zero-length runs remaining in this scanline */
04461         if (j != 0 && ((run_state & 1) == 0)) {
04462             toprun_count = *topRLElen++;
04463             ASSERT(toprun_count == 0);
04464         }
04465         if (j != jcount && ((run_state & 2) == 0)) {
04466             botrun_count = *botRLElen++;
04467             ASSERT(botrun_count == 0);
04468         }
04469 
04470         /* go to next intermediate image scanline */
04471 #ifdef UNROLL_RUN_LOOP
04472         ipixel += intermediate_width - icount;
04473 #ifdef USE_SHADOW_BUFFER
04474         shadow_pixel += shadow_width - icount;
04475 #endif
04476 #else /* UNROLL_RUN_LOOP */
04477         ipixel += intermediate_width - (icount+1);
04478 #ifdef USE_SHADOW_BUFFER
04479         shadow_pixel += shadow_width - (icount+1);
04480 #endif
04481 #endif /* UNROLL_RUN_LOOP */
04482 
04483         Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
04484     } /* for j */
04485 
04486     /***************************************************************
04487      * Finish processing the voxel slice.
04488      ***************************************************************/
04489 
04490     GET_HIRES_TIME(vpc, t1);
04491     STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
04492 
04493     Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
04494 }
 

Powered by Plone

This site conforms to the following standards: