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_compAR3PB.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:22 $
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 #undef UNROLL_RUN_LOOP
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 #define CALLBACK
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 
00123 
00124 
00125 #define RGB
00126     
00127     
00128     
00129     
00130 
00131 
00132 
00133 
00134 
00135 #define RAWVOLUME
00136         
00137         
00138         
00139         
00140         
00141         
00142         
00143 
00144 
00145 #undef INDEX_VOLUME
00146 
00147 
00148 
00149     
00150     
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 /* codes indicating the types of a pair of runs in adjacent scanlines */
00160 #define ALL_ZERO        0       /* both runs are runs of zeros */
00161 #define TOP_NONZERO     1       /* run for top scanline has nonzero data */
00162 #define BOT_NONZERO     2       /* run for bottom scanline has nonzero data */
00163 #define ALL_NONZERO     3       /* both runs have nonzero data */
00164 
00165 /* codes indicating the types for the current left and right voxel pairs */
00166 #define ALL_ZERO__ALL_ZERO              ((ALL_ZERO << 2) | ALL_ZERO)
00167 #define ALL_ZERO__TOP_NONZERO           ((ALL_ZERO << 2) | TOP_NONZERO)
00168 #define ALL_ZERO__BOT_NONZERO           ((ALL_ZERO << 2) | BOT_NONZERO)
00169 #define ALL_ZERO__ALL_NONZERO           ((ALL_ZERO << 2) | ALL_NONZERO)
00170 #define TOP_NONZERO__ALL_ZERO           ((TOP_NONZERO << 2) | ALL_ZERO)
00171 #define TOP_NONZERO__TOP_NONZERO        ((TOP_NONZERO << 2) | TOP_NONZERO)
00172 #define TOP_NONZERO__BOT_NONZERO        ((TOP_NONZERO << 2) | BOT_NONZERO)
00173 #define TOP_NONZERO__ALL_NONZERO        ((TOP_NONZERO << 2) | ALL_NONZERO)
00174 #define BOT_NONZERO__ALL_ZERO           ((BOT_NONZERO << 2) | ALL_ZERO)
00175 #define BOT_NONZERO__TOP_NONZERO        ((BOT_NONZERO << 2) | TOP_NONZERO)
00176 #define BOT_NONZERO__BOT_NONZERO        ((BOT_NONZERO << 2) | BOT_NONZERO)
00177 #define BOT_NONZERO__ALL_NONZERO        ((BOT_NONZERO << 2) | ALL_NONZERO)
00178 #define ALL_NONZERO__ALL_ZERO           ((ALL_NONZERO << 2) | ALL_ZERO)
00179 #define ALL_NONZERO__TOP_NONZERO        ((ALL_NONZERO << 2) | TOP_NONZERO)
00180 #define ALL_NONZERO__BOT_NONZERO        ((ALL_NONZERO << 2) | BOT_NONZERO)
00181 #define ALL_NONZERO__ALL_NONZERO        ((ALL_NONZERO << 2) | ALL_NONZERO)
00182 
00183 #ifdef SKIP_ERT
00184 #define PIXEL_IS_OPAQUE(ipixel) 0
00185 #else
00186 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00187 #endif
00188 
00189 #ifdef STATISTICS
00190 extern int vpResampleCount;
00191 extern int vpCompositeCount;
00192 extern int vpERTSkipCount;
00193 extern int vpERTSkipAgainCount;
00194 extern int vpERTUpdateCount;
00195 extern int vpSpecialZeroSkipCount;
00196 extern int vpRunFragmentCount;
00197 #define COUNT_RESAMPLE          vpResampleCount++
00198 #define COUNT_COMPOSITE         vpCompositeCount++
00199 #define COUNT_ERT_SKIP          vpERTSkipCount++
00200 #define COUNT_ERT_SKIP_AGAIN    vpERTSkipAgainCount++
00201 #define COUNT_ERT_UPDATE        vpERTUpdateCount++
00202 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00203 #define COUNT_RUN_FRAGMENT      vpRunFragmentCount++
00204 #else
00205 #define COUNT_RESAMPLE
00206 #define COUNT_COMPOSITE
00207 #define COUNT_ERT_SKIP
00208 #define COUNT_ERT_SKIP_AGAIN
00209 #define COUNT_ERT_UPDATE
00210 #define COUNT_SPECIAL_ZERO_SKIP
00211 #define COUNT_RUN_FRAGMENT
00212 #endif /* STATISTICS */
00213 
00214 /*
00215  * VPCompAR3PB
00216  *
00217  * Compositing routine for run-length encoded volume data slices.
00218  * Decode and resample one slice of volume data, and composite
00219  * it into the intermediate image.  The resampling filter is a bilirp.
00220  */
00221 
00222 void
00223 VPCompAR3PB (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00224           weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00225           voxel_data, voxel_istride, voxel_jstride )
00226 vpContext *vpc;                 /* context */
00227 int icount;                     /* slice size */
00228 int jcount;
00229 int k;                          /* slice number */
00230 double slice_depth_cueing_dbl;  /* depth cueing factor for slice */
00231 RGBIntPixel *intimage;          /* intermediate image pixels */
00232 double weightTLdbl;             /* resampling weights */
00233 double weightBLdbl;
00234 double weightTRdbl;
00235 double weightBRdbl;
00236 
00237                 void *voxel_data;               /* voxel data for slice */
00238                 int voxel_istride;              /* strides for voxel data */
00239                 int voxel_jstride;
00240 
00241 {
00242     int i, j;                   /* voxel index in rotated object space */
00243     RGBIntPixel *ipixel;        /* current intermediate image pixel */
00244     RGBIntPixel *ipixel2;       /* another intermediate image pixel */
00245     int update_interval;        /* # of pixels to skip when updating links */
00246     float iopc;                 /* intermediate pixel opacity (0-1) */
00247     float iopc_inv;             /* 1-iopc */
00248     float acc_opc;              /* accumulator for resampled voxel opacity */
00249     float top_opc, bot_opc;     /* voxel opacity (top and bottom scanlines) */
00250 #ifdef NO_REUSE_VOXEL
00251 #define voxels_loaded   0
00252 #define CLEAR_VOXELS_LOADED
00253 #define SET_VOXELS_LOADED
00254 #else
00255     int voxels_loaded;          /* if true, top/bot_opc contain valid
00256                                    data loaded during the last resample */
00257 #define CLEAR_VOXELS_LOADED     voxels_loaded = 0
00258 #define SET_VOXELS_LOADED       voxels_loaded = 1
00259 #endif
00260     float wgtTL, wgtBL,         /* weights in the range 0..1 which give the */
00261           wgtTR, wgtBR;         /*   fractional contribution of the */
00262                                 /*   neighboring voxels to the current */
00263                                 /*   intermediate image pixel */
00264     unsigned char *topRLElen;   /* length of current run in top scanline */
00265     unsigned char *botRLElen;   /* length of current run in bottom scanline */
00266     char *topRLEdata;           /* data for current run in top scanline */
00267     char *botRLEdata;           /* data for current run in bottom scanline */
00268     int toprun_count;           /* number of voxels left in top run */
00269     int botrun_count;           /* number of voxels left in bottom run */
00270     int last_run_state;         /* run state code for last resample */
00271     int run_state;              /* run state code for this resample */
00272     int final_run_state;        /* run state code for end of scanline */
00273     float min_opacity;          /* low opacity threshold */
00274     float max_opacity;          /* high opacity threshold */
00275     float slice_depth_cueing;   /* depth cueing factor for slice */
00276     float *opac_correct;        /* opacity correction table */
00277     int ert_skip_count;         /* number of pixels to skip for ERT */
00278     int intermediate_width;     /* width of intermediate image in pixels */
00279     int count;                  /* voxels left in current run */
00280     float *shade_table;         /* shade lookup table */
00281     int norm_offset;            /* byte offset to shade table index in voxel */
00282     int shade_index;            /* shade index */
00283     float shade_factor;         /* attenuation factor for color
00284                                    (voxel opacity * depth cueing) */
00285 
00286 #ifdef MULTIPLE_MATERIALS
00287     float *weight_table;        /* weight lookup table */
00288     int wgt_offset;             /* byte offset to weight table index */
00289     int weight_index;           /* weight index */
00290     int m, num_materials;
00291     float weight1, weight2;
00292 #endif /* MULTIPLE_MATERIALS */
00293 
00294 #ifdef GRAYSCALE
00295     float acc_clr;              /* accumulator for resampled color */
00296     float top_clr, bot_clr;     /* voxel color (top and bottom scanlines) */
00297 #endif /* GRAYSCALE */
00298 
00299 #ifdef RGB
00300     float acc_rclr;             /* accumulator for resampled color */
00301     float acc_gclr;
00302     float acc_bclr;
00303     float top_rclr;             /* voxel color (top and bottom scanlines) */
00304     float bot_rclr;
00305     float top_gclr;
00306     float bot_gclr;
00307     float top_bclr;
00308     float bot_bclr;
00309 #endif
00310 
00311 #ifdef RLEVOLUME
00312     int voxel_istride;          /* size of a voxel in bytes */
00313 #endif
00314 
00315 #ifdef RAWVOLUME
00316     int use_octree;             /* if true then use the min-max octree */
00317     MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00318                                 /* stack for traversal of min-max octree */
00319     int scans_left;             /* scanlines until next octree traversal */
00320     int best_view_axis;         /* viewing axis */
00321     unsigned char runlen_buf1[VP_MAX_VOLUME_DIM]; /* buffers for run lengths */
00322     unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00323     unsigned char *top_len_base;/* first run length for top scanline */
00324     unsigned char *bot_len_base;/* first run length for bottom scanline */
00325     int opac_param;             /* parameter to opacity transfer function */
00326     float opacity;              /* voxel opacity */
00327     int opacity_int;            /* voxel opacity truncated to an integer */
00328     int param0_offset;          /* offset to first parameter in voxel */
00329     int param0_size;            /* size of first parameter in bytes */
00330     float *param0_table;        /* lookup table for first parameter */
00331     int param1_offset;          /* offset to second parameter in voxel */
00332     int param1_size;            /* size of second parameter in bytes */
00333     float *param1_table;        /* lookup table for second parameter */
00334     int param2_offset;          /* offset to third parameter in voxel */
00335     int param2_size;            /* size of third parameter in bytes */
00336     float *param2_table;        /* lookup table for third parameter */
00337 #endif /* RAWVOLUME */
00338 
00339 #ifdef INDEX_VOLUME
00340     unsigned char *scanline_topRLElen; /* first topRLElen in scanline */
00341     unsigned char *scanline_botRLElen; /* first botRLElen in scanline */
00342     char *scanline_topRLEdata;  /* first topRLEdata in scanline */
00343     char *scanline_botRLEdata;  /* first botRLEdata in scanline */
00344     VoxelLocation *top_voxel_index; /* voxel indexes for top scanline */
00345     VoxelLocation *bot_voxel_index; /* voxel indexes for bot scanline */
00346     VoxelLocation *vindex;
00347     int next_i;                 /* i coordinate of voxel to skip to */
00348     int next_scan;              /* true if skipped to next scanline */
00349 #endif /* INDEX_VOLUME */
00350 
00351 #ifdef CALLBACK
00352                                 /* shading callback function */
00353 #ifdef GRAYSCALE
00354     void (*shade_func) ANSI_ARGS((void *, float *, void *));
00355 #endif
00356 #ifdef RGB
00357     void (*shade_func) ANSI_ARGS((void *, float *, float *, float *, void *));
00358 #endif
00359     void *client_data;          /* client data handle */
00360 #endif /* CALLBACK */
00361 
00362 #ifdef USE_SHADOW_BUFFER
00363     float *shadow_table;        /* color lookup table for shadows */
00364     int shadow_width;           /* width of shadow buffer */
00365     GrayIntPixel *shadow_pixel; /* current shadow buffer pixel */
00366 #ifdef GRAYSCALE
00367     float top_sclr, bot_sclr;   /* shadow color (top and bottom scanlines) */
00368 #endif /* GRAYSCALE */
00369 #ifdef RGB
00370     float top_rsclr;            /* shadow color (top and bottom scanlines) */
00371     float bot_rsclr;
00372     float top_gsclr;
00373     float bot_gsclr;
00374     float top_bsclr;
00375     float bot_bsclr;
00376 #endif
00377 #endif /* SHADOW_BUFFER */
00378 
00379 #ifdef DEBUG
00380     float trace_opcTL, trace_opcBL, trace_opcTR, trace_opcBR;
00381     float trace_rsclrTL, trace_rsclrBL, trace_rsclrTR, trace_rsclrBR;
00382     float trace_rclrTL, trace_rclrBL, trace_rclrTR, trace_rclrBR;
00383     float trace_gclrTL, trace_gclrBL, trace_gclrTR, trace_gclrBR;
00384     float trace_bclrTL, trace_bclrBL, trace_bclrTR, trace_bclrBR;
00385     RGBIntPixel *trace_pixel_ptr;
00386 
00387 #ifdef COMPUTE_SHADOW_BUFFER
00388     int slice_u_int, shadow_slice_u_int;
00389     int slice_v_int, shadow_slice_v_int;
00390 #endif
00391 #endif /* DEBUG */
00392 
00393     DECLARE_HIRES_TIME(t0);
00394     DECLARE_HIRES_TIME(t1);
00395 
00396     /*******************************************************************
00397      * Copy parameters from the rendering context into local variables.
00398      *******************************************************************/
00399 
00400     GET_HIRES_TIME(vpc, t0);
00401 
00402     wgtTL = weightTLdbl;
00403     wgtBL = weightBLdbl;
00404     wgtTR = weightTRdbl;
00405     wgtBR = weightBRdbl;
00406     slice_depth_cueing = slice_depth_cueing_dbl;
00407     min_opacity = vpc->min_opacity;
00408     max_opacity = vpc->max_opacity;
00409 #ifdef USE_SHADOW_BUFFER
00410     opac_correct = vpc->shadow_opac_correct;
00411 #else
00412     opac_correct = vpc->affine_opac_correct;
00413 #endif
00414 #ifdef COMPUTE_SHADOW_BUFFER
00415     intermediate_width = vpc->shadow_width;
00416 #else
00417     intermediate_width = vpc->intermediate_width;
00418 #endif
00419 #ifdef USE_SHADOW_BUFFER
00420     shadow_table = vpc->shadow_color_table;
00421     shadow_width = vpc->shadow_width;
00422     shadow_pixel = shadow_buffer;
00423 #endif
00424     ipixel = intimage;
00425     shade_table = vpc->shade_color_table;
00426     norm_offset = vpc->field_offset[vpc->color_field];
00427 
00428 #ifdef MULTIPLE_MATERIALS
00429     weight_table = vpc->shade_weight_table;
00430     wgt_offset = vpc->field_offset[vpc->weight_field];
00431     num_materials = vpc->num_materials;
00432 #endif /* MULTIPLE_MATERIALS */
00433 
00434 #ifdef RLEVOLUME
00435     topRLEdata = voxel_data;
00436     botRLEdata = voxel_data;
00437     topRLElen = run_lengths;
00438     botRLElen = run_lengths;
00439     voxel_istride = vpc->rle_bytes_per_voxel;
00440 #endif /* RLEVOLUME */
00441 
00442 #ifdef RAWVOLUME
00443     ASSERT(vpc->num_clsfy_params > 0);
00444     ASSERT(vpc->num_clsfy_params < 3);
00445     param0_offset = vpc->field_offset[vpc->param_field[0]];
00446     param0_size = vpc->field_size[vpc->param_field[0]];
00447     param0_table = vpc->clsfy_table[0];
00448     if (vpc->num_clsfy_params > 1) {
00449         param1_offset = vpc->field_offset[vpc->param_field[1]];
00450         param1_size = vpc->field_size[vpc->param_field[1]];
00451         param1_table = vpc->clsfy_table[1];
00452     } else {
00453         param1_offset = 0;
00454         param1_size = 0;
00455         param1_table = NULL;
00456     }
00457     if (vpc->num_clsfy_params > 2) {
00458         param2_offset = vpc->field_offset[vpc->param_field[2]];
00459         param2_size = vpc->field_size[vpc->param_field[2]];
00460         param2_table = vpc->clsfy_table[2];
00461     } else {
00462         param2_offset = 0;
00463         param2_size = 0;
00464         param2_table = NULL;
00465     }
00466     if (vpc->mm_octree == NULL) {
00467         use_octree = 0;
00468     } else {
00469         use_octree = 1;
00470         best_view_axis = vpc->best_view_axis;
00471         VPInitOctreeLevelStack(vpc, level_stack, best_view_axis, k);
00472         scans_left = 0;
00473         bot_len_base = runlen_buf1;
00474     }
00475 #endif /* RAWVOLUME */
00476 
00477 #ifdef CALLBACK
00478     shade_func = vpc->shade_func;
00479     client_data = vpc->client_data;
00480     ASSERT(shade_func != NULL);
00481 #endif
00482 
00483 #ifdef DEBUG
00484     trace_pixel_ptr = 0;
00485     if (vpc->trace_u >= 0 && vpc->trace_v >= 0) {
00486 #ifdef GRAYSCALE
00487         trace_pixel_ptr = &vpc->int_image.gray_intim[vpc->trace_u + 
00488                       vpc->trace_v*vpc->intermediate_width];
00489 #endif
00490 #ifdef RGB
00491         trace_pixel_ptr = &vpc->int_image.rgb_intim[vpc->trace_u + 
00492                       vpc->trace_v*vpc->intermediate_width];
00493 #endif
00494 #ifdef COMPUTE_SHADOW_BUFFER
00495         slice_u_int = (int)ceil(vpc->shear_i * vpc->trace_shadow_k +
00496                                 vpc->trans_i) - 1;
00497         shadow_slice_u_int = (int)ceil(vpc->shadow_shear_i * 
00498                              vpc->trace_shadow_k + vpc->shadow_trans_i) - 1;
00499         slice_v_int = (int)ceil(vpc->shear_j * vpc->trace_shadow_k
00500                                 + vpc->trans_j) - 1;
00501         shadow_slice_v_int = (int)ceil(vpc->shadow_shear_j *
00502                              vpc->trace_shadow_k + vpc->shadow_trans_j) - 1;
00503         trace_pixel_ptr = &vpc->shadow_buffer[vpc->trace_u +
00504                 shadow_slice_u_int - slice_u_int + 
00505                 (vpc->trace_v + shadow_slice_v_int -
00506                 slice_v_int)*vpc->shadow_width];
00507 #endif
00508     }
00509 #endif /* DEBUG */
00510 
00511     /*******************************************************************
00512      * Loop over voxel scanlines.
00513      *******************************************************************/
00514 
00515     for (j = 0; j <= jcount; j++) {
00516 
00517         /***************************************************************
00518          * Initialize counters and flags.
00519          ***************************************************************/
00520 
00521         i = icount;
00522         CLEAR_VOXELS_LOADED;
00523         last_run_state = ALL_ZERO;
00524 
00525 #ifdef RAWVOLUME
00526         botRLEdata = (char *)voxel_data + j*voxel_jstride;
00527         topRLEdata = botRLEdata - voxel_jstride;
00528         if (!use_octree) {
00529             if (j == 0) {
00530                 run_state = BOT_NONZERO;
00531                 toprun_count = icount+2;
00532                 botrun_count = icount;
00533             } else if (j == jcount) {
00534                 run_state = TOP_NONZERO;
00535                 toprun_count = icount;
00536                 botrun_count = icount+2;
00537             } else {
00538                 run_state = ALL_NONZERO;
00539                 toprun_count = icount;
00540                 botrun_count = icount;
00541             }
00542         } else
00543 #endif /* RAWVOLUME */
00544         if (j == 0) {
00545             run_state = BOT_NONZERO;
00546             toprun_count = icount+2;
00547             botrun_count = 0;
00548         } else if (j == jcount) {
00549             run_state = TOP_NONZERO;
00550             toprun_count = 0;
00551             botrun_count = icount+2;
00552         } else {
00553             run_state = ALL_NONZERO;
00554             toprun_count = 0;
00555             botrun_count = 0;
00556         }
00557 
00558 #ifdef INDEX_VOLUME
00559         scanline_topRLElen = topRLElen;
00560         scanline_botRLElen = botRLElen;
00561         scanline_topRLEdata = topRLEdata;
00562         scanline_botRLEdata = botRLEdata;
00563         if (j == 0) {
00564             top_voxel_index = voxel_index;
00565             bot_voxel_index = voxel_index;
00566         } else {
00567             top_voxel_index = bot_voxel_index;
00568             bot_voxel_index += icount;
00569         }
00570 #endif /* INDEX_VOLUME */
00571 
00572         /***************************************************************
00573          * If the volume is not run-length encoded, use the min-max
00574          * to find run lengths for the current voxel scanline.
00575          ***************************************************************/
00576 
00577 #ifdef RAWVOLUME
00578         if (use_octree) {
00579             top_len_base = bot_len_base;
00580             if (scans_left == 0) {
00581                 if (bot_len_base == runlen_buf1)
00582                     bot_len_base = runlen_buf2;
00583                 else
00584                     bot_len_base = runlen_buf1;
00585 
00586                 GET_HIRES_TIME(vpc, t1);
00587                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00588                 COPY_HIRES_TIME(t0, t1);
00589 
00590                 scans_left = VPComputeScanRuns(vpc, level_stack, bot_len_base,
00591                                                best_view_axis, j, icount);
00592 
00593                 GET_HIRES_TIME(vpc, t1);
00594                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_OCTREE, t0, t1);
00595                 COPY_HIRES_TIME(t0, t1);
00596             }
00597 #ifdef DEBUG
00598             if (j > 0)
00599                 VPCheckRuns(vpc, top_len_base, best_view_axis, k, j-1);
00600             if (j < jcount)
00601                 VPCheckRuns(vpc, bot_len_base, best_view_axis, k, j);
00602 #endif
00603             scans_left--;
00604             topRLElen = top_len_base;
00605             botRLElen = bot_len_base;
00606         }
00607 #endif /* RAWVOLUME */
00608 
00609         /***************************************************************
00610          * Loop over runs in the voxel scanline.
00611          ***************************************************************/
00612 
00613         Debug((vpc, VPDEBUG_COMPOSITE, "StartIScan(u=%d,v=%d)\n",
00614                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00615                 sizeof(RGBIntPixel)) % vpc->intermediate_width,
00616                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00617                 sizeof(RGBIntPixel)) / vpc->intermediate_width));
00618 
00619 #ifdef UNROLL_RUN_LOOP
00620         while (i > 0) {
00621 #else
00622         while (i >= 0) {
00623 #endif
00624             /***********************************************************
00625              * Skip over any empty runs at beginning of scanline.
00626              ***********************************************************/
00627 
00628             if (last_run_state == ALL_ZERO) {
00629 #ifndef UNROLL_RUN_LOOP
00630                 if (i == 0) {
00631                     Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00632                     ipixel += 1;
00633                     final_run_state = ALL_ZERO;
00634                     i = -1;
00635                     break;      /* scanline is done */
00636                 }
00637 #endif
00638 
00639                 /* check if this is the start of a new run */
00640                 while (toprun_count == 0) {
00641                     toprun_count = *topRLElen++;
00642                     run_state ^= 1;
00643                 }
00644                 while (botrun_count == 0) {
00645                     botrun_count = *botRLElen++;
00646                     run_state ^= 2;
00647                 }
00648                 if (run_state == ALL_ZERO) {
00649                     COUNT_SPECIAL_ZERO_SKIP;
00650 
00651                     /* find the union of the two runs of voxels */
00652                     count = MIN(toprun_count, botrun_count);
00653                     toprun_count -= count;
00654                     botrun_count -= count;
00655                     ipixel += count;
00656                     topRLEdata += count * voxel_istride;
00657                     botRLEdata += count * voxel_istride;
00658                     i -= count;
00659                     ASSERT(i >= 0);
00660                     Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(%d)\n", count));
00661                     continue;
00662                 }
00663             }
00664 
00665 #ifndef SKIP_ERT
00666             /***********************************************************
00667              * Skip over opaque pixels (early-ray termination).
00668              ***********************************************************/
00669 
00670             if ((ert_skip_count = ipixel->lnk) != 0) {
00671 
00672                 GET_HIRES_TIME(vpc, t1);
00673                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00674                 COPY_HIRES_TIME(t0, t1);
00675 
00676                 COUNT_ERT_SKIP;
00677 
00678 #ifndef UNROLL_RUN_LOOP
00679                 if (i == 0) {
00680                     ipixel += 1;
00681                     final_run_state = last_run_state;
00682                     i = -1;
00683                     Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00684                     break;      /* scanline is done */
00685                 }
00686 #endif
00687 
00688                 /* find out how many pixels to skip */
00689                 if (ert_skip_count < i &&
00690                                 (count = ipixel[ert_skip_count].lnk) != 0) {
00691                     /* follow pointer chain */
00692                     do {
00693                         COUNT_ERT_SKIP_AGAIN;
00694                         ert_skip_count += count;
00695                     } while (ert_skip_count < i &&
00696                                  (count = ipixel[ert_skip_count].lnk) != 0);
00697 
00698                     /* update some of the lnk pointers in the run of opaque
00699                        pixels; the more links we update the longer it will
00700                        take to perform the update, but we will potentially
00701                        save time in future slices by not having to follow
00702                        long pointer chains */
00703                     ipixel2 = ipixel;
00704                     update_interval = 1;
00705                     count = ert_skip_count - 1;
00706                     while (count > 0) {
00707                         COUNT_ERT_UPDATE;
00708                         ipixel2 += update_interval;
00709                         if (count > 255)
00710                             ipixel2->lnk = 255;
00711                         else
00712                             ipixel2->lnk = count;
00713                         update_interval *= 2;
00714                         count -= update_interval;
00715                     }
00716 
00717                     /* update the current link */
00718                     COUNT_ERT_UPDATE;
00719                     if (ert_skip_count > 255)
00720                         ert_skip_count = 255;
00721                     ipixel->lnk = ert_skip_count;
00722                 }
00723 
00724                 /* skip over the opaque pixels */
00725                 if (ert_skip_count > i)
00726                     ert_skip_count = i;
00727                 Debug((vpc, VPDEBUG_COMPOSITE,"ERTSkip(%d)\n",ert_skip_count));
00728                 ipixel += ert_skip_count;
00729                 CLEAR_VOXELS_LOADED;
00730 
00731 #ifdef INDEX_VOLUME
00732                 /* compute i coordinate of voxel to skip to */
00733                 next_i = icount - i + ert_skip_count;
00734                 if (next_i == icount) {
00735                     next_i--;
00736                     next_scan = 1;
00737                 } else {
00738                     next_scan = 0;
00739                 }
00740 
00741                 /* skip over voxels in top scanline */
00742                 vindex = &top_voxel_index[next_i];
00743                 toprun_count = vindex->run_count;
00744                 topRLElen = scanline_topRLElen + vindex->len_offset;
00745                 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00746                     run_state &= ~1;
00747                     topRLEdata = scanline_topRLEdata +
00748                         (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00749                 } else {
00750                     run_state |= 1;
00751                     topRLEdata = scanline_topRLEdata + vindex->data_offset;
00752                 }
00753 
00754                 /* skip over voxels in bottom scanline */
00755                 vindex = &bot_voxel_index[next_i];
00756                 botrun_count = vindex->run_count;
00757                 botRLElen = scanline_botRLElen + vindex->len_offset;
00758                 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00759                     run_state &= ~2;
00760                     botRLEdata = scanline_botRLEdata +
00761                         (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00762                 } else {
00763                     run_state |= 2;
00764                     botRLEdata = scanline_botRLEdata + vindex->data_offset;
00765                 }
00766 
00767                 /* special case to skip over last voxel in scanline */
00768                 if (next_scan) {
00769                     /* advance to beginning of next top scanline */
00770                     while (toprun_count == 0) {
00771                         toprun_count = *topRLElen++;
00772                         run_state ^= 1;
00773                     }
00774                     toprun_count--;
00775                     if (run_state & 1) {
00776                         topRLEdata += 1 * voxel_istride;
00777                     } else {
00778                         topRLEdata += 1 * voxel_istride;
00779                     }
00780 
00781                     /* advance to beginning of next bottom scanline */
00782                     while (botrun_count == 0) {
00783                         botrun_count = *botRLElen++;
00784                         run_state ^= 2;
00785                     }
00786                     botrun_count--;
00787                     if (run_state & 2) {
00788                         botRLEdata += 1 * voxel_istride;
00789                     } else {
00790                         botRLEdata += 1 * voxel_istride;
00791                     }
00792                 }
00793 
00794 #else /* !INDEX_VOLUME */
00795                 /* skip over voxels in top scanline */
00796                 count = ert_skip_count;
00797                 for (;;) {
00798                     if (toprun_count >= count) {
00799                         toprun_count -= count;
00800                         if (run_state & 1) {
00801                             topRLEdata += count * voxel_istride;
00802                         } else {
00803                             topRLEdata += count * voxel_istride;
00804                         }
00805                         break;
00806                     } else {
00807                         count -= toprun_count;
00808                         if (run_state & 1) {
00809                             topRLEdata += toprun_count * voxel_istride;
00810                         } else {
00811                             topRLEdata += toprun_count * voxel_istride;
00812                         }
00813                         toprun_count = *topRLElen++;
00814                         if (toprun_count == 0)
00815                             toprun_count = *topRLElen++;
00816                         else
00817                             run_state ^= 1;
00818                     }
00819                 }
00820 
00821                 /* skip over voxels in bottom scanline */
00822                 count = ert_skip_count;
00823                 for (;;) {
00824                     if (botrun_count >= count) {
00825                         botrun_count -= count;
00826                         if (run_state & 2) {
00827                             botRLEdata += count * voxel_istride;
00828                         } else {
00829                             botRLEdata += count * voxel_istride;
00830                         }
00831                         break;
00832                     } else {
00833                         count -= botrun_count;
00834                         if (run_state & 2) {
00835                             botRLEdata += botrun_count * voxel_istride;
00836                         } else {
00837                             botRLEdata += botrun_count * voxel_istride;
00838                         }
00839                         botrun_count = *botRLElen++;
00840                         if (botrun_count == 0)
00841                             botrun_count = *botRLElen++;
00842                         else
00843                             run_state ^= 2;
00844                     }
00845                 }
00846 #endif /* INDEX_VOLUME */
00847                 i -= ert_skip_count;
00848                 last_run_state = run_state;
00849                 if (i == 0) {
00850 #ifdef UNROLL_RUN_LOOP
00851                     break;
00852 #else
00853                     if (last_run_state == ALL_ZERO) {
00854                         ipixel += 1;
00855                         final_run_state = ALL_ZERO;
00856                         i = -1;
00857                         Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00858                         break;  /* scanline is done */
00859                     }
00860                     if (ipixel->lnk != 0) {
00861                         ipixel += 1;
00862                         final_run_state = last_run_state;
00863                         i = -1;
00864                         Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00865                         break;  /* scanline is done */
00866                     }
00867 #endif /* UNROLL_RUN_LOOP */
00868                 }
00869 
00870                 GET_HIRES_TIME(vpc, t1);
00871                 STORE_HIRES_TIME(vpc, VPTIMER_ERT, t0, t1);
00872                 COPY_HIRES_TIME(t0, t1);
00873             }
00874             ASSERT(ipixel->opcflt < max_opacity);
00875 #endif /* SKIP_ERT */
00876 
00877             /***********************************************************
00878              * Compute the length of the current run.
00879              ***********************************************************/
00880 
00881 #ifndef UNROLL_RUN_LOOP
00882             if (i == 0) {
00883                 final_run_state = last_run_state;
00884                 run_state = ALL_ZERO;
00885                 i = -1;
00886                 count = 1;
00887                 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
00888             } else {
00889 #endif
00890                 /* check if this is the start of a new run */
00891                 while (toprun_count == 0) {
00892                     toprun_count = *topRLElen++;
00893                     run_state ^= 1;
00894                 }
00895                 while (botrun_count == 0) {
00896                     botrun_count = *botRLElen++;
00897                     run_state ^= 2;
00898                 }
00899 
00900                 /* find the union of the two runs of voxels */
00901                 count = MIN(toprun_count, botrun_count);
00902                 toprun_count -= count;
00903                 botrun_count -= count;
00904                 i -= count;
00905                 Debug((vpc, VPDEBUG_COMPOSITE, "Run(%d)\n", count));
00906                 ASSERT(i >= 0);
00907 #ifndef UNROLL_RUN_LOOP
00908             }
00909 #endif
00910             COUNT_RUN_FRAGMENT;
00911 
00912             /***********************************************************
00913              * composite the voxels in the current run.
00914              ***********************************************************/
00915 
00916             GET_HIRES_TIME(vpc, t1);
00917             STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00918             COPY_HIRES_TIME(t0, t1);
00919 
00920 #ifdef SKIP_COMPOSITE
00921             switch (run_state) {
00922             case ALL_ZERO:
00923                 ipixel += count;
00924                 topRLEdata += count * voxel_istride;
00925                 botRLEdata += count * voxel_istride;
00926                 count = 0;
00927                 break;
00928             case TOP_NONZERO:
00929                 ipixel += count;
00930                 topRLEdata += count * voxel_istride;
00931                 botRLEdata += count * voxel_istride;
00932                 count = 0;
00933                 break;
00934             case BOT_NONZERO:
00935                 ipixel += count;
00936                 topRLEdata += count * voxel_istride;
00937                 botRLEdata += count * voxel_istride;
00938                 count = 0;
00939                 break;
00940             case ALL_NONZERO:
00941                 ipixel += count;
00942                 topRLEdata += count * voxel_istride;
00943                 botRLEdata += count * voxel_istride;
00944                 count = 0;
00945                 break;
00946             }
00947 #else /* !SKIP_COMPOSITE */
00948 #ifdef UNROLL_RUN_LOOP
00949             /* this run contains pixels, so process them */
00950             switch ((last_run_state << 2) | run_state) {
00951             case ALL_ZERO__ALL_ZERO:
00952                 /* no voxels contribute to the pixels in this run */
00953                 ipixel += count;
00954                 topRLEdata += count * voxel_istride;
00955                 botRLEdata += count * voxel_istride;
00956                 count = 0;
00957                 break;
00958             case TOP_NONZERO__ALL_ZERO:
00959                 /* only the top-left voxel contributes to the first
00960                    pixel of the run, and the rest are zero */
00961                 if (!voxels_loaded) {
00962                     
00963     
00964             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
00965             opacity = param0_table[opac_param];
00966             if (param1_size != 0) {
00967                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
00968                 opacity *= param1_table[opac_param];
00969                 if (param2_size != 0) {
00970                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
00971                     opacity *= param2_table[opac_param];
00972                 }
00973             }
00974             if (opacity > min_opacity) {
00975                 opacity_int = opacity*255.;
00976                 top_opc = opac_correct[opacity_int];
00977             } else {
00978                 top_opc = (float)0.;
00979             };
00980     
00981     
00982     ;
00983     ;
00984     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
00985                              client_data);
00986     shade_factor = top_opc * slice_depth_cueing;
00987     
00988         top_rclr *= shade_factor;
00989         top_gclr *= shade_factor;
00990         top_bclr *= shade_factor;
00991     ;
00992                 }
00993                 
00994 #ifdef DEBUG
00995     if (ipixel == trace_pixel_ptr) {
00996         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
00997         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
00998         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
00999         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01000         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01001     }
01002 #endif
01003 ;
01004                 
01005        acc_opc = top_opc * wgtTL;
01006        
01007             acc_rclr = top_rclr * wgtTL;
01008             acc_gclr = top_gclr * wgtTL;
01009             acc_bclr = top_bclr * wgtTL;
01010        
01011 #ifdef DEBUG
01012     if (ipixel == trace_pixel_ptr) {
01013         trace_opcTL = top_opc;
01014         trace_rclrTL = top_rclr;
01015                      trace_gclrTL = top_gclr;
01016                      trace_bclrTL = top_bclr;
01017         
01018     }
01019 #endif
01020 ;
01021                 
01022         COUNT_RESAMPLE;
01023         if (acc_opc > min_opacity) {
01024             COUNT_COMPOSITE;
01025             iopc = ipixel->opcflt;
01026 #           ifndef SKIP_ERT
01027                 ASSERT(iopc < max_opacity);
01028 #           endif
01029             iopc_inv = (float)1. - iopc;
01030             
01031         ipixel->rclrflt += acc_rclr * iopc_inv;
01032         ipixel->gclrflt += acc_gclr * iopc_inv;
01033         ipixel->bclrflt += acc_bclr * iopc_inv;
01034             iopc += acc_opc * iopc_inv;
01035             ipixel->opcflt = iopc;
01036             
01037 #ifdef DEBUG
01038     if (ipixel == trace_pixel_ptr) {
01039 #ifdef COMPUTE_SHADOW_BUFFER
01040         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01041 #else
01042         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01043 #endif
01044         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01045         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01046         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01047         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01048         printf("  %3.0f %3.0f\n", iopc*255., 
01049                ipixel->rclrflt);
01050         
01051         
01052         printf("              ");
01053         printf("      %3.0f    ",trace_gclrTL);
01054         printf("      %3.0f    ",trace_gclrBL);
01055         printf("      %3.0f    ",trace_gclrTR);
01056         printf("      %3.0f    ",trace_gclrBR);
01057         printf("      %3.0f\n", ipixel->gclrflt);
01058         printf("              ");
01059         printf("      %3.0f    ",trace_bclrTL);
01060         printf("      %3.0f    ",trace_bclrBL);
01061         printf("      %3.0f    ",trace_bclrTR);
01062         printf("      %3.0f    ",trace_bclrBR);
01063         printf("      %3.0f\n", ipixel->bclrflt);
01064     }
01065 #endif /* DEBUG */
01066 ;
01067 #           ifndef SKIP_ERT
01068                 if (iopc >= max_opacity) {
01069                     ASSERT(ipixel->lnk == 0);
01070                     ipixel->lnk = 1;
01071                 }
01072 #           endif
01073         };
01074                 ipixel += count;
01075                 topRLEdata += count * voxel_istride;
01076                 botRLEdata += count * voxel_istride;
01077                 count = 0;
01078                 break;
01079             case BOT_NONZERO__ALL_ZERO:
01080                 /* only the bottom left voxel contributes to the first
01081                    pixel of the run, and the rest are zero */
01082                 if (!voxels_loaded) {
01083                     
01084     
01085             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01086             opacity = param0_table[opac_param];
01087             if (param1_size != 0) {
01088                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01089                 opacity *= param1_table[opac_param];
01090                 if (param2_size != 0) {
01091                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01092                     opacity *= param2_table[opac_param];
01093                 }
01094             }
01095             if (opacity > min_opacity) {
01096                 opacity_int = opacity*255.;
01097                 bot_opc = opac_correct[opacity_int];
01098             } else {
01099                 bot_opc = (float)0.;
01100             };
01101     
01102     
01103     ;
01104     ;
01105     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
01106                              client_data);
01107     shade_factor = bot_opc * slice_depth_cueing;
01108     
01109         bot_rclr *= shade_factor;
01110         bot_gclr *= shade_factor;
01111         bot_bclr *= shade_factor;
01112     ;
01113                 }
01114                 
01115 #ifdef DEBUG
01116     if (ipixel == trace_pixel_ptr) {
01117         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01118         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01119         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01120         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01121         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01122     }
01123 #endif
01124 ;
01125                 
01126        acc_opc = bot_opc * wgtBL;
01127        
01128             acc_rclr = bot_rclr * wgtBL;
01129             acc_gclr = bot_gclr * wgtBL;
01130             acc_bclr = bot_bclr * wgtBL;
01131        
01132 #ifdef DEBUG
01133     if (ipixel == trace_pixel_ptr) {
01134         trace_opcBL = bot_opc;
01135         trace_rclrBL = bot_rclr;
01136                      trace_gclrBL = bot_gclr;
01137                      trace_bclrBL = bot_bclr;
01138         
01139     }
01140 #endif
01141 ;
01142                 
01143         COUNT_RESAMPLE;
01144         if (acc_opc > min_opacity) {
01145             COUNT_COMPOSITE;
01146             iopc = ipixel->opcflt;
01147 #           ifndef SKIP_ERT
01148                 ASSERT(iopc < max_opacity);
01149 #           endif
01150             iopc_inv = (float)1. - iopc;
01151             
01152         ipixel->rclrflt += acc_rclr * iopc_inv;
01153         ipixel->gclrflt += acc_gclr * iopc_inv;
01154         ipixel->bclrflt += acc_bclr * iopc_inv;
01155             iopc += acc_opc * iopc_inv;
01156             ipixel->opcflt = iopc;
01157             
01158 #ifdef DEBUG
01159     if (ipixel == trace_pixel_ptr) {
01160 #ifdef COMPUTE_SHADOW_BUFFER
01161         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01162 #else
01163         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01164 #endif
01165         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01166         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01167         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01168         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01169         printf("  %3.0f %3.0f\n", iopc*255., 
01170                ipixel->rclrflt);
01171         
01172         
01173         printf("              ");
01174         printf("      %3.0f    ",trace_gclrTL);
01175         printf("      %3.0f    ",trace_gclrBL);
01176         printf("      %3.0f    ",trace_gclrTR);
01177         printf("      %3.0f    ",trace_gclrBR);
01178         printf("      %3.0f\n", ipixel->gclrflt);
01179         printf("              ");
01180         printf("      %3.0f    ",trace_bclrTL);
01181         printf("      %3.0f    ",trace_bclrBL);
01182         printf("      %3.0f    ",trace_bclrTR);
01183         printf("      %3.0f    ",trace_bclrBR);
01184         printf("      %3.0f\n", ipixel->bclrflt);
01185     }
01186 #endif /* DEBUG */
01187 ;
01188 #           ifndef SKIP_ERT
01189                 if (iopc >= max_opacity) {
01190                     ASSERT(ipixel->lnk == 0);
01191                     ipixel->lnk = 1;
01192                 }
01193 #           endif
01194         };
01195                 ipixel += count;
01196                 topRLEdata += count * voxel_istride;
01197                 botRLEdata += count * voxel_istride;
01198                 count = 0;
01199                 break;
01200             case ALL_NONZERO__ALL_ZERO:
01201                 /* the top and bottom left voxels contribute to the
01202                    first pixel of the run, and the rest are zero */
01203                 if (!voxels_loaded) {
01204                     
01205     
01206             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01207             opacity = param0_table[opac_param];
01208             if (param1_size != 0) {
01209                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01210                 opacity *= param1_table[opac_param];
01211                 if (param2_size != 0) {
01212                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01213                     opacity *= param2_table[opac_param];
01214                 }
01215             }
01216             if (opacity > min_opacity) {
01217                 opacity_int = opacity*255.;
01218                 top_opc = opac_correct[opacity_int];
01219             } else {
01220                 top_opc = (float)0.;
01221             };
01222     
01223     
01224     ;
01225     ;
01226     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
01227                              client_data);
01228     shade_factor = top_opc * slice_depth_cueing;
01229     
01230         top_rclr *= shade_factor;
01231         top_gclr *= shade_factor;
01232         top_bclr *= shade_factor;
01233     ;
01234                     
01235     
01236             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01237             opacity = param0_table[opac_param];
01238             if (param1_size != 0) {
01239                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01240                 opacity *= param1_table[opac_param];
01241                 if (param2_size != 0) {
01242                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01243                     opacity *= param2_table[opac_param];
01244                 }
01245             }
01246             if (opacity > min_opacity) {
01247                 opacity_int = opacity*255.;
01248                 bot_opc = opac_correct[opacity_int];
01249             } else {
01250                 bot_opc = (float)0.;
01251             };
01252     
01253     
01254     ;
01255     ;
01256     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
01257                              client_data);
01258     shade_factor = bot_opc * slice_depth_cueing;
01259     
01260         bot_rclr *= shade_factor;
01261         bot_gclr *= shade_factor;
01262         bot_bclr *= shade_factor;
01263     ;
01264                 }
01265                 
01266 #ifdef DEBUG
01267     if (ipixel == trace_pixel_ptr) {
01268         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01269         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01270         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01271         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01272         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01273     }
01274 #endif
01275 ;
01276                 
01277        acc_opc = top_opc * wgtTL;
01278        
01279             acc_rclr = top_rclr * wgtTL;
01280             acc_gclr = top_gclr * wgtTL;
01281             acc_bclr = top_bclr * wgtTL;
01282        
01283 #ifdef DEBUG
01284     if (ipixel == trace_pixel_ptr) {
01285         trace_opcTL = top_opc;
01286         trace_rclrTL = top_rclr;
01287                      trace_gclrTL = top_gclr;
01288                      trace_bclrTL = top_bclr;
01289         
01290     }
01291 #endif
01292 ;
01293                 
01294        acc_opc += bot_opc * wgtBL;
01295        
01296             acc_rclr += bot_rclr * wgtBL;
01297             acc_gclr += bot_gclr * wgtBL;
01298             acc_bclr += bot_bclr * wgtBL;
01299        
01300 #ifdef DEBUG
01301     if (ipixel == trace_pixel_ptr) {
01302         trace_opcBL = bot_opc;
01303         trace_rclrBL = bot_rclr;
01304                      trace_gclrBL = bot_gclr;
01305                      trace_bclrBL = bot_bclr;
01306         
01307     }
01308 #endif
01309 ;
01310                 
01311         COUNT_RESAMPLE;
01312         if (acc_opc > min_opacity) {
01313             COUNT_COMPOSITE;
01314             iopc = ipixel->opcflt;
01315 #           ifndef SKIP_ERT
01316                 ASSERT(iopc < max_opacity);
01317 #           endif
01318             iopc_inv = (float)1. - iopc;
01319             
01320         ipixel->rclrflt += acc_rclr * iopc_inv;
01321         ipixel->gclrflt += acc_gclr * iopc_inv;
01322         ipixel->bclrflt += acc_bclr * iopc_inv;
01323             iopc += acc_opc * iopc_inv;
01324             ipixel->opcflt = iopc;
01325             
01326 #ifdef DEBUG
01327     if (ipixel == trace_pixel_ptr) {
01328 #ifdef COMPUTE_SHADOW_BUFFER
01329         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01330 #else
01331         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01332 #endif
01333         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01334         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01335         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01336         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01337         printf("  %3.0f %3.0f\n", iopc*255., 
01338                ipixel->rclrflt);
01339         
01340         
01341         printf("              ");
01342         printf("      %3.0f    ",trace_gclrTL);
01343         printf("      %3.0f    ",trace_gclrBL);
01344         printf("      %3.0f    ",trace_gclrTR);
01345         printf("      %3.0f    ",trace_gclrBR);
01346         printf("      %3.0f\n", ipixel->gclrflt);
01347         printf("              ");
01348         printf("      %3.0f    ",trace_bclrTL);
01349         printf("      %3.0f    ",trace_bclrBL);
01350         printf("      %3.0f    ",trace_bclrTR);
01351         printf("      %3.0f    ",trace_bclrBR);
01352         printf("      %3.0f\n", ipixel->bclrflt);
01353     }
01354 #endif /* DEBUG */
01355 ;
01356 #           ifndef SKIP_ERT
01357                 if (iopc >= max_opacity) {
01358                     ASSERT(ipixel->lnk == 0);
01359                     ipixel->lnk = 1;
01360                 }
01361 #           endif
01362         };
01363                 ipixel += count;
01364                 topRLEdata += count * voxel_istride;
01365                 botRLEdata += count * voxel_istride;
01366                 count = 0;
01367                 break;
01368             case ALL_ZERO__TOP_NONZERO:
01369                 /* first pixel: only the top-right voxel contributes */
01370                 
01371     
01372             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01373             opacity = param0_table[opac_param];
01374             if (param1_size != 0) {
01375                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01376                 opacity *= param1_table[opac_param];
01377                 if (param2_size != 0) {
01378                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01379                     opacity *= param2_table[opac_param];
01380                 }
01381             }
01382             if (opacity > min_opacity) {
01383                 opacity_int = opacity*255.;
01384                 top_opc = opac_correct[opacity_int];
01385             } else {
01386                 top_opc = (float)0.;
01387             };
01388     
01389     
01390     ;
01391     ;
01392     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
01393                              client_data);
01394     shade_factor = top_opc * slice_depth_cueing;
01395     
01396         top_rclr *= shade_factor;
01397         top_gclr *= shade_factor;
01398         top_bclr *= shade_factor;
01399     ;
01400                 
01401 #ifdef DEBUG
01402     if (ipixel == trace_pixel_ptr) {
01403         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01404         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01405         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01406         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01407         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01408     }
01409 #endif
01410 ;
01411                 
01412        acc_opc = top_opc * wgtTR;
01413        
01414             acc_rclr = top_rclr * wgtTR;
01415             acc_gclr = top_gclr * wgtTR;
01416             acc_bclr = top_bclr * wgtTR;
01417        
01418 #ifdef DEBUG
01419     if (ipixel == trace_pixel_ptr) {
01420         trace_opcTR = top_opc;
01421         trace_rclrTR = top_rclr;
01422                      trace_gclrTR = top_gclr;
01423                      trace_bclrTR = top_bclr;
01424         
01425     }
01426 #endif
01427 ;
01428                 
01429         COUNT_RESAMPLE;
01430         if (acc_opc > min_opacity) {
01431             COUNT_COMPOSITE;
01432             iopc = ipixel->opcflt;
01433 #           ifndef SKIP_ERT
01434                 ASSERT(iopc < max_opacity);
01435 #           endif
01436             iopc_inv = (float)1. - iopc;
01437             
01438         ipixel->rclrflt += acc_rclr * iopc_inv;
01439         ipixel->gclrflt += acc_gclr * iopc_inv;
01440         ipixel->bclrflt += acc_bclr * iopc_inv;
01441             iopc += acc_opc * iopc_inv;
01442             ipixel->opcflt = iopc;
01443             
01444 #ifdef DEBUG
01445     if (ipixel == trace_pixel_ptr) {
01446 #ifdef COMPUTE_SHADOW_BUFFER
01447         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01448 #else
01449         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01450 #endif
01451         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01452         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01453         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01454         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01455         printf("  %3.0f %3.0f\n", iopc*255., 
01456                ipixel->rclrflt);
01457         
01458         
01459         printf("              ");
01460         printf("      %3.0f    ",trace_gclrTL);
01461         printf("      %3.0f    ",trace_gclrBL);
01462         printf("      %3.0f    ",trace_gclrTR);
01463         printf("      %3.0f    ",trace_gclrBR);
01464         printf("      %3.0f\n", ipixel->gclrflt);
01465         printf("              ");
01466         printf("      %3.0f    ",trace_bclrTL);
01467         printf("      %3.0f    ",trace_bclrBL);
01468         printf("      %3.0f    ",trace_bclrTR);
01469         printf("      %3.0f    ",trace_bclrBR);
01470         printf("      %3.0f\n", ipixel->bclrflt);
01471     }
01472 #endif /* DEBUG */
01473 ;
01474 #           ifndef SKIP_ERT
01475                 if (iopc >= max_opacity) {
01476                     ASSERT(ipixel->lnk == 0);
01477                     ipixel->lnk = 1;
01478                 }
01479 #           endif
01480         };
01481                 ipixel += 1;
01482                 topRLEdata += 1 * voxel_istride;
01483                 botRLEdata += 1 * voxel_istride;
01484                 count--;
01485                 SET_VOXELS_LOADED;
01486 
01487                 /* do the rest of the pixels in this run;
01488                    the top-left and top-right voxels contribute */
01489                 while (count > 0) {
01490                     if (PIXEL_IS_OPAQUE(ipixel))
01491                         break;
01492                     if (!voxels_loaded) {
01493                         
01494     
01495             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01496             opacity = param0_table[opac_param];
01497             if (param1_size != 0) {
01498                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01499                 opacity *= param1_table[opac_param];
01500                 if (param2_size != 0) {
01501                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01502                     opacity *= param2_table[opac_param];
01503                 }
01504             }
01505             if (opacity > min_opacity) {
01506                 opacity_int = opacity*255.;
01507                 top_opc = opac_correct[opacity_int];
01508             } else {
01509                 top_opc = (float)0.;
01510             };
01511     
01512     
01513     ;
01514     ;
01515     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
01516                              client_data);
01517     shade_factor = top_opc * slice_depth_cueing;
01518     
01519         top_rclr *= shade_factor;
01520         top_gclr *= shade_factor;
01521         top_bclr *= shade_factor;
01522     ;
01523                     }
01524                     
01525 #ifdef DEBUG
01526     if (ipixel == trace_pixel_ptr) {
01527         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01528         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01529         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01530         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01531         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01532     }
01533 #endif
01534 ;
01535                     
01536        acc_opc = top_opc * wgtTL;
01537        
01538             acc_rclr = top_rclr * wgtTL;
01539             acc_gclr = top_gclr * wgtTL;
01540             acc_bclr = top_bclr * wgtTL;
01541        
01542 #ifdef DEBUG
01543     if (ipixel == trace_pixel_ptr) {
01544         trace_opcTL = top_opc;
01545         trace_rclrTL = top_rclr;
01546                      trace_gclrTL = top_gclr;
01547                      trace_bclrTL = top_bclr;
01548         
01549     }
01550 #endif
01551 ;
01552                     
01553     
01554             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01555             opacity = param0_table[opac_param];
01556             if (param1_size != 0) {
01557                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01558                 opacity *= param1_table[opac_param];
01559                 if (param2_size != 0) {
01560                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01561                     opacity *= param2_table[opac_param];
01562                 }
01563             }
01564             if (opacity > min_opacity) {
01565                 opacity_int = opacity*255.;
01566                 top_opc = opac_correct[opacity_int];
01567             } else {
01568                 top_opc = (float)0.;
01569             };
01570     
01571     
01572     ;
01573     ;
01574     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
01575                              client_data);
01576     shade_factor = top_opc * slice_depth_cueing;
01577     
01578         top_rclr *= shade_factor;
01579         top_gclr *= shade_factor;
01580         top_bclr *= shade_factor;
01581     ;
01582                     
01583        acc_opc += top_opc * wgtTR;
01584        
01585             acc_rclr += top_rclr * wgtTR;
01586             acc_gclr += top_gclr * wgtTR;
01587             acc_bclr += top_bclr * wgtTR;
01588        
01589 #ifdef DEBUG
01590     if (ipixel == trace_pixel_ptr) {
01591         trace_opcTR = top_opc;
01592         trace_rclrTR = top_rclr;
01593                      trace_gclrTR = top_gclr;
01594                      trace_bclrTR = top_bclr;
01595         
01596     }
01597 #endif
01598 ;
01599                     
01600         COUNT_RESAMPLE;
01601         if (acc_opc > min_opacity) {
01602             COUNT_COMPOSITE;
01603             iopc = ipixel->opcflt;
01604 #           ifndef SKIP_ERT
01605                 ASSERT(iopc < max_opacity);
01606 #           endif
01607             iopc_inv = (float)1. - iopc;
01608             
01609         ipixel->rclrflt += acc_rclr * iopc_inv;
01610         ipixel->gclrflt += acc_gclr * iopc_inv;
01611         ipixel->bclrflt += acc_bclr * iopc_inv;
01612             iopc += acc_opc * iopc_inv;
01613             ipixel->opcflt = iopc;
01614             
01615 #ifdef DEBUG
01616     if (ipixel == trace_pixel_ptr) {
01617 #ifdef COMPUTE_SHADOW_BUFFER
01618         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01619 #else
01620         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01621 #endif
01622         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01623         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01624         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01625         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01626         printf("  %3.0f %3.0f\n", iopc*255., 
01627                ipixel->rclrflt);
01628         
01629         
01630         printf("              ");
01631         printf("      %3.0f    ",trace_gclrTL);
01632         printf("      %3.0f    ",trace_gclrBL);
01633         printf("      %3.0f    ",trace_gclrTR);
01634         printf("      %3.0f    ",trace_gclrBR);
01635         printf("      %3.0f\n", ipixel->gclrflt);
01636         printf("              ");
01637         printf("      %3.0f    ",trace_bclrTL);
01638         printf("      %3.0f    ",trace_bclrBL);
01639         printf("      %3.0f    ",trace_bclrTR);
01640         printf("      %3.0f    ",trace_bclrBR);
01641         printf("      %3.0f\n", ipixel->bclrflt);
01642     }
01643 #endif /* DEBUG */
01644 ;
01645 #           ifndef SKIP_ERT
01646                 if (iopc >= max_opacity) {
01647                     ASSERT(ipixel->lnk == 0);
01648                     ipixel->lnk = 1;
01649                 }
01650 #           endif
01651         };
01652                     ipixel += 1;
01653                     topRLEdata += 1 * voxel_istride;
01654                     botRLEdata += 1 * voxel_istride;
01655                     count--;
01656                     SET_VOXELS_LOADED;
01657                 }
01658                 break;
01659             case TOP_NONZERO__TOP_NONZERO:
01660                 /* do the pixels in this run; the top-left and
01661                    top-right voxels contribute */
01662                 while (count > 0) {
01663                     if (PIXEL_IS_OPAQUE(ipixel))
01664                         break;
01665                     if (!voxels_loaded) {
01666                         
01667     
01668             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01669             opacity = param0_table[opac_param];
01670             if (param1_size != 0) {
01671                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01672                 opacity *= param1_table[opac_param];
01673                 if (param2_size != 0) {
01674                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01675                     opacity *= param2_table[opac_param];
01676                 }
01677             }
01678             if (opacity > min_opacity) {
01679                 opacity_int = opacity*255.;
01680                 top_opc = opac_correct[opacity_int];
01681             } else {
01682                 top_opc = (float)0.;
01683             };
01684     
01685     
01686     ;
01687     ;
01688     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
01689                              client_data);
01690     shade_factor = top_opc * slice_depth_cueing;
01691     
01692         top_rclr *= shade_factor;
01693         top_gclr *= shade_factor;
01694         top_bclr *= shade_factor;
01695     ;
01696                     }
01697                     
01698 #ifdef DEBUG
01699     if (ipixel == trace_pixel_ptr) {
01700         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01701         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01702         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01703         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01704         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01705     }
01706 #endif
01707 ;
01708                     
01709        acc_opc = top_opc * wgtTL;
01710        
01711             acc_rclr = top_rclr * wgtTL;
01712             acc_gclr = top_gclr * wgtTL;
01713             acc_bclr = top_bclr * wgtTL;
01714        
01715 #ifdef DEBUG
01716     if (ipixel == trace_pixel_ptr) {
01717         trace_opcTL = top_opc;
01718         trace_rclrTL = top_rclr;
01719                      trace_gclrTL = top_gclr;
01720                      trace_bclrTL = top_bclr;
01721         
01722     }
01723 #endif
01724 ;
01725                     
01726     
01727             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01728             opacity = param0_table[opac_param];
01729             if (param1_size != 0) {
01730                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01731                 opacity *= param1_table[opac_param];
01732                 if (param2_size != 0) {
01733                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01734                     opacity *= param2_table[opac_param];
01735                 }
01736             }
01737             if (opacity > min_opacity) {
01738                 opacity_int = opacity*255.;
01739                 top_opc = opac_correct[opacity_int];
01740             } else {
01741                 top_opc = (float)0.;
01742             };
01743     
01744     
01745     ;
01746     ;
01747     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
01748                              client_data);
01749     shade_factor = top_opc * slice_depth_cueing;
01750     
01751         top_rclr *= shade_factor;
01752         top_gclr *= shade_factor;
01753         top_bclr *= shade_factor;
01754     ;
01755                     
01756        acc_opc += top_opc * wgtTR;
01757        
01758             acc_rclr += top_rclr * wgtTR;
01759             acc_gclr += top_gclr * wgtTR;
01760             acc_bclr += top_bclr * wgtTR;
01761        
01762 #ifdef DEBUG
01763     if (ipixel == trace_pixel_ptr) {
01764         trace_opcTR = top_opc;
01765         trace_rclrTR = top_rclr;
01766                      trace_gclrTR = top_gclr;
01767                      trace_bclrTR = top_bclr;
01768         
01769     }
01770 #endif
01771 ;
01772                     
01773         COUNT_RESAMPLE;
01774         if (acc_opc > min_opacity) {
01775             COUNT_COMPOSITE;
01776             iopc = ipixel->opcflt;
01777 #           ifndef SKIP_ERT
01778                 ASSERT(iopc < max_opacity);
01779 #           endif
01780             iopc_inv = (float)1. - iopc;
01781             
01782         ipixel->rclrflt += acc_rclr * iopc_inv;
01783         ipixel->gclrflt += acc_gclr * iopc_inv;
01784         ipixel->bclrflt += acc_bclr * iopc_inv;
01785             iopc += acc_opc * iopc_inv;
01786             ipixel->opcflt = iopc;
01787             
01788 #ifdef DEBUG
01789     if (ipixel == trace_pixel_ptr) {
01790 #ifdef COMPUTE_SHADOW_BUFFER
01791         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01792 #else
01793         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01794 #endif
01795         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01796         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01797         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01798         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01799         printf("  %3.0f %3.0f\n", iopc*255., 
01800                ipixel->rclrflt);
01801         
01802         
01803         printf("              ");
01804         printf("      %3.0f    ",trace_gclrTL);
01805         printf("      %3.0f    ",trace_gclrBL);
01806         printf("      %3.0f    ",trace_gclrTR);
01807         printf("      %3.0f    ",trace_gclrBR);
01808         printf("      %3.0f\n", ipixel->gclrflt);
01809         printf("              ");
01810         printf("      %3.0f    ",trace_bclrTL);
01811         printf("      %3.0f    ",trace_bclrBL);
01812         printf("      %3.0f    ",trace_bclrTR);
01813         printf("      %3.0f    ",trace_bclrBR);
01814         printf("      %3.0f\n", ipixel->bclrflt);
01815     }
01816 #endif /* DEBUG */
01817 ;
01818 #           ifndef SKIP_ERT
01819                 if (iopc >= max_opacity) {
01820                     ASSERT(ipixel->lnk == 0);
01821                     ipixel->lnk = 1;
01822                 }
01823 #           endif
01824         };
01825                     ipixel += 1;
01826                     topRLEdata += 1 * voxel_istride;
01827                     botRLEdata += 1 * voxel_istride;
01828                     count--;
01829                     SET_VOXELS_LOADED;
01830                 }
01831                 break;
01832             case BOT_NONZERO__TOP_NONZERO:
01833                 /* first pixel: bottom-left and top-right voxels
01834                    contribute */
01835                 if (!voxels_loaded) {
01836                     
01837     
01838             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01839             opacity = param0_table[opac_param];
01840             if (param1_size != 0) {
01841                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01842                 opacity *= param1_table[opac_param];
01843                 if (param2_size != 0) {
01844                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01845                     opacity *= param2_table[opac_param];
01846                 }
01847             }
01848             if (opacity > min_opacity) {
01849                 opacity_int = opacity*255.;
01850                 bot_opc = opac_correct[opacity_int];
01851             } else {
01852                 bot_opc = (float)0.;
01853             };
01854     
01855     
01856     ;
01857     ;
01858     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
01859                              client_data);
01860     shade_factor = bot_opc * slice_depth_cueing;
01861     
01862         bot_rclr *= shade_factor;
01863         bot_gclr *= shade_factor;
01864         bot_bclr *= shade_factor;
01865     ;
01866                 }
01867                 
01868 #ifdef DEBUG
01869     if (ipixel == trace_pixel_ptr) {
01870         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01871         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01872         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01873         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01874         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01875     }
01876 #endif
01877 ;
01878                 
01879        acc_opc = bot_opc * wgtBL;
01880        
01881             acc_rclr = bot_rclr * wgtBL;
01882             acc_gclr = bot_gclr * wgtBL;
01883             acc_bclr = bot_bclr * wgtBL;
01884        
01885 #ifdef DEBUG
01886     if (ipixel == trace_pixel_ptr) {
01887         trace_opcBL = bot_opc;
01888         trace_rclrBL = bot_rclr;
01889                      trace_gclrBL = bot_gclr;
01890                      trace_bclrBL = bot_bclr;
01891         
01892     }
01893 #endif
01894 ;
01895                 
01896     
01897             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01898             opacity = param0_table[opac_param];
01899             if (param1_size != 0) {
01900                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01901                 opacity *= param1_table[opac_param];
01902                 if (param2_size != 0) {
01903                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01904                     opacity *= param2_table[opac_param];
01905                 }
01906             }
01907             if (opacity > min_opacity) {
01908                 opacity_int = opacity*255.;
01909                 top_opc = opac_correct[opacity_int];
01910             } else {
01911                 top_opc = (float)0.;
01912             };
01913     
01914     
01915     ;
01916     ;
01917     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
01918                              client_data);
01919     shade_factor = top_opc * slice_depth_cueing;
01920     
01921         top_rclr *= shade_factor;
01922         top_gclr *= shade_factor;
01923         top_bclr *= shade_factor;
01924     ;
01925                 
01926        acc_opc += top_opc * wgtTR;
01927        
01928             acc_rclr += top_rclr * wgtTR;
01929             acc_gclr += top_gclr * wgtTR;
01930             acc_bclr += top_bclr * wgtTR;
01931        
01932 #ifdef DEBUG
01933     if (ipixel == trace_pixel_ptr) {
01934         trace_opcTR = top_opc;
01935         trace_rclrTR = top_rclr;
01936                      trace_gclrTR = top_gclr;
01937                      trace_bclrTR = top_bclr;
01938         
01939     }
01940 #endif
01941 ;
01942                 
01943         COUNT_RESAMPLE;
01944         if (acc_opc > min_opacity) {
01945             COUNT_COMPOSITE;
01946             iopc = ipixel->opcflt;
01947 #           ifndef SKIP_ERT
01948                 ASSERT(iopc < max_opacity);
01949 #           endif
01950             iopc_inv = (float)1. - iopc;
01951             
01952         ipixel->rclrflt += acc_rclr * iopc_inv;
01953         ipixel->gclrflt += acc_gclr * iopc_inv;
01954         ipixel->bclrflt += acc_bclr * iopc_inv;
01955             iopc += acc_opc * iopc_inv;
01956             ipixel->opcflt = iopc;
01957             
01958 #ifdef DEBUG
01959     if (ipixel == trace_pixel_ptr) {
01960 #ifdef COMPUTE_SHADOW_BUFFER
01961         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01962 #else
01963         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01964 #endif
01965         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01966         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01967         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01968         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01969         printf("  %3.0f %3.0f\n", iopc*255., 
01970                ipixel->rclrflt);
01971         
01972         
01973         printf("              ");
01974         printf("      %3.0f    ",trace_gclrTL);
01975         printf("      %3.0f    ",trace_gclrBL);
01976         printf("      %3.0f    ",trace_gclrTR);
01977         printf("      %3.0f    ",trace_gclrBR);
01978         printf("      %3.0f\n", ipixel->gclrflt);
01979         printf("              ");
01980         printf("      %3.0f    ",trace_bclrTL);
01981         printf("      %3.0f    ",trace_bclrBL);
01982         printf("      %3.0f    ",trace_bclrTR);
01983         printf("      %3.0f    ",trace_bclrBR);
01984         printf("      %3.0f\n", ipixel->bclrflt);
01985     }
01986 #endif /* DEBUG */
01987 ;
01988 #           ifndef SKIP_ERT
01989                 if (iopc >= max_opacity) {
01990                     ASSERT(ipixel->lnk == 0);
01991                     ipixel->lnk = 1;
01992                 }
01993 #           endif
01994         };
01995                 ipixel += 1;
01996                 topRLEdata += 1 * voxel_istride;
01997                 botRLEdata += 1 * voxel_istride;
01998                 count--;
01999                 SET_VOXELS_LOADED;
02000 
02001                 /* do the rest of the pixels in this run;
02002                    the top-left and top-right voxels contribute */
02003                 while (count > 0) {
02004                     if (PIXEL_IS_OPAQUE(ipixel))
02005                         break;
02006                     if (!voxels_loaded) {
02007                         
02008     
02009             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02010             opacity = param0_table[opac_param];
02011             if (param1_size != 0) {
02012                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02013                 opacity *= param1_table[opac_param];
02014                 if (param2_size != 0) {
02015                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02016                     opacity *= param2_table[opac_param];
02017                 }
02018             }
02019             if (opacity > min_opacity) {
02020                 opacity_int = opacity*255.;
02021                 top_opc = opac_correct[opacity_int];
02022             } else {
02023                 top_opc = (float)0.;
02024             };
02025     
02026     
02027     ;
02028     ;
02029     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
02030                              client_data);
02031     shade_factor = top_opc * slice_depth_cueing;
02032     
02033         top_rclr *= shade_factor;
02034         top_gclr *= shade_factor;
02035         top_bclr *= shade_factor;
02036     ;
02037                     }
02038                     
02039 #ifdef DEBUG
02040     if (ipixel == trace_pixel_ptr) {
02041         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02042         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02043         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02044         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02045         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02046     }
02047 #endif
02048 ;
02049                     
02050        acc_opc = top_opc * wgtTL;
02051        
02052             acc_rclr = top_rclr * wgtTL;
02053             acc_gclr = top_gclr * wgtTL;
02054             acc_bclr = top_bclr * wgtTL;
02055        
02056 #ifdef DEBUG
02057     if (ipixel == trace_pixel_ptr) {
02058         trace_opcTL = top_opc;
02059         trace_rclrTL = top_rclr;
02060                      trace_gclrTL = top_gclr;
02061                      trace_bclrTL = top_bclr;
02062         
02063     }
02064 #endif
02065 ;
02066                     
02067     
02068             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02069             opacity = param0_table[opac_param];
02070             if (param1_size != 0) {
02071                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02072                 opacity *= param1_table[opac_param];
02073                 if (param2_size != 0) {
02074                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02075                     opacity *= param2_table[opac_param];
02076                 }
02077             }
02078             if (opacity > min_opacity) {
02079                 opacity_int = opacity*255.;
02080                 top_opc = opac_correct[opacity_int];
02081             } else {
02082                 top_opc = (float)0.;
02083             };
02084     
02085     
02086     ;
02087     ;
02088     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
02089                              client_data);
02090     shade_factor = top_opc * slice_depth_cueing;
02091     
02092         top_rclr *= shade_factor;
02093         top_gclr *= shade_factor;
02094         top_bclr *= shade_factor;
02095     ;
02096                     
02097        acc_opc += top_opc * wgtTR;
02098        
02099             acc_rclr += top_rclr * wgtTR;
02100             acc_gclr += top_gclr * wgtTR;
02101             acc_bclr += top_bclr * wgtTR;
02102        
02103 #ifdef DEBUG
02104     if (ipixel == trace_pixel_ptr) {
02105         trace_opcTR = top_opc;
02106         trace_rclrTR = top_rclr;
02107                      trace_gclrTR = top_gclr;
02108                      trace_bclrTR = top_bclr;
02109         
02110     }
02111 #endif
02112 ;
02113                     
02114         COUNT_RESAMPLE;
02115         if (acc_opc > min_opacity) {
02116             COUNT_COMPOSITE;
02117             iopc = ipixel->opcflt;
02118 #           ifndef SKIP_ERT
02119                 ASSERT(iopc < max_opacity);
02120 #           endif
02121             iopc_inv = (float)1. - iopc;
02122             
02123         ipixel->rclrflt += acc_rclr * iopc_inv;
02124         ipixel->gclrflt += acc_gclr * iopc_inv;
02125         ipixel->bclrflt += acc_bclr * iopc_inv;
02126             iopc += acc_opc * iopc_inv;
02127             ipixel->opcflt = iopc;
02128             
02129 #ifdef DEBUG
02130     if (ipixel == trace_pixel_ptr) {
02131 #ifdef COMPUTE_SHADOW_BUFFER
02132         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02133 #else
02134         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02135 #endif
02136         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02137         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02138         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02139         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02140         printf("  %3.0f %3.0f\n", iopc*255., 
02141                ipixel->rclrflt);
02142         
02143         
02144         printf("              ");
02145         printf("      %3.0f    ",trace_gclrTL);
02146         printf("      %3.0f    ",trace_gclrBL);
02147         printf("      %3.0f    ",trace_gclrTR);
02148         printf("      %3.0f    ",trace_gclrBR);
02149         printf("      %3.0f\n", ipixel->gclrflt);
02150         printf("              ");
02151         printf("      %3.0f    ",trace_bclrTL);
02152         printf("      %3.0f    ",trace_bclrBL);
02153         printf("      %3.0f    ",trace_bclrTR);
02154         printf("      %3.0f    ",trace_bclrBR);
02155         printf("      %3.0f\n", ipixel->bclrflt);
02156     }
02157 #endif /* DEBUG */
02158 ;
02159 #           ifndef SKIP_ERT
02160                 if (iopc >= max_opacity) {
02161                     ASSERT(ipixel->lnk == 0);
02162                     ipixel->lnk = 1;
02163                 }
02164 #           endif
02165         };
02166                     ipixel += 1;
02167                     topRLEdata += 1 * voxel_istride;
02168                     botRLEdata += 1 * voxel_istride;
02169                     count--;
02170                     SET_VOXELS_LOADED;
02171                 }
02172                 break;
02173             case ALL_NONZERO__TOP_NONZERO:
02174                 /* first pixel: top-left, bottom-left and top-right voxels
02175                    contribute */
02176                 if (!voxels_loaded) {
02177                     
02178     
02179             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02180             opacity = param0_table[opac_param];
02181             if (param1_size != 0) {
02182                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02183                 opacity *= param1_table[opac_param];
02184                 if (param2_size != 0) {
02185                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02186                     opacity *= param2_table[opac_param];
02187                 }
02188             }
02189             if (opacity > min_opacity) {
02190                 opacity_int = opacity*255.;
02191                 top_opc = opac_correct[opacity_int];
02192             } else {
02193                 top_opc = (float)0.;
02194             };
02195     
02196     
02197     ;
02198     ;
02199     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
02200                              client_data);
02201     shade_factor = top_opc * slice_depth_cueing;
02202     
02203         top_rclr *= shade_factor;
02204         top_gclr *= shade_factor;
02205         top_bclr *= shade_factor;
02206     ;
02207                     
02208     
02209             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02210             opacity = param0_table[opac_param];
02211             if (param1_size != 0) {
02212                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02213                 opacity *= param1_table[opac_param];
02214                 if (param2_size != 0) {
02215                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02216                     opacity *= param2_table[opac_param];
02217                 }
02218             }
02219             if (opacity > min_opacity) {
02220                 opacity_int = opacity*255.;
02221                 bot_opc = opac_correct[opacity_int];
02222             } else {
02223                 bot_opc = (float)0.;
02224             };
02225     
02226     
02227     ;
02228     ;
02229     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
02230                              client_data);
02231     shade_factor = bot_opc * slice_depth_cueing;
02232     
02233         bot_rclr *= shade_factor;
02234         bot_gclr *= shade_factor;
02235         bot_bclr *= shade_factor;
02236     ;
02237                 }
02238                 
02239 #ifdef DEBUG
02240     if (ipixel == trace_pixel_ptr) {
02241         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02242         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02243         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02244         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02245         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02246     }
02247 #endif
02248 ;
02249                 
02250        acc_opc = top_opc * wgtTL;
02251        
02252             acc_rclr = top_rclr * wgtTL;
02253             acc_gclr = top_gclr * wgtTL;
02254             acc_bclr = top_bclr * wgtTL;
02255        
02256 #ifdef DEBUG
02257     if (ipixel == trace_pixel_ptr) {
02258         trace_opcTL = top_opc;
02259         trace_rclrTL = top_rclr;
02260                      trace_gclrTL = top_gclr;
02261                      trace_bclrTL = top_bclr;
02262         
02263     }
02264 #endif
02265 ;
02266                 
02267        acc_opc += bot_opc * wgtBL;
02268        
02269             acc_rclr += bot_rclr * wgtBL;
02270             acc_gclr += bot_gclr * wgtBL;
02271             acc_bclr += bot_bclr * wgtBL;
02272        
02273 #ifdef DEBUG
02274     if (ipixel == trace_pixel_ptr) {
02275         trace_opcBL = bot_opc;
02276         trace_rclrBL = bot_rclr;
02277                      trace_gclrBL = bot_gclr;
02278                      trace_bclrBL = bot_bclr;
02279         
02280     }
02281 #endif
02282 ;
02283                 
02284     
02285             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02286             opacity = param0_table[opac_param];
02287             if (param1_size != 0) {
02288                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02289                 opacity *= param1_table[opac_param];
02290                 if (param2_size != 0) {
02291                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02292                     opacity *= param2_table[opac_param];
02293                 }
02294             }
02295             if (opacity > min_opacity) {
02296                 opacity_int = opacity*255.;
02297                 top_opc = opac_correct[opacity_int];
02298             } else {
02299                 top_opc = (float)0.;
02300             };
02301     
02302     
02303     ;
02304     ;
02305     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
02306                              client_data);
02307     shade_factor = top_opc * slice_depth_cueing;
02308     
02309         top_rclr *= shade_factor;
02310         top_gclr *= shade_factor;
02311         top_bclr *= shade_factor;
02312     ;
02313                 
02314        acc_opc += top_opc * wgtTR;
02315        
02316             acc_rclr += top_rclr * wgtTR;
02317             acc_gclr += top_gclr * wgtTR;
02318             acc_bclr += top_bclr * wgtTR;
02319        
02320 #ifdef DEBUG
02321     if (ipixel == trace_pixel_ptr) {
02322         trace_opcTR = top_opc;
02323         trace_rclrTR = top_rclr;
02324                      trace_gclrTR = top_gclr;
02325                      trace_bclrTR = top_bclr;
02326         
02327     }
02328 #endif
02329 ;
02330                 
02331         COUNT_RESAMPLE;
02332         if (acc_opc > min_opacity) {
02333             COUNT_COMPOSITE;
02334             iopc = ipixel->opcflt;
02335 #           ifndef SKIP_ERT
02336                 ASSERT(iopc < max_opacity);
02337 #           endif
02338             iopc_inv = (float)1. - iopc;
02339             
02340         ipixel->rclrflt += acc_rclr * iopc_inv;
02341         ipixel->gclrflt += acc_gclr * iopc_inv;
02342         ipixel->bclrflt += acc_bclr * iopc_inv;
02343             iopc += acc_opc * iopc_inv;
02344             ipixel->opcflt = iopc;
02345             
02346 #ifdef DEBUG
02347     if (ipixel == trace_pixel_ptr) {
02348 #ifdef COMPUTE_SHADOW_BUFFER
02349         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02350 #else
02351         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02352 #endif
02353         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02354         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02355         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02356         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02357         printf("  %3.0f %3.0f\n", iopc*255., 
02358                ipixel->rclrflt);
02359         
02360         
02361         printf("              ");
02362         printf("      %3.0f    ",trace_gclrTL);
02363         printf("      %3.0f    ",trace_gclrBL);
02364         printf("      %3.0f    ",trace_gclrTR);
02365         printf("      %3.0f    ",trace_gclrBR);
02366         printf("      %3.0f\n", ipixel->gclrflt);
02367         printf("              ");
02368         printf("      %3.0f    ",trace_bclrTL);
02369         printf("      %3.0f    ",trace_bclrBL);
02370         printf("      %3.0f    ",trace_bclrTR);
02371         printf("      %3.0f    ",trace_bclrBR);
02372         printf("      %3.0f\n", ipixel->bclrflt);
02373     }
02374 #endif /* DEBUG */
02375 ;
02376 #           ifndef SKIP_ERT
02377                 if (iopc >= max_opacity) {
02378                     ASSERT(ipixel->lnk == 0);
02379                     ipixel->lnk = 1;
02380                 }
02381 #           endif
02382         };
02383                 ipixel += 1;
02384                 topRLEdata += 1 * voxel_istride;
02385                 botRLEdata += 1 * voxel_istride;
02386                 count--;
02387                 SET_VOXELS_LOADED;
02388 
02389                 /* do the rest of the pixels in this run;
02390                    the top-left and top-right voxels contribute */
02391                 while (count > 0) {
02392                     if (PIXEL_IS_OPAQUE(ipixel))
02393                         break;
02394                     if (!voxels_loaded) {
02395                         
02396     
02397             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02398             opacity = param0_table[opac_param];
02399             if (param1_size != 0) {
02400                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02401                 opacity *= param1_table[opac_param];
02402                 if (param2_size != 0) {
02403                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02404                     opacity *= param2_table[opac_param];
02405                 }
02406             }
02407             if (opacity > min_opacity) {
02408                 opacity_int = opacity*255.;
02409                 top_opc = opac_correct[opacity_int];
02410             } else {
02411                 top_opc = (float)0.;
02412             };
02413     
02414     
02415     ;
02416     ;
02417     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
02418                              client_data);
02419     shade_factor = top_opc * slice_depth_cueing;
02420     
02421         top_rclr *= shade_factor;
02422         top_gclr *= shade_factor;
02423         top_bclr *= shade_factor;
02424     ;
02425                     }
02426                     
02427 #ifdef DEBUG
02428     if (ipixel == trace_pixel_ptr) {
02429         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02430         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02431         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02432         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02433         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02434     }
02435 #endif
02436 ;
02437                     
02438        acc_opc = top_opc * wgtTL;
02439        
02440             acc_rclr = top_rclr * wgtTL;
02441             acc_gclr = top_gclr * wgtTL;
02442             acc_bclr = top_bclr * wgtTL;
02443        
02444 #ifdef DEBUG
02445     if (ipixel == trace_pixel_ptr) {
02446         trace_opcTL = top_opc;
02447         trace_rclrTL = top_rclr;
02448                      trace_gclrTL = top_gclr;
02449                      trace_bclrTL = top_bclr;
02450         
02451     }
02452 #endif
02453 ;
02454                     
02455     
02456             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02457             opacity = param0_table[opac_param];
02458             if (param1_size != 0) {
02459                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02460                 opacity *= param1_table[opac_param];
02461                 if (param2_size != 0) {
02462                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02463                     opacity *= param2_table[opac_param];
02464                 }
02465             }
02466             if (opacity > min_opacity) {
02467                 opacity_int = opacity*255.;
02468                 top_opc = opac_correct[opacity_int];
02469             } else {
02470                 top_opc = (float)0.;
02471             };
02472     
02473     
02474     ;
02475     ;
02476     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
02477                              client_data);
02478     shade_factor = top_opc * slice_depth_cueing;
02479     
02480         top_rclr *= shade_factor;
02481         top_gclr *= shade_factor;
02482         top_bclr *= shade_factor;
02483     ;
02484                     
02485        acc_opc += top_opc * wgtTR;
02486        
02487             acc_rclr += top_rclr * wgtTR;
02488             acc_gclr += top_gclr * wgtTR;
02489             acc_bclr += top_bclr * wgtTR;
02490        
02491 #ifdef DEBUG
02492     if (ipixel == trace_pixel_ptr) {
02493         trace_opcTR = top_opc;
02494         trace_rclrTR = top_rclr;
02495                      trace_gclrTR = top_gclr;
02496                      trace_bclrTR = top_bclr;
02497         
02498     }
02499 #endif
02500 ;
02501                     
02502         COUNT_RESAMPLE;
02503         if (acc_opc > min_opacity) {
02504             COUNT_COMPOSITE;
02505             iopc = ipixel->opcflt;
02506 #           ifndef SKIP_ERT
02507                 ASSERT(iopc < max_opacity);
02508 #           endif
02509             iopc_inv = (float)1. - iopc;
02510             
02511         ipixel->rclrflt += acc_rclr * iopc_inv;
02512         ipixel->gclrflt += acc_gclr * iopc_inv;
02513         ipixel->bclrflt += acc_bclr * iopc_inv;
02514             iopc += acc_opc * iopc_inv;
02515             ipixel->opcflt = iopc;
02516             
02517 #ifdef DEBUG
02518     if (ipixel == trace_pixel_ptr) {
02519 #ifdef COMPUTE_SHADOW_BUFFER
02520         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02521 #else
02522         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02523 #endif
02524         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02525         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02526         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02527         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02528         printf("  %3.0f %3.0f\n", iopc*255., 
02529                ipixel->rclrflt);
02530         
02531         
02532         printf("              ");
02533         printf("      %3.0f    ",trace_gclrTL);
02534         printf("      %3.0f    ",trace_gclrBL);
02535         printf("      %3.0f    ",trace_gclrTR);
02536         printf("      %3.0f    ",trace_gclrBR);
02537         printf("      %3.0f\n", ipixel->gclrflt);
02538         printf("              ");
02539         printf("      %3.0f    ",trace_bclrTL);
02540         printf("      %3.0f    ",trace_bclrBL);
02541         printf("      %3.0f    ",trace_bclrTR);
02542         printf("      %3.0f    ",trace_bclrBR);
02543         printf("      %3.0f\n", ipixel->bclrflt);
02544     }
02545 #endif /* DEBUG */
02546 ;
02547 #           ifndef SKIP_ERT
02548                 if (iopc >= max_opacity) {
02549                     ASSERT(ipixel->lnk == 0);
02550                     ipixel->lnk = 1;
02551                 }
02552 #           endif
02553         };
02554                     ipixel += 1;
02555                     topRLEdata += 1 * voxel_istride;
02556                     botRLEdata += 1 * voxel_istride;
02557                     count--;
02558                     SET_VOXELS_LOADED;
02559                 }
02560                 break;
02561             case ALL_ZERO__BOT_NONZERO:
02562                 /* first pixel: only the bottom-right voxel contributes */
02563                 
02564     
02565             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02566             opacity = param0_table[opac_param];
02567             if (param1_size != 0) {
02568                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02569                 opacity *= param1_table[opac_param];
02570                 if (param2_size != 0) {
02571                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02572                     opacity *= param2_table[opac_param];
02573                 }
02574             }
02575             if (opacity > min_opacity) {
02576                 opacity_int = opacity*255.;
02577                 bot_opc = opac_correct[opacity_int];
02578             } else {
02579                 bot_opc = (float)0.;
02580             };
02581     
02582     
02583     ;
02584     ;
02585     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
02586                              client_data);
02587     shade_factor = bot_opc * slice_depth_cueing;
02588     
02589         bot_rclr *= shade_factor;
02590         bot_gclr *= shade_factor;
02591         bot_bclr *= shade_factor;
02592     ;
02593                 
02594 #ifdef DEBUG
02595     if (ipixel == trace_pixel_ptr) {
02596         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02597         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02598         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02599         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02600         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02601     }
02602 #endif
02603 ;
02604                 
02605        acc_opc = bot_opc * wgtBR;
02606        
02607             acc_rclr = bot_rclr * wgtBR;
02608             acc_gclr = bot_gclr * wgtBR;
02609             acc_bclr = bot_bclr * wgtBR;
02610        
02611 #ifdef DEBUG
02612     if (ipixel == trace_pixel_ptr) {
02613         trace_opcBR = bot_opc;
02614         trace_rclrBR = bot_rclr;
02615                      trace_gclrBR = bot_gclr;
02616                      trace_bclrBR = bot_bclr;
02617         
02618     }
02619 #endif
02620 ;
02621                 
02622         COUNT_RESAMPLE;
02623         if (acc_opc > min_opacity) {
02624             COUNT_COMPOSITE;
02625             iopc = ipixel->opcflt;
02626 #           ifndef SKIP_ERT
02627                 ASSERT(iopc < max_opacity);
02628 #           endif
02629             iopc_inv = (float)1. - iopc;
02630             
02631         ipixel->rclrflt += acc_rclr * iopc_inv;
02632         ipixel->gclrflt += acc_gclr * iopc_inv;
02633         ipixel->bclrflt += acc_bclr * iopc_inv;
02634             iopc += acc_opc * iopc_inv;
02635             ipixel->opcflt = iopc;
02636             
02637 #ifdef DEBUG
02638     if (ipixel == trace_pixel_ptr) {
02639 #ifdef COMPUTE_SHADOW_BUFFER
02640         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02641 #else
02642         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02643 #endif
02644         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02645         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02646         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02647         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02648         printf("  %3.0f %3.0f\n", iopc*255., 
02649                ipixel->rclrflt);
02650         
02651         
02652         printf("              ");
02653         printf("      %3.0f    ",trace_gclrTL);
02654         printf("      %3.0f    ",trace_gclrBL);
02655         printf("      %3.0f    ",trace_gclrTR);
02656         printf("      %3.0f    ",trace_gclrBR);
02657         printf("      %3.0f\n", ipixel->gclrflt);
02658         printf("              ");
02659         printf("      %3.0f    ",trace_bclrTL);
02660         printf("      %3.0f    ",trace_bclrBL);
02661         printf("      %3.0f    ",trace_bclrTR);
02662         printf("      %3.0f    ",trace_bclrBR);
02663         printf("      %3.0f\n", ipixel->bclrflt);
02664     }
02665 #endif /* DEBUG */
02666 ;
02667 #           ifndef SKIP_ERT
02668                 if (iopc >= max_opacity) {
02669                     ASSERT(ipixel->lnk == 0);
02670                     ipixel->lnk = 1;
02671                 }
02672 #           endif
02673         };      
02674                 ipixel += 1;
02675                 topRLEdata += 1 * voxel_istride;
02676                 botRLEdata += 1 * voxel_istride;
02677                 count--;
02678                 SET_VOXELS_LOADED;
02679 
02680                 /* do the rest of the pixels in this run;
02681                    bottom-left and bottom-right voxels contribute */
02682                 while (count > 0) {
02683                     if (PIXEL_IS_OPAQUE(ipixel))
02684                         break;
02685                     if (!voxels_loaded) {
02686                         
02687     
02688             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02689             opacity = param0_table[opac_param];
02690             if (param1_size != 0) {
02691                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02692                 opacity *= param1_table[opac_param];
02693                 if (param2_size != 0) {
02694                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02695                     opacity *= param2_table[opac_param];
02696                 }
02697             }
02698             if (opacity > min_opacity) {
02699                 opacity_int = opacity*255.;
02700                 bot_opc = opac_correct[opacity_int];
02701             } else {
02702                 bot_opc = (float)0.;
02703             };
02704     
02705     
02706     ;
02707     ;
02708     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
02709                              client_data);
02710     shade_factor = bot_opc * slice_depth_cueing;
02711     
02712         bot_rclr *= shade_factor;
02713         bot_gclr *= shade_factor;
02714         bot_bclr *= shade_factor;
02715     ;
02716                     }
02717                     
02718 #ifdef DEBUG
02719     if (ipixel == trace_pixel_ptr) {
02720         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02721         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02722         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02723         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02724         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02725     }
02726 #endif
02727 ;
02728                     
02729        acc_opc = bot_opc * wgtBL;
02730        
02731             acc_rclr = bot_rclr * wgtBL;
02732             acc_gclr = bot_gclr * wgtBL;
02733             acc_bclr = bot_bclr * wgtBL;
02734        
02735 #ifdef DEBUG
02736     if (ipixel == trace_pixel_ptr) {
02737         trace_opcBL = bot_opc;
02738         trace_rclrBL = bot_rclr;
02739                      trace_gclrBL = bot_gclr;
02740                      trace_bclrBL = bot_bclr;
02741         
02742     }
02743 #endif
02744 ;
02745                     
02746     
02747             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02748             opacity = param0_table[opac_param];
02749             if (param1_size != 0) {
02750                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02751                 opacity *= param1_table[opac_param];
02752                 if (param2_size != 0) {
02753                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02754                     opacity *= param2_table[opac_param];
02755                 }
02756             }
02757             if (opacity > min_opacity) {
02758                 opacity_int = opacity*255.;
02759                 bot_opc = opac_correct[opacity_int];
02760             } else {
02761                 bot_opc = (float)0.;
02762             };
02763     
02764     
02765     ;
02766     ;
02767     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
02768                              client_data);
02769     shade_factor = bot_opc * slice_depth_cueing;
02770     
02771         bot_rclr *= shade_factor;
02772         bot_gclr *= shade_factor;
02773         bot_bclr *= shade_factor;
02774     ;
02775                     
02776        acc_opc += bot_opc * wgtBR;
02777        
02778             acc_rclr += bot_rclr * wgtBR;
02779             acc_gclr += bot_gclr * wgtBR;
02780             acc_bclr += bot_bclr * wgtBR;
02781        
02782 #ifdef DEBUG
02783     if (ipixel == trace_pixel_ptr) {
02784         trace_opcBR = bot_opc;
02785         trace_rclrBR = bot_rclr;
02786                      trace_gclrBR = bot_gclr;
02787                      trace_bclrBR = bot_bclr;
02788         
02789     }
02790 #endif
02791 ;
02792                     
02793         COUNT_RESAMPLE;
02794         if (acc_opc > min_opacity) {
02795             COUNT_COMPOSITE;
02796             iopc = ipixel->opcflt;
02797 #           ifndef SKIP_ERT
02798                 ASSERT(iopc < max_opacity);
02799 #           endif
02800             iopc_inv = (float)1. - iopc;
02801             
02802         ipixel->rclrflt += acc_rclr * iopc_inv;
02803         ipixel->gclrflt += acc_gclr * iopc_inv;
02804         ipixel->bclrflt += acc_bclr * iopc_inv;
02805             iopc += acc_opc * iopc_inv;
02806             ipixel->opcflt = iopc;
02807             
02808 #ifdef DEBUG
02809     if (ipixel == trace_pixel_ptr) {
02810 #ifdef COMPUTE_SHADOW_BUFFER
02811         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02812 #else
02813         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02814 #endif
02815         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02816         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02817         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02818         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02819         printf("  %3.0f %3.0f\n", iopc*255., 
02820                ipixel->rclrflt);
02821         
02822         
02823         printf("              ");
02824         printf("      %3.0f    ",trace_gclrTL);
02825         printf("      %3.0f    ",trace_gclrBL);
02826         printf("      %3.0f    ",trace_gclrTR);
02827         printf("      %3.0f    ",trace_gclrBR);
02828         printf("      %3.0f\n", ipixel->gclrflt);
02829         printf("              ");
02830         printf("      %3.0f    ",trace_bclrTL);
02831         printf("      %3.0f    ",trace_bclrBL);
02832         printf("      %3.0f    ",trace_bclrTR);
02833         printf("      %3.0f    ",trace_bclrBR);
02834         printf("      %3.0f\n", ipixel->bclrflt);
02835     }
02836 #endif /* DEBUG */
02837 ;
02838 #           ifndef SKIP_ERT
02839                 if (iopc >= max_opacity) {
02840                     ASSERT(ipixel->lnk == 0);
02841                     ipixel->lnk = 1;
02842                 }
02843 #           endif
02844         };
02845                     ipixel += 1;
02846                     topRLEdata += 1 * voxel_istride;
02847                     botRLEdata += 1 * voxel_istride;
02848                     count--;
02849                     SET_VOXELS_LOADED;
02850                 }
02851                 break;
02852             case TOP_NONZERO__BOT_NONZERO:
02853                 /* first pixel: top-left and bottom-right voxels contribute */
02854                 if (!voxels_loaded) {
02855                     
02856     
02857             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02858             opacity = param0_table[opac_param];
02859             if (param1_size != 0) {
02860                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02861                 opacity *= param1_table[opac_param];
02862                 if (param2_size != 0) {
02863                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02864                     opacity *= param2_table[opac_param];
02865                 }
02866             }
02867             if (opacity > min_opacity) {
02868                 opacity_int = opacity*255.;
02869                 top_opc = opac_correct[opacity_int];
02870             } else {
02871                 top_opc = (float)0.;
02872             };
02873     
02874     
02875     ;
02876     ;
02877     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
02878                              client_data);
02879     shade_factor = top_opc * slice_depth_cueing;
02880     
02881         top_rclr *= shade_factor;
02882         top_gclr *= shade_factor;
02883         top_bclr *= shade_factor;
02884     ;
02885                 }
02886                 
02887 #ifdef DEBUG
02888     if (ipixel == trace_pixel_ptr) {
02889         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02890         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02891         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02892         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02893         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02894     }
02895 #endif
02896 ;
02897                 
02898        acc_opc = top_opc * wgtTL;
02899        
02900             acc_rclr = top_rclr * wgtTL;
02901             acc_gclr = top_gclr * wgtTL;
02902             acc_bclr = top_bclr * wgtTL;
02903        
02904 #ifdef DEBUG
02905     if (ipixel == trace_pixel_ptr) {
02906         trace_opcTL = top_opc;
02907         trace_rclrTL = top_rclr;
02908                      trace_gclrTL = top_gclr;
02909                      trace_bclrTL = top_bclr;
02910         
02911     }
02912 #endif
02913 ;
02914                 
02915     
02916             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
02917             opacity = param0_table[opac_param];
02918             if (param1_size != 0) {
02919                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
02920                 opacity *= param1_table[opac_param];
02921                 if (param2_size != 0) {
02922                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
02923                     opacity *= param2_table[opac_param];
02924                 }
02925             }
02926             if (opacity > min_opacity) {
02927                 opacity_int = opacity*255.;
02928                 bot_opc = opac_correct[opacity_int];
02929             } else {
02930                 bot_opc = (float)0.;
02931             };
02932     
02933     
02934     ;
02935     ;
02936     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
02937                              client_data);
02938     shade_factor = bot_opc * slice_depth_cueing;
02939     
02940         bot_rclr *= shade_factor;
02941         bot_gclr *= shade_factor;
02942         bot_bclr *= shade_factor;
02943     ;
02944                 
02945        acc_opc += bot_opc * wgtBR;
02946        
02947             acc_rclr += bot_rclr * wgtBR;
02948             acc_gclr += bot_gclr * wgtBR;
02949             acc_bclr += bot_bclr * wgtBR;
02950        
02951 #ifdef DEBUG
02952     if (ipixel == trace_pixel_ptr) {
02953         trace_opcBR = bot_opc;
02954         trace_rclrBR = bot_rclr;
02955                      trace_gclrBR = bot_gclr;
02956                      trace_bclrBR = bot_bclr;
02957         
02958     }
02959 #endif
02960 ;
02961                 
02962         COUNT_RESAMPLE;
02963         if (acc_opc > min_opacity) {
02964             COUNT_COMPOSITE;
02965             iopc = ipixel->opcflt;
02966 #           ifndef SKIP_ERT
02967                 ASSERT(iopc < max_opacity);
02968 #           endif
02969             iopc_inv = (float)1. - iopc;
02970             
02971         ipixel->rclrflt += acc_rclr * iopc_inv;
02972         ipixel->gclrflt += acc_gclr * iopc_inv;
02973         ipixel->bclrflt += acc_bclr * iopc_inv;
02974             iopc += acc_opc * iopc_inv;
02975             ipixel->opcflt = iopc;
02976             
02977 #ifdef DEBUG
02978     if (ipixel == trace_pixel_ptr) {
02979 #ifdef COMPUTE_SHADOW_BUFFER
02980         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02981 #else
02982         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02983 #endif
02984         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02985         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02986         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02987         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02988         printf("  %3.0f %3.0f\n", iopc*255., 
02989                ipixel->rclrflt);
02990         
02991         
02992         printf("              ");
02993         printf("      %3.0f    ",trace_gclrTL);
02994         printf("      %3.0f    ",trace_gclrBL);
02995         printf("      %3.0f    ",trace_gclrTR);
02996         printf("      %3.0f    ",trace_gclrBR);
02997         printf("      %3.0f\n", ipixel->gclrflt);
02998         printf("              ");
02999         printf("      %3.0f    ",trace_bclrTL);
03000         printf("      %3.0f    ",trace_bclrBL);
03001         printf("      %3.0f    ",trace_bclrTR);
03002         printf("      %3.0f    ",trace_bclrBR);
03003         printf("      %3.0f\n", ipixel->bclrflt);
03004     }
03005 #endif /* DEBUG */
03006 ;
03007 #           ifndef SKIP_ERT
03008                 if (iopc >= max_opacity) {
03009                     ASSERT(ipixel->lnk == 0);
03010                     ipixel->lnk = 1;
03011                 }
03012 #           endif
03013         };
03014                 ipixel += 1;
03015                 topRLEdata += 1 * voxel_istride;
03016                 botRLEdata += 1 * voxel_istride;
03017                 count--;
03018                 SET_VOXELS_LOADED;
03019 
03020                 /* do the rest of the pixels in this run;
03021                    bottom-left and bottom-right voxels contribute */
03022                 while (count > 0) {
03023                     if (PIXEL_IS_OPAQUE(ipixel))
03024                         break;
03025                     if (!voxels_loaded) {
03026                         
03027     
03028             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03029             opacity = param0_table[opac_param];
03030             if (param1_size != 0) {
03031                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03032                 opacity *= param1_table[opac_param];
03033                 if (param2_size != 0) {
03034                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03035                     opacity *= param2_table[opac_param];
03036                 }
03037             }
03038             if (opacity > min_opacity) {
03039                 opacity_int = opacity*255.;
03040                 bot_opc = opac_correct[opacity_int];
03041             } else {
03042                 bot_opc = (float)0.;
03043             };
03044     
03045     
03046     ;
03047     ;
03048     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03049                              client_data);
03050     shade_factor = bot_opc * slice_depth_cueing;
03051     
03052         bot_rclr *= shade_factor;
03053         bot_gclr *= shade_factor;
03054         bot_bclr *= shade_factor;
03055     ;
03056                     }
03057                     
03058 #ifdef DEBUG
03059     if (ipixel == trace_pixel_ptr) {
03060         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03061         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03062         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03063         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03064         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03065     }
03066 #endif
03067 ;
03068                     
03069        acc_opc = bot_opc * wgtBL;
03070        
03071             acc_rclr = bot_rclr * wgtBL;
03072             acc_gclr = bot_gclr * wgtBL;
03073             acc_bclr = bot_bclr * wgtBL;
03074        
03075 #ifdef DEBUG
03076     if (ipixel == trace_pixel_ptr) {
03077         trace_opcBL = bot_opc;
03078         trace_rclrBL = bot_rclr;
03079                      trace_gclrBL = bot_gclr;
03080                      trace_bclrBL = bot_bclr;
03081         
03082     }
03083 #endif
03084 ;
03085                     
03086     
03087             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03088             opacity = param0_table[opac_param];
03089             if (param1_size != 0) {
03090                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03091                 opacity *= param1_table[opac_param];
03092                 if (param2_size != 0) {
03093                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03094                     opacity *= param2_table[opac_param];
03095                 }
03096             }
03097             if (opacity > min_opacity) {
03098                 opacity_int = opacity*255.;
03099                 bot_opc = opac_correct[opacity_int];
03100             } else {
03101                 bot_opc = (float)0.;
03102             };
03103     
03104     
03105     ;
03106     ;
03107     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03108                              client_data);
03109     shade_factor = bot_opc * slice_depth_cueing;
03110     
03111         bot_rclr *= shade_factor;
03112         bot_gclr *= shade_factor;
03113         bot_bclr *= shade_factor;
03114     ;
03115                     
03116        acc_opc += bot_opc * wgtBR;
03117        
03118             acc_rclr += bot_rclr * wgtBR;
03119             acc_gclr += bot_gclr * wgtBR;
03120             acc_bclr += bot_bclr * wgtBR;
03121        
03122 #ifdef DEBUG
03123     if (ipixel == trace_pixel_ptr) {
03124         trace_opcBR = bot_opc;
03125         trace_rclrBR = bot_rclr;
03126                      trace_gclrBR = bot_gclr;
03127                      trace_bclrBR = bot_bclr;
03128         
03129     }
03130 #endif
03131 ;
03132                     
03133         COUNT_RESAMPLE;
03134         if (acc_opc > min_opacity) {
03135             COUNT_COMPOSITE;
03136             iopc = ipixel->opcflt;
03137 #           ifndef SKIP_ERT
03138                 ASSERT(iopc < max_opacity);
03139 #           endif
03140             iopc_inv = (float)1. - iopc;
03141             
03142         ipixel->rclrflt += acc_rclr * iopc_inv;
03143         ipixel->gclrflt += acc_gclr * iopc_inv;
03144         ipixel->bclrflt += acc_bclr * iopc_inv;
03145             iopc += acc_opc * iopc_inv;
03146             ipixel->opcflt = iopc;
03147             
03148 #ifdef DEBUG
03149     if (ipixel == trace_pixel_ptr) {
03150 #ifdef COMPUTE_SHADOW_BUFFER
03151         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03152 #else
03153         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03154 #endif
03155         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03156         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03157         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03158         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03159         printf("  %3.0f %3.0f\n", iopc*255., 
03160                ipixel->rclrflt);
03161         
03162         
03163         printf("              ");
03164         printf("      %3.0f    ",trace_gclrTL);
03165         printf("      %3.0f    ",trace_gclrBL);
03166         printf("      %3.0f    ",trace_gclrTR);
03167         printf("      %3.0f    ",trace_gclrBR);
03168         printf("      %3.0f\n", ipixel->gclrflt);
03169         printf("              ");
03170         printf("      %3.0f    ",trace_bclrTL);
03171         printf("      %3.0f    ",trace_bclrBL);
03172         printf("      %3.0f    ",trace_bclrTR);
03173         printf("      %3.0f    ",trace_bclrBR);
03174         printf("      %3.0f\n", ipixel->bclrflt);
03175     }
03176 #endif /* DEBUG */
03177 ;
03178 #           ifndef SKIP_ERT
03179                 if (iopc >= max_opacity) {
03180                     ASSERT(ipixel->lnk == 0);
03181                     ipixel->lnk = 1;
03182                 }
03183 #           endif
03184         };
03185                     ipixel += 1;
03186                     topRLEdata += 1 * voxel_istride;
03187                     botRLEdata += 1 * voxel_istride;
03188                     count--;
03189                     SET_VOXELS_LOADED;
03190                 }
03191                 break;
03192             case BOT_NONZERO__BOT_NONZERO:
03193                 /* do the pixels in this run; bottom-left and
03194                    bottom-right voxels contribute */
03195                 while (count > 0) {
03196                     if (PIXEL_IS_OPAQUE(ipixel))
03197                         break;
03198                     if (!voxels_loaded) {
03199                         
03200     
03201             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03202             opacity = param0_table[opac_param];
03203             if (param1_size != 0) {
03204                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03205                 opacity *= param1_table[opac_param];
03206                 if (param2_size != 0) {
03207                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03208                     opacity *= param2_table[opac_param];
03209                 }
03210             }
03211             if (opacity > min_opacity) {
03212                 opacity_int = opacity*255.;
03213                 bot_opc = opac_correct[opacity_int];
03214             } else {
03215                 bot_opc = (float)0.;
03216             };
03217     
03218     
03219     ;
03220     ;
03221     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03222                              client_data);
03223     shade_factor = bot_opc * slice_depth_cueing;
03224     
03225         bot_rclr *= shade_factor;
03226         bot_gclr *= shade_factor;
03227         bot_bclr *= shade_factor;
03228     ;
03229                     }
03230                     
03231 #ifdef DEBUG
03232     if (ipixel == trace_pixel_ptr) {
03233         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03234         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03235         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03236         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03237         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03238     }
03239 #endif
03240 ;
03241                     
03242        acc_opc = bot_opc * wgtBL;
03243        
03244             acc_rclr = bot_rclr * wgtBL;
03245             acc_gclr = bot_gclr * wgtBL;
03246             acc_bclr = bot_bclr * wgtBL;
03247        
03248 #ifdef DEBUG
03249     if (ipixel == trace_pixel_ptr) {
03250         trace_opcBL = bot_opc;
03251         trace_rclrBL = bot_rclr;
03252                      trace_gclrBL = bot_gclr;
03253                      trace_bclrBL = bot_bclr;
03254         
03255     }
03256 #endif
03257 ;
03258                     
03259     
03260             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03261             opacity = param0_table[opac_param];
03262             if (param1_size != 0) {
03263                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03264                 opacity *= param1_table[opac_param];
03265                 if (param2_size != 0) {
03266                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03267                     opacity *= param2_table[opac_param];
03268                 }
03269             }
03270             if (opacity > min_opacity) {
03271                 opacity_int = opacity*255.;
03272                 bot_opc = opac_correct[opacity_int];
03273             } else {
03274                 bot_opc = (float)0.;
03275             };
03276     
03277     
03278     ;
03279     ;
03280     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03281                              client_data);
03282     shade_factor = bot_opc * slice_depth_cueing;
03283     
03284         bot_rclr *= shade_factor;
03285         bot_gclr *= shade_factor;
03286         bot_bclr *= shade_factor;
03287     ;
03288                     
03289        acc_opc += bot_opc * wgtBR;
03290        
03291             acc_rclr += bot_rclr * wgtBR;
03292             acc_gclr += bot_gclr * wgtBR;
03293             acc_bclr += bot_bclr * wgtBR;
03294        
03295 #ifdef DEBUG
03296     if (ipixel == trace_pixel_ptr) {
03297         trace_opcBR = bot_opc;
03298         trace_rclrBR = bot_rclr;
03299                      trace_gclrBR = bot_gclr;
03300                      trace_bclrBR = bot_bclr;
03301         
03302     }
03303 #endif
03304 ;
03305                     
03306         COUNT_RESAMPLE;
03307         if (acc_opc > min_opacity) {
03308             COUNT_COMPOSITE;
03309             iopc = ipixel->opcflt;
03310 #           ifndef SKIP_ERT
03311                 ASSERT(iopc < max_opacity);
03312 #           endif
03313             iopc_inv = (float)1. - iopc;
03314             
03315         ipixel->rclrflt += acc_rclr * iopc_inv;
03316         ipixel->gclrflt += acc_gclr * iopc_inv;
03317         ipixel->bclrflt += acc_bclr * iopc_inv;
03318             iopc += acc_opc * iopc_inv;
03319             ipixel->opcflt = iopc;
03320             
03321 #ifdef DEBUG
03322     if (ipixel == trace_pixel_ptr) {
03323 #ifdef COMPUTE_SHADOW_BUFFER
03324         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03325 #else
03326         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03327 #endif
03328         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03329         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03330         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03331         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03332         printf("  %3.0f %3.0f\n", iopc*255., 
03333                ipixel->rclrflt);
03334         
03335         
03336         printf("              ");
03337         printf("      %3.0f    ",trace_gclrTL);
03338         printf("      %3.0f    ",trace_gclrBL);
03339         printf("      %3.0f    ",trace_gclrTR);
03340         printf("      %3.0f    ",trace_gclrBR);
03341         printf("      %3.0f\n", ipixel->gclrflt);
03342         printf("              ");
03343         printf("      %3.0f    ",trace_bclrTL);
03344         printf("      %3.0f    ",trace_bclrBL);
03345         printf("      %3.0f    ",trace_bclrTR);
03346         printf("      %3.0f    ",trace_bclrBR);
03347         printf("      %3.0f\n", ipixel->bclrflt);
03348     }
03349 #endif /* DEBUG */
03350 ;
03351 #           ifndef SKIP_ERT
03352                 if (iopc >= max_opacity) {
03353                     ASSERT(ipixel->lnk == 0);
03354                     ipixel->lnk = 1;
03355                 }
03356 #           endif
03357         };
03358                     ipixel += 1;
03359                     topRLEdata += 1 * voxel_istride;
03360                     botRLEdata += 1 * voxel_istride;
03361                     count--;
03362                     SET_VOXELS_LOADED;
03363                 }
03364                 break;
03365             case ALL_NONZERO__BOT_NONZERO:
03366                 /* first pixel: top-left, bottom-left and bottom-right
03367                    voxels contribute */
03368                 if (!voxels_loaded) {
03369                     
03370     
03371             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03372             opacity = param0_table[opac_param];
03373             if (param1_size != 0) {
03374                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03375                 opacity *= param1_table[opac_param];
03376                 if (param2_size != 0) {
03377                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03378                     opacity *= param2_table[opac_param];
03379                 }
03380             }
03381             if (opacity > min_opacity) {
03382                 opacity_int = opacity*255.;
03383                 top_opc = opac_correct[opacity_int];
03384             } else {
03385                 top_opc = (float)0.;
03386             };
03387     
03388     
03389     ;
03390     ;
03391     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
03392                              client_data);
03393     shade_factor = top_opc * slice_depth_cueing;
03394     
03395         top_rclr *= shade_factor;
03396         top_gclr *= shade_factor;
03397         top_bclr *= shade_factor;
03398     ;
03399                     
03400     
03401             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03402             opacity = param0_table[opac_param];
03403             if (param1_size != 0) {
03404                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03405                 opacity *= param1_table[opac_param];
03406                 if (param2_size != 0) {
03407                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03408                     opacity *= param2_table[opac_param];
03409                 }
03410             }
03411             if (opacity > min_opacity) {
03412                 opacity_int = opacity*255.;
03413                 bot_opc = opac_correct[opacity_int];
03414             } else {
03415                 bot_opc = (float)0.;
03416             };
03417     
03418     
03419     ;
03420     ;
03421     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03422                              client_data);
03423     shade_factor = bot_opc * slice_depth_cueing;
03424     
03425         bot_rclr *= shade_factor;
03426         bot_gclr *= shade_factor;
03427         bot_bclr *= shade_factor;
03428     ;
03429                 }
03430                 
03431 #ifdef DEBUG
03432     if (ipixel == trace_pixel_ptr) {
03433         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03434         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03435         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03436         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03437         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03438     }
03439 #endif
03440 ;
03441                 
03442        acc_opc = top_opc * wgtTL;
03443        
03444             acc_rclr = top_rclr * wgtTL;
03445             acc_gclr = top_gclr * wgtTL;
03446             acc_bclr = top_bclr * wgtTL;
03447        
03448 #ifdef DEBUG
03449     if (ipixel == trace_pixel_ptr) {
03450         trace_opcTL = top_opc;
03451         trace_rclrTL = top_rclr;
03452                      trace_gclrTL = top_gclr;
03453                      trace_bclrTL = top_bclr;
03454         
03455     }
03456 #endif
03457 ;
03458                 
03459        acc_opc += bot_opc * wgtBL;
03460        
03461             acc_rclr += bot_rclr * wgtBL;
03462             acc_gclr += bot_gclr * wgtBL;
03463             acc_bclr += bot_bclr * wgtBL;
03464        
03465 #ifdef DEBUG
03466     if (ipixel == trace_pixel_ptr) {
03467         trace_opcBL = bot_opc;
03468         trace_rclrBL = bot_rclr;
03469                      trace_gclrBL = bot_gclr;
03470                      trace_bclrBL = bot_bclr;
03471         
03472     }
03473 #endif
03474 ;
03475                 
03476     
03477             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03478             opacity = param0_table[opac_param];
03479             if (param1_size != 0) {
03480                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03481                 opacity *= param1_table[opac_param];
03482                 if (param2_size != 0) {
03483                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03484                     opacity *= param2_table[opac_param];
03485                 }
03486             }
03487             if (opacity > min_opacity) {
03488                 opacity_int = opacity*255.;
03489                 bot_opc = opac_correct[opacity_int];
03490             } else {
03491                 bot_opc = (float)0.;
03492             };
03493     
03494     
03495     ;
03496     ;
03497     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03498                              client_data);
03499     shade_factor = bot_opc * slice_depth_cueing;
03500     
03501         bot_rclr *= shade_factor;
03502         bot_gclr *= shade_factor;
03503         bot_bclr *= shade_factor;
03504     ;
03505                 
03506        acc_opc += bot_opc * wgtBR;
03507        
03508             acc_rclr += bot_rclr * wgtBR;
03509             acc_gclr += bot_gclr * wgtBR;
03510             acc_bclr += bot_bclr * wgtBR;
03511        
03512 #ifdef DEBUG
03513     if (ipixel == trace_pixel_ptr) {
03514         trace_opcBR = bot_opc;
03515         trace_rclrBR = bot_rclr;
03516                      trace_gclrBR = bot_gclr;
03517                      trace_bclrBR = bot_bclr;
03518         
03519     }
03520 #endif
03521 ;
03522                 
03523         COUNT_RESAMPLE;
03524         if (acc_opc > min_opacity) {
03525             COUNT_COMPOSITE;
03526             iopc = ipixel->opcflt;
03527 #           ifndef SKIP_ERT
03528                 ASSERT(iopc < max_opacity);
03529 #           endif
03530             iopc_inv = (float)1. - iopc;
03531             
03532         ipixel->rclrflt += acc_rclr * iopc_inv;
03533         ipixel->gclrflt += acc_gclr * iopc_inv;
03534         ipixel->bclrflt += acc_bclr * iopc_inv;
03535             iopc += acc_opc * iopc_inv;
03536             ipixel->opcflt = iopc;
03537             
03538 #ifdef DEBUG
03539     if (ipixel == trace_pixel_ptr) {
03540 #ifdef COMPUTE_SHADOW_BUFFER
03541         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03542 #else
03543         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03544 #endif
03545         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03546         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03547         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03548         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03549         printf("  %3.0f %3.0f\n", iopc*255., 
03550                ipixel->rclrflt);
03551         
03552         
03553         printf("              ");
03554         printf("      %3.0f    ",trace_gclrTL);
03555         printf("      %3.0f    ",trace_gclrBL);
03556         printf("      %3.0f    ",trace_gclrTR);
03557         printf("      %3.0f    ",trace_gclrBR);
03558         printf("      %3.0f\n", ipixel->gclrflt);
03559         printf("              ");
03560         printf("      %3.0f    ",trace_bclrTL);
03561         printf("      %3.0f    ",trace_bclrBL);
03562         printf("      %3.0f    ",trace_bclrTR);
03563         printf("      %3.0f    ",trace_bclrBR);
03564         printf("      %3.0f\n", ipixel->bclrflt);
03565     }
03566 #endif /* DEBUG */
03567 ;
03568 #           ifndef SKIP_ERT
03569                 if (iopc >= max_opacity) {
03570                     ASSERT(ipixel->lnk == 0);
03571                     ipixel->lnk = 1;
03572                 }
03573 #           endif
03574         };
03575                 ipixel += 1;
03576                 topRLEdata += 1 * voxel_istride;
03577                 botRLEdata += 1 * voxel_istride;
03578                 count--;
03579                 SET_VOXELS_LOADED;
03580 
03581                 /* do the rest of the pixels in this run;
03582                    bottom-left and bottom-right voxels contribute */
03583                 while (count > 0) {
03584                     if (PIXEL_IS_OPAQUE(ipixel))
03585                         break;
03586                     if (!voxels_loaded) {
03587                         
03588     
03589             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03590             opacity = param0_table[opac_param];
03591             if (param1_size != 0) {
03592                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03593                 opacity *= param1_table[opac_param];
03594                 if (param2_size != 0) {
03595                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03596                     opacity *= param2_table[opac_param];
03597                 }
03598             }
03599             if (opacity > min_opacity) {
03600                 opacity_int = opacity*255.;
03601                 bot_opc = opac_correct[opacity_int];
03602             } else {
03603                 bot_opc = (float)0.;
03604             };
03605     
03606     
03607     ;
03608     ;
03609     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03610                              client_data);
03611     shade_factor = bot_opc * slice_depth_cueing;
03612     
03613         bot_rclr *= shade_factor;
03614         bot_gclr *= shade_factor;
03615         bot_bclr *= shade_factor;
03616     ;
03617                     }
03618                     
03619 #ifdef DEBUG
03620     if (ipixel == trace_pixel_ptr) {
03621         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03622         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03623         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03624         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03625         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03626     }
03627 #endif
03628 ;
03629                     
03630        acc_opc = bot_opc * wgtBL;
03631        
03632             acc_rclr = bot_rclr * wgtBL;
03633             acc_gclr = bot_gclr * wgtBL;
03634             acc_bclr = bot_bclr * wgtBL;
03635        
03636 #ifdef DEBUG
03637     if (ipixel == trace_pixel_ptr) {
03638         trace_opcBL = bot_opc;
03639         trace_rclrBL = bot_rclr;
03640                      trace_gclrBL = bot_gclr;
03641                      trace_bclrBL = bot_bclr;
03642         
03643     }
03644 #endif
03645 ;
03646                     
03647     
03648             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03649             opacity = param0_table[opac_param];
03650             if (param1_size != 0) {
03651                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03652                 opacity *= param1_table[opac_param];
03653                 if (param2_size != 0) {
03654                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03655                     opacity *= param2_table[opac_param];
03656                 }
03657             }
03658             if (opacity > min_opacity) {
03659                 opacity_int = opacity*255.;
03660                 bot_opc = opac_correct[opacity_int];
03661             } else {
03662                 bot_opc = (float)0.;
03663             };
03664     
03665     
03666     ;
03667     ;
03668     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03669                              client_data);
03670     shade_factor = bot_opc * slice_depth_cueing;
03671     
03672         bot_rclr *= shade_factor;
03673         bot_gclr *= shade_factor;
03674         bot_bclr *= shade_factor;
03675     ;
03676                     
03677        acc_opc += bot_opc * wgtBR;
03678        
03679             acc_rclr += bot_rclr * wgtBR;
03680             acc_gclr += bot_gclr * wgtBR;
03681             acc_bclr += bot_bclr * wgtBR;
03682        
03683 #ifdef DEBUG
03684     if (ipixel == trace_pixel_ptr) {
03685         trace_opcBR = bot_opc;
03686         trace_rclrBR = bot_rclr;
03687                      trace_gclrBR = bot_gclr;
03688                      trace_bclrBR = bot_bclr;
03689         
03690     }
03691 #endif
03692 ;
03693                     
03694         COUNT_RESAMPLE;
03695         if (acc_opc > min_opacity) {
03696             COUNT_COMPOSITE;
03697             iopc = ipixel->opcflt;
03698 #           ifndef SKIP_ERT
03699                 ASSERT(iopc < max_opacity);
03700 #           endif
03701             iopc_inv = (float)1. - iopc;
03702             
03703         ipixel->rclrflt += acc_rclr * iopc_inv;
03704         ipixel->gclrflt += acc_gclr * iopc_inv;
03705         ipixel->bclrflt += acc_bclr * iopc_inv;
03706             iopc += acc_opc * iopc_inv;
03707             ipixel->opcflt = iopc;
03708             
03709 #ifdef DEBUG
03710     if (ipixel == trace_pixel_ptr) {
03711 #ifdef COMPUTE_SHADOW_BUFFER
03712         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03713 #else
03714         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03715 #endif
03716         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03717         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03718         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03719         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03720         printf("  %3.0f %3.0f\n", iopc*255., 
03721                ipixel->rclrflt);
03722         
03723         
03724         printf("              ");
03725         printf("      %3.0f    ",trace_gclrTL);
03726         printf("      %3.0f    ",trace_gclrBL);
03727         printf("      %3.0f    ",trace_gclrTR);
03728         printf("      %3.0f    ",trace_gclrBR);
03729         printf("      %3.0f\n", ipixel->gclrflt);
03730         printf("              ");
03731         printf("      %3.0f    ",trace_bclrTL);
03732         printf("      %3.0f    ",trace_bclrBL);
03733         printf("      %3.0f    ",trace_bclrTR);
03734         printf("      %3.0f    ",trace_bclrBR);
03735         printf("      %3.0f\n", ipixel->bclrflt);
03736     }
03737 #endif /* DEBUG */
03738 ;
03739 #           ifndef SKIP_ERT
03740                 if (iopc >= max_opacity) {
03741                     ASSERT(ipixel->lnk == 0);
03742                     ipixel->lnk = 1;
03743                 }
03744 #           endif
03745         };
03746                     ipixel += 1;
03747                     topRLEdata += 1 * voxel_istride;
03748                     botRLEdata += 1 * voxel_istride;
03749                     count--;
03750                     SET_VOXELS_LOADED;
03751                 }
03752                 break;
03753             case ALL_ZERO__ALL_NONZERO:
03754                 /* first pixel: top-right and bottom-right voxels contribute */
03755                 
03756     
03757             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
03758             opacity = param0_table[opac_param];
03759             if (param1_size != 0) {
03760                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
03761                 opacity *= param1_table[opac_param];
03762                 if (param2_size != 0) {
03763                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
03764                     opacity *= param2_table[opac_param];
03765                 }
03766             }
03767             if (opacity > min_opacity) {
03768                 opacity_int = opacity*255.;
03769                 top_opc = opac_correct[opacity_int];
03770             } else {
03771                 top_opc = (float)0.;
03772             };
03773     
03774     
03775     ;
03776     ;
03777     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
03778                              client_data);
03779     shade_factor = top_opc * slice_depth_cueing;
03780     
03781         top_rclr *= shade_factor;
03782         top_gclr *= shade_factor;
03783         top_bclr *= shade_factor;
03784     ;
03785                 
03786     
03787             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03788             opacity = param0_table[opac_param];
03789             if (param1_size != 0) {
03790                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03791                 opacity *= param1_table[opac_param];
03792                 if (param2_size != 0) {
03793                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03794                     opacity *= param2_table[opac_param];
03795                 }
03796             }
03797             if (opacity > min_opacity) {
03798                 opacity_int = opacity*255.;
03799                 bot_opc = opac_correct[opacity_int];
03800             } else {
03801                 bot_opc = (float)0.;
03802             };
03803     
03804     
03805     ;
03806     ;
03807     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03808                              client_data);
03809     shade_factor = bot_opc * slice_depth_cueing;
03810     
03811         bot_rclr *= shade_factor;
03812         bot_gclr *= shade_factor;
03813         bot_bclr *= shade_factor;
03814     ;
03815                 
03816 #ifdef DEBUG
03817     if (ipixel == trace_pixel_ptr) {
03818         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03819         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03820         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03821         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03822         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03823     }
03824 #endif
03825 ;
03826                 
03827        acc_opc = top_opc * wgtTR;
03828        
03829             acc_rclr = top_rclr * wgtTR;
03830             acc_gclr = top_gclr * wgtTR;
03831             acc_bclr = top_bclr * wgtTR;
03832        
03833 #ifdef DEBUG
03834     if (ipixel == trace_pixel_ptr) {
03835         trace_opcTR = top_opc;
03836         trace_rclrTR = top_rclr;
03837                      trace_gclrTR = top_gclr;
03838                      trace_bclrTR = top_bclr;
03839         
03840     }
03841 #endif
03842 ;
03843                 
03844        acc_opc += bot_opc * wgtBR;
03845        
03846             acc_rclr += bot_rclr * wgtBR;
03847             acc_gclr += bot_gclr * wgtBR;
03848             acc_bclr += bot_bclr * wgtBR;
03849        
03850 #ifdef DEBUG
03851     if (ipixel == trace_pixel_ptr) {
03852         trace_opcBR = bot_opc;
03853         trace_rclrBR = bot_rclr;
03854                      trace_gclrBR = bot_gclr;
03855                      trace_bclrBR = bot_bclr;
03856         
03857     }
03858 #endif
03859 ;
03860                 
03861         COUNT_RESAMPLE;
03862         if (acc_opc > min_opacity) {
03863             COUNT_COMPOSITE;
03864             iopc = ipixel->opcflt;
03865 #           ifndef SKIP_ERT
03866                 ASSERT(iopc < max_opacity);
03867 #           endif
03868             iopc_inv = (float)1. - iopc;
03869             
03870         ipixel->rclrflt += acc_rclr * iopc_inv;
03871         ipixel->gclrflt += acc_gclr * iopc_inv;
03872         ipixel->bclrflt += acc_bclr * iopc_inv;
03873             iopc += acc_opc * iopc_inv;
03874             ipixel->opcflt = iopc;
03875             
03876 #ifdef DEBUG
03877     if (ipixel == trace_pixel_ptr) {
03878 #ifdef COMPUTE_SHADOW_BUFFER
03879         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03880 #else
03881         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03882 #endif
03883         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03884         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03885         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03886         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03887         printf("  %3.0f %3.0f\n", iopc*255., 
03888                ipixel->rclrflt);
03889         
03890         
03891         printf("              ");
03892         printf("      %3.0f    ",trace_gclrTL);
03893         printf("      %3.0f    ",trace_gclrBL);
03894         printf("      %3.0f    ",trace_gclrTR);
03895         printf("      %3.0f    ",trace_gclrBR);
03896         printf("      %3.0f\n", ipixel->gclrflt);
03897         printf("              ");
03898         printf("      %3.0f    ",trace_bclrTL);
03899         printf("      %3.0f    ",trace_bclrBL);
03900         printf("      %3.0f    ",trace_bclrTR);
03901         printf("      %3.0f    ",trace_bclrBR);
03902         printf("      %3.0f\n", ipixel->bclrflt);
03903     }
03904 #endif /* DEBUG */
03905 ;
03906 #           ifndef SKIP_ERT
03907                 if (iopc >= max_opacity) {
03908                     ASSERT(ipixel->lnk == 0);
03909                     ipixel->lnk = 1;
03910                 }
03911 #           endif
03912         };
03913                 ipixel += 1;
03914                 topRLEdata += 1 * voxel_istride;
03915                 botRLEdata += 1 * voxel_istride;
03916                 count--;
03917                 SET_VOXELS_LOADED;
03918 
03919                 /* do the rest of the pixels in this run;
03920                    all four voxels contribute */
03921                 while (count > 0) {
03922                     if (PIXEL_IS_OPAQUE(ipixel))
03923                         break;
03924                     if (!voxels_loaded) {
03925                         
03926     
03927             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03928             opacity = param0_table[opac_param];
03929             if (param1_size != 0) {
03930                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03931                 opacity *= param1_table[opac_param];
03932                 if (param2_size != 0) {
03933                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03934                     opacity *= param2_table[opac_param];
03935                 }
03936             }
03937             if (opacity > min_opacity) {
03938                 opacity_int = opacity*255.;
03939                 top_opc = opac_correct[opacity_int];
03940             } else {
03941                 top_opc = (float)0.;
03942             };
03943     
03944     
03945     ;
03946     ;
03947     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
03948                              client_data);
03949     shade_factor = top_opc * slice_depth_cueing;
03950     
03951         top_rclr *= shade_factor;
03952         top_gclr *= shade_factor;
03953         top_bclr *= shade_factor;
03954     ;
03955                         
03956     
03957             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03958             opacity = param0_table[opac_param];
03959             if (param1_size != 0) {
03960                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03961                 opacity *= param1_table[opac_param];
03962                 if (param2_size != 0) {
03963                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03964                     opacity *= param2_table[opac_param];
03965                 }
03966             }
03967             if (opacity > min_opacity) {
03968                 opacity_int = opacity*255.;
03969                 bot_opc = opac_correct[opacity_int];
03970             } else {
03971                 bot_opc = (float)0.;
03972             };
03973     
03974     
03975     ;
03976     ;
03977     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
03978                              client_data);
03979     shade_factor = bot_opc * slice_depth_cueing;
03980     
03981         bot_rclr *= shade_factor;
03982         bot_gclr *= shade_factor;
03983         bot_bclr *= shade_factor;
03984     ;
03985                     }
03986                     
03987 #ifdef DEBUG
03988     if (ipixel == trace_pixel_ptr) {
03989         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03990         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03991         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03992         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03993         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03994     }
03995 #endif
03996 ;
03997                     
03998        acc_opc = top_opc * wgtTL;
03999        
04000             acc_rclr = top_rclr * wgtTL;
04001             acc_gclr = top_gclr * wgtTL;
04002             acc_bclr = top_bclr * wgtTL;
04003        
04004 #ifdef DEBUG
04005     if (ipixel == trace_pixel_ptr) {
04006         trace_opcTL = top_opc;
04007         trace_rclrTL = top_rclr;
04008                      trace_gclrTL = top_gclr;
04009                      trace_bclrTL = top_bclr;
04010         
04011     }
04012 #endif
04013 ;
04014                     
04015        acc_opc += bot_opc * wgtBL;
04016        
04017             acc_rclr += bot_rclr * wgtBL;
04018             acc_gclr += bot_gclr * wgtBL;
04019             acc_bclr += bot_bclr * wgtBL;
04020        
04021 #ifdef DEBUG
04022     if (ipixel == trace_pixel_ptr) {
04023         trace_opcBL = bot_opc;
04024         trace_rclrBL = bot_rclr;
04025                      trace_gclrBL = bot_gclr;
04026                      trace_bclrBL = bot_bclr;
04027         
04028     }
04029 #endif
04030 ;
04031                     
04032     
04033             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04034             opacity = param0_table[opac_param];
04035             if (param1_size != 0) {
04036                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04037                 opacity *= param1_table[opac_param];
04038                 if (param2_size != 0) {
04039                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04040                     opacity *= param2_table[opac_param];
04041                 }
04042             }
04043             if (opacity > min_opacity) {
04044                 opacity_int = opacity*255.;
04045                 top_opc = opac_correct[opacity_int];
04046             } else {
04047                 top_opc = (float)0.;
04048             };
04049     
04050     
04051     ;
04052     ;
04053     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
04054                              client_data);
04055     shade_factor = top_opc * slice_depth_cueing;
04056     
04057         top_rclr *= shade_factor;
04058         top_gclr *= shade_factor;
04059         top_bclr *= shade_factor;
04060     ;
04061                     
04062     
04063             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04064             opacity = param0_table[opac_param];
04065             if (param1_size != 0) {
04066                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04067                 opacity *= param1_table[opac_param];
04068                 if (param2_size != 0) {
04069                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04070                     opacity *= param2_table[opac_param];
04071                 }
04072             }
04073             if (opacity > min_opacity) {
04074                 opacity_int = opacity*255.;
04075                 bot_opc = opac_correct[opacity_int];
04076             } else {
04077                 bot_opc = (float)0.;
04078             };
04079     
04080     
04081     ;
04082     ;
04083     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04084                              client_data);
04085     shade_factor = bot_opc * slice_depth_cueing;
04086     
04087         bot_rclr *= shade_factor;
04088         bot_gclr *= shade_factor;
04089         bot_bclr *= shade_factor;
04090     ;
04091                     
04092        acc_opc += top_opc * wgtTR;
04093        
04094             acc_rclr += top_rclr * wgtTR;
04095             acc_gclr += top_gclr * wgtTR;
04096             acc_bclr += top_bclr * wgtTR;
04097        
04098 #ifdef DEBUG
04099     if (ipixel == trace_pixel_ptr) {
04100         trace_opcTR = top_opc;
04101         trace_rclrTR = top_rclr;
04102                      trace_gclrTR = top_gclr;
04103                      trace_bclrTR = top_bclr;
04104         
04105     }
04106 #endif
04107 ;
04108                     
04109        acc_opc += bot_opc * wgtBR;
04110        
04111             acc_rclr += bot_rclr * wgtBR;
04112             acc_gclr += bot_gclr * wgtBR;
04113             acc_bclr += bot_bclr * wgtBR;
04114        
04115 #ifdef DEBUG
04116     if (ipixel == trace_pixel_ptr) {
04117         trace_opcBR = bot_opc;
04118         trace_rclrBR = bot_rclr;
04119                      trace_gclrBR = bot_gclr;
04120                      trace_bclrBR = bot_bclr;
04121         
04122     }
04123 #endif
04124 ;
04125                     
04126         COUNT_RESAMPLE;
04127         if (acc_opc > min_opacity) {
04128             COUNT_COMPOSITE;
04129             iopc = ipixel->opcflt;
04130 #           ifndef SKIP_ERT
04131                 ASSERT(iopc < max_opacity);
04132 #           endif
04133             iopc_inv = (float)1. - iopc;
04134             
04135         ipixel->rclrflt += acc_rclr * iopc_inv;
04136         ipixel->gclrflt += acc_gclr * iopc_inv;
04137         ipixel->bclrflt += acc_bclr * iopc_inv;
04138             iopc += acc_opc * iopc_inv;
04139             ipixel->opcflt = iopc;
04140             
04141 #ifdef DEBUG
04142     if (ipixel == trace_pixel_ptr) {
04143 #ifdef COMPUTE_SHADOW_BUFFER
04144         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04145 #else
04146         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04147 #endif
04148         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04149         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04150         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04151         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04152         printf("  %3.0f %3.0f\n", iopc*255., 
04153                ipixel->rclrflt);
04154         
04155         
04156         printf("              ");
04157         printf("      %3.0f    ",trace_gclrTL);
04158         printf("      %3.0f    ",trace_gclrBL);
04159         printf("      %3.0f    ",trace_gclrTR);
04160         printf("      %3.0f    ",trace_gclrBR);
04161         printf("      %3.0f\n", ipixel->gclrflt);
04162         printf("              ");
04163         printf("      %3.0f    ",trace_bclrTL);
04164         printf("      %3.0f    ",trace_bclrBL);
04165         printf("      %3.0f    ",trace_bclrTR);
04166         printf("      %3.0f    ",trace_bclrBR);
04167         printf("      %3.0f\n", ipixel->bclrflt);
04168     }
04169 #endif /* DEBUG */
04170 ;
04171 #           ifndef SKIP_ERT
04172                 if (iopc >= max_opacity) {
04173                     ASSERT(ipixel->lnk == 0);
04174                     ipixel->lnk = 1;
04175                 }
04176 #           endif
04177         };
04178                     ipixel += 1;
04179                     topRLEdata += 1 * voxel_istride;
04180                     botRLEdata += 1 * voxel_istride;
04181                     count--;
04182                     SET_VOXELS_LOADED;
04183                 }
04184                 break;
04185             case TOP_NONZERO__ALL_NONZERO:
04186                 /* first pixel: top-left, top-right and bottom-right
04187                    voxels contribute */
04188                 if (!voxels_loaded) {
04189                     
04190     
04191             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04192             opacity = param0_table[opac_param];
04193             if (param1_size != 0) {
04194                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04195                 opacity *= param1_table[opac_param];
04196                 if (param2_size != 0) {
04197                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04198                     opacity *= param2_table[opac_param];
04199                 }
04200             }
04201             if (opacity > min_opacity) {
04202                 opacity_int = opacity*255.;
04203                 top_opc = opac_correct[opacity_int];
04204             } else {
04205                 top_opc = (float)0.;
04206             };
04207     
04208     
04209     ;
04210     ;
04211     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
04212                              client_data);
04213     shade_factor = top_opc * slice_depth_cueing;
04214     
04215         top_rclr *= shade_factor;
04216         top_gclr *= shade_factor;
04217         top_bclr *= shade_factor;
04218     ;
04219                 }
04220                 
04221 #ifdef DEBUG
04222     if (ipixel == trace_pixel_ptr) {
04223         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04224         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04225         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04226         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04227         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04228     }
04229 #endif
04230 ;
04231                 
04232        acc_opc = top_opc * wgtTL;
04233        
04234             acc_rclr = top_rclr * wgtTL;
04235             acc_gclr = top_gclr * wgtTL;
04236             acc_bclr = top_bclr * wgtTL;
04237        
04238 #ifdef DEBUG
04239     if (ipixel == trace_pixel_ptr) {
04240         trace_opcTL = top_opc;
04241         trace_rclrTL = top_rclr;
04242                      trace_gclrTL = top_gclr;
04243                      trace_bclrTL = top_bclr;
04244         
04245     }
04246 #endif
04247 ;
04248                 
04249     
04250             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04251             opacity = param0_table[opac_param];
04252             if (param1_size != 0) {
04253                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04254                 opacity *= param1_table[opac_param];
04255                 if (param2_size != 0) {
04256                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04257                     opacity *= param2_table[opac_param];
04258                 }
04259             }
04260             if (opacity > min_opacity) {
04261                 opacity_int = opacity*255.;
04262                 top_opc = opac_correct[opacity_int];
04263             } else {
04264                 top_opc = (float)0.;
04265             };
04266     
04267     
04268     ;
04269     ;
04270     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
04271                              client_data);
04272     shade_factor = top_opc * slice_depth_cueing;
04273     
04274         top_rclr *= shade_factor;
04275         top_gclr *= shade_factor;
04276         top_bclr *= shade_factor;
04277     ;
04278                 
04279     
04280             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04281             opacity = param0_table[opac_param];
04282             if (param1_size != 0) {
04283                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04284                 opacity *= param1_table[opac_param];
04285                 if (param2_size != 0) {
04286                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04287                     opacity *= param2_table[opac_param];
04288                 }
04289             }
04290             if (opacity > min_opacity) {
04291                 opacity_int = opacity*255.;
04292                 bot_opc = opac_correct[opacity_int];
04293             } else {
04294                 bot_opc = (float)0.;
04295             };
04296     
04297     
04298     ;
04299     ;
04300     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04301                              client_data);
04302     shade_factor = bot_opc * slice_depth_cueing;
04303     
04304         bot_rclr *= shade_factor;
04305         bot_gclr *= shade_factor;
04306         bot_bclr *= shade_factor;
04307     ;
04308                 
04309        acc_opc += top_opc * wgtTR;
04310        
04311             acc_rclr += top_rclr * wgtTR;
04312             acc_gclr += top_gclr * wgtTR;
04313             acc_bclr += top_bclr * wgtTR;
04314        
04315 #ifdef DEBUG
04316     if (ipixel == trace_pixel_ptr) {
04317         trace_opcTR = top_opc;
04318         trace_rclrTR = top_rclr;
04319                      trace_gclrTR = top_gclr;
04320                      trace_bclrTR = top_bclr;
04321         
04322     }
04323 #endif
04324 ;
04325                 
04326        acc_opc += bot_opc * wgtBR;
04327        
04328             acc_rclr += bot_rclr * wgtBR;
04329             acc_gclr += bot_gclr * wgtBR;
04330             acc_bclr += bot_bclr * wgtBR;
04331        
04332 #ifdef DEBUG
04333     if (ipixel == trace_pixel_ptr) {
04334         trace_opcBR = bot_opc;
04335         trace_rclrBR = bot_rclr;
04336                      trace_gclrBR = bot_gclr;
04337                      trace_bclrBR = bot_bclr;
04338         
04339     }
04340 #endif
04341 ;
04342                 
04343         COUNT_RESAMPLE;
04344         if (acc_opc > min_opacity) {
04345             COUNT_COMPOSITE;
04346             iopc = ipixel->opcflt;
04347 #           ifndef SKIP_ERT
04348                 ASSERT(iopc < max_opacity);
04349 #           endif
04350             iopc_inv = (float)1. - iopc;
04351             
04352         ipixel->rclrflt += acc_rclr * iopc_inv;
04353         ipixel->gclrflt += acc_gclr * iopc_inv;
04354         ipixel->bclrflt += acc_bclr * iopc_inv;
04355             iopc += acc_opc * iopc_inv;
04356             ipixel->opcflt = iopc;
04357             
04358 #ifdef DEBUG
04359     if (ipixel == trace_pixel_ptr) {
04360 #ifdef COMPUTE_SHADOW_BUFFER
04361         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04362 #else
04363         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04364 #endif
04365         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04366         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04367         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04368         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04369         printf("  %3.0f %3.0f\n", iopc*255., 
04370                ipixel->rclrflt);
04371         
04372         
04373         printf("              ");
04374         printf("      %3.0f    ",trace_gclrTL);
04375         printf("      %3.0f    ",trace_gclrBL);
04376         printf("      %3.0f    ",trace_gclrTR);
04377         printf("      %3.0f    ",trace_gclrBR);
04378         printf("      %3.0f\n", ipixel->gclrflt);
04379         printf("              ");
04380         printf("      %3.0f    ",trace_bclrTL);
04381         printf("      %3.0f    ",trace_bclrBL);
04382         printf("      %3.0f    ",trace_bclrTR);
04383         printf("      %3.0f    ",trace_bclrBR);
04384         printf("      %3.0f\n", ipixel->bclrflt);
04385     }
04386 #endif /* DEBUG */
04387 ;
04388 #           ifndef SKIP_ERT
04389                 if (iopc >= max_opacity) {
04390                     ASSERT(ipixel->lnk == 0);
04391                     ipixel->lnk = 1;
04392                 }
04393 #           endif
04394         };
04395                 ipixel += 1;
04396                 topRLEdata += 1 * voxel_istride;
04397                 botRLEdata += 1 * voxel_istride;
04398                 count--;
04399                 SET_VOXELS_LOADED;
04400                     
04401                 /* do the rest of the pixels in this run;
04402                    all four voxels contribute */
04403                 while (count > 0) {
04404                     if (PIXEL_IS_OPAQUE(ipixel))
04405                         break;
04406                     if (!voxels_loaded) {
04407                         
04408     
04409             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04410             opacity = param0_table[opac_param];
04411             if (param1_size != 0) {
04412                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04413                 opacity *= param1_table[opac_param];
04414                 if (param2_size != 0) {
04415                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04416                     opacity *= param2_table[opac_param];
04417                 }
04418             }
04419             if (opacity > min_opacity) {
04420                 opacity_int = opacity*255.;
04421                 top_opc = opac_correct[opacity_int];
04422             } else {
04423                 top_opc = (float)0.;
04424             };
04425     
04426     
04427     ;
04428     ;
04429     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
04430                              client_data);
04431     shade_factor = top_opc * slice_depth_cueing;
04432     
04433         top_rclr *= shade_factor;
04434         top_gclr *= shade_factor;
04435         top_bclr *= shade_factor;
04436     ;
04437                         
04438     
04439             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04440             opacity = param0_table[opac_param];
04441             if (param1_size != 0) {
04442                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04443                 opacity *= param1_table[opac_param];
04444                 if (param2_size != 0) {
04445                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04446                     opacity *= param2_table[opac_param];
04447                 }
04448             }
04449             if (opacity > min_opacity) {
04450                 opacity_int = opacity*255.;
04451                 bot_opc = opac_correct[opacity_int];
04452             } else {
04453                 bot_opc = (float)0.;
04454             };
04455     
04456     
04457     ;
04458     ;
04459     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04460                              client_data);
04461     shade_factor = bot_opc * slice_depth_cueing;
04462     
04463         bot_rclr *= shade_factor;
04464         bot_gclr *= shade_factor;
04465         bot_bclr *= shade_factor;
04466     ;
04467                     }
04468                     
04469 #ifdef DEBUG
04470     if (ipixel == trace_pixel_ptr) {
04471         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04472         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04473         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04474         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04475         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04476     }
04477 #endif
04478 ;
04479                     
04480        acc_opc = top_opc * wgtTL;
04481        
04482             acc_rclr = top_rclr * wgtTL;
04483             acc_gclr = top_gclr * wgtTL;
04484             acc_bclr = top_bclr * wgtTL;
04485        
04486 #ifdef DEBUG
04487     if (ipixel == trace_pixel_ptr) {
04488         trace_opcTL = top_opc;
04489         trace_rclrTL = top_rclr;
04490                      trace_gclrTL = top_gclr;
04491                      trace_bclrTL = top_bclr;
04492         
04493     }
04494 #endif
04495 ;
04496                     
04497        acc_opc += bot_opc * wgtBL;
04498        
04499             acc_rclr += bot_rclr * wgtBL;
04500             acc_gclr += bot_gclr * wgtBL;
04501             acc_bclr += bot_bclr * wgtBL;
04502        
04503 #ifdef DEBUG
04504     if (ipixel == trace_pixel_ptr) {
04505         trace_opcBL = bot_opc;
04506         trace_rclrBL = bot_rclr;
04507                      trace_gclrBL = bot_gclr;
04508                      trace_bclrBL = bot_bclr;
04509         
04510     }
04511 #endif
04512 ;
04513                     
04514     
04515             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04516             opacity = param0_table[opac_param];
04517             if (param1_size != 0) {
04518                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04519                 opacity *= param1_table[opac_param];
04520                 if (param2_size != 0) {
04521                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04522                     opacity *= param2_table[opac_param];
04523                 }
04524             }
04525             if (opacity > min_opacity) {
04526                 opacity_int = opacity*255.;
04527                 top_opc = opac_correct[opacity_int];
04528             } else {
04529                 top_opc = (float)0.;
04530             };
04531     
04532     
04533     ;
04534     ;
04535     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
04536                              client_data);
04537     shade_factor = top_opc * slice_depth_cueing;
04538     
04539         top_rclr *= shade_factor;
04540         top_gclr *= shade_factor;
04541         top_bclr *= shade_factor;
04542     ;
04543                     
04544     
04545             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04546             opacity = param0_table[opac_param];
04547             if (param1_size != 0) {
04548                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04549                 opacity *= param1_table[opac_param];
04550                 if (param2_size != 0) {
04551                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04552                     opacity *= param2_table[opac_param];
04553                 }
04554             }
04555             if (opacity > min_opacity) {
04556                 opacity_int = opacity*255.;
04557                 bot_opc = opac_correct[opacity_int];
04558             } else {
04559                 bot_opc = (float)0.;
04560             };
04561     
04562     
04563     ;
04564     ;
04565     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04566                              client_data);
04567     shade_factor = bot_opc * slice_depth_cueing;
04568     
04569         bot_rclr *= shade_factor;
04570         bot_gclr *= shade_factor;
04571         bot_bclr *= shade_factor;
04572     ;
04573                     
04574        acc_opc += top_opc * wgtTR;
04575        
04576             acc_rclr += top_rclr * wgtTR;
04577             acc_gclr += top_gclr * wgtTR;
04578             acc_bclr += top_bclr * wgtTR;
04579        
04580 #ifdef DEBUG
04581     if (ipixel == trace_pixel_ptr) {
04582         trace_opcTR = top_opc;
04583         trace_rclrTR = top_rclr;
04584                      trace_gclrTR = top_gclr;
04585                      trace_bclrTR = top_bclr;
04586         
04587     }
04588 #endif
04589 ;
04590                     
04591        acc_opc += bot_opc * wgtBR;
04592        
04593             acc_rclr += bot_rclr * wgtBR;
04594             acc_gclr += bot_gclr * wgtBR;
04595             acc_bclr += bot_bclr * wgtBR;
04596        
04597 #ifdef DEBUG
04598     if (ipixel == trace_pixel_ptr) {
04599         trace_opcBR = bot_opc;
04600         trace_rclrBR = bot_rclr;
04601                      trace_gclrBR = bot_gclr;
04602                      trace_bclrBR = bot_bclr;
04603         
04604     }
04605 #endif
04606 ;
04607                     
04608         COUNT_RESAMPLE;
04609         if (acc_opc > min_opacity) {
04610             COUNT_COMPOSITE;
04611             iopc = ipixel->opcflt;
04612 #           ifndef SKIP_ERT
04613                 ASSERT(iopc < max_opacity);
04614 #           endif
04615             iopc_inv = (float)1. - iopc;
04616             
04617         ipixel->rclrflt += acc_rclr * iopc_inv;
04618         ipixel->gclrflt += acc_gclr * iopc_inv;
04619         ipixel->bclrflt += acc_bclr * iopc_inv;
04620             iopc += acc_opc * iopc_inv;
04621             ipixel->opcflt = iopc;
04622             
04623 #ifdef DEBUG
04624     if (ipixel == trace_pixel_ptr) {
04625 #ifdef COMPUTE_SHADOW_BUFFER
04626         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04627 #else
04628         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04629 #endif
04630         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04631         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04632         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04633         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04634         printf("  %3.0f %3.0f\n", iopc*255., 
04635                ipixel->rclrflt);
04636         
04637         
04638         printf("              ");
04639         printf("      %3.0f    ",trace_gclrTL);
04640         printf("      %3.0f    ",trace_gclrBL);
04641         printf("      %3.0f    ",trace_gclrTR);
04642         printf("      %3.0f    ",trace_gclrBR);
04643         printf("      %3.0f\n", ipixel->gclrflt);
04644         printf("              ");
04645         printf("      %3.0f    ",trace_bclrTL);
04646         printf("      %3.0f    ",trace_bclrBL);
04647         printf("      %3.0f    ",trace_bclrTR);
04648         printf("      %3.0f    ",trace_bclrBR);
04649         printf("      %3.0f\n", ipixel->bclrflt);
04650     }
04651 #endif /* DEBUG */
04652 ;
04653 #           ifndef SKIP_ERT
04654                 if (iopc >= max_opacity) {
04655                     ASSERT(ipixel->lnk == 0);
04656                     ipixel->lnk = 1;
04657                 }
04658 #           endif
04659         };
04660                     ipixel += 1;
04661                     topRLEdata += 1 * voxel_istride;
04662                     botRLEdata += 1 * voxel_istride;
04663                     count--;
04664                     SET_VOXELS_LOADED;
04665                 }
04666                 break;
04667             case BOT_NONZERO__ALL_NONZERO:
04668                 /* first pixel: bottom-left, top-right and bottom-right
04669                    voxels contribute */
04670                 if (!voxels_loaded) {
04671                     
04672     
04673             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04674             opacity = param0_table[opac_param];
04675             if (param1_size != 0) {
04676                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04677                 opacity *= param1_table[opac_param];
04678                 if (param2_size != 0) {
04679                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04680                     opacity *= param2_table[opac_param];
04681                 }
04682             }
04683             if (opacity > min_opacity) {
04684                 opacity_int = opacity*255.;
04685                 bot_opc = opac_correct[opacity_int];
04686             } else {
04687                 bot_opc = (float)0.;
04688             };
04689     
04690     
04691     ;
04692     ;
04693     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04694                              client_data);
04695     shade_factor = bot_opc * slice_depth_cueing;
04696     
04697         bot_rclr *= shade_factor;
04698         bot_gclr *= shade_factor;
04699         bot_bclr *= shade_factor;
04700     ;
04701                 }
04702                 
04703 #ifdef DEBUG
04704     if (ipixel == trace_pixel_ptr) {
04705         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04706         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04707         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04708         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04709         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04710     }
04711 #endif
04712 ;
04713                 
04714        acc_opc = bot_opc * wgtBL;
04715        
04716             acc_rclr = bot_rclr * wgtBL;
04717             acc_gclr = bot_gclr * wgtBL;
04718             acc_bclr = bot_bclr * wgtBL;
04719        
04720 #ifdef DEBUG
04721     if (ipixel == trace_pixel_ptr) {
04722         trace_opcBL = bot_opc;
04723         trace_rclrBL = bot_rclr;
04724                      trace_gclrBL = bot_gclr;
04725                      trace_bclrBL = bot_bclr;
04726         
04727     }
04728 #endif
04729 ;
04730                 
04731     
04732             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04733             opacity = param0_table[opac_param];
04734             if (param1_size != 0) {
04735                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04736                 opacity *= param1_table[opac_param];
04737                 if (param2_size != 0) {
04738                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04739                     opacity *= param2_table[opac_param];
04740                 }
04741             }
04742             if (opacity > min_opacity) {
04743                 opacity_int = opacity*255.;
04744                 top_opc = opac_correct[opacity_int];
04745             } else {
04746                 top_opc = (float)0.;
04747             };
04748     
04749     
04750     ;
04751     ;
04752     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
04753                              client_data);
04754     shade_factor = top_opc * slice_depth_cueing;
04755     
04756         top_rclr *= shade_factor;
04757         top_gclr *= shade_factor;
04758         top_bclr *= shade_factor;
04759     ;
04760                 
04761     
04762             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04763             opacity = param0_table[opac_param];
04764             if (param1_size != 0) {
04765                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04766                 opacity *= param1_table[opac_param];
04767                 if (param2_size != 0) {
04768                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04769                     opacity *= param2_table[opac_param];
04770                 }
04771             }
04772             if (opacity > min_opacity) {
04773                 opacity_int = opacity*255.;
04774                 bot_opc = opac_correct[opacity_int];
04775             } else {
04776                 bot_opc = (float)0.;
04777             };
04778     
04779     
04780     ;
04781     ;
04782     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04783                              client_data);
04784     shade_factor = bot_opc * slice_depth_cueing;
04785     
04786         bot_rclr *= shade_factor;
04787         bot_gclr *= shade_factor;
04788         bot_bclr *= shade_factor;
04789     ;
04790                 
04791        acc_opc += top_opc * wgtTR;
04792        
04793             acc_rclr += top_rclr * wgtTR;
04794             acc_gclr += top_gclr * wgtTR;
04795             acc_bclr += top_bclr * wgtTR;
04796        
04797 #ifdef DEBUG
04798     if (ipixel == trace_pixel_ptr) {
04799         trace_opcTR = top_opc;
04800         trace_rclrTR = top_rclr;
04801                      trace_gclrTR = top_gclr;
04802                      trace_bclrTR = top_bclr;
04803         
04804     }
04805 #endif
04806 ;
04807                 
04808        acc_opc += bot_opc * wgtBR;
04809        
04810             acc_rclr += bot_rclr * wgtBR;
04811             acc_gclr += bot_gclr * wgtBR;
04812             acc_bclr += bot_bclr * wgtBR;
04813        
04814 #ifdef DEBUG
04815     if (ipixel == trace_pixel_ptr) {
04816         trace_opcBR = bot_opc;
04817         trace_rclrBR = bot_rclr;
04818                      trace_gclrBR = bot_gclr;
04819                      trace_bclrBR = bot_bclr;
04820         
04821     }
04822 #endif
04823 ;
04824                 
04825         COUNT_RESAMPLE;
04826         if (acc_opc > min_opacity) {
04827             COUNT_COMPOSITE;
04828             iopc = ipixel->opcflt;
04829 #           ifndef SKIP_ERT
04830                 ASSERT(iopc < max_opacity);
04831 #           endif
04832             iopc_inv = (float)1. - iopc;
04833             
04834         ipixel->rclrflt += acc_rclr * iopc_inv;
04835         ipixel->gclrflt += acc_gclr * iopc_inv;
04836         ipixel->bclrflt += acc_bclr * iopc_inv;
04837             iopc += acc_opc * iopc_inv;
04838             ipixel->opcflt = iopc;
04839             
04840 #ifdef DEBUG
04841     if (ipixel == trace_pixel_ptr) {
04842 #ifdef COMPUTE_SHADOW_BUFFER
04843         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04844 #else
04845         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04846 #endif
04847         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04848         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04849         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04850         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04851         printf("  %3.0f %3.0f\n", iopc*255., 
04852                ipixel->rclrflt);
04853         
04854         
04855         printf("              ");
04856         printf("      %3.0f    ",trace_gclrTL);
04857         printf("      %3.0f    ",trace_gclrBL);
04858         printf("      %3.0f    ",trace_gclrTR);
04859         printf("      %3.0f    ",trace_gclrBR);
04860         printf("      %3.0f\n", ipixel->gclrflt);
04861         printf("              ");
04862         printf("      %3.0f    ",trace_bclrTL);
04863         printf("      %3.0f    ",trace_bclrBL);
04864         printf("      %3.0f    ",trace_bclrTR);
04865         printf("      %3.0f    ",trace_bclrBR);
04866         printf("      %3.0f\n", ipixel->bclrflt);
04867     }
04868 #endif /* DEBUG */
04869 ;
04870 #           ifndef SKIP_ERT
04871                 if (iopc >= max_opacity) {
04872                     ASSERT(ipixel->lnk == 0);
04873                     ipixel->lnk = 1;
04874                 }
04875 #           endif
04876         };
04877                 ipixel += 1;
04878                 topRLEdata += 1 * voxel_istride;
04879                 botRLEdata += 1 * voxel_istride;
04880                 count--;
04881                 SET_VOXELS_LOADED;
04882                     
04883                 /* do the rest of the pixels in this run;
04884                    all four voxels contribute */
04885                 while (count > 0) {
04886                     if (PIXEL_IS_OPAQUE(ipixel))
04887                         break;
04888                     if (!voxels_loaded) {
04889                         
04890     
04891             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04892             opacity = param0_table[opac_param];
04893             if (param1_size != 0) {
04894                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04895                 opacity *= param1_table[opac_param];
04896                 if (param2_size != 0) {
04897                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04898                     opacity *= param2_table[opac_param];
04899                 }
04900             }
04901             if (opacity > min_opacity) {
04902                 opacity_int = opacity*255.;
04903                 top_opc = opac_correct[opacity_int];
04904             } else {
04905                 top_opc = (float)0.;
04906             };
04907     
04908     
04909     ;
04910     ;
04911     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
04912                              client_data);
04913     shade_factor = top_opc * slice_depth_cueing;
04914     
04915         top_rclr *= shade_factor;
04916         top_gclr *= shade_factor;
04917         top_bclr *= shade_factor;
04918     ;
04919                         
04920     
04921             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04922             opacity = param0_table[opac_param];
04923             if (param1_size != 0) {
04924                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04925                 opacity *= param1_table[opac_param];
04926                 if (param2_size != 0) {
04927                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04928                     opacity *= param2_table[opac_param];
04929                 }
04930             }
04931             if (opacity > min_opacity) {
04932                 opacity_int = opacity*255.;
04933                 bot_opc = opac_correct[opacity_int];
04934             } else {
04935                 bot_opc = (float)0.;
04936             };
04937     
04938     
04939     ;
04940     ;
04941     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
04942                              client_data);
04943     shade_factor = bot_opc * slice_depth_cueing;
04944     
04945         bot_rclr *= shade_factor;
04946         bot_gclr *= shade_factor;
04947         bot_bclr *= shade_factor;
04948     ;
04949                     }
04950                     
04951 #ifdef DEBUG
04952     if (ipixel == trace_pixel_ptr) {
04953         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04954         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04955         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04956         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04957         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04958     }
04959 #endif
04960 ;
04961                     
04962        acc_opc = top_opc * wgtTL;
04963        
04964             acc_rclr = top_rclr * wgtTL;
04965             acc_gclr = top_gclr * wgtTL;
04966             acc_bclr = top_bclr * wgtTL;
04967        
04968 #ifdef DEBUG
04969     if (ipixel == trace_pixel_ptr) {
04970         trace_opcTL = top_opc;
04971         trace_rclrTL = top_rclr;
04972                      trace_gclrTL = top_gclr;
04973                      trace_bclrTL = top_bclr;
04974         
04975     }
04976 #endif
04977 ;
04978                     
04979        acc_opc += bot_opc * wgtBL;
04980        
04981             acc_rclr += bot_rclr * wgtBL;
04982             acc_gclr += bot_gclr * wgtBL;
04983             acc_bclr += bot_bclr * wgtBL;
04984        
04985 #ifdef DEBUG
04986     if (ipixel == trace_pixel_ptr) {
04987         trace_opcBL = bot_opc;
04988         trace_rclrBL = bot_rclr;
04989                      trace_gclrBL = bot_gclr;
04990                      trace_bclrBL = bot_bclr;
04991         
04992     }
04993 #endif
04994 ;
04995                     
04996     
04997             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04998             opacity = param0_table[opac_param];
04999             if (param1_size != 0) {
05000                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
05001                 opacity *= param1_table[opac_param];
05002                 if (param2_size != 0) {
05003                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
05004                     opacity *= param2_table[opac_param];
05005                 }
05006             }
05007             if (opacity > min_opacity) {
05008                 opacity_int = opacity*255.;
05009                 top_opc = opac_correct[opacity_int];
05010             } else {
05011                 top_opc = (float)0.;
05012             };
05013     
05014     
05015     ;
05016     ;
05017     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
05018                              client_data);
05019     shade_factor = top_opc * slice_depth_cueing;
05020     
05021         top_rclr *= shade_factor;
05022         top_gclr *= shade_factor;
05023         top_bclr *= shade_factor;
05024     ;
05025                     
05026     
05027             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05028             opacity = param0_table[opac_param];
05029             if (param1_size != 0) {
05030                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
05031                 opacity *= param1_table[opac_param];
05032                 if (param2_size != 0) {
05033                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
05034                     opacity *= param2_table[opac_param];
05035                 }
05036             }
05037             if (opacity > min_opacity) {
05038                 opacity_int = opacity*255.;
05039                 bot_opc = opac_correct[opacity_int];
05040             } else {
05041                 bot_opc = (float)0.;
05042             };
05043     
05044     
05045     ;
05046     ;
05047     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
05048                              client_data);
05049     shade_factor = bot_opc * slice_depth_cueing;
05050     
05051         bot_rclr *= shade_factor;
05052         bot_gclr *= shade_factor;
05053         bot_bclr *= shade_factor;
05054     ;
05055                     
05056        acc_opc += top_opc * wgtTR;
05057        
05058             acc_rclr += top_rclr * wgtTR;
05059             acc_gclr += top_gclr * wgtTR;
05060             acc_bclr += top_bclr * wgtTR;
05061        
05062 #ifdef DEBUG
05063     if (ipixel == trace_pixel_ptr) {
05064         trace_opcTR = top_opc;
05065         trace_rclrTR = top_rclr;
05066                      trace_gclrTR = top_gclr;
05067                      trace_bclrTR = top_bclr;
05068         
05069     }
05070 #endif
05071 ;
05072                     
05073        acc_opc += bot_opc * wgtBR;
05074        
05075             acc_rclr += bot_rclr * wgtBR;
05076             acc_gclr += bot_gclr * wgtBR;
05077             acc_bclr += bot_bclr * wgtBR;
05078        
05079 #ifdef DEBUG
05080     if (ipixel == trace_pixel_ptr) {
05081         trace_opcBR = bot_opc;
05082         trace_rclrBR = bot_rclr;
05083                      trace_gclrBR = bot_gclr;
05084                      trace_bclrBR = bot_bclr;
05085         
05086     }
05087 #endif
05088 ;
05089                     
05090         COUNT_RESAMPLE;
05091         if (acc_opc > min_opacity) {
05092             COUNT_COMPOSITE;
05093             iopc = ipixel->opcflt;
05094 #           ifndef SKIP_ERT
05095                 ASSERT(iopc < max_opacity);
05096 #           endif
05097             iopc_inv = (float)1. - iopc;
05098             
05099         ipixel->rclrflt += acc_rclr * iopc_inv;
05100         ipixel->gclrflt += acc_gclr * iopc_inv;
05101         ipixel->bclrflt += acc_bclr * iopc_inv;
05102             iopc += acc_opc * iopc_inv;
05103             ipixel->opcflt = iopc;
05104             
05105 #ifdef DEBUG
05106     if (ipixel == trace_pixel_ptr) {
05107 #ifdef COMPUTE_SHADOW_BUFFER
05108         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05109 #else
05110         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05111 #endif
05112         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05113         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05114         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05115         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05116         printf("  %3.0f %3.0f\n", iopc*255., 
05117                ipixel->rclrflt);
05118         
05119         
05120         printf("              ");
05121         printf("      %3.0f    ",trace_gclrTL);
05122         printf("      %3.0f    ",trace_gclrBL);
05123         printf("      %3.0f    ",trace_gclrTR);
05124         printf("      %3.0f    ",trace_gclrBR);
05125         printf("      %3.0f\n", ipixel->gclrflt);
05126         printf("              ");
05127         printf("      %3.0f    ",trace_bclrTL);
05128         printf("      %3.0f    ",trace_bclrBL);
05129         printf("      %3.0f    ",trace_bclrTR);
05130         printf("      %3.0f    ",trace_bclrBR);
05131         printf("      %3.0f\n", ipixel->bclrflt);
05132     }
05133 #endif /* DEBUG */
05134 ;
05135 #           ifndef SKIP_ERT
05136                 if (iopc >= max_opacity) {
05137                     ASSERT(ipixel->lnk == 0);
05138                     ipixel->lnk = 1;
05139                 }
05140 #           endif
05141         };
05142                     ipixel += 1;
05143                     topRLEdata += 1 * voxel_istride;
05144                     botRLEdata += 1 * voxel_istride;
05145                     count--;
05146                     SET_VOXELS_LOADED;
05147                 }
05148                 break;
05149             case ALL_NONZERO__ALL_NONZERO:
05150                 /* do the pixels in this run; all four voxels contribute */
05151                 while (count > 0) {
05152                     if (PIXEL_IS_OPAQUE(ipixel))
05153                         break;
05154                     if (!voxels_loaded) {
05155                         
05156     
05157             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05158             opacity = param0_table[opac_param];
05159             if (param1_size != 0) {
05160                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05161                 opacity *= param1_table[opac_param];
05162                 if (param2_size != 0) {
05163                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05164                     opacity *= param2_table[opac_param];
05165                 }
05166             }
05167             if (opacity > min_opacity) {
05168                 opacity_int = opacity*255.;
05169                 top_opc = opac_correct[opacity_int];
05170             } else {
05171                 top_opc = (float)0.;
05172             };
05173     
05174     
05175     ;
05176     ;
05177     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
05178                              client_data);
05179     shade_factor = top_opc * slice_depth_cueing;
05180     
05181         top_rclr *= shade_factor;
05182         top_gclr *= shade_factor;
05183         top_bclr *= shade_factor;
05184     ;
05185                         
05186     
05187             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05188             opacity = param0_table[opac_param];
05189             if (param1_size != 0) {
05190                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05191                 opacity *= param1_table[opac_param];
05192                 if (param2_size != 0) {
05193                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05194                     opacity *= param2_table[opac_param];
05195                 }
05196             }
05197             if (opacity > min_opacity) {
05198                 opacity_int = opacity*255.;
05199                 bot_opc = opac_correct[opacity_int];
05200             } else {
05201                 bot_opc = (float)0.;
05202             };
05203     
05204     
05205     ;
05206     ;
05207     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
05208                              client_data);
05209     shade_factor = bot_opc * slice_depth_cueing;
05210     
05211         bot_rclr *= shade_factor;
05212         bot_gclr *= shade_factor;
05213         bot_bclr *= shade_factor;
05214     ;
05215                     }
05216                     
05217 #ifdef DEBUG
05218     if (ipixel == trace_pixel_ptr) {
05219         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05220         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05221         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05222         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05223         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05224     }
05225 #endif
05226 ;
05227                     
05228        acc_opc = top_opc * wgtTL;
05229        
05230             acc_rclr = top_rclr * wgtTL;
05231             acc_gclr = top_gclr * wgtTL;
05232             acc_bclr = top_bclr * wgtTL;
05233        
05234 #ifdef DEBUG
05235     if (ipixel == trace_pixel_ptr) {
05236         trace_opcTL = top_opc;
05237         trace_rclrTL = top_rclr;
05238                      trace_gclrTL = top_gclr;
05239                      trace_bclrTL = top_bclr;
05240         
05241     }
05242 #endif
05243 ;
05244                     
05245        acc_opc += bot_opc * wgtBL;
05246        
05247             acc_rclr += bot_rclr * wgtBL;
05248             acc_gclr += bot_gclr * wgtBL;
05249             acc_bclr += bot_bclr * wgtBL;
05250        
05251 #ifdef DEBUG
05252     if (ipixel == trace_pixel_ptr) {
05253         trace_opcBL = bot_opc;
05254         trace_rclrBL = bot_rclr;
05255                      trace_gclrBL = bot_gclr;
05256                      trace_bclrBL = bot_bclr;
05257         
05258     }
05259 #endif
05260 ;
05261                     
05262     
05263             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
05264             opacity = param0_table[opac_param];
05265             if (param1_size != 0) {
05266                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
05267                 opacity *= param1_table[opac_param];
05268                 if (param2_size != 0) {
05269                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
05270                     opacity *= param2_table[opac_param];
05271                 }
05272             }
05273             if (opacity > min_opacity) {
05274                 opacity_int = opacity*255.;
05275                 top_opc = opac_correct[opacity_int];
05276             } else {
05277                 top_opc = (float)0.;
05278             };
05279     
05280     
05281     ;
05282     ;
05283     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
05284                              client_data);
05285     shade_factor = top_opc * slice_depth_cueing;
05286     
05287         top_rclr *= shade_factor;
05288         top_gclr *= shade_factor;
05289         top_bclr *= shade_factor;
05290     ;
05291                     
05292     
05293             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05294             opacity = param0_table[opac_param];
05295             if (param1_size != 0) {
05296                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
05297                 opacity *= param1_table[opac_param];
05298                 if (param2_size != 0) {
05299                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
05300                     opacity *= param2_table[opac_param];
05301                 }
05302             }
05303             if (opacity > min_opacity) {
05304                 opacity_int = opacity*255.;
05305                 bot_opc = opac_correct[opacity_int];
05306             } else {
05307                 bot_opc = (float)0.;
05308             };
05309     
05310     
05311     ;
05312     ;
05313     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
05314                              client_data);
05315     shade_factor = bot_opc * slice_depth_cueing;
05316     
05317         bot_rclr *= shade_factor;
05318         bot_gclr *= shade_factor;
05319         bot_bclr *= shade_factor;
05320     ;
05321                     
05322        acc_opc += top_opc * wgtTR;
05323        
05324             acc_rclr += top_rclr * wgtTR;
05325             acc_gclr += top_gclr * wgtTR;
05326             acc_bclr += top_bclr * wgtTR;
05327        
05328 #ifdef DEBUG
05329     if (ipixel == trace_pixel_ptr) {
05330         trace_opcTR = top_opc;
05331         trace_rclrTR = top_rclr;
05332                      trace_gclrTR = top_gclr;
05333                      trace_bclrTR = top_bclr;
05334         
05335     }
05336 #endif
05337 ;
05338                     
05339        acc_opc += bot_opc * wgtBR;
05340        
05341             acc_rclr += bot_rclr * wgtBR;
05342             acc_gclr += bot_gclr * wgtBR;
05343             acc_bclr += bot_bclr * wgtBR;
05344        
05345 #ifdef DEBUG
05346     if (ipixel == trace_pixel_ptr) {
05347         trace_opcBR = bot_opc;
05348         trace_rclrBR = bot_rclr;
05349                      trace_gclrBR = bot_gclr;
05350                      trace_bclrBR = bot_bclr;
05351         
05352     }
05353 #endif
05354 ;
05355                     
05356         COUNT_RESAMPLE;
05357         if (acc_opc > min_opacity) {
05358             COUNT_COMPOSITE;
05359             iopc = ipixel->opcflt;
05360 #           ifndef SKIP_ERT
05361                 ASSERT(iopc < max_opacity);
05362 #           endif
05363             iopc_inv = (float)1. - iopc;
05364             
05365         ipixel->rclrflt += acc_rclr * iopc_inv;
05366         ipixel->gclrflt += acc_gclr * iopc_inv;
05367         ipixel->bclrflt += acc_bclr * iopc_inv;
05368             iopc += acc_opc * iopc_inv;
05369             ipixel->opcflt = iopc;
05370             
05371 #ifdef DEBUG
05372     if (ipixel == trace_pixel_ptr) {
05373 #ifdef COMPUTE_SHADOW_BUFFER
05374         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05375 #else
05376         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05377 #endif
05378         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05379         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05380         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05381         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05382         printf("  %3.0f %3.0f\n", iopc*255., 
05383                ipixel->rclrflt);
05384         
05385         
05386         printf("              ");
05387         printf("      %3.0f    ",trace_gclrTL);
05388         printf("      %3.0f    ",trace_gclrBL);
05389         printf("      %3.0f    ",trace_gclrTR);
05390         printf("      %3.0f    ",trace_gclrBR);
05391         printf("      %3.0f\n", ipixel->gclrflt);
05392         printf("              ");
05393         printf("      %3.0f    ",trace_bclrTL);
05394         printf("      %3.0f    ",trace_bclrBL);
05395         printf("      %3.0f    ",trace_bclrTR);
05396         printf("      %3.0f    ",trace_bclrBR);
05397         printf("      %3.0f\n", ipixel->bclrflt);
05398     }
05399 #endif /* DEBUG */
05400 ;
05401 #           ifndef SKIP_ERT
05402                 if (iopc >= max_opacity) {
05403                     ASSERT(ipixel->lnk == 0);
05404                     ipixel->lnk = 1;
05405                 }
05406 #           endif
05407         };
05408                     ipixel += 1;
05409                     topRLEdata += 1 * voxel_istride;
05410                     botRLEdata += 1 * voxel_istride;
05411                     count--;
05412                     SET_VOXELS_LOADED;
05413                 }
05414                 break;
05415             default:
05416                 VPBug("illegal value for run states in compositing loop");
05417             }
05418 #else /* UNROLL_RUN_LOOP */
05419             /* this run contains pixels, so process them */
05420             while (count > 0) {
05421                 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
05422                     ipixel += count;
05423                     if (i != -1) {
05424                         topRLEdata += count * voxel_istride;
05425                         botRLEdata += count * voxel_istride;
05426                     }
05427                     count = 0;
05428                     break;
05429                 }
05430                 if (ipixel->lnk != 0)
05431                     break;
05432                 
05433 #ifdef DEBUG
05434     if (ipixel == trace_pixel_ptr) {
05435         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05436         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05437         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05438         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05439         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05440     }
05441 #endif
05442 ;
05443                 
05444        acc_opc = 0;
05445        acc_rclr = acc_gclr = acc_bclr = 0;
05446                 if (last_run_state & TOP_NONZERO) {
05447                     if (!voxels_loaded) {
05448                         
05449     
05450             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05451             opacity = param0_table[opac_param];
05452             if (param1_size != 0) {
05453                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05454                 opacity *= param1_table[opac_param];
05455                 if (param2_size != 0) {
05456                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05457                     opacity *= param2_table[opac_param];
05458                 }
05459             }
05460             if (opacity > min_opacity) {
05461                 opacity_int = opacity*255.;
05462                 top_opc = opac_correct[opacity_int];
05463             } else {
05464                 top_opc = (float)0.;
05465             };
05466     
05467     
05468     ;
05469     ;
05470     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
05471                              client_data);
05472     shade_factor = top_opc * slice_depth_cueing;
05473     
05474         top_rclr *= shade_factor;
05475         top_gclr *= shade_factor;
05476         top_bclr *= shade_factor;
05477     ;
05478                     }
05479                     
05480        acc_opc += top_opc * wgtTL;
05481        
05482             acc_rclr += top_rclr * wgtTL;
05483             acc_gclr += top_gclr * wgtTL;
05484             acc_bclr += top_bclr * wgtTL;
05485        
05486 #ifdef DEBUG
05487     if (ipixel == trace_pixel_ptr) {
05488         trace_opcTL = top_opc;
05489         trace_rclrTL = top_rclr;
05490                      trace_gclrTL = top_gclr;
05491                      trace_bclrTL = top_bclr;
05492         
05493     }
05494 #endif
05495 ;
05496                 }
05497                 if (last_run_state & BOT_NONZERO) {
05498                     if (!voxels_loaded) {
05499                         
05500     
05501             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05502             opacity = param0_table[opac_param];
05503             if (param1_size != 0) {
05504                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05505                 opacity *= param1_table[opac_param];
05506                 if (param2_size != 0) {
05507                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05508                     opacity *= param2_table[opac_param];
05509                 }
05510             }
05511             if (opacity > min_opacity) {
05512                 opacity_int = opacity*255.;
05513                 bot_opc = opac_correct[opacity_int];
05514             } else {
05515                 bot_opc = (float)0.;
05516             };
05517     
05518     
05519     ;
05520     ;
05521     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
05522                              client_data);
05523     shade_factor = bot_opc * slice_depth_cueing;
05524     
05525         bot_rclr *= shade_factor;
05526         bot_gclr *= shade_factor;
05527         bot_bclr *= shade_factor;
05528     ;
05529                     }
05530                     
05531        acc_opc += bot_opc * wgtBL;
05532        
05533             acc_rclr += bot_rclr * wgtBL;
05534             acc_gclr += bot_gclr * wgtBL;
05535             acc_bclr += bot_bclr * wgtBL;
05536        
05537 #ifdef DEBUG
05538     if (ipixel == trace_pixel_ptr) {
05539         trace_opcBL = bot_opc;
05540         trace_rclrBL = bot_rclr;
05541                      trace_gclrBL = bot_gclr;
05542                      trace_bclrBL = bot_bclr;
05543         
05544     }
05545 #endif
05546 ;
05547                 }
05548                 if (run_state & TOP_NONZERO) {
05549                     
05550     
05551             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
05552             opacity = param0_table[opac_param];
05553             if (param1_size != 0) {
05554                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
05555                 opacity *= param1_table[opac_param];
05556                 if (param2_size != 0) {
05557                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
05558                     opacity *= param2_table[opac_param];
05559                 }
05560             }
05561             if (opacity > min_opacity) {
05562                 opacity_int = opacity*255.;
05563                 top_opc = opac_correct[opacity_int];
05564             } else {
05565                 top_opc = (float)0.;
05566             };
05567     
05568     
05569     ;
05570     ;
05571     shade_func(topRLEdata, &(top_rclr), &(top_gclr), &(top_bclr),
05572                              client_data);
05573     shade_factor = top_opc * slice_depth_cueing;
05574     
05575         top_rclr *= shade_factor;
05576         top_gclr *= shade_factor;
05577         top_bclr *= shade_factor;
05578     ;
05579                     
05580        acc_opc += top_opc * wgtTR;
05581        
05582             acc_rclr += top_rclr * wgtTR;
05583             acc_gclr += top_gclr * wgtTR;
05584             acc_bclr += top_bclr * wgtTR;
05585        
05586 #ifdef DEBUG
05587     if (ipixel == trace_pixel_ptr) {
05588         trace_opcTR = top_opc;
05589         trace_rclrTR = top_rclr;
05590                      trace_gclrTR = top_gclr;
05591                      trace_bclrTR = top_bclr;
05592         
05593     }
05594 #endif
05595 ;
05596                     topRLEdata += 1 * voxel_istride;
05597                 } else {
05598                     if (i != -1) {
05599                         topRLEdata += 1 * voxel_istride;
05600                     }
05601                 }
05602                 if (run_state & BOT_NONZERO) {
05603                     
05604     
05605             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05606             opacity = param0_table[opac_param];
05607             if (param1_size != 0) {
05608                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
05609                 opacity *= param1_table[opac_param];
05610                 if (param2_size != 0) {
05611                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
05612                     opacity *= param2_table[opac_param];
05613                 }
05614             }
05615             if (opacity > min_opacity) {
05616                 opacity_int = opacity*255.;
05617                 bot_opc = opac_correct[opacity_int];
05618             } else {
05619                 bot_opc = (float)0.;
05620             };
05621     
05622     
05623     ;
05624     ;
05625     shade_func(botRLEdata, &(bot_rclr), &(bot_gclr), &(bot_bclr),
05626                              client_data);
05627     shade_factor = bot_opc * slice_depth_cueing;
05628     
05629         bot_rclr *= shade_factor;
05630         bot_gclr *= shade_factor;
05631         bot_bclr *= shade_factor;
05632     ;
05633                     
05634        acc_opc += bot_opc * wgtBR;
05635        
05636             acc_rclr += bot_rclr * wgtBR;
05637             acc_gclr += bot_gclr * wgtBR;
05638             acc_bclr += bot_bclr * wgtBR;
05639        
05640 #ifdef DEBUG
05641     if (ipixel == trace_pixel_ptr) {
05642         trace_opcBR = bot_opc;
05643         trace_rclrBR = bot_rclr;
05644                      trace_gclrBR = bot_gclr;
05645                      trace_bclrBR = bot_bclr;
05646         
05647     }
05648 #endif
05649 ;
05650                     botRLEdata += 1 * voxel_istride;
05651                 } else {
05652                     if (i != -1) {
05653                         botRLEdata += 1 * voxel_istride;
05654                     }
05655                 }
05656                 
05657         COUNT_RESAMPLE;
05658         if (acc_opc > min_opacity) {
05659             COUNT_COMPOSITE;
05660             iopc = ipixel->opcflt;
05661 #           ifndef SKIP_ERT
05662                 ASSERT(iopc < max_opacity);
05663 #           endif
05664             iopc_inv = (float)1. - iopc;
05665             
05666         ipixel->rclrflt += acc_rclr * iopc_inv;
05667         ipixel->gclrflt += acc_gclr * iopc_inv;
05668         ipixel->bclrflt += acc_bclr * iopc_inv;
05669             iopc += acc_opc * iopc_inv;
05670             ipixel->opcflt = iopc;
05671             
05672 #ifdef DEBUG
05673     if (ipixel == trace_pixel_ptr) {
05674 #ifdef COMPUTE_SHADOW_BUFFER
05675         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05676 #else
05677         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05678 #endif
05679         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05680         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05681         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05682         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05683         printf("  %3.0f %3.0f\n", iopc*255., 
05684                ipixel->rclrflt);
05685         
05686         
05687         printf("              ");
05688         printf("      %3.0f    ",trace_gclrTL);
05689         printf("      %3.0f    ",trace_gclrBL);
05690         printf("      %3.0f    ",trace_gclrTR);
05691         printf("      %3.0f    ",trace_gclrBR);
05692         printf("      %3.0f\n", ipixel->gclrflt);
05693         printf("              ");
05694         printf("      %3.0f    ",trace_bclrTL);
05695         printf("      %3.0f    ",trace_bclrBL);
05696         printf("      %3.0f    ",trace_bclrTR);
05697         printf("      %3.0f    ",trace_bclrBR);
05698         printf("      %3.0f\n", ipixel->bclrflt);
05699     }
05700 #endif /* DEBUG */
05701 ;
05702 #           ifndef SKIP_ERT
05703                 if (iopc >= max_opacity) {
05704                     ASSERT(ipixel->lnk == 0);
05705                     ipixel->lnk = 1;
05706                 }
05707 #           endif
05708         };
05709                 ipixel += 1;
05710                 count--;
05711                 SET_VOXELS_LOADED;
05712                 last_run_state = run_state;
05713             }
05714 #endif /* UNROLL_RUN_LOOP */
05715 
05716             GET_HIRES_TIME(vpc, t1);
05717             STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
05718             COPY_HIRES_TIME(t0, t1);
05719 
05720             if (count > 0) {
05721                 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
05722                 toprun_count += count;
05723                 botrun_count += count;
05724                 i += count;
05725             }
05726 #endif /* SKIP_COMPOSITE */
05727 
05728             /***********************************************************
05729              * Go on to next voxel run.
05730              ***********************************************************/
05731 
05732             last_run_state = run_state;
05733         } /* while (i > 0) */
05734 
05735         /***************************************************************
05736          * Finish processing voxel scanline and go on to next one.
05737          ***************************************************************/
05738 
05739 #ifdef UNROLL_RUN_LOOP
05740         ASSERT(i == 0);
05741 #else
05742         ASSERT(i == -1);
05743 #endif
05744 
05745 #ifndef SKIP_COMPOSITE
05746 #ifdef UNROLL_RUN_LOOP
05747         /* do the last pixel (to the right of the last voxel) */
05748         if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
05749             /* last voxels are nonzero and the pixel is not opaque yet
05750                so there is work to be done */
05751             Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
05752             switch (last_run_state) {
05753             case TOP_NONZERO:
05754                 /* only the top-left voxel contributes */
05755                 if (!voxels_loaded) {
05756                     
05757     
05758             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05759             opacity = param0_table[opac_param];
05760             if (param1_size != 0) {
05761                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05762                 opacity *= param1_table[opac_param];
05763                 if (param2_size != 0) {
05764                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05765                     opacity *= param2_table[opac_param];
05766                 }
05767             }
05768             if (opacity > min_opacity) {
05769                 opacity_int = opacity*255.;
05770                 top_opc = opac_correct[opacity_int];
05771             } else {
05772                 top_opc = (float)0.;
05773             };
05774     
05775     
05776     ;
05777     ;
05778     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
05779                              client_data);
05780     shade_factor = top_opc * slice_depth_cueing;
05781     
05782         top_rclr *= shade_factor;
05783         top_gclr *= shade_factor;
05784         top_bclr *= shade_factor;
05785     ;
05786                 }
05787                 
05788 #ifdef DEBUG
05789     if (ipixel == trace_pixel_ptr) {
05790         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05791         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05792         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05793         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05794         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05795     }
05796 #endif
05797 ;
05798                 
05799        acc_opc = top_opc * wgtTL;
05800        
05801             acc_rclr = top_rclr * wgtTL;
05802             acc_gclr = top_gclr * wgtTL;
05803             acc_bclr = top_bclr * wgtTL;
05804        
05805 #ifdef DEBUG
05806     if (ipixel == trace_pixel_ptr) {
05807         trace_opcTL = top_opc;
05808         trace_rclrTL = top_rclr;
05809                      trace_gclrTL = top_gclr;
05810                      trace_bclrTL = top_bclr;
05811         
05812     }
05813 #endif
05814 ;
05815                 
05816         COUNT_RESAMPLE;
05817         if (acc_opc > min_opacity) {
05818             COUNT_COMPOSITE;
05819             iopc = ipixel->opcflt;
05820 #           ifndef SKIP_ERT
05821                 ASSERT(iopc < max_opacity);
05822 #           endif
05823             iopc_inv = (float)1. - iopc;
05824             
05825         ipixel->rclrflt += acc_rclr * iopc_inv;
05826         ipixel->gclrflt += acc_gclr * iopc_inv;
05827         ipixel->bclrflt += acc_bclr * iopc_inv;
05828             iopc += acc_opc * iopc_inv;
05829             ipixel->opcflt = iopc;
05830             
05831 #ifdef DEBUG
05832     if (ipixel == trace_pixel_ptr) {
05833 #ifdef COMPUTE_SHADOW_BUFFER
05834         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05835 #else
05836         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05837 #endif
05838         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05839         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05840         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05841         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05842         printf("  %3.0f %3.0f\n", iopc*255., 
05843                ipixel->rclrflt);
05844         
05845         
05846         printf("              ");
05847         printf("      %3.0f    ",trace_gclrTL);
05848         printf("      %3.0f    ",trace_gclrBL);
05849         printf("      %3.0f    ",trace_gclrTR);
05850         printf("      %3.0f    ",trace_gclrBR);
05851         printf("      %3.0f\n", ipixel->gclrflt);
05852         printf("              ");
05853         printf("      %3.0f    ",trace_bclrTL);
05854         printf("      %3.0f    ",trace_bclrBL);
05855         printf("      %3.0f    ",trace_bclrTR);
05856         printf("      %3.0f    ",trace_bclrBR);
05857         printf("      %3.0f\n", ipixel->bclrflt);
05858     }
05859 #endif /* DEBUG */
05860 ;
05861 #           ifndef SKIP_ERT
05862                 if (iopc >= max_opacity) {
05863                     ASSERT(ipixel->lnk == 0);
05864                     ipixel->lnk = 1;
05865                 }
05866 #           endif
05867         };
05868                 break;
05869             case BOT_NONZERO:
05870                 /* only the bottom left voxel contributes */
05871                 if (!voxels_loaded) {
05872                     
05873     
05874             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05875             opacity = param0_table[opac_param];
05876             if (param1_size != 0) {
05877                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05878                 opacity *= param1_table[opac_param];
05879                 if (param2_size != 0) {
05880                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05881                     opacity *= param2_table[opac_param];
05882                 }
05883             }
05884             if (opacity > min_opacity) {
05885                 opacity_int = opacity*255.;
05886                 bot_opc = opac_correct[opacity_int];
05887             } else {
05888                 bot_opc = (float)0.;
05889             };
05890     
05891     
05892     ;
05893     ;
05894     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
05895                              client_data);
05896     shade_factor = bot_opc * slice_depth_cueing;
05897     
05898         bot_rclr *= shade_factor;
05899         bot_gclr *= shade_factor;
05900         bot_bclr *= shade_factor;
05901     ;
05902                 }
05903                 
05904 #ifdef DEBUG
05905     if (ipixel == trace_pixel_ptr) {
05906         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05907         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05908         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05909         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05910         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05911     }
05912 #endif
05913 ;
05914                 
05915        acc_opc = bot_opc * wgtBL;
05916        
05917             acc_rclr = bot_rclr * wgtBL;
05918             acc_gclr = bot_gclr * wgtBL;
05919             acc_bclr = bot_bclr * wgtBL;
05920        
05921 #ifdef DEBUG
05922     if (ipixel == trace_pixel_ptr) {
05923         trace_opcBL = bot_opc;
05924         trace_rclrBL = bot_rclr;
05925                      trace_gclrBL = bot_gclr;
05926                      trace_bclrBL = bot_bclr;
05927         
05928     }
05929 #endif
05930 ;
05931                 
05932         COUNT_RESAMPLE;
05933         if (acc_opc > min_opacity) {
05934             COUNT_COMPOSITE;
05935             iopc = ipixel->opcflt;
05936 #           ifndef SKIP_ERT
05937                 ASSERT(iopc < max_opacity);
05938 #           endif
05939             iopc_inv = (float)1. - iopc;
05940             
05941         ipixel->rclrflt += acc_rclr * iopc_inv;
05942         ipixel->gclrflt += acc_gclr * iopc_inv;
05943         ipixel->bclrflt += acc_bclr * iopc_inv;
05944             iopc += acc_opc * iopc_inv;
05945             ipixel->opcflt = iopc;
05946             
05947 #ifdef DEBUG
05948     if (ipixel == trace_pixel_ptr) {
05949 #ifdef COMPUTE_SHADOW_BUFFER
05950         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05951 #else
05952         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05953 #endif
05954         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05955         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05956         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05957         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05958         printf("  %3.0f %3.0f\n", iopc*255., 
05959                ipixel->rclrflt);
05960         
05961         
05962         printf("              ");
05963         printf("      %3.0f    ",trace_gclrTL);
05964         printf("      %3.0f    ",trace_gclrBL);
05965         printf("      %3.0f    ",trace_gclrTR);
05966         printf("      %3.0f    ",trace_gclrBR);
05967         printf("      %3.0f\n", ipixel->gclrflt);
05968         printf("              ");
05969         printf("      %3.0f    ",trace_bclrTL);
05970         printf("      %3.0f    ",trace_bclrBL);
05971         printf("      %3.0f    ",trace_bclrTR);
05972         printf("      %3.0f    ",trace_bclrBR);
05973         printf("      %3.0f\n", ipixel->bclrflt);
05974     }
05975 #endif /* DEBUG */
05976 ;
05977 #           ifndef SKIP_ERT
05978                 if (iopc >= max_opacity) {
05979                     ASSERT(ipixel->lnk == 0);
05980                     ipixel->lnk = 1;
05981                 }
05982 #           endif
05983         };
05984                 break;
05985             case ALL_NONZERO:
05986                 /* the top and bottom left voxels contribute */
05987                 if (!voxels_loaded) {
05988                     
05989     
05990             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05991             opacity = param0_table[opac_param];
05992             if (param1_size != 0) {
05993                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05994                 opacity *= param1_table[opac_param];
05995                 if (param2_size != 0) {
05996                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05997                     opacity *= param2_table[opac_param];
05998                 }
05999             }
06000             if (opacity > min_opacity) {
06001                 opacity_int = opacity*255.;
06002                 top_opc = opac_correct[opacity_int];
06003             } else {
06004                 top_opc = (float)0.;
06005             };
06006     
06007     
06008     ;
06009     ;
06010     shade_func(topRLEdata - voxel_istride, &(top_rclr), &(top_gclr), &(top_bclr),
06011                              client_data);
06012     shade_factor = top_opc * slice_depth_cueing;
06013     
06014         top_rclr *= shade_factor;
06015         top_gclr *= shade_factor;
06016         top_bclr *= shade_factor;
06017     ;
06018                     
06019     
06020             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
06021             opacity = param0_table[opac_param];
06022             if (param1_size != 0) {
06023                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
06024                 opacity *= param1_table[opac_param];
06025                 if (param2_size != 0) {
06026                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
06027                     opacity *= param2_table[opac_param];
06028                 }
06029             }
06030             if (opacity > min_opacity) {
06031                 opacity_int = opacity*255.;
06032                 bot_opc = opac_correct[opacity_int];
06033             } else {
06034                 bot_opc = (float)0.;
06035             };
06036     
06037     
06038     ;
06039     ;
06040     shade_func(botRLEdata - voxel_istride, &(bot_rclr), &(bot_gclr), &(bot_bclr),
06041                              client_data);
06042     shade_factor = bot_opc * slice_depth_cueing;
06043     
06044         bot_rclr *= shade_factor;
06045         bot_gclr *= shade_factor;
06046         bot_bclr *= shade_factor;
06047     ;
06048                 }
06049                 
06050 #ifdef DEBUG
06051     if (ipixel == trace_pixel_ptr) {
06052         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06053         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06054         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06055         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06056         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06057     }
06058 #endif
06059 ;
06060                 
06061        acc_opc = top_opc * wgtTL;
06062        
06063             acc_rclr = top_rclr * wgtTL;
06064             acc_gclr = top_gclr * wgtTL;
06065             acc_bclr = top_bclr * wgtTL;
06066        
06067 #ifdef DEBUG
06068     if (ipixel == trace_pixel_ptr) {
06069         trace_opcTL = top_opc;
06070         trace_rclrTL = top_rclr;
06071                      trace_gclrTL = top_gclr;
06072                      trace_bclrTL = top_bclr;
06073         
06074     }
06075 #endif
06076 ;
06077                 
06078        acc_opc += bot_opc * wgtBL;
06079        
06080             acc_rclr += bot_rclr * wgtBL;
06081             acc_gclr += bot_gclr * wgtBL;
06082             acc_bclr += bot_bclr * wgtBL;
06083        
06084 #ifdef DEBUG
06085     if (ipixel == trace_pixel_ptr) {
06086         trace_opcBL = bot_opc;
06087         trace_rclrBL = bot_rclr;
06088                      trace_gclrBL = bot_gclr;
06089                      trace_bclrBL = bot_bclr;
06090         
06091     }
06092 #endif
06093 ;
06094                 
06095         COUNT_RESAMPLE;
06096         if (acc_opc > min_opacity) {
06097             COUNT_COMPOSITE;
06098             iopc = ipixel->opcflt;
06099 #           ifndef SKIP_ERT
06100                 ASSERT(iopc < max_opacity);
06101 #           endif
06102             iopc_inv = (float)1. - iopc;
06103             
06104         ipixel->rclrflt += acc_rclr * iopc_inv;
06105         ipixel->gclrflt += acc_gclr * iopc_inv;
06106         ipixel->bclrflt += acc_bclr * iopc_inv;
06107             iopc += acc_opc * iopc_inv;
06108             ipixel->opcflt = iopc;
06109             
06110 #ifdef DEBUG
06111     if (ipixel == trace_pixel_ptr) {
06112 #ifdef COMPUTE_SHADOW_BUFFER
06113         printf("{%3d}  %3d %3d", k, icount-i-count, j);
06114 #else
06115         printf("[%3d]  %3d %3d", k, icount-i-count, j);
06116 #endif
06117         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06118         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06119         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06120         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06121         printf("  %3.0f %3.0f\n", iopc*255., 
06122                ipixel->rclrflt);
06123         
06124         
06125         printf("              ");
06126         printf("      %3.0f    ",trace_gclrTL);
06127         printf("      %3.0f    ",trace_gclrBL);
06128         printf("      %3.0f    ",trace_gclrTR);
06129         printf("      %3.0f    ",trace_gclrBR);
06130         printf("      %3.0f\n", ipixel->gclrflt);
06131         printf("              ");
06132         printf("      %3.0f    ",trace_bclrTL);
06133         printf("      %3.0f    ",trace_bclrBL);
06134         printf("      %3.0f    ",trace_bclrTR);
06135         printf("      %3.0f    ",trace_bclrBR);
06136         printf("      %3.0f\n", ipixel->bclrflt);
06137     }
06138 #endif /* DEBUG */
06139 ;
06140 #           ifndef SKIP_ERT
06141                 if (iopc >= max_opacity) {
06142                     ASSERT(ipixel->lnk == 0);
06143                     ipixel->lnk = 1;
06144                 }
06145 #           endif
06146         };
06147                 break;
06148             default:
06149                 VPBug("illegal value for run state at end of scanline");
06150             }
06151         } else if (last_run_state == ALL_ZERO) {
06152             Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
06153         } else {
06154             Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
06155         }
06156 #endif /* UNROLL_RUN_LOOP */
06157 #endif /* SKIP_COMPOSITE */
06158 
06159 #ifndef UNROLL_RUN_LOOP
06160         run_state = final_run_state;
06161 #endif
06162         /* skip over any zero-length runs remaining in this scanline */
06163         if (j != 0 && ((run_state & 1) == 0)) {
06164             toprun_count = *topRLElen++;
06165             ASSERT(toprun_count == 0);
06166         }
06167         if (j != jcount && ((run_state & 2) == 0)) {
06168             botrun_count = *botRLElen++;
06169             ASSERT(botrun_count == 0);
06170         }
06171 
06172         /* go to next intermediate image scanline */
06173 #ifdef UNROLL_RUN_LOOP
06174         ipixel += intermediate_width - icount;
06175 #ifdef USE_SHADOW_BUFFER
06176         shadow_pixel += shadow_width - icount;
06177 #endif
06178 #else /* UNROLL_RUN_LOOP */
06179         ipixel += intermediate_width - (icount+1);
06180 #ifdef USE_SHADOW_BUFFER
06181         shadow_pixel += shadow_width - (icount+1);
06182 #endif
06183 #endif /* UNROLL_RUN_LOOP */
06184 
06185         Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
06186     } /* for j */
06187 
06188     /***************************************************************
06189      * Finish processing the voxel slice.
06190      ***************************************************************/
06191 
06192     GET_HIRES_TIME(vpc, t1);
06193     STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
06194 
06195     Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
06196 }
 

Powered by Plone

This site conforms to the following standards: