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_compAR3NB.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 MULTIPLE_MATERIALS
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  * VPCompAR3NB
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 VPCompAR3NB (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     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
00983     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
00984     
00985         
00986         
00987     top_rclr = 
00988     shade_table[shade_index + 3*0 + 0] * 
00989         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00990         
00991     top_gclr = 
00992     shade_table[shade_index + 3*0 + 1] * 
00993         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00994         
00995     top_bclr = 
00996     shade_table[shade_index + 3*0 + 2] * 
00997         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00998         ;
00999         ;
01000         ;
01001         for (m = 1; m < num_materials; m++) {
01002              
01003         
01004     top_rclr += 
01005     shade_table[shade_index + 3*m + 0] * 
01006         weight_table[weight_index + m];
01007         
01008     top_gclr += 
01009     shade_table[shade_index + 3*m + 1] * 
01010         weight_table[weight_index + m];
01011         
01012     top_bclr += 
01013     shade_table[shade_index + 3*m + 2] * 
01014         weight_table[weight_index + m];
01015         ;
01016         ;
01017         ;
01018         };
01019     shade_factor = top_opc * slice_depth_cueing;
01020     
01021         top_rclr *= shade_factor;
01022         top_gclr *= shade_factor;
01023         top_bclr *= shade_factor;
01024     ;
01025                 }
01026                 
01027 #ifdef DEBUG
01028     if (ipixel == trace_pixel_ptr) {
01029         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01030         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01031         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01032         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01033         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01034     }
01035 #endif
01036 ;
01037                 
01038        acc_opc = top_opc * wgtTL;
01039        
01040             acc_rclr = top_rclr * wgtTL;
01041             acc_gclr = top_gclr * wgtTL;
01042             acc_bclr = top_bclr * wgtTL;
01043        
01044 #ifdef DEBUG
01045     if (ipixel == trace_pixel_ptr) {
01046         trace_opcTL = top_opc;
01047         trace_rclrTL = top_rclr;
01048                      trace_gclrTL = top_gclr;
01049                      trace_bclrTL = top_bclr;
01050         
01051     }
01052 #endif
01053 ;
01054                 
01055         COUNT_RESAMPLE;
01056         if (acc_opc > min_opacity) {
01057             COUNT_COMPOSITE;
01058             iopc = ipixel->opcflt;
01059 #           ifndef SKIP_ERT
01060                 ASSERT(iopc < max_opacity);
01061 #           endif
01062             iopc_inv = (float)1. - iopc;
01063             
01064         ipixel->rclrflt += acc_rclr * iopc_inv;
01065         ipixel->gclrflt += acc_gclr * iopc_inv;
01066         ipixel->bclrflt += acc_bclr * iopc_inv;
01067             iopc += acc_opc * iopc_inv;
01068             ipixel->opcflt = iopc;
01069             
01070 #ifdef DEBUG
01071     if (ipixel == trace_pixel_ptr) {
01072 #ifdef COMPUTE_SHADOW_BUFFER
01073         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01074 #else
01075         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01076 #endif
01077         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01078         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01079         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01080         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01081         printf("  %3.0f %3.0f\n", iopc*255., 
01082                ipixel->rclrflt);
01083         
01084         
01085         printf("              ");
01086         printf("      %3.0f    ",trace_gclrTL);
01087         printf("      %3.0f    ",trace_gclrBL);
01088         printf("      %3.0f    ",trace_gclrTR);
01089         printf("      %3.0f    ",trace_gclrBR);
01090         printf("      %3.0f\n", ipixel->gclrflt);
01091         printf("              ");
01092         printf("      %3.0f    ",trace_bclrTL);
01093         printf("      %3.0f    ",trace_bclrBL);
01094         printf("      %3.0f    ",trace_bclrTR);
01095         printf("      %3.0f    ",trace_bclrBR);
01096         printf("      %3.0f\n", ipixel->bclrflt);
01097     }
01098 #endif /* DEBUG */
01099 ;
01100 #           ifndef SKIP_ERT
01101                 if (iopc >= max_opacity) {
01102                     ASSERT(ipixel->lnk == 0);
01103                     ipixel->lnk = 1;
01104                 }
01105 #           endif
01106         };
01107                 ipixel += count;
01108                 topRLEdata += count * voxel_istride;
01109                 botRLEdata += count * voxel_istride;
01110                 count = 0;
01111                 break;
01112             case BOT_NONZERO__ALL_ZERO:
01113                 /* only the bottom left voxel contributes to the first
01114                    pixel of the run, and the rest are zero */
01115                 if (!voxels_loaded) {
01116                     
01117     
01118             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01119             opacity = param0_table[opac_param];
01120             if (param1_size != 0) {
01121                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01122                 opacity *= param1_table[opac_param];
01123                 if (param2_size != 0) {
01124                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01125                     opacity *= param2_table[opac_param];
01126                 }
01127             }
01128             if (opacity > min_opacity) {
01129                 opacity_int = opacity*255.;
01130                 bot_opc = opac_correct[opacity_int];
01131             } else {
01132                 bot_opc = (float)0.;
01133             };
01134     
01135     
01136     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01137     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01138     
01139         
01140         
01141     bot_rclr = 
01142     shade_table[shade_index + 3*0 + 0] * 
01143         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01144         
01145     bot_gclr = 
01146     shade_table[shade_index + 3*0 + 1] * 
01147         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01148         
01149     bot_bclr = 
01150     shade_table[shade_index + 3*0 + 2] * 
01151         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01152         ;
01153         ;
01154         ;
01155         for (m = 1; m < num_materials; m++) {
01156              
01157         
01158     bot_rclr += 
01159     shade_table[shade_index + 3*m + 0] * 
01160         weight_table[weight_index + m];
01161         
01162     bot_gclr += 
01163     shade_table[shade_index + 3*m + 1] * 
01164         weight_table[weight_index + m];
01165         
01166     bot_bclr += 
01167     shade_table[shade_index + 3*m + 2] * 
01168         weight_table[weight_index + m];
01169         ;
01170         ;
01171         ;
01172         };
01173     shade_factor = bot_opc * slice_depth_cueing;
01174     
01175         bot_rclr *= shade_factor;
01176         bot_gclr *= shade_factor;
01177         bot_bclr *= shade_factor;
01178     ;
01179                 }
01180                 
01181 #ifdef DEBUG
01182     if (ipixel == trace_pixel_ptr) {
01183         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01184         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01185         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01186         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01187         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01188     }
01189 #endif
01190 ;
01191                 
01192        acc_opc = bot_opc * wgtBL;
01193        
01194             acc_rclr = bot_rclr * wgtBL;
01195             acc_gclr = bot_gclr * wgtBL;
01196             acc_bclr = bot_bclr * wgtBL;
01197        
01198 #ifdef DEBUG
01199     if (ipixel == trace_pixel_ptr) {
01200         trace_opcBL = bot_opc;
01201         trace_rclrBL = bot_rclr;
01202                      trace_gclrBL = bot_gclr;
01203                      trace_bclrBL = bot_bclr;
01204         
01205     }
01206 #endif
01207 ;
01208                 
01209         COUNT_RESAMPLE;
01210         if (acc_opc > min_opacity) {
01211             COUNT_COMPOSITE;
01212             iopc = ipixel->opcflt;
01213 #           ifndef SKIP_ERT
01214                 ASSERT(iopc < max_opacity);
01215 #           endif
01216             iopc_inv = (float)1. - iopc;
01217             
01218         ipixel->rclrflt += acc_rclr * iopc_inv;
01219         ipixel->gclrflt += acc_gclr * iopc_inv;
01220         ipixel->bclrflt += acc_bclr * iopc_inv;
01221             iopc += acc_opc * iopc_inv;
01222             ipixel->opcflt = iopc;
01223             
01224 #ifdef DEBUG
01225     if (ipixel == trace_pixel_ptr) {
01226 #ifdef COMPUTE_SHADOW_BUFFER
01227         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01228 #else
01229         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01230 #endif
01231         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01232         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01233         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01234         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01235         printf("  %3.0f %3.0f\n", iopc*255., 
01236                ipixel->rclrflt);
01237         
01238         
01239         printf("              ");
01240         printf("      %3.0f    ",trace_gclrTL);
01241         printf("      %3.0f    ",trace_gclrBL);
01242         printf("      %3.0f    ",trace_gclrTR);
01243         printf("      %3.0f    ",trace_gclrBR);
01244         printf("      %3.0f\n", ipixel->gclrflt);
01245         printf("              ");
01246         printf("      %3.0f    ",trace_bclrTL);
01247         printf("      %3.0f    ",trace_bclrBL);
01248         printf("      %3.0f    ",trace_bclrTR);
01249         printf("      %3.0f    ",trace_bclrBR);
01250         printf("      %3.0f\n", ipixel->bclrflt);
01251     }
01252 #endif /* DEBUG */
01253 ;
01254 #           ifndef SKIP_ERT
01255                 if (iopc >= max_opacity) {
01256                     ASSERT(ipixel->lnk == 0);
01257                     ipixel->lnk = 1;
01258                 }
01259 #           endif
01260         };
01261                 ipixel += count;
01262                 topRLEdata += count * voxel_istride;
01263                 botRLEdata += count * voxel_istride;
01264                 count = 0;
01265                 break;
01266             case ALL_NONZERO__ALL_ZERO:
01267                 /* the top and bottom left voxels contribute to the
01268                    first pixel of the run, and the rest are zero */
01269                 if (!voxels_loaded) {
01270                     
01271     
01272             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01273             opacity = param0_table[opac_param];
01274             if (param1_size != 0) {
01275                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01276                 opacity *= param1_table[opac_param];
01277                 if (param2_size != 0) {
01278                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01279                     opacity *= param2_table[opac_param];
01280                 }
01281             }
01282             if (opacity > min_opacity) {
01283                 opacity_int = opacity*255.;
01284                 top_opc = opac_correct[opacity_int];
01285             } else {
01286                 top_opc = (float)0.;
01287             };
01288     
01289     
01290     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01291     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01292     
01293         
01294         
01295     top_rclr = 
01296     shade_table[shade_index + 3*0 + 0] * 
01297         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01298         
01299     top_gclr = 
01300     shade_table[shade_index + 3*0 + 1] * 
01301         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01302         
01303     top_bclr = 
01304     shade_table[shade_index + 3*0 + 2] * 
01305         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01306         ;
01307         ;
01308         ;
01309         for (m = 1; m < num_materials; m++) {
01310              
01311         
01312     top_rclr += 
01313     shade_table[shade_index + 3*m + 0] * 
01314         weight_table[weight_index + m];
01315         
01316     top_gclr += 
01317     shade_table[shade_index + 3*m + 1] * 
01318         weight_table[weight_index + m];
01319         
01320     top_bclr += 
01321     shade_table[shade_index + 3*m + 2] * 
01322         weight_table[weight_index + m];
01323         ;
01324         ;
01325         ;
01326         };
01327     shade_factor = top_opc * slice_depth_cueing;
01328     
01329         top_rclr *= shade_factor;
01330         top_gclr *= shade_factor;
01331         top_bclr *= shade_factor;
01332     ;
01333                     
01334     
01335             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
01336             opacity = param0_table[opac_param];
01337             if (param1_size != 0) {
01338                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
01339                 opacity *= param1_table[opac_param];
01340                 if (param2_size != 0) {
01341                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
01342                     opacity *= param2_table[opac_param];
01343                 }
01344             }
01345             if (opacity > min_opacity) {
01346                 opacity_int = opacity*255.;
01347                 bot_opc = opac_correct[opacity_int];
01348             } else {
01349                 bot_opc = (float)0.;
01350             };
01351     
01352     
01353     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01354     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01355     
01356         
01357         
01358     bot_rclr = 
01359     shade_table[shade_index + 3*0 + 0] * 
01360         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01361         
01362     bot_gclr = 
01363     shade_table[shade_index + 3*0 + 1] * 
01364         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01365         
01366     bot_bclr = 
01367     shade_table[shade_index + 3*0 + 2] * 
01368         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01369         ;
01370         ;
01371         ;
01372         for (m = 1; m < num_materials; m++) {
01373              
01374         
01375     bot_rclr += 
01376     shade_table[shade_index + 3*m + 0] * 
01377         weight_table[weight_index + m];
01378         
01379     bot_gclr += 
01380     shade_table[shade_index + 3*m + 1] * 
01381         weight_table[weight_index + m];
01382         
01383     bot_bclr += 
01384     shade_table[shade_index + 3*m + 2] * 
01385         weight_table[weight_index + m];
01386         ;
01387         ;
01388         ;
01389         };
01390     shade_factor = bot_opc * slice_depth_cueing;
01391     
01392         bot_rclr *= shade_factor;
01393         bot_gclr *= shade_factor;
01394         bot_bclr *= shade_factor;
01395     ;
01396                 }
01397                 
01398 #ifdef DEBUG
01399     if (ipixel == trace_pixel_ptr) {
01400         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01401         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01402         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01403         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01404         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01405     }
01406 #endif
01407 ;
01408                 
01409        acc_opc = top_opc * wgtTL;
01410        
01411             acc_rclr = top_rclr * wgtTL;
01412             acc_gclr = top_gclr * wgtTL;
01413             acc_bclr = top_bclr * wgtTL;
01414        
01415 #ifdef DEBUG
01416     if (ipixel == trace_pixel_ptr) {
01417         trace_opcTL = top_opc;
01418         trace_rclrTL = top_rclr;
01419                      trace_gclrTL = top_gclr;
01420                      trace_bclrTL = top_bclr;
01421         
01422     }
01423 #endif
01424 ;
01425                 
01426        acc_opc += bot_opc * wgtBL;
01427        
01428             acc_rclr += bot_rclr * wgtBL;
01429             acc_gclr += bot_gclr * wgtBL;
01430             acc_bclr += bot_bclr * wgtBL;
01431        
01432 #ifdef DEBUG
01433     if (ipixel == trace_pixel_ptr) {
01434         trace_opcBL = bot_opc;
01435         trace_rclrBL = bot_rclr;
01436                      trace_gclrBL = bot_gclr;
01437                      trace_bclrBL = bot_bclr;
01438         
01439     }
01440 #endif
01441 ;
01442                 
01443         COUNT_RESAMPLE;
01444         if (acc_opc > min_opacity) {
01445             COUNT_COMPOSITE;
01446             iopc = ipixel->opcflt;
01447 #           ifndef SKIP_ERT
01448                 ASSERT(iopc < max_opacity);
01449 #           endif
01450             iopc_inv = (float)1. - iopc;
01451             
01452         ipixel->rclrflt += acc_rclr * iopc_inv;
01453         ipixel->gclrflt += acc_gclr * iopc_inv;
01454         ipixel->bclrflt += acc_bclr * iopc_inv;
01455             iopc += acc_opc * iopc_inv;
01456             ipixel->opcflt = iopc;
01457             
01458 #ifdef DEBUG
01459     if (ipixel == trace_pixel_ptr) {
01460 #ifdef COMPUTE_SHADOW_BUFFER
01461         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01462 #else
01463         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01464 #endif
01465         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01466         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01467         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01468         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01469         printf("  %3.0f %3.0f\n", iopc*255., 
01470                ipixel->rclrflt);
01471         
01472         
01473         printf("              ");
01474         printf("      %3.0f    ",trace_gclrTL);
01475         printf("      %3.0f    ",trace_gclrBL);
01476         printf("      %3.0f    ",trace_gclrTR);
01477         printf("      %3.0f    ",trace_gclrBR);
01478         printf("      %3.0f\n", ipixel->gclrflt);
01479         printf("              ");
01480         printf("      %3.0f    ",trace_bclrTL);
01481         printf("      %3.0f    ",trace_bclrBL);
01482         printf("      %3.0f    ",trace_bclrTR);
01483         printf("      %3.0f    ",trace_bclrBR);
01484         printf("      %3.0f\n", ipixel->bclrflt);
01485     }
01486 #endif /* DEBUG */
01487 ;
01488 #           ifndef SKIP_ERT
01489                 if (iopc >= max_opacity) {
01490                     ASSERT(ipixel->lnk == 0);
01491                     ipixel->lnk = 1;
01492                 }
01493 #           endif
01494         };
01495                 ipixel += count;
01496                 topRLEdata += count * voxel_istride;
01497                 botRLEdata += count * voxel_istride;
01498                 count = 0;
01499                 break;
01500             case ALL_ZERO__TOP_NONZERO:
01501                 /* first pixel: only the top-right voxel contributes */
01502                 
01503     
01504             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01505             opacity = param0_table[opac_param];
01506             if (param1_size != 0) {
01507                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01508                 opacity *= param1_table[opac_param];
01509                 if (param2_size != 0) {
01510                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01511                     opacity *= param2_table[opac_param];
01512                 }
01513             }
01514             if (opacity > min_opacity) {
01515                 opacity_int = opacity*255.;
01516                 top_opc = opac_correct[opacity_int];
01517             } else {
01518                 top_opc = (float)0.;
01519             };
01520     
01521     
01522     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
01523     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01524     
01525         
01526         
01527     top_rclr = 
01528     shade_table[shade_index + 3*0 + 0] * 
01529         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01530         
01531     top_gclr = 
01532     shade_table[shade_index + 3*0 + 1] * 
01533         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01534         
01535     top_bclr = 
01536     shade_table[shade_index + 3*0 + 2] * 
01537         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01538         ;
01539         ;
01540         ;
01541         for (m = 1; m < num_materials; m++) {
01542              
01543         
01544     top_rclr += 
01545     shade_table[shade_index + 3*m + 0] * 
01546         weight_table[weight_index + m];
01547         
01548     top_gclr += 
01549     shade_table[shade_index + 3*m + 1] * 
01550         weight_table[weight_index + m];
01551         
01552     top_bclr += 
01553     shade_table[shade_index + 3*m + 2] * 
01554         weight_table[weight_index + m];
01555         ;
01556         ;
01557         ;
01558         };
01559     shade_factor = top_opc * slice_depth_cueing;
01560     
01561         top_rclr *= shade_factor;
01562         top_gclr *= shade_factor;
01563         top_bclr *= shade_factor;
01564     ;
01565                 
01566 #ifdef DEBUG
01567     if (ipixel == trace_pixel_ptr) {
01568         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01569         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01570         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01571         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01572         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01573     }
01574 #endif
01575 ;
01576                 
01577        acc_opc = top_opc * wgtTR;
01578        
01579             acc_rclr = top_rclr * wgtTR;
01580             acc_gclr = top_gclr * wgtTR;
01581             acc_bclr = top_bclr * wgtTR;
01582        
01583 #ifdef DEBUG
01584     if (ipixel == trace_pixel_ptr) {
01585         trace_opcTR = top_opc;
01586         trace_rclrTR = top_rclr;
01587                      trace_gclrTR = top_gclr;
01588                      trace_bclrTR = top_bclr;
01589         
01590     }
01591 #endif
01592 ;
01593                 
01594         COUNT_RESAMPLE;
01595         if (acc_opc > min_opacity) {
01596             COUNT_COMPOSITE;
01597             iopc = ipixel->opcflt;
01598 #           ifndef SKIP_ERT
01599                 ASSERT(iopc < max_opacity);
01600 #           endif
01601             iopc_inv = (float)1. - iopc;
01602             
01603         ipixel->rclrflt += acc_rclr * iopc_inv;
01604         ipixel->gclrflt += acc_gclr * iopc_inv;
01605         ipixel->bclrflt += acc_bclr * iopc_inv;
01606             iopc += acc_opc * iopc_inv;
01607             ipixel->opcflt = iopc;
01608             
01609 #ifdef DEBUG
01610     if (ipixel == trace_pixel_ptr) {
01611 #ifdef COMPUTE_SHADOW_BUFFER
01612         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01613 #else
01614         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01615 #endif
01616         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01617         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01618         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01619         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01620         printf("  %3.0f %3.0f\n", iopc*255., 
01621                ipixel->rclrflt);
01622         
01623         
01624         printf("              ");
01625         printf("      %3.0f    ",trace_gclrTL);
01626         printf("      %3.0f    ",trace_gclrBL);
01627         printf("      %3.0f    ",trace_gclrTR);
01628         printf("      %3.0f    ",trace_gclrBR);
01629         printf("      %3.0f\n", ipixel->gclrflt);
01630         printf("              ");
01631         printf("      %3.0f    ",trace_bclrTL);
01632         printf("      %3.0f    ",trace_bclrBL);
01633         printf("      %3.0f    ",trace_bclrTR);
01634         printf("      %3.0f    ",trace_bclrBR);
01635         printf("      %3.0f\n", ipixel->bclrflt);
01636     }
01637 #endif /* DEBUG */
01638 ;
01639 #           ifndef SKIP_ERT
01640                 if (iopc >= max_opacity) {
01641                     ASSERT(ipixel->lnk == 0);
01642                     ipixel->lnk = 1;
01643                 }
01644 #           endif
01645         };
01646                 ipixel += 1;
01647                 topRLEdata += 1 * voxel_istride;
01648                 botRLEdata += 1 * voxel_istride;
01649                 count--;
01650                 SET_VOXELS_LOADED;
01651 
01652                 /* do the rest of the pixels in this run;
01653                    the top-left and top-right voxels contribute */
01654                 while (count > 0) {
01655                     if (PIXEL_IS_OPAQUE(ipixel))
01656                         break;
01657                     if (!voxels_loaded) {
01658                         
01659     
01660             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01661             opacity = param0_table[opac_param];
01662             if (param1_size != 0) {
01663                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01664                 opacity *= param1_table[opac_param];
01665                 if (param2_size != 0) {
01666                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01667                     opacity *= param2_table[opac_param];
01668                 }
01669             }
01670             if (opacity > min_opacity) {
01671                 opacity_int = opacity*255.;
01672                 top_opc = opac_correct[opacity_int];
01673             } else {
01674                 top_opc = (float)0.;
01675             };
01676     
01677     
01678     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01679     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01680     
01681         
01682         
01683     top_rclr = 
01684     shade_table[shade_index + 3*0 + 0] * 
01685         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01686         
01687     top_gclr = 
01688     shade_table[shade_index + 3*0 + 1] * 
01689         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01690         
01691     top_bclr = 
01692     shade_table[shade_index + 3*0 + 2] * 
01693         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01694         ;
01695         ;
01696         ;
01697         for (m = 1; m < num_materials; m++) {
01698              
01699         
01700     top_rclr += 
01701     shade_table[shade_index + 3*m + 0] * 
01702         weight_table[weight_index + m];
01703         
01704     top_gclr += 
01705     shade_table[shade_index + 3*m + 1] * 
01706         weight_table[weight_index + m];
01707         
01708     top_bclr += 
01709     shade_table[shade_index + 3*m + 2] * 
01710         weight_table[weight_index + m];
01711         ;
01712         ;
01713         ;
01714         };
01715     shade_factor = top_opc * slice_depth_cueing;
01716     
01717         top_rclr *= shade_factor;
01718         top_gclr *= shade_factor;
01719         top_bclr *= shade_factor;
01720     ;
01721                     }
01722                     
01723 #ifdef DEBUG
01724     if (ipixel == trace_pixel_ptr) {
01725         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01726         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01727         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01728         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01729         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01730     }
01731 #endif
01732 ;
01733                     
01734        acc_opc = top_opc * wgtTL;
01735        
01736             acc_rclr = top_rclr * wgtTL;
01737             acc_gclr = top_gclr * wgtTL;
01738             acc_bclr = top_bclr * wgtTL;
01739        
01740 #ifdef DEBUG
01741     if (ipixel == trace_pixel_ptr) {
01742         trace_opcTL = top_opc;
01743         trace_rclrTL = top_rclr;
01744                      trace_gclrTL = top_gclr;
01745                      trace_bclrTL = top_bclr;
01746         
01747     }
01748 #endif
01749 ;
01750                     
01751     
01752             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01753             opacity = param0_table[opac_param];
01754             if (param1_size != 0) {
01755                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01756                 opacity *= param1_table[opac_param];
01757                 if (param2_size != 0) {
01758                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01759                     opacity *= param2_table[opac_param];
01760                 }
01761             }
01762             if (opacity > min_opacity) {
01763                 opacity_int = opacity*255.;
01764                 top_opc = opac_correct[opacity_int];
01765             } else {
01766                 top_opc = (float)0.;
01767             };
01768     
01769     
01770     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
01771     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01772     
01773         
01774         
01775     top_rclr = 
01776     shade_table[shade_index + 3*0 + 0] * 
01777         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01778         
01779     top_gclr = 
01780     shade_table[shade_index + 3*0 + 1] * 
01781         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01782         
01783     top_bclr = 
01784     shade_table[shade_index + 3*0 + 2] * 
01785         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01786         ;
01787         ;
01788         ;
01789         for (m = 1; m < num_materials; m++) {
01790              
01791         
01792     top_rclr += 
01793     shade_table[shade_index + 3*m + 0] * 
01794         weight_table[weight_index + m];
01795         
01796     top_gclr += 
01797     shade_table[shade_index + 3*m + 1] * 
01798         weight_table[weight_index + m];
01799         
01800     top_bclr += 
01801     shade_table[shade_index + 3*m + 2] * 
01802         weight_table[weight_index + m];
01803         ;
01804         ;
01805         ;
01806         };
01807     shade_factor = top_opc * slice_depth_cueing;
01808     
01809         top_rclr *= shade_factor;
01810         top_gclr *= shade_factor;
01811         top_bclr *= shade_factor;
01812     ;
01813                     
01814        acc_opc += top_opc * wgtTR;
01815        
01816             acc_rclr += top_rclr * wgtTR;
01817             acc_gclr += top_gclr * wgtTR;
01818             acc_bclr += top_bclr * wgtTR;
01819        
01820 #ifdef DEBUG
01821     if (ipixel == trace_pixel_ptr) {
01822         trace_opcTR = top_opc;
01823         trace_rclrTR = top_rclr;
01824                      trace_gclrTR = top_gclr;
01825                      trace_bclrTR = top_bclr;
01826         
01827     }
01828 #endif
01829 ;
01830                     
01831         COUNT_RESAMPLE;
01832         if (acc_opc > min_opacity) {
01833             COUNT_COMPOSITE;
01834             iopc = ipixel->opcflt;
01835 #           ifndef SKIP_ERT
01836                 ASSERT(iopc < max_opacity);
01837 #           endif
01838             iopc_inv = (float)1. - iopc;
01839             
01840         ipixel->rclrflt += acc_rclr * iopc_inv;
01841         ipixel->gclrflt += acc_gclr * iopc_inv;
01842         ipixel->bclrflt += acc_bclr * iopc_inv;
01843             iopc += acc_opc * iopc_inv;
01844             ipixel->opcflt = iopc;
01845             
01846 #ifdef DEBUG
01847     if (ipixel == trace_pixel_ptr) {
01848 #ifdef COMPUTE_SHADOW_BUFFER
01849         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01850 #else
01851         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01852 #endif
01853         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01854         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01855         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01856         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01857         printf("  %3.0f %3.0f\n", iopc*255., 
01858                ipixel->rclrflt);
01859         
01860         
01861         printf("              ");
01862         printf("      %3.0f    ",trace_gclrTL);
01863         printf("      %3.0f    ",trace_gclrBL);
01864         printf("      %3.0f    ",trace_gclrTR);
01865         printf("      %3.0f    ",trace_gclrBR);
01866         printf("      %3.0f\n", ipixel->gclrflt);
01867         printf("              ");
01868         printf("      %3.0f    ",trace_bclrTL);
01869         printf("      %3.0f    ",trace_bclrBL);
01870         printf("      %3.0f    ",trace_bclrTR);
01871         printf("      %3.0f    ",trace_bclrBR);
01872         printf("      %3.0f\n", ipixel->bclrflt);
01873     }
01874 #endif /* DEBUG */
01875 ;
01876 #           ifndef SKIP_ERT
01877                 if (iopc >= max_opacity) {
01878                     ASSERT(ipixel->lnk == 0);
01879                     ipixel->lnk = 1;
01880                 }
01881 #           endif
01882         };
01883                     ipixel += 1;
01884                     topRLEdata += 1 * voxel_istride;
01885                     botRLEdata += 1 * voxel_istride;
01886                     count--;
01887                     SET_VOXELS_LOADED;
01888                 }
01889                 break;
01890             case TOP_NONZERO__TOP_NONZERO:
01891                 /* do the pixels in this run; the top-left and
01892                    top-right voxels contribute */
01893                 while (count > 0) {
01894                     if (PIXEL_IS_OPAQUE(ipixel))
01895                         break;
01896                     if (!voxels_loaded) {
01897                         
01898     
01899             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
01900             opacity = param0_table[opac_param];
01901             if (param1_size != 0) {
01902                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
01903                 opacity *= param1_table[opac_param];
01904                 if (param2_size != 0) {
01905                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
01906                     opacity *= param2_table[opac_param];
01907                 }
01908             }
01909             if (opacity > min_opacity) {
01910                 opacity_int = opacity*255.;
01911                 top_opc = opac_correct[opacity_int];
01912             } else {
01913                 top_opc = (float)0.;
01914             };
01915     
01916     
01917     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01918     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01919     
01920         
01921         
01922     top_rclr = 
01923     shade_table[shade_index + 3*0 + 0] * 
01924         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01925         
01926     top_gclr = 
01927     shade_table[shade_index + 3*0 + 1] * 
01928         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01929         
01930     top_bclr = 
01931     shade_table[shade_index + 3*0 + 2] * 
01932         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01933         ;
01934         ;
01935         ;
01936         for (m = 1; m < num_materials; m++) {
01937              
01938         
01939     top_rclr += 
01940     shade_table[shade_index + 3*m + 0] * 
01941         weight_table[weight_index + m];
01942         
01943     top_gclr += 
01944     shade_table[shade_index + 3*m + 1] * 
01945         weight_table[weight_index + m];
01946         
01947     top_bclr += 
01948     shade_table[shade_index + 3*m + 2] * 
01949         weight_table[weight_index + m];
01950         ;
01951         ;
01952         ;
01953         };
01954     shade_factor = top_opc * slice_depth_cueing;
01955     
01956         top_rclr *= shade_factor;
01957         top_gclr *= shade_factor;
01958         top_bclr *= shade_factor;
01959     ;
01960                     }
01961                     
01962 #ifdef DEBUG
01963     if (ipixel == trace_pixel_ptr) {
01964         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01965         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01966         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01967         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01968         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01969     }
01970 #endif
01971 ;
01972                     
01973        acc_opc = top_opc * wgtTL;
01974        
01975             acc_rclr = top_rclr * wgtTL;
01976             acc_gclr = top_gclr * wgtTL;
01977             acc_bclr = top_bclr * wgtTL;
01978        
01979 #ifdef DEBUG
01980     if (ipixel == trace_pixel_ptr) {
01981         trace_opcTL = top_opc;
01982         trace_rclrTL = top_rclr;
01983                      trace_gclrTL = top_gclr;
01984                      trace_bclrTL = top_bclr;
01985         
01986     }
01987 #endif
01988 ;
01989                     
01990     
01991             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
01992             opacity = param0_table[opac_param];
01993             if (param1_size != 0) {
01994                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
01995                 opacity *= param1_table[opac_param];
01996                 if (param2_size != 0) {
01997                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
01998                     opacity *= param2_table[opac_param];
01999                 }
02000             }
02001             if (opacity > min_opacity) {
02002                 opacity_int = opacity*255.;
02003                 top_opc = opac_correct[opacity_int];
02004             } else {
02005                 top_opc = (float)0.;
02006             };
02007     
02008     
02009     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02010     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02011     
02012         
02013         
02014     top_rclr = 
02015     shade_table[shade_index + 3*0 + 0] * 
02016         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02017         
02018     top_gclr = 
02019     shade_table[shade_index + 3*0 + 1] * 
02020         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02021         
02022     top_bclr = 
02023     shade_table[shade_index + 3*0 + 2] * 
02024         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02025         ;
02026         ;
02027         ;
02028         for (m = 1; m < num_materials; m++) {
02029              
02030         
02031     top_rclr += 
02032     shade_table[shade_index + 3*m + 0] * 
02033         weight_table[weight_index + m];
02034         
02035     top_gclr += 
02036     shade_table[shade_index + 3*m + 1] * 
02037         weight_table[weight_index + m];
02038         
02039     top_bclr += 
02040     shade_table[shade_index + 3*m + 2] * 
02041         weight_table[weight_index + m];
02042         ;
02043         ;
02044         ;
02045         };
02046     shade_factor = top_opc * slice_depth_cueing;
02047     
02048         top_rclr *= shade_factor;
02049         top_gclr *= shade_factor;
02050         top_bclr *= shade_factor;
02051     ;
02052                     
02053        acc_opc += top_opc * wgtTR;
02054        
02055             acc_rclr += top_rclr * wgtTR;
02056             acc_gclr += top_gclr * wgtTR;
02057             acc_bclr += top_bclr * wgtTR;
02058        
02059 #ifdef DEBUG
02060     if (ipixel == trace_pixel_ptr) {
02061         trace_opcTR = top_opc;
02062         trace_rclrTR = top_rclr;
02063                      trace_gclrTR = top_gclr;
02064                      trace_bclrTR = top_bclr;
02065         
02066     }
02067 #endif
02068 ;
02069                     
02070         COUNT_RESAMPLE;
02071         if (acc_opc > min_opacity) {
02072             COUNT_COMPOSITE;
02073             iopc = ipixel->opcflt;
02074 #           ifndef SKIP_ERT
02075                 ASSERT(iopc < max_opacity);
02076 #           endif
02077             iopc_inv = (float)1. - iopc;
02078             
02079         ipixel->rclrflt += acc_rclr * iopc_inv;
02080         ipixel->gclrflt += acc_gclr * iopc_inv;
02081         ipixel->bclrflt += acc_bclr * iopc_inv;
02082             iopc += acc_opc * iopc_inv;
02083             ipixel->opcflt = iopc;
02084             
02085 #ifdef DEBUG
02086     if (ipixel == trace_pixel_ptr) {
02087 #ifdef COMPUTE_SHADOW_BUFFER
02088         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02089 #else
02090         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02091 #endif
02092         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02093         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02094         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02095         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02096         printf("  %3.0f %3.0f\n", iopc*255., 
02097                ipixel->rclrflt);
02098         
02099         
02100         printf("              ");
02101         printf("      %3.0f    ",trace_gclrTL);
02102         printf("      %3.0f    ",trace_gclrBL);
02103         printf("      %3.0f    ",trace_gclrTR);
02104         printf("      %3.0f    ",trace_gclrBR);
02105         printf("      %3.0f\n", ipixel->gclrflt);
02106         printf("              ");
02107         printf("      %3.0f    ",trace_bclrTL);
02108         printf("      %3.0f    ",trace_bclrBL);
02109         printf("      %3.0f    ",trace_bclrTR);
02110         printf("      %3.0f    ",trace_bclrBR);
02111         printf("      %3.0f\n", ipixel->bclrflt);
02112     }
02113 #endif /* DEBUG */
02114 ;
02115 #           ifndef SKIP_ERT
02116                 if (iopc >= max_opacity) {
02117                     ASSERT(ipixel->lnk == 0);
02118                     ipixel->lnk = 1;
02119                 }
02120 #           endif
02121         };
02122                     ipixel += 1;
02123                     topRLEdata += 1 * voxel_istride;
02124                     botRLEdata += 1 * voxel_istride;
02125                     count--;
02126                     SET_VOXELS_LOADED;
02127                 }
02128                 break;
02129             case BOT_NONZERO__TOP_NONZERO:
02130                 /* first pixel: bottom-left and top-right voxels
02131                    contribute */
02132                 if (!voxels_loaded) {
02133                     
02134     
02135             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02136             opacity = param0_table[opac_param];
02137             if (param1_size != 0) {
02138                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02139                 opacity *= param1_table[opac_param];
02140                 if (param2_size != 0) {
02141                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02142                     opacity *= param2_table[opac_param];
02143                 }
02144             }
02145             if (opacity > min_opacity) {
02146                 opacity_int = opacity*255.;
02147                 bot_opc = opac_correct[opacity_int];
02148             } else {
02149                 bot_opc = (float)0.;
02150             };
02151     
02152     
02153     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
02154     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02155     
02156         
02157         
02158     bot_rclr = 
02159     shade_table[shade_index + 3*0 + 0] * 
02160         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02161         
02162     bot_gclr = 
02163     shade_table[shade_index + 3*0 + 1] * 
02164         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02165         
02166     bot_bclr = 
02167     shade_table[shade_index + 3*0 + 2] * 
02168         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02169         ;
02170         ;
02171         ;
02172         for (m = 1; m < num_materials; m++) {
02173              
02174         
02175     bot_rclr += 
02176     shade_table[shade_index + 3*m + 0] * 
02177         weight_table[weight_index + m];
02178         
02179     bot_gclr += 
02180     shade_table[shade_index + 3*m + 1] * 
02181         weight_table[weight_index + m];
02182         
02183     bot_bclr += 
02184     shade_table[shade_index + 3*m + 2] * 
02185         weight_table[weight_index + m];
02186         ;
02187         ;
02188         ;
02189         };
02190     shade_factor = bot_opc * slice_depth_cueing;
02191     
02192         bot_rclr *= shade_factor;
02193         bot_gclr *= shade_factor;
02194         bot_bclr *= shade_factor;
02195     ;
02196                 }
02197                 
02198 #ifdef DEBUG
02199     if (ipixel == trace_pixel_ptr) {
02200         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02201         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02202         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02203         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02204         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02205     }
02206 #endif
02207 ;
02208                 
02209        acc_opc = bot_opc * wgtBL;
02210        
02211             acc_rclr = bot_rclr * wgtBL;
02212             acc_gclr = bot_gclr * wgtBL;
02213             acc_bclr = bot_bclr * wgtBL;
02214        
02215 #ifdef DEBUG
02216     if (ipixel == trace_pixel_ptr) {
02217         trace_opcBL = bot_opc;
02218         trace_rclrBL = bot_rclr;
02219                      trace_gclrBL = bot_gclr;
02220                      trace_bclrBL = bot_bclr;
02221         
02222     }
02223 #endif
02224 ;
02225                 
02226     
02227             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02228             opacity = param0_table[opac_param];
02229             if (param1_size != 0) {
02230                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02231                 opacity *= param1_table[opac_param];
02232                 if (param2_size != 0) {
02233                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02234                     opacity *= param2_table[opac_param];
02235                 }
02236             }
02237             if (opacity > min_opacity) {
02238                 opacity_int = opacity*255.;
02239                 top_opc = opac_correct[opacity_int];
02240             } else {
02241                 top_opc = (float)0.;
02242             };
02243     
02244     
02245     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02246     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02247     
02248         
02249         
02250     top_rclr = 
02251     shade_table[shade_index + 3*0 + 0] * 
02252         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02253         
02254     top_gclr = 
02255     shade_table[shade_index + 3*0 + 1] * 
02256         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02257         
02258     top_bclr = 
02259     shade_table[shade_index + 3*0 + 2] * 
02260         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02261         ;
02262         ;
02263         ;
02264         for (m = 1; m < num_materials; m++) {
02265              
02266         
02267     top_rclr += 
02268     shade_table[shade_index + 3*m + 0] * 
02269         weight_table[weight_index + m];
02270         
02271     top_gclr += 
02272     shade_table[shade_index + 3*m + 1] * 
02273         weight_table[weight_index + m];
02274         
02275     top_bclr += 
02276     shade_table[shade_index + 3*m + 2] * 
02277         weight_table[weight_index + m];
02278         ;
02279         ;
02280         ;
02281         };
02282     shade_factor = top_opc * slice_depth_cueing;
02283     
02284         top_rclr *= shade_factor;
02285         top_gclr *= shade_factor;
02286         top_bclr *= shade_factor;
02287     ;
02288                 
02289        acc_opc += top_opc * wgtTR;
02290        
02291             acc_rclr += top_rclr * wgtTR;
02292             acc_gclr += top_gclr * wgtTR;
02293             acc_bclr += top_bclr * wgtTR;
02294        
02295 #ifdef DEBUG
02296     if (ipixel == trace_pixel_ptr) {
02297         trace_opcTR = top_opc;
02298         trace_rclrTR = top_rclr;
02299                      trace_gclrTR = top_gclr;
02300                      trace_bclrTR = top_bclr;
02301         
02302     }
02303 #endif
02304 ;
02305                 
02306         COUNT_RESAMPLE;
02307         if (acc_opc > min_opacity) {
02308             COUNT_COMPOSITE;
02309             iopc = ipixel->opcflt;
02310 #           ifndef SKIP_ERT
02311                 ASSERT(iopc < max_opacity);
02312 #           endif
02313             iopc_inv = (float)1. - iopc;
02314             
02315         ipixel->rclrflt += acc_rclr * iopc_inv;
02316         ipixel->gclrflt += acc_gclr * iopc_inv;
02317         ipixel->bclrflt += acc_bclr * iopc_inv;
02318             iopc += acc_opc * iopc_inv;
02319             ipixel->opcflt = iopc;
02320             
02321 #ifdef DEBUG
02322     if (ipixel == trace_pixel_ptr) {
02323 #ifdef COMPUTE_SHADOW_BUFFER
02324         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02325 #else
02326         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02327 #endif
02328         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02329         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02330         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02331         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02332         printf("  %3.0f %3.0f\n", iopc*255., 
02333                ipixel->rclrflt);
02334         
02335         
02336         printf("              ");
02337         printf("      %3.0f    ",trace_gclrTL);
02338         printf("      %3.0f    ",trace_gclrBL);
02339         printf("      %3.0f    ",trace_gclrTR);
02340         printf("      %3.0f    ",trace_gclrBR);
02341         printf("      %3.0f\n", ipixel->gclrflt);
02342         printf("              ");
02343         printf("      %3.0f    ",trace_bclrTL);
02344         printf("      %3.0f    ",trace_bclrBL);
02345         printf("      %3.0f    ",trace_bclrTR);
02346         printf("      %3.0f    ",trace_bclrBR);
02347         printf("      %3.0f\n", ipixel->bclrflt);
02348     }
02349 #endif /* DEBUG */
02350 ;
02351 #           ifndef SKIP_ERT
02352                 if (iopc >= max_opacity) {
02353                     ASSERT(ipixel->lnk == 0);
02354                     ipixel->lnk = 1;
02355                 }
02356 #           endif
02357         };
02358                 ipixel += 1;
02359                 topRLEdata += 1 * voxel_istride;
02360                 botRLEdata += 1 * voxel_istride;
02361                 count--;
02362                 SET_VOXELS_LOADED;
02363 
02364                 /* do the rest of the pixels in this run;
02365                    the top-left and top-right voxels contribute */
02366                 while (count > 0) {
02367                     if (PIXEL_IS_OPAQUE(ipixel))
02368                         break;
02369                     if (!voxels_loaded) {
02370                         
02371     
02372             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02373             opacity = param0_table[opac_param];
02374             if (param1_size != 0) {
02375                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02376                 opacity *= param1_table[opac_param];
02377                 if (param2_size != 0) {
02378                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02379                     opacity *= param2_table[opac_param];
02380                 }
02381             }
02382             if (opacity > min_opacity) {
02383                 opacity_int = opacity*255.;
02384                 top_opc = opac_correct[opacity_int];
02385             } else {
02386                 top_opc = (float)0.;
02387             };
02388     
02389     
02390     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02391     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02392     
02393         
02394         
02395     top_rclr = 
02396     shade_table[shade_index + 3*0 + 0] * 
02397         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02398         
02399     top_gclr = 
02400     shade_table[shade_index + 3*0 + 1] * 
02401         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02402         
02403     top_bclr = 
02404     shade_table[shade_index + 3*0 + 2] * 
02405         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02406         ;
02407         ;
02408         ;
02409         for (m = 1; m < num_materials; m++) {
02410              
02411         
02412     top_rclr += 
02413     shade_table[shade_index + 3*m + 0] * 
02414         weight_table[weight_index + m];
02415         
02416     top_gclr += 
02417     shade_table[shade_index + 3*m + 1] * 
02418         weight_table[weight_index + m];
02419         
02420     top_bclr += 
02421     shade_table[shade_index + 3*m + 2] * 
02422         weight_table[weight_index + m];
02423         ;
02424         ;
02425         ;
02426         };
02427     shade_factor = top_opc * slice_depth_cueing;
02428     
02429         top_rclr *= shade_factor;
02430         top_gclr *= shade_factor;
02431         top_bclr *= shade_factor;
02432     ;
02433                     }
02434                     
02435 #ifdef DEBUG
02436     if (ipixel == trace_pixel_ptr) {
02437         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02438         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02439         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02440         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02441         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02442     }
02443 #endif
02444 ;
02445                     
02446        acc_opc = top_opc * wgtTL;
02447        
02448             acc_rclr = top_rclr * wgtTL;
02449             acc_gclr = top_gclr * wgtTL;
02450             acc_bclr = top_bclr * wgtTL;
02451        
02452 #ifdef DEBUG
02453     if (ipixel == trace_pixel_ptr) {
02454         trace_opcTL = top_opc;
02455         trace_rclrTL = top_rclr;
02456                      trace_gclrTL = top_gclr;
02457                      trace_bclrTL = top_bclr;
02458         
02459     }
02460 #endif
02461 ;
02462                     
02463     
02464             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02465             opacity = param0_table[opac_param];
02466             if (param1_size != 0) {
02467                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02468                 opacity *= param1_table[opac_param];
02469                 if (param2_size != 0) {
02470                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02471                     opacity *= param2_table[opac_param];
02472                 }
02473             }
02474             if (opacity > min_opacity) {
02475                 opacity_int = opacity*255.;
02476                 top_opc = opac_correct[opacity_int];
02477             } else {
02478                 top_opc = (float)0.;
02479             };
02480     
02481     
02482     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02483     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02484     
02485         
02486         
02487     top_rclr = 
02488     shade_table[shade_index + 3*0 + 0] * 
02489         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02490         
02491     top_gclr = 
02492     shade_table[shade_index + 3*0 + 1] * 
02493         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02494         
02495     top_bclr = 
02496     shade_table[shade_index + 3*0 + 2] * 
02497         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02498         ;
02499         ;
02500         ;
02501         for (m = 1; m < num_materials; m++) {
02502              
02503         
02504     top_rclr += 
02505     shade_table[shade_index + 3*m + 0] * 
02506         weight_table[weight_index + m];
02507         
02508     top_gclr += 
02509     shade_table[shade_index + 3*m + 1] * 
02510         weight_table[weight_index + m];
02511         
02512     top_bclr += 
02513     shade_table[shade_index + 3*m + 2] * 
02514         weight_table[weight_index + m];
02515         ;
02516         ;
02517         ;
02518         };
02519     shade_factor = top_opc * slice_depth_cueing;
02520     
02521         top_rclr *= shade_factor;
02522         top_gclr *= shade_factor;
02523         top_bclr *= shade_factor;
02524     ;
02525                     
02526        acc_opc += top_opc * wgtTR;
02527        
02528             acc_rclr += top_rclr * wgtTR;
02529             acc_gclr += top_gclr * wgtTR;
02530             acc_bclr += top_bclr * wgtTR;
02531        
02532 #ifdef DEBUG
02533     if (ipixel == trace_pixel_ptr) {
02534         trace_opcTR = top_opc;
02535         trace_rclrTR = top_rclr;
02536                      trace_gclrTR = top_gclr;
02537                      trace_bclrTR = top_bclr;
02538         
02539     }
02540 #endif
02541 ;
02542                     
02543         COUNT_RESAMPLE;
02544         if (acc_opc > min_opacity) {
02545             COUNT_COMPOSITE;
02546             iopc = ipixel->opcflt;
02547 #           ifndef SKIP_ERT
02548                 ASSERT(iopc < max_opacity);
02549 #           endif
02550             iopc_inv = (float)1. - iopc;
02551             
02552         ipixel->rclrflt += acc_rclr * iopc_inv;
02553         ipixel->gclrflt += acc_gclr * iopc_inv;
02554         ipixel->bclrflt += acc_bclr * iopc_inv;
02555             iopc += acc_opc * iopc_inv;
02556             ipixel->opcflt = iopc;
02557             
02558 #ifdef DEBUG
02559     if (ipixel == trace_pixel_ptr) {
02560 #ifdef COMPUTE_SHADOW_BUFFER
02561         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02562 #else
02563         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02564 #endif
02565         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02566         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02567         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02568         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02569         printf("  %3.0f %3.0f\n", iopc*255., 
02570                ipixel->rclrflt);
02571         
02572         
02573         printf("              ");
02574         printf("      %3.0f    ",trace_gclrTL);
02575         printf("      %3.0f    ",trace_gclrBL);
02576         printf("      %3.0f    ",trace_gclrTR);
02577         printf("      %3.0f    ",trace_gclrBR);
02578         printf("      %3.0f\n", ipixel->gclrflt);
02579         printf("              ");
02580         printf("      %3.0f    ",trace_bclrTL);
02581         printf("      %3.0f    ",trace_bclrBL);
02582         printf("      %3.0f    ",trace_bclrTR);
02583         printf("      %3.0f    ",trace_bclrBR);
02584         printf("      %3.0f\n", ipixel->bclrflt);
02585     }
02586 #endif /* DEBUG */
02587 ;
02588 #           ifndef SKIP_ERT
02589                 if (iopc >= max_opacity) {
02590                     ASSERT(ipixel->lnk == 0);
02591                     ipixel->lnk = 1;
02592                 }
02593 #           endif
02594         };
02595                     ipixel += 1;
02596                     topRLEdata += 1 * voxel_istride;
02597                     botRLEdata += 1 * voxel_istride;
02598                     count--;
02599                     SET_VOXELS_LOADED;
02600                 }
02601                 break;
02602             case ALL_NONZERO__TOP_NONZERO:
02603                 /* first pixel: top-left, bottom-left and top-right voxels
02604                    contribute */
02605                 if (!voxels_loaded) {
02606                     
02607     
02608             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02609             opacity = param0_table[opac_param];
02610             if (param1_size != 0) {
02611                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02612                 opacity *= param1_table[opac_param];
02613                 if (param2_size != 0) {
02614                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02615                     opacity *= param2_table[opac_param];
02616                 }
02617             }
02618             if (opacity > min_opacity) {
02619                 opacity_int = opacity*255.;
02620                 top_opc = opac_correct[opacity_int];
02621             } else {
02622                 top_opc = (float)0.;
02623             };
02624     
02625     
02626     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02627     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02628     
02629         
02630         
02631     top_rclr = 
02632     shade_table[shade_index + 3*0 + 0] * 
02633         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02634         
02635     top_gclr = 
02636     shade_table[shade_index + 3*0 + 1] * 
02637         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02638         
02639     top_bclr = 
02640     shade_table[shade_index + 3*0 + 2] * 
02641         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02642         ;
02643         ;
02644         ;
02645         for (m = 1; m < num_materials; m++) {
02646              
02647         
02648     top_rclr += 
02649     shade_table[shade_index + 3*m + 0] * 
02650         weight_table[weight_index + m];
02651         
02652     top_gclr += 
02653     shade_table[shade_index + 3*m + 1] * 
02654         weight_table[weight_index + m];
02655         
02656     top_bclr += 
02657     shade_table[shade_index + 3*m + 2] * 
02658         weight_table[weight_index + m];
02659         ;
02660         ;
02661         ;
02662         };
02663     shade_factor = top_opc * slice_depth_cueing;
02664     
02665         top_rclr *= shade_factor;
02666         top_gclr *= shade_factor;
02667         top_bclr *= shade_factor;
02668     ;
02669                     
02670     
02671             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
02672             opacity = param0_table[opac_param];
02673             if (param1_size != 0) {
02674                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
02675                 opacity *= param1_table[opac_param];
02676                 if (param2_size != 0) {
02677                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
02678                     opacity *= param2_table[opac_param];
02679                 }
02680             }
02681             if (opacity > min_opacity) {
02682                 opacity_int = opacity*255.;
02683                 bot_opc = opac_correct[opacity_int];
02684             } else {
02685                 bot_opc = (float)0.;
02686             };
02687     
02688     
02689     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
02690     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02691     
02692         
02693         
02694     bot_rclr = 
02695     shade_table[shade_index + 3*0 + 0] * 
02696         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02697         
02698     bot_gclr = 
02699     shade_table[shade_index + 3*0 + 1] * 
02700         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02701         
02702     bot_bclr = 
02703     shade_table[shade_index + 3*0 + 2] * 
02704         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02705         ;
02706         ;
02707         ;
02708         for (m = 1; m < num_materials; m++) {
02709              
02710         
02711     bot_rclr += 
02712     shade_table[shade_index + 3*m + 0] * 
02713         weight_table[weight_index + m];
02714         
02715     bot_gclr += 
02716     shade_table[shade_index + 3*m + 1] * 
02717         weight_table[weight_index + m];
02718         
02719     bot_bclr += 
02720     shade_table[shade_index + 3*m + 2] * 
02721         weight_table[weight_index + m];
02722         ;
02723         ;
02724         ;
02725         };
02726     shade_factor = bot_opc * slice_depth_cueing;
02727     
02728         bot_rclr *= shade_factor;
02729         bot_gclr *= shade_factor;
02730         bot_bclr *= shade_factor;
02731     ;
02732                 }
02733                 
02734 #ifdef DEBUG
02735     if (ipixel == trace_pixel_ptr) {
02736         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02737         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02738         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02739         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02740         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02741     }
02742 #endif
02743 ;
02744                 
02745        acc_opc = top_opc * wgtTL;
02746        
02747             acc_rclr = top_rclr * wgtTL;
02748             acc_gclr = top_gclr * wgtTL;
02749             acc_bclr = top_bclr * wgtTL;
02750        
02751 #ifdef DEBUG
02752     if (ipixel == trace_pixel_ptr) {
02753         trace_opcTL = top_opc;
02754         trace_rclrTL = top_rclr;
02755                      trace_gclrTL = top_gclr;
02756                      trace_bclrTL = top_bclr;
02757         
02758     }
02759 #endif
02760 ;
02761                 
02762        acc_opc += bot_opc * wgtBL;
02763        
02764             acc_rclr += bot_rclr * wgtBL;
02765             acc_gclr += bot_gclr * wgtBL;
02766             acc_bclr += bot_bclr * wgtBL;
02767        
02768 #ifdef DEBUG
02769     if (ipixel == trace_pixel_ptr) {
02770         trace_opcBL = bot_opc;
02771         trace_rclrBL = bot_rclr;
02772                      trace_gclrBL = bot_gclr;
02773                      trace_bclrBL = bot_bclr;
02774         
02775     }
02776 #endif
02777 ;
02778                 
02779     
02780             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
02781             opacity = param0_table[opac_param];
02782             if (param1_size != 0) {
02783                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
02784                 opacity *= param1_table[opac_param];
02785                 if (param2_size != 0) {
02786                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
02787                     opacity *= param2_table[opac_param];
02788                 }
02789             }
02790             if (opacity > min_opacity) {
02791                 opacity_int = opacity*255.;
02792                 top_opc = opac_correct[opacity_int];
02793             } else {
02794                 top_opc = (float)0.;
02795             };
02796     
02797     
02798     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02799     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02800     
02801         
02802         
02803     top_rclr = 
02804     shade_table[shade_index + 3*0 + 0] * 
02805         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02806         
02807     top_gclr = 
02808     shade_table[shade_index + 3*0 + 1] * 
02809         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02810         
02811     top_bclr = 
02812     shade_table[shade_index + 3*0 + 2] * 
02813         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02814         ;
02815         ;
02816         ;
02817         for (m = 1; m < num_materials; m++) {
02818              
02819         
02820     top_rclr += 
02821     shade_table[shade_index + 3*m + 0] * 
02822         weight_table[weight_index + m];
02823         
02824     top_gclr += 
02825     shade_table[shade_index + 3*m + 1] * 
02826         weight_table[weight_index + m];
02827         
02828     top_bclr += 
02829     shade_table[shade_index + 3*m + 2] * 
02830         weight_table[weight_index + m];
02831         ;
02832         ;
02833         ;
02834         };
02835     shade_factor = top_opc * slice_depth_cueing;
02836     
02837         top_rclr *= shade_factor;
02838         top_gclr *= shade_factor;
02839         top_bclr *= shade_factor;
02840     ;
02841                 
02842        acc_opc += top_opc * wgtTR;
02843        
02844             acc_rclr += top_rclr * wgtTR;
02845             acc_gclr += top_gclr * wgtTR;
02846             acc_bclr += top_bclr * wgtTR;
02847        
02848 #ifdef DEBUG
02849     if (ipixel == trace_pixel_ptr) {
02850         trace_opcTR = top_opc;
02851         trace_rclrTR = top_rclr;
02852                      trace_gclrTR = top_gclr;
02853                      trace_bclrTR = top_bclr;
02854         
02855     }
02856 #endif
02857 ;
02858                 
02859         COUNT_RESAMPLE;
02860         if (acc_opc > min_opacity) {
02861             COUNT_COMPOSITE;
02862             iopc = ipixel->opcflt;
02863 #           ifndef SKIP_ERT
02864                 ASSERT(iopc < max_opacity);
02865 #           endif
02866             iopc_inv = (float)1. - iopc;
02867             
02868         ipixel->rclrflt += acc_rclr * iopc_inv;
02869         ipixel->gclrflt += acc_gclr * iopc_inv;
02870         ipixel->bclrflt += acc_bclr * iopc_inv;
02871             iopc += acc_opc * iopc_inv;
02872             ipixel->opcflt = iopc;
02873             
02874 #ifdef DEBUG
02875     if (ipixel == trace_pixel_ptr) {
02876 #ifdef COMPUTE_SHADOW_BUFFER
02877         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02878 #else
02879         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02880 #endif
02881         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02882         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02883         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02884         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02885         printf("  %3.0f %3.0f\n", iopc*255., 
02886                ipixel->rclrflt);
02887         
02888         
02889         printf("              ");
02890         printf("      %3.0f    ",trace_gclrTL);
02891         printf("      %3.0f    ",trace_gclrBL);
02892         printf("      %3.0f    ",trace_gclrTR);
02893         printf("      %3.0f    ",trace_gclrBR);
02894         printf("      %3.0f\n", ipixel->gclrflt);
02895         printf("              ");
02896         printf("      %3.0f    ",trace_bclrTL);
02897         printf("      %3.0f    ",trace_bclrBL);
02898         printf("      %3.0f    ",trace_bclrTR);
02899         printf("      %3.0f    ",trace_bclrBR);
02900         printf("      %3.0f\n", ipixel->bclrflt);
02901     }
02902 #endif /* DEBUG */
02903 ;
02904 #           ifndef SKIP_ERT
02905                 if (iopc >= max_opacity) {
02906                     ASSERT(ipixel->lnk == 0);
02907                     ipixel->lnk = 1;
02908                 }
02909 #           endif
02910         };
02911                 ipixel += 1;
02912                 topRLEdata += 1 * voxel_istride;
02913                 botRLEdata += 1 * voxel_istride;
02914                 count--;
02915                 SET_VOXELS_LOADED;
02916 
02917                 /* do the rest of the pixels in this run;
02918                    the top-left and top-right voxels contribute */
02919                 while (count > 0) {
02920                     if (PIXEL_IS_OPAQUE(ipixel))
02921                         break;
02922                     if (!voxels_loaded) {
02923                         
02924     
02925             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
02926             opacity = param0_table[opac_param];
02927             if (param1_size != 0) {
02928                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
02929                 opacity *= param1_table[opac_param];
02930                 if (param2_size != 0) {
02931                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
02932                     opacity *= param2_table[opac_param];
02933                 }
02934             }
02935             if (opacity > min_opacity) {
02936                 opacity_int = opacity*255.;
02937                 top_opc = opac_correct[opacity_int];
02938             } else {
02939                 top_opc = (float)0.;
02940             };
02941     
02942     
02943     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02944     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02945     
02946         
02947         
02948     top_rclr = 
02949     shade_table[shade_index + 3*0 + 0] * 
02950         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02951         
02952     top_gclr = 
02953     shade_table[shade_index + 3*0 + 1] * 
02954         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02955         
02956     top_bclr = 
02957     shade_table[shade_index + 3*0 + 2] * 
02958         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02959         ;
02960         ;
02961         ;
02962         for (m = 1; m < num_materials; m++) {
02963              
02964         
02965     top_rclr += 
02966     shade_table[shade_index + 3*m + 0] * 
02967         weight_table[weight_index + m];
02968         
02969     top_gclr += 
02970     shade_table[shade_index + 3*m + 1] * 
02971         weight_table[weight_index + m];
02972         
02973     top_bclr += 
02974     shade_table[shade_index + 3*m + 2] * 
02975         weight_table[weight_index + m];
02976         ;
02977         ;
02978         ;
02979         };
02980     shade_factor = top_opc * slice_depth_cueing;
02981     
02982         top_rclr *= shade_factor;
02983         top_gclr *= shade_factor;
02984         top_bclr *= shade_factor;
02985     ;
02986                     }
02987                     
02988 #ifdef DEBUG
02989     if (ipixel == trace_pixel_ptr) {
02990         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02991         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02992         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02993         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02994         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02995     }
02996 #endif
02997 ;
02998                     
02999        acc_opc = top_opc * wgtTL;
03000        
03001             acc_rclr = top_rclr * wgtTL;
03002             acc_gclr = top_gclr * wgtTL;
03003             acc_bclr = top_bclr * wgtTL;
03004        
03005 #ifdef DEBUG
03006     if (ipixel == trace_pixel_ptr) {
03007         trace_opcTL = top_opc;
03008         trace_rclrTL = top_rclr;
03009                      trace_gclrTL = top_gclr;
03010                      trace_bclrTL = top_bclr;
03011         
03012     }
03013 #endif
03014 ;
03015                     
03016     
03017             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
03018             opacity = param0_table[opac_param];
03019             if (param1_size != 0) {
03020                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
03021                 opacity *= param1_table[opac_param];
03022                 if (param2_size != 0) {
03023                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
03024                     opacity *= param2_table[opac_param];
03025                 }
03026             }
03027             if (opacity > min_opacity) {
03028                 opacity_int = opacity*255.;
03029                 top_opc = opac_correct[opacity_int];
03030             } else {
03031                 top_opc = (float)0.;
03032             };
03033     
03034     
03035     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
03036     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03037     
03038         
03039         
03040     top_rclr = 
03041     shade_table[shade_index + 3*0 + 0] * 
03042         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03043         
03044     top_gclr = 
03045     shade_table[shade_index + 3*0 + 1] * 
03046         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03047         
03048     top_bclr = 
03049     shade_table[shade_index + 3*0 + 2] * 
03050         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03051         ;
03052         ;
03053         ;
03054         for (m = 1; m < num_materials; m++) {
03055              
03056         
03057     top_rclr += 
03058     shade_table[shade_index + 3*m + 0] * 
03059         weight_table[weight_index + m];
03060         
03061     top_gclr += 
03062     shade_table[shade_index + 3*m + 1] * 
03063         weight_table[weight_index + m];
03064         
03065     top_bclr += 
03066     shade_table[shade_index + 3*m + 2] * 
03067         weight_table[weight_index + m];
03068         ;
03069         ;
03070         ;
03071         };
03072     shade_factor = top_opc * slice_depth_cueing;
03073     
03074         top_rclr *= shade_factor;
03075         top_gclr *= shade_factor;
03076         top_bclr *= shade_factor;
03077     ;
03078                     
03079        acc_opc += top_opc * wgtTR;
03080        
03081             acc_rclr += top_rclr * wgtTR;
03082             acc_gclr += top_gclr * wgtTR;
03083             acc_bclr += top_bclr * wgtTR;
03084        
03085 #ifdef DEBUG
03086     if (ipixel == trace_pixel_ptr) {
03087         trace_opcTR = top_opc;
03088         trace_rclrTR = top_rclr;
03089                      trace_gclrTR = top_gclr;
03090                      trace_bclrTR = top_bclr;
03091         
03092     }
03093 #endif
03094 ;
03095                     
03096         COUNT_RESAMPLE;
03097         if (acc_opc > min_opacity) {
03098             COUNT_COMPOSITE;
03099             iopc = ipixel->opcflt;
03100 #           ifndef SKIP_ERT
03101                 ASSERT(iopc < max_opacity);
03102 #           endif
03103             iopc_inv = (float)1. - iopc;
03104             
03105         ipixel->rclrflt += acc_rclr * iopc_inv;
03106         ipixel->gclrflt += acc_gclr * iopc_inv;
03107         ipixel->bclrflt += acc_bclr * iopc_inv;
03108             iopc += acc_opc * iopc_inv;
03109             ipixel->opcflt = iopc;
03110             
03111 #ifdef DEBUG
03112     if (ipixel == trace_pixel_ptr) {
03113 #ifdef COMPUTE_SHADOW_BUFFER
03114         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03115 #else
03116         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03117 #endif
03118         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03119         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03120         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03121         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03122         printf("  %3.0f %3.0f\n", iopc*255., 
03123                ipixel->rclrflt);
03124         
03125         
03126         printf("              ");
03127         printf("      %3.0f    ",trace_gclrTL);
03128         printf("      %3.0f    ",trace_gclrBL);
03129         printf("      %3.0f    ",trace_gclrTR);
03130         printf("      %3.0f    ",trace_gclrBR);
03131         printf("      %3.0f\n", ipixel->gclrflt);
03132         printf("              ");
03133         printf("      %3.0f    ",trace_bclrTL);
03134         printf("      %3.0f    ",trace_bclrBL);
03135         printf("      %3.0f    ",trace_bclrTR);
03136         printf("      %3.0f    ",trace_bclrBR);
03137         printf("      %3.0f\n", ipixel->bclrflt);
03138     }
03139 #endif /* DEBUG */
03140 ;
03141 #           ifndef SKIP_ERT
03142                 if (iopc >= max_opacity) {
03143                     ASSERT(ipixel->lnk == 0);
03144                     ipixel->lnk = 1;
03145                 }
03146 #           endif
03147         };
03148                     ipixel += 1;
03149                     topRLEdata += 1 * voxel_istride;
03150                     botRLEdata += 1 * voxel_istride;
03151                     count--;
03152                     SET_VOXELS_LOADED;
03153                 }
03154                 break;
03155             case ALL_ZERO__BOT_NONZERO:
03156                 /* first pixel: only the bottom-right voxel contributes */
03157                 
03158     
03159             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03160             opacity = param0_table[opac_param];
03161             if (param1_size != 0) {
03162                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03163                 opacity *= param1_table[opac_param];
03164                 if (param2_size != 0) {
03165                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03166                     opacity *= param2_table[opac_param];
03167                 }
03168             }
03169             if (opacity > min_opacity) {
03170                 opacity_int = opacity*255.;
03171                 bot_opc = opac_correct[opacity_int];
03172             } else {
03173                 bot_opc = (float)0.;
03174             };
03175     
03176     
03177     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03178     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03179     
03180         
03181         
03182     bot_rclr = 
03183     shade_table[shade_index + 3*0 + 0] * 
03184         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03185         
03186     bot_gclr = 
03187     shade_table[shade_index + 3*0 + 1] * 
03188         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03189         
03190     bot_bclr = 
03191     shade_table[shade_index + 3*0 + 2] * 
03192         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03193         ;
03194         ;
03195         ;
03196         for (m = 1; m < num_materials; m++) {
03197              
03198         
03199     bot_rclr += 
03200     shade_table[shade_index + 3*m + 0] * 
03201         weight_table[weight_index + m];
03202         
03203     bot_gclr += 
03204     shade_table[shade_index + 3*m + 1] * 
03205         weight_table[weight_index + m];
03206         
03207     bot_bclr += 
03208     shade_table[shade_index + 3*m + 2] * 
03209         weight_table[weight_index + m];
03210         ;
03211         ;
03212         ;
03213         };
03214     shade_factor = bot_opc * slice_depth_cueing;
03215     
03216         bot_rclr *= shade_factor;
03217         bot_gclr *= shade_factor;
03218         bot_bclr *= shade_factor;
03219     ;
03220                 
03221 #ifdef DEBUG
03222     if (ipixel == trace_pixel_ptr) {
03223         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03224         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03225         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03226         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03227         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03228     }
03229 #endif
03230 ;
03231                 
03232        acc_opc = bot_opc * wgtBR;
03233        
03234             acc_rclr = bot_rclr * wgtBR;
03235             acc_gclr = bot_gclr * wgtBR;
03236             acc_bclr = bot_bclr * wgtBR;
03237        
03238 #ifdef DEBUG
03239     if (ipixel == trace_pixel_ptr) {
03240         trace_opcBR = bot_opc;
03241         trace_rclrBR = bot_rclr;
03242                      trace_gclrBR = bot_gclr;
03243                      trace_bclrBR = bot_bclr;
03244         
03245     }
03246 #endif
03247 ;
03248                 
03249         COUNT_RESAMPLE;
03250         if (acc_opc > min_opacity) {
03251             COUNT_COMPOSITE;
03252             iopc = ipixel->opcflt;
03253 #           ifndef SKIP_ERT
03254                 ASSERT(iopc < max_opacity);
03255 #           endif
03256             iopc_inv = (float)1. - iopc;
03257             
03258         ipixel->rclrflt += acc_rclr * iopc_inv;
03259         ipixel->gclrflt += acc_gclr * iopc_inv;
03260         ipixel->bclrflt += acc_bclr * iopc_inv;
03261             iopc += acc_opc * iopc_inv;
03262             ipixel->opcflt = iopc;
03263             
03264 #ifdef DEBUG
03265     if (ipixel == trace_pixel_ptr) {
03266 #ifdef COMPUTE_SHADOW_BUFFER
03267         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03268 #else
03269         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03270 #endif
03271         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03272         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03273         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03274         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03275         printf("  %3.0f %3.0f\n", iopc*255., 
03276                ipixel->rclrflt);
03277         
03278         
03279         printf("              ");
03280         printf("      %3.0f    ",trace_gclrTL);
03281         printf("      %3.0f    ",trace_gclrBL);
03282         printf("      %3.0f    ",trace_gclrTR);
03283         printf("      %3.0f    ",trace_gclrBR);
03284         printf("      %3.0f\n", ipixel->gclrflt);
03285         printf("              ");
03286         printf("      %3.0f    ",trace_bclrTL);
03287         printf("      %3.0f    ",trace_bclrBL);
03288         printf("      %3.0f    ",trace_bclrTR);
03289         printf("      %3.0f    ",trace_bclrBR);
03290         printf("      %3.0f\n", ipixel->bclrflt);
03291     }
03292 #endif /* DEBUG */
03293 ;
03294 #           ifndef SKIP_ERT
03295                 if (iopc >= max_opacity) {
03296                     ASSERT(ipixel->lnk == 0);
03297                     ipixel->lnk = 1;
03298                 }
03299 #           endif
03300         };      
03301                 ipixel += 1;
03302                 topRLEdata += 1 * voxel_istride;
03303                 botRLEdata += 1 * voxel_istride;
03304                 count--;
03305                 SET_VOXELS_LOADED;
03306 
03307                 /* do the rest of the pixels in this run;
03308                    bottom-left and bottom-right voxels contribute */
03309                 while (count > 0) {
03310                     if (PIXEL_IS_OPAQUE(ipixel))
03311                         break;
03312                     if (!voxels_loaded) {
03313                         
03314     
03315             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03316             opacity = param0_table[opac_param];
03317             if (param1_size != 0) {
03318                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03319                 opacity *= param1_table[opac_param];
03320                 if (param2_size != 0) {
03321                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
03322                     opacity *= param2_table[opac_param];
03323                 }
03324             }
03325             if (opacity > min_opacity) {
03326                 opacity_int = opacity*255.;
03327                 bot_opc = opac_correct[opacity_int];
03328             } else {
03329                 bot_opc = (float)0.;
03330             };
03331     
03332     
03333     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03334     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03335     
03336         
03337         
03338     bot_rclr = 
03339     shade_table[shade_index + 3*0 + 0] * 
03340         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03341         
03342     bot_gclr = 
03343     shade_table[shade_index + 3*0 + 1] * 
03344         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03345         
03346     bot_bclr = 
03347     shade_table[shade_index + 3*0 + 2] * 
03348         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03349         ;
03350         ;
03351         ;
03352         for (m = 1; m < num_materials; m++) {
03353              
03354         
03355     bot_rclr += 
03356     shade_table[shade_index + 3*m + 0] * 
03357         weight_table[weight_index + m];
03358         
03359     bot_gclr += 
03360     shade_table[shade_index + 3*m + 1] * 
03361         weight_table[weight_index + m];
03362         
03363     bot_bclr += 
03364     shade_table[shade_index + 3*m + 2] * 
03365         weight_table[weight_index + m];
03366         ;
03367         ;
03368         ;
03369         };
03370     shade_factor = bot_opc * slice_depth_cueing;
03371     
03372         bot_rclr *= shade_factor;
03373         bot_gclr *= shade_factor;
03374         bot_bclr *= shade_factor;
03375     ;
03376                     }
03377                     
03378 #ifdef DEBUG
03379     if (ipixel == trace_pixel_ptr) {
03380         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03381         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03382         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03383         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03384         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03385     }
03386 #endif
03387 ;
03388                     
03389        acc_opc = bot_opc * wgtBL;
03390        
03391             acc_rclr = bot_rclr * wgtBL;
03392             acc_gclr = bot_gclr * wgtBL;
03393             acc_bclr = bot_bclr * wgtBL;
03394        
03395 #ifdef DEBUG
03396     if (ipixel == trace_pixel_ptr) {
03397         trace_opcBL = bot_opc;
03398         trace_rclrBL = bot_rclr;
03399                      trace_gclrBL = bot_gclr;
03400                      trace_bclrBL = bot_bclr;
03401         
03402     }
03403 #endif
03404 ;
03405                     
03406     
03407             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03408             opacity = param0_table[opac_param];
03409             if (param1_size != 0) {
03410                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03411                 opacity *= param1_table[opac_param];
03412                 if (param2_size != 0) {
03413                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03414                     opacity *= param2_table[opac_param];
03415                 }
03416             }
03417             if (opacity > min_opacity) {
03418                 opacity_int = opacity*255.;
03419                 bot_opc = opac_correct[opacity_int];
03420             } else {
03421                 bot_opc = (float)0.;
03422             };
03423     
03424     
03425     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03426     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03427     
03428         
03429         
03430     bot_rclr = 
03431     shade_table[shade_index + 3*0 + 0] * 
03432         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03433         
03434     bot_gclr = 
03435     shade_table[shade_index + 3*0 + 1] * 
03436         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03437         
03438     bot_bclr = 
03439     shade_table[shade_index + 3*0 + 2] * 
03440         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03441         ;
03442         ;
03443         ;
03444         for (m = 1; m < num_materials; m++) {
03445              
03446         
03447     bot_rclr += 
03448     shade_table[shade_index + 3*m + 0] * 
03449         weight_table[weight_index + m];
03450         
03451     bot_gclr += 
03452     shade_table[shade_index + 3*m + 1] * 
03453         weight_table[weight_index + m];
03454         
03455     bot_bclr += 
03456     shade_table[shade_index + 3*m + 2] * 
03457         weight_table[weight_index + m];
03458         ;
03459         ;
03460         ;
03461         };
03462     shade_factor = bot_opc * slice_depth_cueing;
03463     
03464         bot_rclr *= shade_factor;
03465         bot_gclr *= shade_factor;
03466         bot_bclr *= shade_factor;
03467     ;
03468                     
03469        acc_opc += bot_opc * wgtBR;
03470        
03471             acc_rclr += bot_rclr * wgtBR;
03472             acc_gclr += bot_gclr * wgtBR;
03473             acc_bclr += bot_bclr * wgtBR;
03474        
03475 #ifdef DEBUG
03476     if (ipixel == trace_pixel_ptr) {
03477         trace_opcBR = bot_opc;
03478         trace_rclrBR = bot_rclr;
03479                      trace_gclrBR = bot_gclr;
03480                      trace_bclrBR = bot_bclr;
03481         
03482     }
03483 #endif
03484 ;
03485                     
03486         COUNT_RESAMPLE;
03487         if (acc_opc > min_opacity) {
03488             COUNT_COMPOSITE;
03489             iopc = ipixel->opcflt;
03490 #           ifndef SKIP_ERT
03491                 ASSERT(iopc < max_opacity);
03492 #           endif
03493             iopc_inv = (float)1. - iopc;
03494             
03495         ipixel->rclrflt += acc_rclr * iopc_inv;
03496         ipixel->gclrflt += acc_gclr * iopc_inv;
03497         ipixel->bclrflt += acc_bclr * iopc_inv;
03498             iopc += acc_opc * iopc_inv;
03499             ipixel->opcflt = iopc;
03500             
03501 #ifdef DEBUG
03502     if (ipixel == trace_pixel_ptr) {
03503 #ifdef COMPUTE_SHADOW_BUFFER
03504         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03505 #else
03506         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03507 #endif
03508         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03509         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03510         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03511         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03512         printf("  %3.0f %3.0f\n", iopc*255., 
03513                ipixel->rclrflt);
03514         
03515         
03516         printf("              ");
03517         printf("      %3.0f    ",trace_gclrTL);
03518         printf("      %3.0f    ",trace_gclrBL);
03519         printf("      %3.0f    ",trace_gclrTR);
03520         printf("      %3.0f    ",trace_gclrBR);
03521         printf("      %3.0f\n", ipixel->gclrflt);
03522         printf("              ");
03523         printf("      %3.0f    ",trace_bclrTL);
03524         printf("      %3.0f    ",trace_bclrBL);
03525         printf("      %3.0f    ",trace_bclrTR);
03526         printf("      %3.0f    ",trace_bclrBR);
03527         printf("      %3.0f\n", ipixel->bclrflt);
03528     }
03529 #endif /* DEBUG */
03530 ;
03531 #           ifndef SKIP_ERT
03532                 if (iopc >= max_opacity) {
03533                     ASSERT(ipixel->lnk == 0);
03534                     ipixel->lnk = 1;
03535                 }
03536 #           endif
03537         };
03538                     ipixel += 1;
03539                     topRLEdata += 1 * voxel_istride;
03540                     botRLEdata += 1 * voxel_istride;
03541                     count--;
03542                     SET_VOXELS_LOADED;
03543                 }
03544                 break;
03545             case TOP_NONZERO__BOT_NONZERO:
03546                 /* first pixel: top-left and bottom-right voxels contribute */
03547                 if (!voxels_loaded) {
03548                     
03549     
03550             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
03551             opacity = param0_table[opac_param];
03552             if (param1_size != 0) {
03553                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
03554                 opacity *= param1_table[opac_param];
03555                 if (param2_size != 0) {
03556                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
03557                     opacity *= param2_table[opac_param];
03558                 }
03559             }
03560             if (opacity > min_opacity) {
03561                 opacity_int = opacity*255.;
03562                 top_opc = opac_correct[opacity_int];
03563             } else {
03564                 top_opc = (float)0.;
03565             };
03566     
03567     
03568     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
03569     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03570     
03571         
03572         
03573     top_rclr = 
03574     shade_table[shade_index + 3*0 + 0] * 
03575         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03576         
03577     top_gclr = 
03578     shade_table[shade_index + 3*0 + 1] * 
03579         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03580         
03581     top_bclr = 
03582     shade_table[shade_index + 3*0 + 2] * 
03583         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03584         ;
03585         ;
03586         ;
03587         for (m = 1; m < num_materials; m++) {
03588              
03589         
03590     top_rclr += 
03591     shade_table[shade_index + 3*m + 0] * 
03592         weight_table[weight_index + m];
03593         
03594     top_gclr += 
03595     shade_table[shade_index + 3*m + 1] * 
03596         weight_table[weight_index + m];
03597         
03598     top_bclr += 
03599     shade_table[shade_index + 3*m + 2] * 
03600         weight_table[weight_index + m];
03601         ;
03602         ;
03603         ;
03604         };
03605     shade_factor = top_opc * slice_depth_cueing;
03606     
03607         top_rclr *= shade_factor;
03608         top_gclr *= shade_factor;
03609         top_bclr *= shade_factor;
03610     ;
03611                 }
03612                 
03613 #ifdef DEBUG
03614     if (ipixel == trace_pixel_ptr) {
03615         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03616         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03617         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03618         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03619         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03620     }
03621 #endif
03622 ;
03623                 
03624        acc_opc = top_opc * wgtTL;
03625        
03626             acc_rclr = top_rclr * wgtTL;
03627             acc_gclr = top_gclr * wgtTL;
03628             acc_bclr = top_bclr * wgtTL;
03629        
03630 #ifdef DEBUG
03631     if (ipixel == trace_pixel_ptr) {
03632         trace_opcTL = top_opc;
03633         trace_rclrTL = top_rclr;
03634                      trace_gclrTL = top_gclr;
03635                      trace_bclrTL = top_bclr;
03636         
03637     }
03638 #endif
03639 ;
03640                 
03641     
03642             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03643             opacity = param0_table[opac_param];
03644             if (param1_size != 0) {
03645                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03646                 opacity *= param1_table[opac_param];
03647                 if (param2_size != 0) {
03648                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03649                     opacity *= param2_table[opac_param];
03650                 }
03651             }
03652             if (opacity > min_opacity) {
03653                 opacity_int = opacity*255.;
03654                 bot_opc = opac_correct[opacity_int];
03655             } else {
03656                 bot_opc = (float)0.;
03657             };
03658     
03659     
03660     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03661     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03662     
03663         
03664         
03665     bot_rclr = 
03666     shade_table[shade_index + 3*0 + 0] * 
03667         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03668         
03669     bot_gclr = 
03670     shade_table[shade_index + 3*0 + 1] * 
03671         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03672         
03673     bot_bclr = 
03674     shade_table[shade_index + 3*0 + 2] * 
03675         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03676         ;
03677         ;
03678         ;
03679         for (m = 1; m < num_materials; m++) {
03680              
03681         
03682     bot_rclr += 
03683     shade_table[shade_index + 3*m + 0] * 
03684         weight_table[weight_index + m];
03685         
03686     bot_gclr += 
03687     shade_table[shade_index + 3*m + 1] * 
03688         weight_table[weight_index + m];
03689         
03690     bot_bclr += 
03691     shade_table[shade_index + 3*m + 2] * 
03692         weight_table[weight_index + m];
03693         ;
03694         ;
03695         ;
03696         };
03697     shade_factor = bot_opc * slice_depth_cueing;
03698     
03699         bot_rclr *= shade_factor;
03700         bot_gclr *= shade_factor;
03701         bot_bclr *= shade_factor;
03702     ;
03703                 
03704        acc_opc += bot_opc * wgtBR;
03705        
03706             acc_rclr += bot_rclr * wgtBR;
03707             acc_gclr += bot_gclr * wgtBR;
03708             acc_bclr += bot_bclr * wgtBR;
03709        
03710 #ifdef DEBUG
03711     if (ipixel == trace_pixel_ptr) {
03712         trace_opcBR = bot_opc;
03713         trace_rclrBR = bot_rclr;
03714                      trace_gclrBR = bot_gclr;
03715                      trace_bclrBR = bot_bclr;
03716         
03717     }
03718 #endif
03719 ;
03720                 
03721         COUNT_RESAMPLE;
03722         if (acc_opc > min_opacity) {
03723             COUNT_COMPOSITE;
03724             iopc = ipixel->opcflt;
03725 #           ifndef SKIP_ERT
03726                 ASSERT(iopc < max_opacity);
03727 #           endif
03728             iopc_inv = (float)1. - iopc;
03729             
03730         ipixel->rclrflt += acc_rclr * iopc_inv;
03731         ipixel->gclrflt += acc_gclr * iopc_inv;
03732         ipixel->bclrflt += acc_bclr * iopc_inv;
03733             iopc += acc_opc * iopc_inv;
03734             ipixel->opcflt = iopc;
03735             
03736 #ifdef DEBUG
03737     if (ipixel == trace_pixel_ptr) {
03738 #ifdef COMPUTE_SHADOW_BUFFER
03739         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03740 #else
03741         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03742 #endif
03743         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03744         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03745         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03746         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03747         printf("  %3.0f %3.0f\n", iopc*255., 
03748                ipixel->rclrflt);
03749         
03750         
03751         printf("              ");
03752         printf("      %3.0f    ",trace_gclrTL);
03753         printf("      %3.0f    ",trace_gclrBL);
03754         printf("      %3.0f    ",trace_gclrTR);
03755         printf("      %3.0f    ",trace_gclrBR);
03756         printf("      %3.0f\n", ipixel->gclrflt);
03757         printf("              ");
03758         printf("      %3.0f    ",trace_bclrTL);
03759         printf("      %3.0f    ",trace_bclrBL);
03760         printf("      %3.0f    ",trace_bclrTR);
03761         printf("      %3.0f    ",trace_bclrBR);
03762         printf("      %3.0f\n", ipixel->bclrflt);
03763     }
03764 #endif /* DEBUG */
03765 ;
03766 #           ifndef SKIP_ERT
03767                 if (iopc >= max_opacity) {
03768                     ASSERT(ipixel->lnk == 0);
03769                     ipixel->lnk = 1;
03770                 }
03771 #           endif
03772         };
03773                 ipixel += 1;
03774                 topRLEdata += 1 * voxel_istride;
03775                 botRLEdata += 1 * voxel_istride;
03776                 count--;
03777                 SET_VOXELS_LOADED;
03778 
03779                 /* do the rest of the pixels in this run;
03780                    bottom-left and bottom-right voxels contribute */
03781                 while (count > 0) {
03782                     if (PIXEL_IS_OPAQUE(ipixel))
03783                         break;
03784                     if (!voxels_loaded) {
03785                         
03786     
03787             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
03788             opacity = param0_table[opac_param];
03789             if (param1_size != 0) {
03790                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
03791                 opacity *= param1_table[opac_param];
03792                 if (param2_size != 0) {
03793                     opac_param = VoxelField(botRLEdata - voxel_istride, 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     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03806     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03807     
03808         
03809         
03810     bot_rclr = 
03811     shade_table[shade_index + 3*0 + 0] * 
03812         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03813         
03814     bot_gclr = 
03815     shade_table[shade_index + 3*0 + 1] * 
03816         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03817         
03818     bot_bclr = 
03819     shade_table[shade_index + 3*0 + 2] * 
03820         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03821         ;
03822         ;
03823         ;
03824         for (m = 1; m < num_materials; m++) {
03825              
03826         
03827     bot_rclr += 
03828     shade_table[shade_index + 3*m + 0] * 
03829         weight_table[weight_index + m];
03830         
03831     bot_gclr += 
03832     shade_table[shade_index + 3*m + 1] * 
03833         weight_table[weight_index + m];
03834         
03835     bot_bclr += 
03836     shade_table[shade_index + 3*m + 2] * 
03837         weight_table[weight_index + m];
03838         ;
03839         ;
03840         ;
03841         };
03842     shade_factor = bot_opc * slice_depth_cueing;
03843     
03844         bot_rclr *= shade_factor;
03845         bot_gclr *= shade_factor;
03846         bot_bclr *= shade_factor;
03847     ;
03848                     }
03849                     
03850 #ifdef DEBUG
03851     if (ipixel == trace_pixel_ptr) {
03852         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03853         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03854         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03855         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03856         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03857     }
03858 #endif
03859 ;
03860                     
03861        acc_opc = bot_opc * wgtBL;
03862        
03863             acc_rclr = bot_rclr * wgtBL;
03864             acc_gclr = bot_gclr * wgtBL;
03865             acc_bclr = bot_bclr * wgtBL;
03866        
03867 #ifdef DEBUG
03868     if (ipixel == trace_pixel_ptr) {
03869         trace_opcBL = bot_opc;
03870         trace_rclrBL = bot_rclr;
03871                      trace_gclrBL = bot_gclr;
03872                      trace_bclrBL = bot_bclr;
03873         
03874     }
03875 #endif
03876 ;
03877                     
03878     
03879             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
03880             opacity = param0_table[opac_param];
03881             if (param1_size != 0) {
03882                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
03883                 opacity *= param1_table[opac_param];
03884                 if (param2_size != 0) {
03885                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
03886                     opacity *= param2_table[opac_param];
03887                 }
03888             }
03889             if (opacity > min_opacity) {
03890                 opacity_int = opacity*255.;
03891                 bot_opc = opac_correct[opacity_int];
03892             } else {
03893                 bot_opc = (float)0.;
03894             };
03895     
03896     
03897     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03898     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03899     
03900         
03901         
03902     bot_rclr = 
03903     shade_table[shade_index + 3*0 + 0] * 
03904         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03905         
03906     bot_gclr = 
03907     shade_table[shade_index + 3*0 + 1] * 
03908         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03909         
03910     bot_bclr = 
03911     shade_table[shade_index + 3*0 + 2] * 
03912         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03913         ;
03914         ;
03915         ;
03916         for (m = 1; m < num_materials; m++) {
03917              
03918         
03919     bot_rclr += 
03920     shade_table[shade_index + 3*m + 0] * 
03921         weight_table[weight_index + m];
03922         
03923     bot_gclr += 
03924     shade_table[shade_index + 3*m + 1] * 
03925         weight_table[weight_index + m];
03926         
03927     bot_bclr += 
03928     shade_table[shade_index + 3*m + 2] * 
03929         weight_table[weight_index + m];
03930         ;
03931         ;
03932         ;
03933         };
03934     shade_factor = bot_opc * slice_depth_cueing;
03935     
03936         bot_rclr *= shade_factor;
03937         bot_gclr *= shade_factor;
03938         bot_bclr *= shade_factor;
03939     ;
03940                     
03941        acc_opc += bot_opc * wgtBR;
03942        
03943             acc_rclr += bot_rclr * wgtBR;
03944             acc_gclr += bot_gclr * wgtBR;
03945             acc_bclr += bot_bclr * wgtBR;
03946        
03947 #ifdef DEBUG
03948     if (ipixel == trace_pixel_ptr) {
03949         trace_opcBR = bot_opc;
03950         trace_rclrBR = bot_rclr;
03951                      trace_gclrBR = bot_gclr;
03952                      trace_bclrBR = bot_bclr;
03953         
03954     }
03955 #endif
03956 ;
03957                     
03958         COUNT_RESAMPLE;
03959         if (acc_opc > min_opacity) {
03960             COUNT_COMPOSITE;
03961             iopc = ipixel->opcflt;
03962 #           ifndef SKIP_ERT
03963                 ASSERT(iopc < max_opacity);
03964 #           endif
03965             iopc_inv = (float)1. - iopc;
03966             
03967         ipixel->rclrflt += acc_rclr * iopc_inv;
03968         ipixel->gclrflt += acc_gclr * iopc_inv;
03969         ipixel->bclrflt += acc_bclr * iopc_inv;
03970             iopc += acc_opc * iopc_inv;
03971             ipixel->opcflt = iopc;
03972             
03973 #ifdef DEBUG
03974     if (ipixel == trace_pixel_ptr) {
03975 #ifdef COMPUTE_SHADOW_BUFFER
03976         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03977 #else
03978         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03979 #endif
03980         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03981         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03982         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03983         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03984         printf("  %3.0f %3.0f\n", iopc*255., 
03985                ipixel->rclrflt);
03986         
03987         
03988         printf("              ");
03989         printf("      %3.0f    ",trace_gclrTL);
03990         printf("      %3.0f    ",trace_gclrBL);
03991         printf("      %3.0f    ",trace_gclrTR);
03992         printf("      %3.0f    ",trace_gclrBR);
03993         printf("      %3.0f\n", ipixel->gclrflt);
03994         printf("              ");
03995         printf("      %3.0f    ",trace_bclrTL);
03996         printf("      %3.0f    ",trace_bclrBL);
03997         printf("      %3.0f    ",trace_bclrTR);
03998         printf("      %3.0f    ",trace_bclrBR);
03999         printf("      %3.0f\n", ipixel->bclrflt);
04000     }
04001 #endif /* DEBUG */
04002 ;
04003 #           ifndef SKIP_ERT
04004                 if (iopc >= max_opacity) {
04005                     ASSERT(ipixel->lnk == 0);
04006                     ipixel->lnk = 1;
04007                 }
04008 #           endif
04009         };
04010                     ipixel += 1;
04011                     topRLEdata += 1 * voxel_istride;
04012                     botRLEdata += 1 * voxel_istride;
04013                     count--;
04014                     SET_VOXELS_LOADED;
04015                 }
04016                 break;
04017             case BOT_NONZERO__BOT_NONZERO:
04018                 /* do the pixels in this run; bottom-left and
04019                    bottom-right voxels contribute */
04020                 while (count > 0) {
04021                     if (PIXEL_IS_OPAQUE(ipixel))
04022                         break;
04023                     if (!voxels_loaded) {
04024                         
04025     
04026             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04027             opacity = param0_table[opac_param];
04028             if (param1_size != 0) {
04029                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04030                 opacity *= param1_table[opac_param];
04031                 if (param2_size != 0) {
04032                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04033                     opacity *= param2_table[opac_param];
04034                 }
04035             }
04036             if (opacity > min_opacity) {
04037                 opacity_int = opacity*255.;
04038                 bot_opc = opac_correct[opacity_int];
04039             } else {
04040                 bot_opc = (float)0.;
04041             };
04042     
04043     
04044     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04045     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04046     
04047         
04048         
04049     bot_rclr = 
04050     shade_table[shade_index + 3*0 + 0] * 
04051         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04052         
04053     bot_gclr = 
04054     shade_table[shade_index + 3*0 + 1] * 
04055         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04056         
04057     bot_bclr = 
04058     shade_table[shade_index + 3*0 + 2] * 
04059         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04060         ;
04061         ;
04062         ;
04063         for (m = 1; m < num_materials; m++) {
04064              
04065         
04066     bot_rclr += 
04067     shade_table[shade_index + 3*m + 0] * 
04068         weight_table[weight_index + m];
04069         
04070     bot_gclr += 
04071     shade_table[shade_index + 3*m + 1] * 
04072         weight_table[weight_index + m];
04073         
04074     bot_bclr += 
04075     shade_table[shade_index + 3*m + 2] * 
04076         weight_table[weight_index + m];
04077         ;
04078         ;
04079         ;
04080         };
04081     shade_factor = bot_opc * slice_depth_cueing;
04082     
04083         bot_rclr *= shade_factor;
04084         bot_gclr *= shade_factor;
04085         bot_bclr *= shade_factor;
04086     ;
04087                     }
04088                     
04089 #ifdef DEBUG
04090     if (ipixel == trace_pixel_ptr) {
04091         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04092         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04093         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04094         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04095         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04096     }
04097 #endif
04098 ;
04099                     
04100        acc_opc = bot_opc * wgtBL;
04101        
04102             acc_rclr = bot_rclr * wgtBL;
04103             acc_gclr = bot_gclr * wgtBL;
04104             acc_bclr = bot_bclr * wgtBL;
04105        
04106 #ifdef DEBUG
04107     if (ipixel == trace_pixel_ptr) {
04108         trace_opcBL = bot_opc;
04109         trace_rclrBL = bot_rclr;
04110                      trace_gclrBL = bot_gclr;
04111                      trace_bclrBL = bot_bclr;
04112         
04113     }
04114 #endif
04115 ;
04116                     
04117     
04118             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04119             opacity = param0_table[opac_param];
04120             if (param1_size != 0) {
04121                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04122                 opacity *= param1_table[opac_param];
04123                 if (param2_size != 0) {
04124                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04125                     opacity *= param2_table[opac_param];
04126                 }
04127             }
04128             if (opacity > min_opacity) {
04129                 opacity_int = opacity*255.;
04130                 bot_opc = opac_correct[opacity_int];
04131             } else {
04132                 bot_opc = (float)0.;
04133             };
04134     
04135     
04136     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04137     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04138     
04139         
04140         
04141     bot_rclr = 
04142     shade_table[shade_index + 3*0 + 0] * 
04143         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04144         
04145     bot_gclr = 
04146     shade_table[shade_index + 3*0 + 1] * 
04147         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04148         
04149     bot_bclr = 
04150     shade_table[shade_index + 3*0 + 2] * 
04151         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04152         ;
04153         ;
04154         ;
04155         for (m = 1; m < num_materials; m++) {
04156              
04157         
04158     bot_rclr += 
04159     shade_table[shade_index + 3*m + 0] * 
04160         weight_table[weight_index + m];
04161         
04162     bot_gclr += 
04163     shade_table[shade_index + 3*m + 1] * 
04164         weight_table[weight_index + m];
04165         
04166     bot_bclr += 
04167     shade_table[shade_index + 3*m + 2] * 
04168         weight_table[weight_index + m];
04169         ;
04170         ;
04171         ;
04172         };
04173     shade_factor = bot_opc * slice_depth_cueing;
04174     
04175         bot_rclr *= shade_factor;
04176         bot_gclr *= shade_factor;
04177         bot_bclr *= shade_factor;
04178     ;
04179                     
04180        acc_opc += bot_opc * wgtBR;
04181        
04182             acc_rclr += bot_rclr * wgtBR;
04183             acc_gclr += bot_gclr * wgtBR;
04184             acc_bclr += bot_bclr * wgtBR;
04185        
04186 #ifdef DEBUG
04187     if (ipixel == trace_pixel_ptr) {
04188         trace_opcBR = bot_opc;
04189         trace_rclrBR = bot_rclr;
04190                      trace_gclrBR = bot_gclr;
04191                      trace_bclrBR = bot_bclr;
04192         
04193     }
04194 #endif
04195 ;
04196                     
04197         COUNT_RESAMPLE;
04198         if (acc_opc > min_opacity) {
04199             COUNT_COMPOSITE;
04200             iopc = ipixel->opcflt;
04201 #           ifndef SKIP_ERT
04202                 ASSERT(iopc < max_opacity);
04203 #           endif
04204             iopc_inv = (float)1. - iopc;
04205             
04206         ipixel->rclrflt += acc_rclr * iopc_inv;
04207         ipixel->gclrflt += acc_gclr * iopc_inv;
04208         ipixel->bclrflt += acc_bclr * iopc_inv;
04209             iopc += acc_opc * iopc_inv;
04210             ipixel->opcflt = iopc;
04211             
04212 #ifdef DEBUG
04213     if (ipixel == trace_pixel_ptr) {
04214 #ifdef COMPUTE_SHADOW_BUFFER
04215         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04216 #else
04217         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04218 #endif
04219         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04220         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04221         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04222         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04223         printf("  %3.0f %3.0f\n", iopc*255., 
04224                ipixel->rclrflt);
04225         
04226         
04227         printf("              ");
04228         printf("      %3.0f    ",trace_gclrTL);
04229         printf("      %3.0f    ",trace_gclrBL);
04230         printf("      %3.0f    ",trace_gclrTR);
04231         printf("      %3.0f    ",trace_gclrBR);
04232         printf("      %3.0f\n", ipixel->gclrflt);
04233         printf("              ");
04234         printf("      %3.0f    ",trace_bclrTL);
04235         printf("      %3.0f    ",trace_bclrBL);
04236         printf("      %3.0f    ",trace_bclrTR);
04237         printf("      %3.0f    ",trace_bclrBR);
04238         printf("      %3.0f\n", ipixel->bclrflt);
04239     }
04240 #endif /* DEBUG */
04241 ;
04242 #           ifndef SKIP_ERT
04243                 if (iopc >= max_opacity) {
04244                     ASSERT(ipixel->lnk == 0);
04245                     ipixel->lnk = 1;
04246                 }
04247 #           endif
04248         };
04249                     ipixel += 1;
04250                     topRLEdata += 1 * voxel_istride;
04251                     botRLEdata += 1 * voxel_istride;
04252                     count--;
04253                     SET_VOXELS_LOADED;
04254                 }
04255                 break;
04256             case ALL_NONZERO__BOT_NONZERO:
04257                 /* first pixel: top-left, bottom-left and bottom-right
04258                    voxels contribute */
04259                 if (!voxels_loaded) {
04260                     
04261     
04262             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
04263             opacity = param0_table[opac_param];
04264             if (param1_size != 0) {
04265                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
04266                 opacity *= param1_table[opac_param];
04267                 if (param2_size != 0) {
04268                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
04269                     opacity *= param2_table[opac_param];
04270                 }
04271             }
04272             if (opacity > min_opacity) {
04273                 opacity_int = opacity*255.;
04274                 top_opc = opac_correct[opacity_int];
04275             } else {
04276                 top_opc = (float)0.;
04277             };
04278     
04279     
04280     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
04281     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04282     
04283         
04284         
04285     top_rclr = 
04286     shade_table[shade_index + 3*0 + 0] * 
04287         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04288         
04289     top_gclr = 
04290     shade_table[shade_index + 3*0 + 1] * 
04291         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04292         
04293     top_bclr = 
04294     shade_table[shade_index + 3*0 + 2] * 
04295         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04296         ;
04297         ;
04298         ;
04299         for (m = 1; m < num_materials; m++) {
04300              
04301         
04302     top_rclr += 
04303     shade_table[shade_index + 3*m + 0] * 
04304         weight_table[weight_index + m];
04305         
04306     top_gclr += 
04307     shade_table[shade_index + 3*m + 1] * 
04308         weight_table[weight_index + m];
04309         
04310     top_bclr += 
04311     shade_table[shade_index + 3*m + 2] * 
04312         weight_table[weight_index + m];
04313         ;
04314         ;
04315         ;
04316         };
04317     shade_factor = top_opc * slice_depth_cueing;
04318     
04319         top_rclr *= shade_factor;
04320         top_gclr *= shade_factor;
04321         top_bclr *= shade_factor;
04322     ;
04323                     
04324     
04325             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04326             opacity = param0_table[opac_param];
04327             if (param1_size != 0) {
04328                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04329                 opacity *= param1_table[opac_param];
04330                 if (param2_size != 0) {
04331                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04332                     opacity *= param2_table[opac_param];
04333                 }
04334             }
04335             if (opacity > min_opacity) {
04336                 opacity_int = opacity*255.;
04337                 bot_opc = opac_correct[opacity_int];
04338             } else {
04339                 bot_opc = (float)0.;
04340             };
04341     
04342     
04343     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04344     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04345     
04346         
04347         
04348     bot_rclr = 
04349     shade_table[shade_index + 3*0 + 0] * 
04350         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04351         
04352     bot_gclr = 
04353     shade_table[shade_index + 3*0 + 1] * 
04354         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04355         
04356     bot_bclr = 
04357     shade_table[shade_index + 3*0 + 2] * 
04358         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04359         ;
04360         ;
04361         ;
04362         for (m = 1; m < num_materials; m++) {
04363              
04364         
04365     bot_rclr += 
04366     shade_table[shade_index + 3*m + 0] * 
04367         weight_table[weight_index + m];
04368         
04369     bot_gclr += 
04370     shade_table[shade_index + 3*m + 1] * 
04371         weight_table[weight_index + m];
04372         
04373     bot_bclr += 
04374     shade_table[shade_index + 3*m + 2] * 
04375         weight_table[weight_index + m];
04376         ;
04377         ;
04378         ;
04379         };
04380     shade_factor = bot_opc * slice_depth_cueing;
04381     
04382         bot_rclr *= shade_factor;
04383         bot_gclr *= shade_factor;
04384         bot_bclr *= shade_factor;
04385     ;
04386                 }
04387                 
04388 #ifdef DEBUG
04389     if (ipixel == trace_pixel_ptr) {
04390         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04391         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04392         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04393         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04394         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04395     }
04396 #endif
04397 ;
04398                 
04399        acc_opc = top_opc * wgtTL;
04400        
04401             acc_rclr = top_rclr * wgtTL;
04402             acc_gclr = top_gclr * wgtTL;
04403             acc_bclr = top_bclr * wgtTL;
04404        
04405 #ifdef DEBUG
04406     if (ipixel == trace_pixel_ptr) {
04407         trace_opcTL = top_opc;
04408         trace_rclrTL = top_rclr;
04409                      trace_gclrTL = top_gclr;
04410                      trace_bclrTL = top_bclr;
04411         
04412     }
04413 #endif
04414 ;
04415                 
04416        acc_opc += bot_opc * wgtBL;
04417        
04418             acc_rclr += bot_rclr * wgtBL;
04419             acc_gclr += bot_gclr * wgtBL;
04420             acc_bclr += bot_bclr * wgtBL;
04421        
04422 #ifdef DEBUG
04423     if (ipixel == trace_pixel_ptr) {
04424         trace_opcBL = bot_opc;
04425         trace_rclrBL = bot_rclr;
04426                      trace_gclrBL = bot_gclr;
04427                      trace_bclrBL = bot_bclr;
04428         
04429     }
04430 #endif
04431 ;
04432                 
04433     
04434             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04435             opacity = param0_table[opac_param];
04436             if (param1_size != 0) {
04437                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04438                 opacity *= param1_table[opac_param];
04439                 if (param2_size != 0) {
04440                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04441                     opacity *= param2_table[opac_param];
04442                 }
04443             }
04444             if (opacity > min_opacity) {
04445                 opacity_int = opacity*255.;
04446                 bot_opc = opac_correct[opacity_int];
04447             } else {
04448                 bot_opc = (float)0.;
04449             };
04450     
04451     
04452     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04453     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04454     
04455         
04456         
04457     bot_rclr = 
04458     shade_table[shade_index + 3*0 + 0] * 
04459         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04460         
04461     bot_gclr = 
04462     shade_table[shade_index + 3*0 + 1] * 
04463         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04464         
04465     bot_bclr = 
04466     shade_table[shade_index + 3*0 + 2] * 
04467         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04468         ;
04469         ;
04470         ;
04471         for (m = 1; m < num_materials; m++) {
04472              
04473         
04474     bot_rclr += 
04475     shade_table[shade_index + 3*m + 0] * 
04476         weight_table[weight_index + m];
04477         
04478     bot_gclr += 
04479     shade_table[shade_index + 3*m + 1] * 
04480         weight_table[weight_index + m];
04481         
04482     bot_bclr += 
04483     shade_table[shade_index + 3*m + 2] * 
04484         weight_table[weight_index + m];
04485         ;
04486         ;
04487         ;
04488         };
04489     shade_factor = bot_opc * slice_depth_cueing;
04490     
04491         bot_rclr *= shade_factor;
04492         bot_gclr *= shade_factor;
04493         bot_bclr *= shade_factor;
04494     ;
04495                 
04496        acc_opc += bot_opc * wgtBR;
04497        
04498             acc_rclr += bot_rclr * wgtBR;
04499             acc_gclr += bot_gclr * wgtBR;
04500             acc_bclr += bot_bclr * wgtBR;
04501        
04502 #ifdef DEBUG
04503     if (ipixel == trace_pixel_ptr) {
04504         trace_opcBR = bot_opc;
04505         trace_rclrBR = bot_rclr;
04506                      trace_gclrBR = bot_gclr;
04507                      trace_bclrBR = bot_bclr;
04508         
04509     }
04510 #endif
04511 ;
04512                 
04513         COUNT_RESAMPLE;
04514         if (acc_opc > min_opacity) {
04515             COUNT_COMPOSITE;
04516             iopc = ipixel->opcflt;
04517 #           ifndef SKIP_ERT
04518                 ASSERT(iopc < max_opacity);
04519 #           endif
04520             iopc_inv = (float)1. - iopc;
04521             
04522         ipixel->rclrflt += acc_rclr * iopc_inv;
04523         ipixel->gclrflt += acc_gclr * iopc_inv;
04524         ipixel->bclrflt += acc_bclr * iopc_inv;
04525             iopc += acc_opc * iopc_inv;
04526             ipixel->opcflt = iopc;
04527             
04528 #ifdef DEBUG
04529     if (ipixel == trace_pixel_ptr) {
04530 #ifdef COMPUTE_SHADOW_BUFFER
04531         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04532 #else
04533         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04534 #endif
04535         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04536         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04537         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04538         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04539         printf("  %3.0f %3.0f\n", iopc*255., 
04540                ipixel->rclrflt);
04541         
04542         
04543         printf("              ");
04544         printf("      %3.0f    ",trace_gclrTL);
04545         printf("      %3.0f    ",trace_gclrBL);
04546         printf("      %3.0f    ",trace_gclrTR);
04547         printf("      %3.0f    ",trace_gclrBR);
04548         printf("      %3.0f\n", ipixel->gclrflt);
04549         printf("              ");
04550         printf("      %3.0f    ",trace_bclrTL);
04551         printf("      %3.0f    ",trace_bclrBL);
04552         printf("      %3.0f    ",trace_bclrTR);
04553         printf("      %3.0f    ",trace_bclrBR);
04554         printf("      %3.0f\n", ipixel->bclrflt);
04555     }
04556 #endif /* DEBUG */
04557 ;
04558 #           ifndef SKIP_ERT
04559                 if (iopc >= max_opacity) {
04560                     ASSERT(ipixel->lnk == 0);
04561                     ipixel->lnk = 1;
04562                 }
04563 #           endif
04564         };
04565                 ipixel += 1;
04566                 topRLEdata += 1 * voxel_istride;
04567                 botRLEdata += 1 * voxel_istride;
04568                 count--;
04569                 SET_VOXELS_LOADED;
04570 
04571                 /* do the rest of the pixels in this run;
04572                    bottom-left and bottom-right voxels contribute */
04573                 while (count > 0) {
04574                     if (PIXEL_IS_OPAQUE(ipixel))
04575                         break;
04576                     if (!voxels_loaded) {
04577                         
04578     
04579             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
04580             opacity = param0_table[opac_param];
04581             if (param1_size != 0) {
04582                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
04583                 opacity *= param1_table[opac_param];
04584                 if (param2_size != 0) {
04585                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
04586                     opacity *= param2_table[opac_param];
04587                 }
04588             }
04589             if (opacity > min_opacity) {
04590                 opacity_int = opacity*255.;
04591                 bot_opc = opac_correct[opacity_int];
04592             } else {
04593                 bot_opc = (float)0.;
04594             };
04595     
04596     
04597     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04598     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04599     
04600         
04601         
04602     bot_rclr = 
04603     shade_table[shade_index + 3*0 + 0] * 
04604         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04605         
04606     bot_gclr = 
04607     shade_table[shade_index + 3*0 + 1] * 
04608         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04609         
04610     bot_bclr = 
04611     shade_table[shade_index + 3*0 + 2] * 
04612         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04613         ;
04614         ;
04615         ;
04616         for (m = 1; m < num_materials; m++) {
04617              
04618         
04619     bot_rclr += 
04620     shade_table[shade_index + 3*m + 0] * 
04621         weight_table[weight_index + m];
04622         
04623     bot_gclr += 
04624     shade_table[shade_index + 3*m + 1] * 
04625         weight_table[weight_index + m];
04626         
04627     bot_bclr += 
04628     shade_table[shade_index + 3*m + 2] * 
04629         weight_table[weight_index + m];
04630         ;
04631         ;
04632         ;
04633         };
04634     shade_factor = bot_opc * slice_depth_cueing;
04635     
04636         bot_rclr *= shade_factor;
04637         bot_gclr *= shade_factor;
04638         bot_bclr *= shade_factor;
04639     ;
04640                     }
04641                     
04642 #ifdef DEBUG
04643     if (ipixel == trace_pixel_ptr) {
04644         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04645         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04646         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04647         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04648         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04649     }
04650 #endif
04651 ;
04652                     
04653        acc_opc = bot_opc * wgtBL;
04654        
04655             acc_rclr = bot_rclr * wgtBL;
04656             acc_gclr = bot_gclr * wgtBL;
04657             acc_bclr = bot_bclr * wgtBL;
04658        
04659 #ifdef DEBUG
04660     if (ipixel == trace_pixel_ptr) {
04661         trace_opcBL = bot_opc;
04662         trace_rclrBL = bot_rclr;
04663                      trace_gclrBL = bot_gclr;
04664                      trace_bclrBL = bot_bclr;
04665         
04666     }
04667 #endif
04668 ;
04669                     
04670     
04671             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04672             opacity = param0_table[opac_param];
04673             if (param1_size != 0) {
04674                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04675                 opacity *= param1_table[opac_param];
04676                 if (param2_size != 0) {
04677                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04678                     opacity *= param2_table[opac_param];
04679                 }
04680             }
04681             if (opacity > min_opacity) {
04682                 opacity_int = opacity*255.;
04683                 bot_opc = opac_correct[opacity_int];
04684             } else {
04685                 bot_opc = (float)0.;
04686             };
04687     
04688     
04689     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04690     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04691     
04692         
04693         
04694     bot_rclr = 
04695     shade_table[shade_index + 3*0 + 0] * 
04696         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04697         
04698     bot_gclr = 
04699     shade_table[shade_index + 3*0 + 1] * 
04700         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04701         
04702     bot_bclr = 
04703     shade_table[shade_index + 3*0 + 2] * 
04704         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04705         ;
04706         ;
04707         ;
04708         for (m = 1; m < num_materials; m++) {
04709              
04710         
04711     bot_rclr += 
04712     shade_table[shade_index + 3*m + 0] * 
04713         weight_table[weight_index + m];
04714         
04715     bot_gclr += 
04716     shade_table[shade_index + 3*m + 1] * 
04717         weight_table[weight_index + m];
04718         
04719     bot_bclr += 
04720     shade_table[shade_index + 3*m + 2] * 
04721         weight_table[weight_index + m];
04722         ;
04723         ;
04724         ;
04725         };
04726     shade_factor = bot_opc * slice_depth_cueing;
04727     
04728         bot_rclr *= shade_factor;
04729         bot_gclr *= shade_factor;
04730         bot_bclr *= shade_factor;
04731     ;
04732                     
04733        acc_opc += bot_opc * wgtBR;
04734        
04735             acc_rclr += bot_rclr * wgtBR;
04736             acc_gclr += bot_gclr * wgtBR;
04737             acc_bclr += bot_bclr * wgtBR;
04738        
04739 #ifdef DEBUG
04740     if (ipixel == trace_pixel_ptr) {
04741         trace_opcBR = bot_opc;
04742         trace_rclrBR = bot_rclr;
04743                      trace_gclrBR = bot_gclr;
04744                      trace_bclrBR = bot_bclr;
04745         
04746     }
04747 #endif
04748 ;
04749                     
04750         COUNT_RESAMPLE;
04751         if (acc_opc > min_opacity) {
04752             COUNT_COMPOSITE;
04753             iopc = ipixel->opcflt;
04754 #           ifndef SKIP_ERT
04755                 ASSERT(iopc < max_opacity);
04756 #           endif
04757             iopc_inv = (float)1. - iopc;
04758             
04759         ipixel->rclrflt += acc_rclr * iopc_inv;
04760         ipixel->gclrflt += acc_gclr * iopc_inv;
04761         ipixel->bclrflt += acc_bclr * iopc_inv;
04762             iopc += acc_opc * iopc_inv;
04763             ipixel->opcflt = iopc;
04764             
04765 #ifdef DEBUG
04766     if (ipixel == trace_pixel_ptr) {
04767 #ifdef COMPUTE_SHADOW_BUFFER
04768         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04769 #else
04770         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04771 #endif
04772         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04773         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04774         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04775         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04776         printf("  %3.0f %3.0f\n", iopc*255., 
04777                ipixel->rclrflt);
04778         
04779         
04780         printf("              ");
04781         printf("      %3.0f    ",trace_gclrTL);
04782         printf("      %3.0f    ",trace_gclrBL);
04783         printf("      %3.0f    ",trace_gclrTR);
04784         printf("      %3.0f    ",trace_gclrBR);
04785         printf("      %3.0f\n", ipixel->gclrflt);
04786         printf("              ");
04787         printf("      %3.0f    ",trace_bclrTL);
04788         printf("      %3.0f    ",trace_bclrBL);
04789         printf("      %3.0f    ",trace_bclrTR);
04790         printf("      %3.0f    ",trace_bclrBR);
04791         printf("      %3.0f\n", ipixel->bclrflt);
04792     }
04793 #endif /* DEBUG */
04794 ;
04795 #           ifndef SKIP_ERT
04796                 if (iopc >= max_opacity) {
04797                     ASSERT(ipixel->lnk == 0);
04798                     ipixel->lnk = 1;
04799                 }
04800 #           endif
04801         };
04802                     ipixel += 1;
04803                     topRLEdata += 1 * voxel_istride;
04804                     botRLEdata += 1 * voxel_istride;
04805                     count--;
04806                     SET_VOXELS_LOADED;
04807                 }
04808                 break;
04809             case ALL_ZERO__ALL_NONZERO:
04810                 /* first pixel: top-right and bottom-right voxels contribute */
04811                 
04812     
04813             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
04814             opacity = param0_table[opac_param];
04815             if (param1_size != 0) {
04816                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
04817                 opacity *= param1_table[opac_param];
04818                 if (param2_size != 0) {
04819                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
04820                     opacity *= param2_table[opac_param];
04821                 }
04822             }
04823             if (opacity > min_opacity) {
04824                 opacity_int = opacity*255.;
04825                 top_opc = opac_correct[opacity_int];
04826             } else {
04827                 top_opc = (float)0.;
04828             };
04829     
04830     
04831     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
04832     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04833     
04834         
04835         
04836     top_rclr = 
04837     shade_table[shade_index + 3*0 + 0] * 
04838         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04839         
04840     top_gclr = 
04841     shade_table[shade_index + 3*0 + 1] * 
04842         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04843         
04844     top_bclr = 
04845     shade_table[shade_index + 3*0 + 2] * 
04846         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04847         ;
04848         ;
04849         ;
04850         for (m = 1; m < num_materials; m++) {
04851              
04852         
04853     top_rclr += 
04854     shade_table[shade_index + 3*m + 0] * 
04855         weight_table[weight_index + m];
04856         
04857     top_gclr += 
04858     shade_table[shade_index + 3*m + 1] * 
04859         weight_table[weight_index + m];
04860         
04861     top_bclr += 
04862     shade_table[shade_index + 3*m + 2] * 
04863         weight_table[weight_index + m];
04864         ;
04865         ;
04866         ;
04867         };
04868     shade_factor = top_opc * slice_depth_cueing;
04869     
04870         top_rclr *= shade_factor;
04871         top_gclr *= shade_factor;
04872         top_bclr *= shade_factor;
04873     ;
04874                 
04875     
04876             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
04877             opacity = param0_table[opac_param];
04878             if (param1_size != 0) {
04879                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
04880                 opacity *= param1_table[opac_param];
04881                 if (param2_size != 0) {
04882                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
04883                     opacity *= param2_table[opac_param];
04884                 }
04885             }
04886             if (opacity > min_opacity) {
04887                 opacity_int = opacity*255.;
04888                 bot_opc = opac_correct[opacity_int];
04889             } else {
04890                 bot_opc = (float)0.;
04891             };
04892     
04893     
04894     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04895     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04896     
04897         
04898         
04899     bot_rclr = 
04900     shade_table[shade_index + 3*0 + 0] * 
04901         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04902         
04903     bot_gclr = 
04904     shade_table[shade_index + 3*0 + 1] * 
04905         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04906         
04907     bot_bclr = 
04908     shade_table[shade_index + 3*0 + 2] * 
04909         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04910         ;
04911         ;
04912         ;
04913         for (m = 1; m < num_materials; m++) {
04914              
04915         
04916     bot_rclr += 
04917     shade_table[shade_index + 3*m + 0] * 
04918         weight_table[weight_index + m];
04919         
04920     bot_gclr += 
04921     shade_table[shade_index + 3*m + 1] * 
04922         weight_table[weight_index + m];
04923         
04924     bot_bclr += 
04925     shade_table[shade_index + 3*m + 2] * 
04926         weight_table[weight_index + m];
04927         ;
04928         ;
04929         ;
04930         };
04931     shade_factor = bot_opc * slice_depth_cueing;
04932     
04933         bot_rclr *= shade_factor;
04934         bot_gclr *= shade_factor;
04935         bot_bclr *= shade_factor;
04936     ;
04937                 
04938 #ifdef DEBUG
04939     if (ipixel == trace_pixel_ptr) {
04940         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04941         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04942         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04943         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04944         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04945     }
04946 #endif
04947 ;
04948                 
04949        acc_opc = top_opc * wgtTR;
04950        
04951             acc_rclr = top_rclr * wgtTR;
04952             acc_gclr = top_gclr * wgtTR;
04953             acc_bclr = top_bclr * wgtTR;
04954        
04955 #ifdef DEBUG
04956     if (ipixel == trace_pixel_ptr) {
04957         trace_opcTR = top_opc;
04958         trace_rclrTR = top_rclr;
04959                      trace_gclrTR = top_gclr;
04960                      trace_bclrTR = top_bclr;
04961         
04962     }
04963 #endif
04964 ;
04965                 
04966        acc_opc += bot_opc * wgtBR;
04967        
04968             acc_rclr += bot_rclr * wgtBR;
04969             acc_gclr += bot_gclr * wgtBR;
04970             acc_bclr += bot_bclr * wgtBR;
04971        
04972 #ifdef DEBUG
04973     if (ipixel == trace_pixel_ptr) {
04974         trace_opcBR = bot_opc;
04975         trace_rclrBR = bot_rclr;
04976                      trace_gclrBR = bot_gclr;
04977                      trace_bclrBR = bot_bclr;
04978         
04979     }
04980 #endif
04981 ;
04982                 
04983         COUNT_RESAMPLE;
04984         if (acc_opc > min_opacity) {
04985             COUNT_COMPOSITE;
04986             iopc = ipixel->opcflt;
04987 #           ifndef SKIP_ERT
04988                 ASSERT(iopc < max_opacity);
04989 #           endif
04990             iopc_inv = (float)1. - iopc;
04991             
04992         ipixel->rclrflt += acc_rclr * iopc_inv;
04993         ipixel->gclrflt += acc_gclr * iopc_inv;
04994         ipixel->bclrflt += acc_bclr * iopc_inv;
04995             iopc += acc_opc * iopc_inv;
04996             ipixel->opcflt = iopc;
04997             
04998 #ifdef DEBUG
04999     if (ipixel == trace_pixel_ptr) {
05000 #ifdef COMPUTE_SHADOW_BUFFER
05001         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05002 #else
05003         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05004 #endif
05005         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05006         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05007         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05008         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05009         printf("  %3.0f %3.0f\n", iopc*255., 
05010                ipixel->rclrflt);
05011         
05012         
05013         printf("              ");
05014         printf("      %3.0f    ",trace_gclrTL);
05015         printf("      %3.0f    ",trace_gclrBL);
05016         printf("      %3.0f    ",trace_gclrTR);
05017         printf("      %3.0f    ",trace_gclrBR);
05018         printf("      %3.0f\n", ipixel->gclrflt);
05019         printf("              ");
05020         printf("      %3.0f    ",trace_bclrTL);
05021         printf("      %3.0f    ",trace_bclrBL);
05022         printf("      %3.0f    ",trace_bclrTR);
05023         printf("      %3.0f    ",trace_bclrBR);
05024         printf("      %3.0f\n", ipixel->bclrflt);
05025     }
05026 #endif /* DEBUG */
05027 ;
05028 #           ifndef SKIP_ERT
05029                 if (iopc >= max_opacity) {
05030                     ASSERT(ipixel->lnk == 0);
05031                     ipixel->lnk = 1;
05032                 }
05033 #           endif
05034         };
05035                 ipixel += 1;
05036                 topRLEdata += 1 * voxel_istride;
05037                 botRLEdata += 1 * voxel_istride;
05038                 count--;
05039                 SET_VOXELS_LOADED;
05040 
05041                 /* do the rest of the pixels in this run;
05042                    all four voxels contribute */
05043                 while (count > 0) {
05044                     if (PIXEL_IS_OPAQUE(ipixel))
05045                         break;
05046                     if (!voxels_loaded) {
05047                         
05048     
05049             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05050             opacity = param0_table[opac_param];
05051             if (param1_size != 0) {
05052                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05053                 opacity *= param1_table[opac_param];
05054                 if (param2_size != 0) {
05055                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05056                     opacity *= param2_table[opac_param];
05057                 }
05058             }
05059             if (opacity > min_opacity) {
05060                 opacity_int = opacity*255.;
05061                 top_opc = opac_correct[opacity_int];
05062             } else {
05063                 top_opc = (float)0.;
05064             };
05065     
05066     
05067     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05068     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05069     
05070         
05071         
05072     top_rclr = 
05073     shade_table[shade_index + 3*0 + 0] * 
05074         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05075         
05076     top_gclr = 
05077     shade_table[shade_index + 3*0 + 1] * 
05078         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05079         
05080     top_bclr = 
05081     shade_table[shade_index + 3*0 + 2] * 
05082         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05083         ;
05084         ;
05085         ;
05086         for (m = 1; m < num_materials; m++) {
05087              
05088         
05089     top_rclr += 
05090     shade_table[shade_index + 3*m + 0] * 
05091         weight_table[weight_index + m];
05092         
05093     top_gclr += 
05094     shade_table[shade_index + 3*m + 1] * 
05095         weight_table[weight_index + m];
05096         
05097     top_bclr += 
05098     shade_table[shade_index + 3*m + 2] * 
05099         weight_table[weight_index + m];
05100         ;
05101         ;
05102         ;
05103         };
05104     shade_factor = top_opc * slice_depth_cueing;
05105     
05106         top_rclr *= shade_factor;
05107         top_gclr *= shade_factor;
05108         top_bclr *= shade_factor;
05109     ;
05110                         
05111     
05112             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05113             opacity = param0_table[opac_param];
05114             if (param1_size != 0) {
05115                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05116                 opacity *= param1_table[opac_param];
05117                 if (param2_size != 0) {
05118                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05119                     opacity *= param2_table[opac_param];
05120                 }
05121             }
05122             if (opacity > min_opacity) {
05123                 opacity_int = opacity*255.;
05124                 bot_opc = opac_correct[opacity_int];
05125             } else {
05126                 bot_opc = (float)0.;
05127             };
05128     
05129     
05130     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
05131     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
05132     
05133         
05134         
05135     bot_rclr = 
05136     shade_table[shade_index + 3*0 + 0] * 
05137         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05138         
05139     bot_gclr = 
05140     shade_table[shade_index + 3*0 + 1] * 
05141         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05142         
05143     bot_bclr = 
05144     shade_table[shade_index + 3*0 + 2] * 
05145         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05146         ;
05147         ;
05148         ;
05149         for (m = 1; m < num_materials; m++) {
05150              
05151         
05152     bot_rclr += 
05153     shade_table[shade_index + 3*m + 0] * 
05154         weight_table[weight_index + m];
05155         
05156     bot_gclr += 
05157     shade_table[shade_index + 3*m + 1] * 
05158         weight_table[weight_index + m];
05159         
05160     bot_bclr += 
05161     shade_table[shade_index + 3*m + 2] * 
05162         weight_table[weight_index + m];
05163         ;
05164         ;
05165         ;
05166         };
05167     shade_factor = bot_opc * slice_depth_cueing;
05168     
05169         bot_rclr *= shade_factor;
05170         bot_gclr *= shade_factor;
05171         bot_bclr *= shade_factor;
05172     ;
05173                     }
05174                     
05175 #ifdef DEBUG
05176     if (ipixel == trace_pixel_ptr) {
05177         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05178         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05179         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05180         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05181         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05182     }
05183 #endif
05184 ;
05185                     
05186        acc_opc = top_opc * wgtTL;
05187        
05188             acc_rclr = top_rclr * wgtTL;
05189             acc_gclr = top_gclr * wgtTL;
05190             acc_bclr = top_bclr * wgtTL;
05191        
05192 #ifdef DEBUG
05193     if (ipixel == trace_pixel_ptr) {
05194         trace_opcTL = top_opc;
05195         trace_rclrTL = top_rclr;
05196                      trace_gclrTL = top_gclr;
05197                      trace_bclrTL = top_bclr;
05198         
05199     }
05200 #endif
05201 ;
05202                     
05203        acc_opc += bot_opc * wgtBL;
05204        
05205             acc_rclr += bot_rclr * wgtBL;
05206             acc_gclr += bot_gclr * wgtBL;
05207             acc_bclr += bot_bclr * wgtBL;
05208        
05209 #ifdef DEBUG
05210     if (ipixel == trace_pixel_ptr) {
05211         trace_opcBL = bot_opc;
05212         trace_rclrBL = bot_rclr;
05213                      trace_gclrBL = bot_gclr;
05214                      trace_bclrBL = bot_bclr;
05215         
05216     }
05217 #endif
05218 ;
05219                     
05220     
05221             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
05222             opacity = param0_table[opac_param];
05223             if (param1_size != 0) {
05224                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
05225                 opacity *= param1_table[opac_param];
05226                 if (param2_size != 0) {
05227                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
05228                     opacity *= param2_table[opac_param];
05229                 }
05230             }
05231             if (opacity > min_opacity) {
05232                 opacity_int = opacity*255.;
05233                 top_opc = opac_correct[opacity_int];
05234             } else {
05235                 top_opc = (float)0.;
05236             };
05237     
05238     
05239     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
05240     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05241     
05242         
05243         
05244     top_rclr = 
05245     shade_table[shade_index + 3*0 + 0] * 
05246         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05247         
05248     top_gclr = 
05249     shade_table[shade_index + 3*0 + 1] * 
05250         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05251         
05252     top_bclr = 
05253     shade_table[shade_index + 3*0 + 2] * 
05254         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05255         ;
05256         ;
05257         ;
05258         for (m = 1; m < num_materials; m++) {
05259              
05260         
05261     top_rclr += 
05262     shade_table[shade_index + 3*m + 0] * 
05263         weight_table[weight_index + m];
05264         
05265     top_gclr += 
05266     shade_table[shade_index + 3*m + 1] * 
05267         weight_table[weight_index + m];
05268         
05269     top_bclr += 
05270     shade_table[shade_index + 3*m + 2] * 
05271         weight_table[weight_index + m];
05272         ;
05273         ;
05274         ;
05275         };
05276     shade_factor = top_opc * slice_depth_cueing;
05277     
05278         top_rclr *= shade_factor;
05279         top_gclr *= shade_factor;
05280         top_bclr *= shade_factor;
05281     ;
05282                     
05283     
05284             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05285             opacity = param0_table[opac_param];
05286             if (param1_size != 0) {
05287                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
05288                 opacity *= param1_table[opac_param];
05289                 if (param2_size != 0) {
05290                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
05291                     opacity *= param2_table[opac_param];
05292                 }
05293             }
05294             if (opacity > min_opacity) {
05295                 opacity_int = opacity*255.;
05296                 bot_opc = opac_correct[opacity_int];
05297             } else {
05298                 bot_opc = (float)0.;
05299             };
05300     
05301     
05302     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
05303     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
05304     
05305         
05306         
05307     bot_rclr = 
05308     shade_table[shade_index + 3*0 + 0] * 
05309         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05310         
05311     bot_gclr = 
05312     shade_table[shade_index + 3*0 + 1] * 
05313         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05314         
05315     bot_bclr = 
05316     shade_table[shade_index + 3*0 + 2] * 
05317         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05318         ;
05319         ;
05320         ;
05321         for (m = 1; m < num_materials; m++) {
05322              
05323         
05324     bot_rclr += 
05325     shade_table[shade_index + 3*m + 0] * 
05326         weight_table[weight_index + m];
05327         
05328     bot_gclr += 
05329     shade_table[shade_index + 3*m + 1] * 
05330         weight_table[weight_index + m];
05331         
05332     bot_bclr += 
05333     shade_table[shade_index + 3*m + 2] * 
05334         weight_table[weight_index + m];
05335         ;
05336         ;
05337         ;
05338         };
05339     shade_factor = bot_opc * slice_depth_cueing;
05340     
05341         bot_rclr *= shade_factor;
05342         bot_gclr *= shade_factor;
05343         bot_bclr *= shade_factor;
05344     ;
05345                     
05346        acc_opc += top_opc * wgtTR;
05347        
05348             acc_rclr += top_rclr * wgtTR;
05349             acc_gclr += top_gclr * wgtTR;
05350             acc_bclr += top_bclr * wgtTR;
05351        
05352 #ifdef DEBUG
05353     if (ipixel == trace_pixel_ptr) {
05354         trace_opcTR = top_opc;
05355         trace_rclrTR = top_rclr;
05356                      trace_gclrTR = top_gclr;
05357                      trace_bclrTR = top_bclr;
05358         
05359     }
05360 #endif
05361 ;
05362                     
05363        acc_opc += bot_opc * wgtBR;
05364        
05365             acc_rclr += bot_rclr * wgtBR;
05366             acc_gclr += bot_gclr * wgtBR;
05367             acc_bclr += bot_bclr * wgtBR;
05368        
05369 #ifdef DEBUG
05370     if (ipixel == trace_pixel_ptr) {
05371         trace_opcBR = bot_opc;
05372         trace_rclrBR = bot_rclr;
05373                      trace_gclrBR = bot_gclr;
05374                      trace_bclrBR = bot_bclr;
05375         
05376     }
05377 #endif
05378 ;
05379                     
05380         COUNT_RESAMPLE;
05381         if (acc_opc > min_opacity) {
05382             COUNT_COMPOSITE;
05383             iopc = ipixel->opcflt;
05384 #           ifndef SKIP_ERT
05385                 ASSERT(iopc < max_opacity);
05386 #           endif
05387             iopc_inv = (float)1. - iopc;
05388             
05389         ipixel->rclrflt += acc_rclr * iopc_inv;
05390         ipixel->gclrflt += acc_gclr * iopc_inv;
05391         ipixel->bclrflt += acc_bclr * iopc_inv;
05392             iopc += acc_opc * iopc_inv;
05393             ipixel->opcflt = iopc;
05394             
05395 #ifdef DEBUG
05396     if (ipixel == trace_pixel_ptr) {
05397 #ifdef COMPUTE_SHADOW_BUFFER
05398         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05399 #else
05400         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05401 #endif
05402         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05403         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05404         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05405         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05406         printf("  %3.0f %3.0f\n", iopc*255., 
05407                ipixel->rclrflt);
05408         
05409         
05410         printf("              ");
05411         printf("      %3.0f    ",trace_gclrTL);
05412         printf("      %3.0f    ",trace_gclrBL);
05413         printf("      %3.0f    ",trace_gclrTR);
05414         printf("      %3.0f    ",trace_gclrBR);
05415         printf("      %3.0f\n", ipixel->gclrflt);
05416         printf("              ");
05417         printf("      %3.0f    ",trace_bclrTL);
05418         printf("      %3.0f    ",trace_bclrBL);
05419         printf("      %3.0f    ",trace_bclrTR);
05420         printf("      %3.0f    ",trace_bclrBR);
05421         printf("      %3.0f\n", ipixel->bclrflt);
05422     }
05423 #endif /* DEBUG */
05424 ;
05425 #           ifndef SKIP_ERT
05426                 if (iopc >= max_opacity) {
05427                     ASSERT(ipixel->lnk == 0);
05428                     ipixel->lnk = 1;
05429                 }
05430 #           endif
05431         };
05432                     ipixel += 1;
05433                     topRLEdata += 1 * voxel_istride;
05434                     botRLEdata += 1 * voxel_istride;
05435                     count--;
05436                     SET_VOXELS_LOADED;
05437                 }
05438                 break;
05439             case TOP_NONZERO__ALL_NONZERO:
05440                 /* first pixel: top-left, top-right and bottom-right
05441                    voxels contribute */
05442                 if (!voxels_loaded) {
05443                     
05444     
05445             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05446             opacity = param0_table[opac_param];
05447             if (param1_size != 0) {
05448                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05449                 opacity *= param1_table[opac_param];
05450                 if (param2_size != 0) {
05451                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05452                     opacity *= param2_table[opac_param];
05453                 }
05454             }
05455             if (opacity > min_opacity) {
05456                 opacity_int = opacity*255.;
05457                 top_opc = opac_correct[opacity_int];
05458             } else {
05459                 top_opc = (float)0.;
05460             };
05461     
05462     
05463     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05464     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05465     
05466         
05467         
05468     top_rclr = 
05469     shade_table[shade_index + 3*0 + 0] * 
05470         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05471         
05472     top_gclr = 
05473     shade_table[shade_index + 3*0 + 1] * 
05474         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05475         
05476     top_bclr = 
05477     shade_table[shade_index + 3*0 + 2] * 
05478         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05479         ;
05480         ;
05481         ;
05482         for (m = 1; m < num_materials; m++) {
05483              
05484         
05485     top_rclr += 
05486     shade_table[shade_index + 3*m + 0] * 
05487         weight_table[weight_index + m];
05488         
05489     top_gclr += 
05490     shade_table[shade_index + 3*m + 1] * 
05491         weight_table[weight_index + m];
05492         
05493     top_bclr += 
05494     shade_table[shade_index + 3*m + 2] * 
05495         weight_table[weight_index + m];
05496         ;
05497         ;
05498         ;
05499         };
05500     shade_factor = top_opc * slice_depth_cueing;
05501     
05502         top_rclr *= shade_factor;
05503         top_gclr *= shade_factor;
05504         top_bclr *= shade_factor;
05505     ;
05506                 }
05507                 
05508 #ifdef DEBUG
05509     if (ipixel == trace_pixel_ptr) {
05510         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05511         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05512         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05513         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05514         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05515     }
05516 #endif
05517 ;
05518                 
05519        acc_opc = top_opc * wgtTL;
05520        
05521             acc_rclr = top_rclr * wgtTL;
05522             acc_gclr = top_gclr * wgtTL;
05523             acc_bclr = top_bclr * wgtTL;
05524        
05525 #ifdef DEBUG
05526     if (ipixel == trace_pixel_ptr) {
05527         trace_opcTL = top_opc;
05528         trace_rclrTL = top_rclr;
05529                      trace_gclrTL = top_gclr;
05530                      trace_bclrTL = top_bclr;
05531         
05532     }
05533 #endif
05534 ;
05535                 
05536     
05537             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
05538             opacity = param0_table[opac_param];
05539             if (param1_size != 0) {
05540                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
05541                 opacity *= param1_table[opac_param];
05542                 if (param2_size != 0) {
05543                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
05544                     opacity *= param2_table[opac_param];
05545                 }
05546             }
05547             if (opacity > min_opacity) {
05548                 opacity_int = opacity*255.;
05549                 top_opc = opac_correct[opacity_int];
05550             } else {
05551                 top_opc = (float)0.;
05552             };
05553     
05554     
05555     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
05556     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05557     
05558         
05559         
05560     top_rclr = 
05561     shade_table[shade_index + 3*0 + 0] * 
05562         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05563         
05564     top_gclr = 
05565     shade_table[shade_index + 3*0 + 1] * 
05566         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05567         
05568     top_bclr = 
05569     shade_table[shade_index + 3*0 + 2] * 
05570         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05571         ;
05572         ;
05573         ;
05574         for (m = 1; m < num_materials; m++) {
05575              
05576         
05577     top_rclr += 
05578     shade_table[shade_index + 3*m + 0] * 
05579         weight_table[weight_index + m];
05580         
05581     top_gclr += 
05582     shade_table[shade_index + 3*m + 1] * 
05583         weight_table[weight_index + m];
05584         
05585     top_bclr += 
05586     shade_table[shade_index + 3*m + 2] * 
05587         weight_table[weight_index + m];
05588         ;
05589         ;
05590         ;
05591         };
05592     shade_factor = top_opc * slice_depth_cueing;
05593     
05594         top_rclr *= shade_factor;
05595         top_gclr *= shade_factor;
05596         top_bclr *= shade_factor;
05597     ;
05598                 
05599     
05600             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05601             opacity = param0_table[opac_param];
05602             if (param1_size != 0) {
05603                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
05604                 opacity *= param1_table[opac_param];
05605                 if (param2_size != 0) {
05606                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
05607                     opacity *= param2_table[opac_param];
05608                 }
05609             }
05610             if (opacity > min_opacity) {
05611                 opacity_int = opacity*255.;
05612                 bot_opc = opac_correct[opacity_int];
05613             } else {
05614                 bot_opc = (float)0.;
05615             };
05616     
05617     
05618     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
05619     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
05620     
05621         
05622         
05623     bot_rclr = 
05624     shade_table[shade_index + 3*0 + 0] * 
05625         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05626         
05627     bot_gclr = 
05628     shade_table[shade_index + 3*0 + 1] * 
05629         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05630         
05631     bot_bclr = 
05632     shade_table[shade_index + 3*0 + 2] * 
05633         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05634         ;
05635         ;
05636         ;
05637         for (m = 1; m < num_materials; m++) {
05638              
05639         
05640     bot_rclr += 
05641     shade_table[shade_index + 3*m + 0] * 
05642         weight_table[weight_index + m];
05643         
05644     bot_gclr += 
05645     shade_table[shade_index + 3*m + 1] * 
05646         weight_table[weight_index + m];
05647         
05648     bot_bclr += 
05649     shade_table[shade_index + 3*m + 2] * 
05650         weight_table[weight_index + m];
05651         ;
05652         ;
05653         ;
05654         };
05655     shade_factor = bot_opc * slice_depth_cueing;
05656     
05657         bot_rclr *= shade_factor;
05658         bot_gclr *= shade_factor;
05659         bot_bclr *= shade_factor;
05660     ;
05661                 
05662        acc_opc += top_opc * wgtTR;
05663        
05664             acc_rclr += top_rclr * wgtTR;
05665             acc_gclr += top_gclr * wgtTR;
05666             acc_bclr += top_bclr * wgtTR;
05667        
05668 #ifdef DEBUG
05669     if (ipixel == trace_pixel_ptr) {
05670         trace_opcTR = top_opc;
05671         trace_rclrTR = top_rclr;
05672                      trace_gclrTR = top_gclr;
05673                      trace_bclrTR = top_bclr;
05674         
05675     }
05676 #endif
05677 ;
05678                 
05679        acc_opc += bot_opc * wgtBR;
05680        
05681             acc_rclr += bot_rclr * wgtBR;
05682             acc_gclr += bot_gclr * wgtBR;
05683             acc_bclr += bot_bclr * wgtBR;
05684        
05685 #ifdef DEBUG
05686     if (ipixel == trace_pixel_ptr) {
05687         trace_opcBR = bot_opc;
05688         trace_rclrBR = bot_rclr;
05689                      trace_gclrBR = bot_gclr;
05690                      trace_bclrBR = bot_bclr;
05691         
05692     }
05693 #endif
05694 ;
05695                 
05696         COUNT_RESAMPLE;
05697         if (acc_opc > min_opacity) {
05698             COUNT_COMPOSITE;
05699             iopc = ipixel->opcflt;
05700 #           ifndef SKIP_ERT
05701                 ASSERT(iopc < max_opacity);
05702 #           endif
05703             iopc_inv = (float)1. - iopc;
05704             
05705         ipixel->rclrflt += acc_rclr * iopc_inv;
05706         ipixel->gclrflt += acc_gclr * iopc_inv;
05707         ipixel->bclrflt += acc_bclr * iopc_inv;
05708             iopc += acc_opc * iopc_inv;
05709             ipixel->opcflt = iopc;
05710             
05711 #ifdef DEBUG
05712     if (ipixel == trace_pixel_ptr) {
05713 #ifdef COMPUTE_SHADOW_BUFFER
05714         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05715 #else
05716         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05717 #endif
05718         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05719         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05720         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05721         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05722         printf("  %3.0f %3.0f\n", iopc*255., 
05723                ipixel->rclrflt);
05724         
05725         
05726         printf("              ");
05727         printf("      %3.0f    ",trace_gclrTL);
05728         printf("      %3.0f    ",trace_gclrBL);
05729         printf("      %3.0f    ",trace_gclrTR);
05730         printf("      %3.0f    ",trace_gclrBR);
05731         printf("      %3.0f\n", ipixel->gclrflt);
05732         printf("              ");
05733         printf("      %3.0f    ",trace_bclrTL);
05734         printf("      %3.0f    ",trace_bclrBL);
05735         printf("      %3.0f    ",trace_bclrTR);
05736         printf("      %3.0f    ",trace_bclrBR);
05737         printf("      %3.0f\n", ipixel->bclrflt);
05738     }
05739 #endif /* DEBUG */
05740 ;
05741 #           ifndef SKIP_ERT
05742                 if (iopc >= max_opacity) {
05743                     ASSERT(ipixel->lnk == 0);
05744                     ipixel->lnk = 1;
05745                 }
05746 #           endif
05747         };
05748                 ipixel += 1;
05749                 topRLEdata += 1 * voxel_istride;
05750                 botRLEdata += 1 * voxel_istride;
05751                 count--;
05752                 SET_VOXELS_LOADED;
05753                     
05754                 /* do the rest of the pixels in this run;
05755                    all four voxels contribute */
05756                 while (count > 0) {
05757                     if (PIXEL_IS_OPAQUE(ipixel))
05758                         break;
05759                     if (!voxels_loaded) {
05760                         
05761     
05762             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
05763             opacity = param0_table[opac_param];
05764             if (param1_size != 0) {
05765                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
05766                 opacity *= param1_table[opac_param];
05767                 if (param2_size != 0) {
05768                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
05769                     opacity *= param2_table[opac_param];
05770                 }
05771             }
05772             if (opacity > min_opacity) {
05773                 opacity_int = opacity*255.;
05774                 top_opc = opac_correct[opacity_int];
05775             } else {
05776                 top_opc = (float)0.;
05777             };
05778     
05779     
05780     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05781     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05782     
05783         
05784         
05785     top_rclr = 
05786     shade_table[shade_index + 3*0 + 0] * 
05787         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05788         
05789     top_gclr = 
05790     shade_table[shade_index + 3*0 + 1] * 
05791         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05792         
05793     top_bclr = 
05794     shade_table[shade_index + 3*0 + 2] * 
05795         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05796         ;
05797         ;
05798         ;
05799         for (m = 1; m < num_materials; m++) {
05800              
05801         
05802     top_rclr += 
05803     shade_table[shade_index + 3*m + 0] * 
05804         weight_table[weight_index + m];
05805         
05806     top_gclr += 
05807     shade_table[shade_index + 3*m + 1] * 
05808         weight_table[weight_index + m];
05809         
05810     top_bclr += 
05811     shade_table[shade_index + 3*m + 2] * 
05812         weight_table[weight_index + m];
05813         ;
05814         ;
05815         ;
05816         };
05817     shade_factor = top_opc * slice_depth_cueing;
05818     
05819         top_rclr *= shade_factor;
05820         top_gclr *= shade_factor;
05821         top_bclr *= shade_factor;
05822     ;
05823                         
05824     
05825             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
05826             opacity = param0_table[opac_param];
05827             if (param1_size != 0) {
05828                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
05829                 opacity *= param1_table[opac_param];
05830                 if (param2_size != 0) {
05831                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
05832                     opacity *= param2_table[opac_param];
05833                 }
05834             }
05835             if (opacity > min_opacity) {
05836                 opacity_int = opacity*255.;
05837                 bot_opc = opac_correct[opacity_int];
05838             } else {
05839                 bot_opc = (float)0.;
05840             };
05841     
05842     
05843     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
05844     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
05845     
05846         
05847         
05848     bot_rclr = 
05849     shade_table[shade_index + 3*0 + 0] * 
05850         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05851         
05852     bot_gclr = 
05853     shade_table[shade_index + 3*0 + 1] * 
05854         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05855         
05856     bot_bclr = 
05857     shade_table[shade_index + 3*0 + 2] * 
05858         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05859         ;
05860         ;
05861         ;
05862         for (m = 1; m < num_materials; m++) {
05863              
05864         
05865     bot_rclr += 
05866     shade_table[shade_index + 3*m + 0] * 
05867         weight_table[weight_index + m];
05868         
05869     bot_gclr += 
05870     shade_table[shade_index + 3*m + 1] * 
05871         weight_table[weight_index + m];
05872         
05873     bot_bclr += 
05874     shade_table[shade_index + 3*m + 2] * 
05875         weight_table[weight_index + m];
05876         ;
05877         ;
05878         ;
05879         };
05880     shade_factor = bot_opc * slice_depth_cueing;
05881     
05882         bot_rclr *= shade_factor;
05883         bot_gclr *= shade_factor;
05884         bot_bclr *= shade_factor;
05885     ;
05886                     }
05887                     
05888 #ifdef DEBUG
05889     if (ipixel == trace_pixel_ptr) {
05890         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05891         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05892         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05893         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05894         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05895     }
05896 #endif
05897 ;
05898                     
05899        acc_opc = top_opc * wgtTL;
05900        
05901             acc_rclr = top_rclr * wgtTL;
05902             acc_gclr = top_gclr * wgtTL;
05903             acc_bclr = top_bclr * wgtTL;
05904        
05905 #ifdef DEBUG
05906     if (ipixel == trace_pixel_ptr) {
05907         trace_opcTL = top_opc;
05908         trace_rclrTL = top_rclr;
05909                      trace_gclrTL = top_gclr;
05910                      trace_bclrTL = top_bclr;
05911         
05912     }
05913 #endif
05914 ;
05915                     
05916        acc_opc += bot_opc * wgtBL;
05917        
05918             acc_rclr += bot_rclr * wgtBL;
05919             acc_gclr += bot_gclr * wgtBL;
05920             acc_bclr += bot_bclr * wgtBL;
05921        
05922 #ifdef DEBUG
05923     if (ipixel == trace_pixel_ptr) {
05924         trace_opcBL = bot_opc;
05925         trace_rclrBL = bot_rclr;
05926                      trace_gclrBL = bot_gclr;
05927                      trace_bclrBL = bot_bclr;
05928         
05929     }
05930 #endif
05931 ;
05932                     
05933     
05934             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
05935             opacity = param0_table[opac_param];
05936             if (param1_size != 0) {
05937                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
05938                 opacity *= param1_table[opac_param];
05939                 if (param2_size != 0) {
05940                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
05941                     opacity *= param2_table[opac_param];
05942                 }
05943             }
05944             if (opacity > min_opacity) {
05945                 opacity_int = opacity*255.;
05946                 top_opc = opac_correct[opacity_int];
05947             } else {
05948                 top_opc = (float)0.;
05949             };
05950     
05951     
05952     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
05953     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05954     
05955         
05956         
05957     top_rclr = 
05958     shade_table[shade_index + 3*0 + 0] * 
05959         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05960         
05961     top_gclr = 
05962     shade_table[shade_index + 3*0 + 1] * 
05963         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05964         
05965     top_bclr = 
05966     shade_table[shade_index + 3*0 + 2] * 
05967         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05968         ;
05969         ;
05970         ;
05971         for (m = 1; m < num_materials; m++) {
05972              
05973         
05974     top_rclr += 
05975     shade_table[shade_index + 3*m + 0] * 
05976         weight_table[weight_index + m];
05977         
05978     top_gclr += 
05979     shade_table[shade_index + 3*m + 1] * 
05980         weight_table[weight_index + m];
05981         
05982     top_bclr += 
05983     shade_table[shade_index + 3*m + 2] * 
05984         weight_table[weight_index + m];
05985         ;
05986         ;
05987         ;
05988         };
05989     shade_factor = top_opc * slice_depth_cueing;
05990     
05991         top_rclr *= shade_factor;
05992         top_gclr *= shade_factor;
05993         top_bclr *= shade_factor;
05994     ;
05995                     
05996     
05997             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
05998             opacity = param0_table[opac_param];
05999             if (param1_size != 0) {
06000                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
06001                 opacity *= param1_table[opac_param];
06002                 if (param2_size != 0) {
06003                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
06004                     opacity *= param2_table[opac_param];
06005                 }
06006             }
06007             if (opacity > min_opacity) {
06008                 opacity_int = opacity*255.;
06009                 bot_opc = opac_correct[opacity_int];
06010             } else {
06011                 bot_opc = (float)0.;
06012             };
06013     
06014     
06015     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
06016     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
06017     
06018         
06019         
06020     bot_rclr = 
06021     shade_table[shade_index + 3*0 + 0] * 
06022         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06023         
06024     bot_gclr = 
06025     shade_table[shade_index + 3*0 + 1] * 
06026         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06027         
06028     bot_bclr = 
06029     shade_table[shade_index + 3*0 + 2] * 
06030         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06031         ;
06032         ;
06033         ;
06034         for (m = 1; m < num_materials; m++) {
06035              
06036         
06037     bot_rclr += 
06038     shade_table[shade_index + 3*m + 0] * 
06039         weight_table[weight_index + m];
06040         
06041     bot_gclr += 
06042     shade_table[shade_index + 3*m + 1] * 
06043         weight_table[weight_index + m];
06044         
06045     bot_bclr += 
06046     shade_table[shade_index + 3*m + 2] * 
06047         weight_table[weight_index + m];
06048         ;
06049         ;
06050         ;
06051         };
06052     shade_factor = bot_opc * slice_depth_cueing;
06053     
06054         bot_rclr *= shade_factor;
06055         bot_gclr *= shade_factor;
06056         bot_bclr *= shade_factor;
06057     ;
06058                     
06059        acc_opc += top_opc * wgtTR;
06060        
06061             acc_rclr += top_rclr * wgtTR;
06062             acc_gclr += top_gclr * wgtTR;
06063             acc_bclr += top_bclr * wgtTR;
06064        
06065 #ifdef DEBUG
06066     if (ipixel == trace_pixel_ptr) {
06067         trace_opcTR = top_opc;
06068         trace_rclrTR = top_rclr;
06069                      trace_gclrTR = top_gclr;
06070                      trace_bclrTR = top_bclr;
06071         
06072     }
06073 #endif
06074 ;
06075                     
06076        acc_opc += bot_opc * wgtBR;
06077        
06078             acc_rclr += bot_rclr * wgtBR;
06079             acc_gclr += bot_gclr * wgtBR;
06080             acc_bclr += bot_bclr * wgtBR;
06081        
06082 #ifdef DEBUG
06083     if (ipixel == trace_pixel_ptr) {
06084         trace_opcBR = bot_opc;
06085         trace_rclrBR = bot_rclr;
06086                      trace_gclrBR = bot_gclr;
06087                      trace_bclrBR = bot_bclr;
06088         
06089     }
06090 #endif
06091 ;
06092                     
06093         COUNT_RESAMPLE;
06094         if (acc_opc > min_opacity) {
06095             COUNT_COMPOSITE;
06096             iopc = ipixel->opcflt;
06097 #           ifndef SKIP_ERT
06098                 ASSERT(iopc < max_opacity);
06099 #           endif
06100             iopc_inv = (float)1. - iopc;
06101             
06102         ipixel->rclrflt += acc_rclr * iopc_inv;
06103         ipixel->gclrflt += acc_gclr * iopc_inv;
06104         ipixel->bclrflt += acc_bclr * iopc_inv;
06105             iopc += acc_opc * iopc_inv;
06106             ipixel->opcflt = iopc;
06107             
06108 #ifdef DEBUG
06109     if (ipixel == trace_pixel_ptr) {
06110 #ifdef COMPUTE_SHADOW_BUFFER
06111         printf("{%3d}  %3d %3d", k, icount-i-count, j);
06112 #else
06113         printf("[%3d]  %3d %3d", k, icount-i-count, j);
06114 #endif
06115         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06116         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06117         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06118         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06119         printf("  %3.0f %3.0f\n", iopc*255., 
06120                ipixel->rclrflt);
06121         
06122         
06123         printf("              ");
06124         printf("      %3.0f    ",trace_gclrTL);
06125         printf("      %3.0f    ",trace_gclrBL);
06126         printf("      %3.0f    ",trace_gclrTR);
06127         printf("      %3.0f    ",trace_gclrBR);
06128         printf("      %3.0f\n", ipixel->gclrflt);
06129         printf("              ");
06130         printf("      %3.0f    ",trace_bclrTL);
06131         printf("      %3.0f    ",trace_bclrBL);
06132         printf("      %3.0f    ",trace_bclrTR);
06133         printf("      %3.0f    ",trace_bclrBR);
06134         printf("      %3.0f\n", ipixel->bclrflt);
06135     }
06136 #endif /* DEBUG */
06137 ;
06138 #           ifndef SKIP_ERT
06139                 if (iopc >= max_opacity) {
06140                     ASSERT(ipixel->lnk == 0);
06141                     ipixel->lnk = 1;
06142                 }
06143 #           endif
06144         };
06145                     ipixel += 1;
06146                     topRLEdata += 1 * voxel_istride;
06147                     botRLEdata += 1 * voxel_istride;
06148                     count--;
06149                     SET_VOXELS_LOADED;
06150                 }
06151                 break;
06152             case BOT_NONZERO__ALL_NONZERO:
06153                 /* first pixel: bottom-left, top-right and bottom-right
06154                    voxels contribute */
06155                 if (!voxels_loaded) {
06156                     
06157     
06158             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
06159             opacity = param0_table[opac_param];
06160             if (param1_size != 0) {
06161                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
06162                 opacity *= param1_table[opac_param];
06163                 if (param2_size != 0) {
06164                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
06165                     opacity *= param2_table[opac_param];
06166                 }
06167             }
06168             if (opacity > min_opacity) {
06169                 opacity_int = opacity*255.;
06170                 bot_opc = opac_correct[opacity_int];
06171             } else {
06172                 bot_opc = (float)0.;
06173             };
06174     
06175     
06176     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06177     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
06178     
06179         
06180         
06181     bot_rclr = 
06182     shade_table[shade_index + 3*0 + 0] * 
06183         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06184         
06185     bot_gclr = 
06186     shade_table[shade_index + 3*0 + 1] * 
06187         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06188         
06189     bot_bclr = 
06190     shade_table[shade_index + 3*0 + 2] * 
06191         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06192         ;
06193         ;
06194         ;
06195         for (m = 1; m < num_materials; m++) {
06196              
06197         
06198     bot_rclr += 
06199     shade_table[shade_index + 3*m + 0] * 
06200         weight_table[weight_index + m];
06201         
06202     bot_gclr += 
06203     shade_table[shade_index + 3*m + 1] * 
06204         weight_table[weight_index + m];
06205         
06206     bot_bclr += 
06207     shade_table[shade_index + 3*m + 2] * 
06208         weight_table[weight_index + m];
06209         ;
06210         ;
06211         ;
06212         };
06213     shade_factor = bot_opc * slice_depth_cueing;
06214     
06215         bot_rclr *= shade_factor;
06216         bot_gclr *= shade_factor;
06217         bot_bclr *= shade_factor;
06218     ;
06219                 }
06220                 
06221 #ifdef DEBUG
06222     if (ipixel == trace_pixel_ptr) {
06223         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06224         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06225         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06226         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06227         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06228     }
06229 #endif
06230 ;
06231                 
06232        acc_opc = bot_opc * wgtBL;
06233        
06234             acc_rclr = bot_rclr * wgtBL;
06235             acc_gclr = bot_gclr * wgtBL;
06236             acc_bclr = bot_bclr * wgtBL;
06237        
06238 #ifdef DEBUG
06239     if (ipixel == trace_pixel_ptr) {
06240         trace_opcBL = bot_opc;
06241         trace_rclrBL = bot_rclr;
06242                      trace_gclrBL = bot_gclr;
06243                      trace_bclrBL = bot_bclr;
06244         
06245     }
06246 #endif
06247 ;
06248                 
06249     
06250             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
06251             opacity = param0_table[opac_param];
06252             if (param1_size != 0) {
06253                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
06254                 opacity *= param1_table[opac_param];
06255                 if (param2_size != 0) {
06256                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
06257                     opacity *= param2_table[opac_param];
06258                 }
06259             }
06260             if (opacity > min_opacity) {
06261                 opacity_int = opacity*255.;
06262                 top_opc = opac_correct[opacity_int];
06263             } else {
06264                 top_opc = (float)0.;
06265             };
06266     
06267     
06268     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
06269     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
06270     
06271         
06272         
06273     top_rclr = 
06274     shade_table[shade_index + 3*0 + 0] * 
06275         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06276         
06277     top_gclr = 
06278     shade_table[shade_index + 3*0 + 1] * 
06279         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06280         
06281     top_bclr = 
06282     shade_table[shade_index + 3*0 + 2] * 
06283         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06284         ;
06285         ;
06286         ;
06287         for (m = 1; m < num_materials; m++) {
06288              
06289         
06290     top_rclr += 
06291     shade_table[shade_index + 3*m + 0] * 
06292         weight_table[weight_index + m];
06293         
06294     top_gclr += 
06295     shade_table[shade_index + 3*m + 1] * 
06296         weight_table[weight_index + m];
06297         
06298     top_bclr += 
06299     shade_table[shade_index + 3*m + 2] * 
06300         weight_table[weight_index + m];
06301         ;
06302         ;
06303         ;
06304         };
06305     shade_factor = top_opc * slice_depth_cueing;
06306     
06307         top_rclr *= shade_factor;
06308         top_gclr *= shade_factor;
06309         top_bclr *= shade_factor;
06310     ;
06311                 
06312     
06313             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
06314             opacity = param0_table[opac_param];
06315             if (param1_size != 0) {
06316                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
06317                 opacity *= param1_table[opac_param];
06318                 if (param2_size != 0) {
06319                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
06320                     opacity *= param2_table[opac_param];
06321                 }
06322             }
06323             if (opacity > min_opacity) {
06324                 opacity_int = opacity*255.;
06325                 bot_opc = opac_correct[opacity_int];
06326             } else {
06327                 bot_opc = (float)0.;
06328             };
06329     
06330     
06331     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
06332     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
06333     
06334         
06335         
06336     bot_rclr = 
06337     shade_table[shade_index + 3*0 + 0] * 
06338         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06339         
06340     bot_gclr = 
06341     shade_table[shade_index + 3*0 + 1] * 
06342         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06343         
06344     bot_bclr = 
06345     shade_table[shade_index + 3*0 + 2] * 
06346         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06347         ;
06348         ;
06349         ;
06350         for (m = 1; m < num_materials; m++) {
06351              
06352         
06353     bot_rclr += 
06354     shade_table[shade_index + 3*m + 0] * 
06355         weight_table[weight_index + m];
06356         
06357     bot_gclr += 
06358     shade_table[shade_index + 3*m + 1] * 
06359         weight_table[weight_index + m];
06360         
06361     bot_bclr += 
06362     shade_table[shade_index + 3*m + 2] * 
06363         weight_table[weight_index + m];
06364         ;
06365         ;
06366         ;
06367         };
06368     shade_factor = bot_opc * slice_depth_cueing;
06369     
06370         bot_rclr *= shade_factor;
06371         bot_gclr *= shade_factor;
06372         bot_bclr *= shade_factor;
06373     ;
06374                 
06375        acc_opc += top_opc * wgtTR;
06376        
06377             acc_rclr += top_rclr * wgtTR;
06378             acc_gclr += top_gclr * wgtTR;
06379             acc_bclr += top_bclr * wgtTR;
06380        
06381 #ifdef DEBUG
06382     if (ipixel == trace_pixel_ptr) {
06383         trace_opcTR = top_opc;
06384         trace_rclrTR = top_rclr;
06385                      trace_gclrTR = top_gclr;
06386                      trace_bclrTR = top_bclr;
06387         
06388     }
06389 #endif
06390 ;
06391                 
06392        acc_opc += bot_opc * wgtBR;
06393        
06394             acc_rclr += bot_rclr * wgtBR;
06395             acc_gclr += bot_gclr * wgtBR;
06396             acc_bclr += bot_bclr * wgtBR;
06397        
06398 #ifdef DEBUG
06399     if (ipixel == trace_pixel_ptr) {
06400         trace_opcBR = bot_opc;
06401         trace_rclrBR = bot_rclr;
06402                      trace_gclrBR = bot_gclr;
06403                      trace_bclrBR = bot_bclr;
06404         
06405     }
06406 #endif
06407 ;
06408                 
06409         COUNT_RESAMPLE;
06410         if (acc_opc > min_opacity) {
06411             COUNT_COMPOSITE;
06412             iopc = ipixel->opcflt;
06413 #           ifndef SKIP_ERT
06414                 ASSERT(iopc < max_opacity);
06415 #           endif
06416             iopc_inv = (float)1. - iopc;
06417             
06418         ipixel->rclrflt += acc_rclr * iopc_inv;
06419         ipixel->gclrflt += acc_gclr * iopc_inv;
06420         ipixel->bclrflt += acc_bclr * iopc_inv;
06421             iopc += acc_opc * iopc_inv;
06422             ipixel->opcflt = iopc;
06423             
06424 #ifdef DEBUG
06425     if (ipixel == trace_pixel_ptr) {
06426 #ifdef COMPUTE_SHADOW_BUFFER
06427         printf("{%3d}  %3d %3d", k, icount-i-count, j);
06428 #else
06429         printf("[%3d]  %3d %3d", k, icount-i-count, j);
06430 #endif
06431         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06432         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06433         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06434         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06435         printf("  %3.0f %3.0f\n", iopc*255., 
06436                ipixel->rclrflt);
06437         
06438         
06439         printf("              ");
06440         printf("      %3.0f    ",trace_gclrTL);
06441         printf("      %3.0f    ",trace_gclrBL);
06442         printf("      %3.0f    ",trace_gclrTR);
06443         printf("      %3.0f    ",trace_gclrBR);
06444         printf("      %3.0f\n", ipixel->gclrflt);
06445         printf("              ");
06446         printf("      %3.0f    ",trace_bclrTL);
06447         printf("      %3.0f    ",trace_bclrBL);
06448         printf("      %3.0f    ",trace_bclrTR);
06449         printf("      %3.0f    ",trace_bclrBR);
06450         printf("      %3.0f\n", ipixel->bclrflt);
06451     }
06452 #endif /* DEBUG */
06453 ;
06454 #           ifndef SKIP_ERT
06455                 if (iopc >= max_opacity) {
06456                     ASSERT(ipixel->lnk == 0);
06457                     ipixel->lnk = 1;
06458                 }
06459 #           endif
06460         };
06461                 ipixel += 1;
06462                 topRLEdata += 1 * voxel_istride;
06463                 botRLEdata += 1 * voxel_istride;
06464                 count--;
06465                 SET_VOXELS_LOADED;
06466                     
06467                 /* do the rest of the pixels in this run;
06468                    all four voxels contribute */
06469                 while (count > 0) {
06470                     if (PIXEL_IS_OPAQUE(ipixel))
06471                         break;
06472                     if (!voxels_loaded) {
06473                         
06474     
06475             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
06476             opacity = param0_table[opac_param];
06477             if (param1_size != 0) {
06478                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
06479                 opacity *= param1_table[opac_param];
06480                 if (param2_size != 0) {
06481                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
06482                     opacity *= param2_table[opac_param];
06483                 }
06484             }
06485             if (opacity > min_opacity) {
06486                 opacity_int = opacity*255.;
06487                 top_opc = opac_correct[opacity_int];
06488             } else {
06489                 top_opc = (float)0.;
06490             };
06491     
06492     
06493     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
06494     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
06495     
06496         
06497         
06498     top_rclr = 
06499     shade_table[shade_index + 3*0 + 0] * 
06500         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06501         
06502     top_gclr = 
06503     shade_table[shade_index + 3*0 + 1] * 
06504         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06505         
06506     top_bclr = 
06507     shade_table[shade_index + 3*0 + 2] * 
06508         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06509         ;
06510         ;
06511         ;
06512         for (m = 1; m < num_materials; m++) {
06513              
06514         
06515     top_rclr += 
06516     shade_table[shade_index + 3*m + 0] * 
06517         weight_table[weight_index + m];
06518         
06519     top_gclr += 
06520     shade_table[shade_index + 3*m + 1] * 
06521         weight_table[weight_index + m];
06522         
06523     top_bclr += 
06524     shade_table[shade_index + 3*m + 2] * 
06525         weight_table[weight_index + m];
06526         ;
06527         ;
06528         ;
06529         };
06530     shade_factor = top_opc * slice_depth_cueing;
06531     
06532         top_rclr *= shade_factor;
06533         top_gclr *= shade_factor;
06534         top_bclr *= shade_factor;
06535     ;
06536                         
06537     
06538             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
06539             opacity = param0_table[opac_param];
06540             if (param1_size != 0) {
06541                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
06542                 opacity *= param1_table[opac_param];
06543                 if (param2_size != 0) {
06544                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
06545                     opacity *= param2_table[opac_param];
06546                 }
06547             }
06548             if (opacity > min_opacity) {
06549                 opacity_int = opacity*255.;
06550                 bot_opc = opac_correct[opacity_int];
06551             } else {
06552                 bot_opc = (float)0.;
06553             };
06554     
06555     
06556     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06557     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
06558     
06559         
06560         
06561     bot_rclr = 
06562     shade_table[shade_index + 3*0 + 0] * 
06563         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06564         
06565     bot_gclr = 
06566     shade_table[shade_index + 3*0 + 1] * 
06567         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06568         
06569     bot_bclr = 
06570     shade_table[shade_index + 3*0 + 2] * 
06571         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06572         ;
06573         ;
06574         ;
06575         for (m = 1; m < num_materials; m++) {
06576              
06577         
06578     bot_rclr += 
06579     shade_table[shade_index + 3*m + 0] * 
06580         weight_table[weight_index + m];
06581         
06582     bot_gclr += 
06583     shade_table[shade_index + 3*m + 1] * 
06584         weight_table[weight_index + m];
06585         
06586     bot_bclr += 
06587     shade_table[shade_index + 3*m + 2] * 
06588         weight_table[weight_index + m];
06589         ;
06590         ;
06591         ;
06592         };
06593     shade_factor = bot_opc * slice_depth_cueing;
06594     
06595         bot_rclr *= shade_factor;
06596         bot_gclr *= shade_factor;
06597         bot_bclr *= shade_factor;
06598     ;
06599                     }
06600                     
06601 #ifdef DEBUG
06602     if (ipixel == trace_pixel_ptr) {
06603         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06604         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06605         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06606         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06607         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06608     }
06609 #endif
06610 ;
06611                     
06612        acc_opc = top_opc * wgtTL;
06613        
06614             acc_rclr = top_rclr * wgtTL;
06615             acc_gclr = top_gclr * wgtTL;
06616             acc_bclr = top_bclr * wgtTL;
06617        
06618 #ifdef DEBUG
06619     if (ipixel == trace_pixel_ptr) {
06620         trace_opcTL = top_opc;
06621         trace_rclrTL = top_rclr;
06622                      trace_gclrTL = top_gclr;
06623                      trace_bclrTL = top_bclr;
06624         
06625     }
06626 #endif
06627 ;
06628                     
06629        acc_opc += bot_opc * wgtBL;
06630        
06631             acc_rclr += bot_rclr * wgtBL;
06632             acc_gclr += bot_gclr * wgtBL;
06633             acc_bclr += bot_bclr * wgtBL;
06634        
06635 #ifdef DEBUG
06636     if (ipixel == trace_pixel_ptr) {
06637         trace_opcBL = bot_opc;
06638         trace_rclrBL = bot_rclr;
06639                      trace_gclrBL = bot_gclr;
06640                      trace_bclrBL = bot_bclr;
06641         
06642     }
06643 #endif
06644 ;
06645                     
06646     
06647             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
06648             opacity = param0_table[opac_param];
06649             if (param1_size != 0) {
06650                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
06651                 opacity *= param1_table[opac_param];
06652                 if (param2_size != 0) {
06653                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
06654                     opacity *= param2_table[opac_param];
06655                 }
06656             }
06657             if (opacity > min_opacity) {
06658                 opacity_int = opacity*255.;
06659                 top_opc = opac_correct[opacity_int];
06660             } else {
06661                 top_opc = (float)0.;
06662             };
06663     
06664     
06665     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
06666     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
06667     
06668         
06669         
06670     top_rclr = 
06671     shade_table[shade_index + 3*0 + 0] * 
06672         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06673         
06674     top_gclr = 
06675     shade_table[shade_index + 3*0 + 1] * 
06676         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06677         
06678     top_bclr = 
06679     shade_table[shade_index + 3*0 + 2] * 
06680         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06681         ;
06682         ;
06683         ;
06684         for (m = 1; m < num_materials; m++) {
06685              
06686         
06687     top_rclr += 
06688     shade_table[shade_index + 3*m + 0] * 
06689         weight_table[weight_index + m];
06690         
06691     top_gclr += 
06692     shade_table[shade_index + 3*m + 1] * 
06693         weight_table[weight_index + m];
06694         
06695     top_bclr += 
06696     shade_table[shade_index + 3*m + 2] * 
06697         weight_table[weight_index + m];
06698         ;
06699         ;
06700         ;
06701         };
06702     shade_factor = top_opc * slice_depth_cueing;
06703     
06704         top_rclr *= shade_factor;
06705         top_gclr *= shade_factor;
06706         top_bclr *= shade_factor;
06707     ;
06708                     
06709     
06710             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
06711             opacity = param0_table[opac_param];
06712             if (param1_size != 0) {
06713                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
06714                 opacity *= param1_table[opac_param];
06715                 if (param2_size != 0) {
06716                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
06717                     opacity *= param2_table[opac_param];
06718                 }
06719             }
06720             if (opacity > min_opacity) {
06721                 opacity_int = opacity*255.;
06722                 bot_opc = opac_correct[opacity_int];
06723             } else {
06724                 bot_opc = (float)0.;
06725             };
06726     
06727     
06728     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
06729     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
06730     
06731         
06732         
06733     bot_rclr = 
06734     shade_table[shade_index + 3*0 + 0] * 
06735         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06736         
06737     bot_gclr = 
06738     shade_table[shade_index + 3*0 + 1] * 
06739         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06740         
06741     bot_bclr = 
06742     shade_table[shade_index + 3*0 + 2] * 
06743         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06744         ;
06745         ;
06746         ;
06747         for (m = 1; m < num_materials; m++) {
06748              
06749         
06750     bot_rclr += 
06751     shade_table[shade_index + 3*m + 0] * 
06752         weight_table[weight_index + m];
06753         
06754     bot_gclr += 
06755     shade_table[shade_index + 3*m + 1] * 
06756         weight_table[weight_index + m];
06757         
06758     bot_bclr += 
06759     shade_table[shade_index + 3*m + 2] * 
06760         weight_table[weight_index + m];
06761         ;
06762         ;
06763         ;
06764         };
06765     shade_factor = bot_opc * slice_depth_cueing;
06766     
06767         bot_rclr *= shade_factor;
06768         bot_gclr *= shade_factor;
06769         bot_bclr *= shade_factor;
06770     ;
06771                     
06772        acc_opc += top_opc * wgtTR;
06773        
06774             acc_rclr += top_rclr * wgtTR;
06775             acc_gclr += top_gclr * wgtTR;
06776             acc_bclr += top_bclr * wgtTR;
06777        
06778 #ifdef DEBUG
06779     if (ipixel == trace_pixel_ptr) {
06780         trace_opcTR = top_opc;
06781         trace_rclrTR = top_rclr;
06782                      trace_gclrTR = top_gclr;
06783                      trace_bclrTR = top_bclr;
06784         
06785     }
06786 #endif
06787 ;
06788                     
06789        acc_opc += bot_opc * wgtBR;
06790        
06791             acc_rclr += bot_rclr * wgtBR;
06792             acc_gclr += bot_gclr * wgtBR;
06793             acc_bclr += bot_bclr * wgtBR;
06794        
06795 #ifdef DEBUG
06796     if (ipixel == trace_pixel_ptr) {
06797         trace_opcBR = bot_opc;
06798         trace_rclrBR = bot_rclr;
06799                      trace_gclrBR = bot_gclr;
06800                      trace_bclrBR = bot_bclr;
06801         
06802     }
06803 #endif
06804 ;
06805                     
06806         COUNT_RESAMPLE;
06807         if (acc_opc > min_opacity) {
06808             COUNT_COMPOSITE;
06809             iopc = ipixel->opcflt;
06810 #           ifndef SKIP_ERT
06811                 ASSERT(iopc < max_opacity);
06812 #           endif
06813             iopc_inv = (float)1. - iopc;
06814             
06815         ipixel->rclrflt += acc_rclr * iopc_inv;
06816         ipixel->gclrflt += acc_gclr * iopc_inv;
06817         ipixel->bclrflt += acc_bclr * iopc_inv;
06818             iopc += acc_opc * iopc_inv;
06819             ipixel->opcflt = iopc;
06820             
06821 #ifdef DEBUG
06822     if (ipixel == trace_pixel_ptr) {
06823 #ifdef COMPUTE_SHADOW_BUFFER
06824         printf("{%3d}  %3d %3d", k, icount-i-count, j);
06825 #else
06826         printf("[%3d]  %3d %3d", k, icount-i-count, j);
06827 #endif
06828         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06829         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06830         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06831         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06832         printf("  %3.0f %3.0f\n", iopc*255., 
06833                ipixel->rclrflt);
06834         
06835         
06836         printf("              ");
06837         printf("      %3.0f    ",trace_gclrTL);
06838         printf("      %3.0f    ",trace_gclrBL);
06839         printf("      %3.0f    ",trace_gclrTR);
06840         printf("      %3.0f    ",trace_gclrBR);
06841         printf("      %3.0f\n", ipixel->gclrflt);
06842         printf("              ");
06843         printf("      %3.0f    ",trace_bclrTL);
06844         printf("      %3.0f    ",trace_bclrBL);
06845         printf("      %3.0f    ",trace_bclrTR);
06846         printf("      %3.0f    ",trace_bclrBR);
06847         printf("      %3.0f\n", ipixel->bclrflt);
06848     }
06849 #endif /* DEBUG */
06850 ;
06851 #           ifndef SKIP_ERT
06852                 if (iopc >= max_opacity) {
06853                     ASSERT(ipixel->lnk == 0);
06854                     ipixel->lnk = 1;
06855                 }
06856 #           endif
06857         };
06858                     ipixel += 1;
06859                     topRLEdata += 1 * voxel_istride;
06860                     botRLEdata += 1 * voxel_istride;
06861                     count--;
06862                     SET_VOXELS_LOADED;
06863                 }
06864                 break;
06865             case ALL_NONZERO__ALL_NONZERO:
06866                 /* do the pixels in this run; all four voxels contribute */
06867                 while (count > 0) {
06868                     if (PIXEL_IS_OPAQUE(ipixel))
06869                         break;
06870                     if (!voxels_loaded) {
06871                         
06872     
06873             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
06874             opacity = param0_table[opac_param];
06875             if (param1_size != 0) {
06876                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
06877                 opacity *= param1_table[opac_param];
06878                 if (param2_size != 0) {
06879                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
06880                     opacity *= param2_table[opac_param];
06881                 }
06882             }
06883             if (opacity > min_opacity) {
06884                 opacity_int = opacity*255.;
06885                 top_opc = opac_correct[opacity_int];
06886             } else {
06887                 top_opc = (float)0.;
06888             };
06889     
06890     
06891     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
06892     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
06893     
06894         
06895         
06896     top_rclr = 
06897     shade_table[shade_index + 3*0 + 0] * 
06898         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06899         
06900     top_gclr = 
06901     shade_table[shade_index + 3*0 + 1] * 
06902         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06903         
06904     top_bclr = 
06905     shade_table[shade_index + 3*0 + 2] * 
06906         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06907         ;
06908         ;
06909         ;
06910         for (m = 1; m < num_materials; m++) {
06911              
06912         
06913     top_rclr += 
06914     shade_table[shade_index + 3*m + 0] * 
06915         weight_table[weight_index + m];
06916         
06917     top_gclr += 
06918     shade_table[shade_index + 3*m + 1] * 
06919         weight_table[weight_index + m];
06920         
06921     top_bclr += 
06922     shade_table[shade_index + 3*m + 2] * 
06923         weight_table[weight_index + m];
06924         ;
06925         ;
06926         ;
06927         };
06928     shade_factor = top_opc * slice_depth_cueing;
06929     
06930         top_rclr *= shade_factor;
06931         top_gclr *= shade_factor;
06932         top_bclr *= shade_factor;
06933     ;
06934                         
06935     
06936             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
06937             opacity = param0_table[opac_param];
06938             if (param1_size != 0) {
06939                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
06940                 opacity *= param1_table[opac_param];
06941                 if (param2_size != 0) {
06942                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
06943                     opacity *= param2_table[opac_param];
06944                 }
06945             }
06946             if (opacity > min_opacity) {
06947                 opacity_int = opacity*255.;
06948                 bot_opc = opac_correct[opacity_int];
06949             } else {
06950                 bot_opc = (float)0.;
06951             };
06952     
06953     
06954     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06955     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
06956     
06957         
06958         
06959     bot_rclr = 
06960     shade_table[shade_index + 3*0 + 0] * 
06961         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06962         
06963     bot_gclr = 
06964     shade_table[shade_index + 3*0 + 1] * 
06965         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06966         
06967     bot_bclr = 
06968     shade_table[shade_index + 3*0 + 2] * 
06969         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06970         ;
06971         ;
06972         ;
06973         for (m = 1; m < num_materials; m++) {
06974              
06975         
06976     bot_rclr += 
06977     shade_table[shade_index + 3*m + 0] * 
06978         weight_table[weight_index + m];
06979         
06980     bot_gclr += 
06981     shade_table[shade_index + 3*m + 1] * 
06982         weight_table[weight_index + m];
06983         
06984     bot_bclr += 
06985     shade_table[shade_index + 3*m + 2] * 
06986         weight_table[weight_index + m];
06987         ;
06988         ;
06989         ;
06990         };
06991     shade_factor = bot_opc * slice_depth_cueing;
06992     
06993         bot_rclr *= shade_factor;
06994         bot_gclr *= shade_factor;
06995         bot_bclr *= shade_factor;
06996     ;
06997                     }
06998                     
06999 #ifdef DEBUG
07000     if (ipixel == trace_pixel_ptr) {
07001         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07002         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07003         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07004         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07005         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07006     }
07007 #endif
07008 ;
07009                     
07010        acc_opc = top_opc * wgtTL;
07011        
07012             acc_rclr = top_rclr * wgtTL;
07013             acc_gclr = top_gclr * wgtTL;
07014             acc_bclr = top_bclr * wgtTL;
07015        
07016 #ifdef DEBUG
07017     if (ipixel == trace_pixel_ptr) {
07018         trace_opcTL = top_opc;
07019         trace_rclrTL = top_rclr;
07020                      trace_gclrTL = top_gclr;
07021                      trace_bclrTL = top_bclr;
07022         
07023     }
07024 #endif
07025 ;
07026                     
07027        acc_opc += bot_opc * wgtBL;
07028        
07029             acc_rclr += bot_rclr * wgtBL;
07030             acc_gclr += bot_gclr * wgtBL;
07031             acc_bclr += bot_bclr * wgtBL;
07032        
07033 #ifdef DEBUG
07034     if (ipixel == trace_pixel_ptr) {
07035         trace_opcBL = bot_opc;
07036         trace_rclrBL = bot_rclr;
07037                      trace_gclrBL = bot_gclr;
07038                      trace_bclrBL = bot_bclr;
07039         
07040     }
07041 #endif
07042 ;
07043                     
07044     
07045             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
07046             opacity = param0_table[opac_param];
07047             if (param1_size != 0) {
07048                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
07049                 opacity *= param1_table[opac_param];
07050                 if (param2_size != 0) {
07051                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
07052                     opacity *= param2_table[opac_param];
07053                 }
07054             }
07055             if (opacity > min_opacity) {
07056                 opacity_int = opacity*255.;
07057                 top_opc = opac_correct[opacity_int];
07058             } else {
07059                 top_opc = (float)0.;
07060             };
07061     
07062     
07063     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
07064     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
07065     
07066         
07067         
07068     top_rclr = 
07069     shade_table[shade_index + 3*0 + 0] * 
07070         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07071         
07072     top_gclr = 
07073     shade_table[shade_index + 3*0 + 1] * 
07074         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07075         
07076     top_bclr = 
07077     shade_table[shade_index + 3*0 + 2] * 
07078         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07079         ;
07080         ;
07081         ;
07082         for (m = 1; m < num_materials; m++) {
07083              
07084         
07085     top_rclr += 
07086     shade_table[shade_index + 3*m + 0] * 
07087         weight_table[weight_index + m];
07088         
07089     top_gclr += 
07090     shade_table[shade_index + 3*m + 1] * 
07091         weight_table[weight_index + m];
07092         
07093     top_bclr += 
07094     shade_table[shade_index + 3*m + 2] * 
07095         weight_table[weight_index + m];
07096         ;
07097         ;
07098         ;
07099         };
07100     shade_factor = top_opc * slice_depth_cueing;
07101     
07102         top_rclr *= shade_factor;
07103         top_gclr *= shade_factor;
07104         top_bclr *= shade_factor;
07105     ;
07106                     
07107     
07108             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
07109             opacity = param0_table[opac_param];
07110             if (param1_size != 0) {
07111                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
07112                 opacity *= param1_table[opac_param];
07113                 if (param2_size != 0) {
07114                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
07115                     opacity *= param2_table[opac_param];
07116                 }
07117             }
07118             if (opacity > min_opacity) {
07119                 opacity_int = opacity*255.;
07120                 bot_opc = opac_correct[opacity_int];
07121             } else {
07122                 bot_opc = (float)0.;
07123             };
07124     
07125     
07126     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
07127     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
07128     
07129         
07130         
07131     bot_rclr = 
07132     shade_table[shade_index + 3*0 + 0] * 
07133         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07134         
07135     bot_gclr = 
07136     shade_table[shade_index + 3*0 + 1] * 
07137         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07138         
07139     bot_bclr = 
07140     shade_table[shade_index + 3*0 + 2] * 
07141         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07142         ;
07143         ;
07144         ;
07145         for (m = 1; m < num_materials; m++) {
07146              
07147         
07148     bot_rclr += 
07149     shade_table[shade_index + 3*m + 0] * 
07150         weight_table[weight_index + m];
07151         
07152     bot_gclr += 
07153     shade_table[shade_index + 3*m + 1] * 
07154         weight_table[weight_index + m];
07155         
07156     bot_bclr += 
07157     shade_table[shade_index + 3*m + 2] * 
07158         weight_table[weight_index + m];
07159         ;
07160         ;
07161         ;
07162         };
07163     shade_factor = bot_opc * slice_depth_cueing;
07164     
07165         bot_rclr *= shade_factor;
07166         bot_gclr *= shade_factor;
07167         bot_bclr *= shade_factor;
07168     ;
07169                     
07170        acc_opc += top_opc * wgtTR;
07171        
07172             acc_rclr += top_rclr * wgtTR;
07173             acc_gclr += top_gclr * wgtTR;
07174             acc_bclr += top_bclr * wgtTR;
07175        
07176 #ifdef DEBUG
07177     if (ipixel == trace_pixel_ptr) {
07178         trace_opcTR = top_opc;
07179         trace_rclrTR = top_rclr;
07180                      trace_gclrTR = top_gclr;
07181                      trace_bclrTR = top_bclr;
07182         
07183     }
07184 #endif
07185 ;
07186                     
07187        acc_opc += bot_opc * wgtBR;
07188        
07189             acc_rclr += bot_rclr * wgtBR;
07190             acc_gclr += bot_gclr * wgtBR;
07191             acc_bclr += bot_bclr * wgtBR;
07192        
07193 #ifdef DEBUG
07194     if (ipixel == trace_pixel_ptr) {
07195         trace_opcBR = bot_opc;
07196         trace_rclrBR = bot_rclr;
07197                      trace_gclrBR = bot_gclr;
07198                      trace_bclrBR = bot_bclr;
07199         
07200     }
07201 #endif
07202 ;
07203                     
07204         COUNT_RESAMPLE;
07205         if (acc_opc > min_opacity) {
07206             COUNT_COMPOSITE;
07207             iopc = ipixel->opcflt;
07208 #           ifndef SKIP_ERT
07209                 ASSERT(iopc < max_opacity);
07210 #           endif
07211             iopc_inv = (float)1. - iopc;
07212             
07213         ipixel->rclrflt += acc_rclr * iopc_inv;
07214         ipixel->gclrflt += acc_gclr * iopc_inv;
07215         ipixel->bclrflt += acc_bclr * iopc_inv;
07216             iopc += acc_opc * iopc_inv;
07217             ipixel->opcflt = iopc;
07218             
07219 #ifdef DEBUG
07220     if (ipixel == trace_pixel_ptr) {
07221 #ifdef COMPUTE_SHADOW_BUFFER
07222         printf("{%3d}  %3d %3d", k, icount-i-count, j);
07223 #else
07224         printf("[%3d]  %3d %3d", k, icount-i-count, j);
07225 #endif
07226         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
07227         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
07228         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
07229         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
07230         printf("  %3.0f %3.0f\n", iopc*255., 
07231                ipixel->rclrflt);
07232         
07233         
07234         printf("              ");
07235         printf("      %3.0f    ",trace_gclrTL);
07236         printf("      %3.0f    ",trace_gclrBL);
07237         printf("      %3.0f    ",trace_gclrTR);
07238         printf("      %3.0f    ",trace_gclrBR);
07239         printf("      %3.0f\n", ipixel->gclrflt);
07240         printf("              ");
07241         printf("      %3.0f    ",trace_bclrTL);
07242         printf("      %3.0f    ",trace_bclrBL);
07243         printf("      %3.0f    ",trace_bclrTR);
07244         printf("      %3.0f    ",trace_bclrBR);
07245         printf("      %3.0f\n", ipixel->bclrflt);
07246     }
07247 #endif /* DEBUG */
07248 ;
07249 #           ifndef SKIP_ERT
07250                 if (iopc >= max_opacity) {
07251                     ASSERT(ipixel->lnk == 0);
07252                     ipixel->lnk = 1;
07253                 }
07254 #           endif
07255         };
07256                     ipixel += 1;
07257                     topRLEdata += 1 * voxel_istride;
07258                     botRLEdata += 1 * voxel_istride;
07259                     count--;
07260                     SET_VOXELS_LOADED;
07261                 }
07262                 break;
07263             default:
07264                 VPBug("illegal value for run states in compositing loop");
07265             }
07266 #else /* UNROLL_RUN_LOOP */
07267             /* this run contains pixels, so process them */
07268             while (count > 0) {
07269                 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
07270                     ipixel += count;
07271                     if (i != -1) {
07272                         topRLEdata += count * voxel_istride;
07273                         botRLEdata += count * voxel_istride;
07274                     }
07275                     count = 0;
07276                     break;
07277                 }
07278                 if (ipixel->lnk != 0)
07279                     break;
07280                 
07281 #ifdef DEBUG
07282     if (ipixel == trace_pixel_ptr) {
07283         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07284         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07285         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07286         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07287         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07288     }
07289 #endif
07290 ;
07291                 
07292        acc_opc = 0;
07293        acc_rclr = acc_gclr = acc_bclr = 0;
07294                 if (last_run_state & TOP_NONZERO) {
07295                     if (!voxels_loaded) {
07296                         
07297     
07298             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
07299             opacity = param0_table[opac_param];
07300             if (param1_size != 0) {
07301                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
07302                 opacity *= param1_table[opac_param];
07303                 if (param2_size != 0) {
07304                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
07305                     opacity *= param2_table[opac_param];
07306                 }
07307             }
07308             if (opacity > min_opacity) {
07309                 opacity_int = opacity*255.;
07310                 top_opc = opac_correct[opacity_int];
07311             } else {
07312                 top_opc = (float)0.;
07313             };
07314     
07315     
07316     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
07317     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
07318     
07319         
07320         
07321     top_rclr = 
07322     shade_table[shade_index + 3*0 + 0] * 
07323         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07324         
07325     top_gclr = 
07326     shade_table[shade_index + 3*0 + 1] * 
07327         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07328         
07329     top_bclr = 
07330     shade_table[shade_index + 3*0 + 2] * 
07331         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07332         ;
07333         ;
07334         ;
07335         for (m = 1; m < num_materials; m++) {
07336              
07337         
07338     top_rclr += 
07339     shade_table[shade_index + 3*m + 0] * 
07340         weight_table[weight_index + m];
07341         
07342     top_gclr += 
07343     shade_table[shade_index + 3*m + 1] * 
07344         weight_table[weight_index + m];
07345         
07346     top_bclr += 
07347     shade_table[shade_index + 3*m + 2] * 
07348         weight_table[weight_index + m];
07349         ;
07350         ;
07351         ;
07352         };
07353     shade_factor = top_opc * slice_depth_cueing;
07354     
07355         top_rclr *= shade_factor;
07356         top_gclr *= shade_factor;
07357         top_bclr *= shade_factor;
07358     ;
07359                     }
07360                     
07361        acc_opc += top_opc * wgtTL;
07362        
07363             acc_rclr += top_rclr * wgtTL;
07364             acc_gclr += top_gclr * wgtTL;
07365             acc_bclr += top_bclr * wgtTL;
07366        
07367 #ifdef DEBUG
07368     if (ipixel == trace_pixel_ptr) {
07369         trace_opcTL = top_opc;
07370         trace_rclrTL = top_rclr;
07371                      trace_gclrTL = top_gclr;
07372                      trace_bclrTL = top_bclr;
07373         
07374     }
07375 #endif
07376 ;
07377                 }
07378                 if (last_run_state & BOT_NONZERO) {
07379                     if (!voxels_loaded) {
07380                         
07381     
07382             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
07383             opacity = param0_table[opac_param];
07384             if (param1_size != 0) {
07385                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
07386                 opacity *= param1_table[opac_param];
07387                 if (param2_size != 0) {
07388                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
07389                     opacity *= param2_table[opac_param];
07390                 }
07391             }
07392             if (opacity > min_opacity) {
07393                 opacity_int = opacity*255.;
07394                 bot_opc = opac_correct[opacity_int];
07395             } else {
07396                 bot_opc = (float)0.;
07397             };
07398     
07399     
07400     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
07401     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
07402     
07403         
07404         
07405     bot_rclr = 
07406     shade_table[shade_index + 3*0 + 0] * 
07407         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07408         
07409     bot_gclr = 
07410     shade_table[shade_index + 3*0 + 1] * 
07411         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07412         
07413     bot_bclr = 
07414     shade_table[shade_index + 3*0 + 2] * 
07415         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07416         ;
07417         ;
07418         ;
07419         for (m = 1; m < num_materials; m++) {
07420              
07421         
07422     bot_rclr += 
07423     shade_table[shade_index + 3*m + 0] * 
07424         weight_table[weight_index + m];
07425         
07426     bot_gclr += 
07427     shade_table[shade_index + 3*m + 1] * 
07428         weight_table[weight_index + m];
07429         
07430     bot_bclr += 
07431     shade_table[shade_index + 3*m + 2] * 
07432         weight_table[weight_index + m];
07433         ;
07434         ;
07435         ;
07436         };
07437     shade_factor = bot_opc * slice_depth_cueing;
07438     
07439         bot_rclr *= shade_factor;
07440         bot_gclr *= shade_factor;
07441         bot_bclr *= shade_factor;
07442     ;
07443                     }
07444                     
07445        acc_opc += bot_opc * wgtBL;
07446        
07447             acc_rclr += bot_rclr * wgtBL;
07448             acc_gclr += bot_gclr * wgtBL;
07449             acc_bclr += bot_bclr * wgtBL;
07450        
07451 #ifdef DEBUG
07452     if (ipixel == trace_pixel_ptr) {
07453         trace_opcBL = bot_opc;
07454         trace_rclrBL = bot_rclr;
07455                      trace_gclrBL = bot_gclr;
07456                      trace_bclrBL = bot_bclr;
07457         
07458     }
07459 #endif
07460 ;
07461                 }
07462                 if (run_state & TOP_NONZERO) {
07463                     
07464     
07465             opac_param = VoxelField(topRLEdata, param0_offset, param0_size);
07466             opacity = param0_table[opac_param];
07467             if (param1_size != 0) {
07468                 opac_param = VoxelField(topRLEdata, param1_offset, param1_size);
07469                 opacity *= param1_table[opac_param];
07470                 if (param2_size != 0) {
07471                     opac_param = VoxelField(topRLEdata, param2_offset, param2_size);
07472                     opacity *= param2_table[opac_param];
07473                 }
07474             }
07475             if (opacity > min_opacity) {
07476                 opacity_int = opacity*255.;
07477                 top_opc = opac_correct[opacity_int];
07478             } else {
07479                 top_opc = (float)0.;
07480             };
07481     
07482     
07483     shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
07484     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
07485     
07486         
07487         
07488     top_rclr = 
07489     shade_table[shade_index + 3*0 + 0] * 
07490         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07491         
07492     top_gclr = 
07493     shade_table[shade_index + 3*0 + 1] * 
07494         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07495         
07496     top_bclr = 
07497     shade_table[shade_index + 3*0 + 2] * 
07498         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07499         ;
07500         ;
07501         ;
07502         for (m = 1; m < num_materials; m++) {
07503              
07504         
07505     top_rclr += 
07506     shade_table[shade_index + 3*m + 0] * 
07507         weight_table[weight_index + m];
07508         
07509     top_gclr += 
07510     shade_table[shade_index + 3*m + 1] * 
07511         weight_table[weight_index + m];
07512         
07513     top_bclr += 
07514     shade_table[shade_index + 3*m + 2] * 
07515         weight_table[weight_index + m];
07516         ;
07517         ;
07518         ;
07519         };
07520     shade_factor = top_opc * slice_depth_cueing;
07521     
07522         top_rclr *= shade_factor;
07523         top_gclr *= shade_factor;
07524         top_bclr *= shade_factor;
07525     ;
07526                     
07527        acc_opc += top_opc * wgtTR;
07528        
07529             acc_rclr += top_rclr * wgtTR;
07530             acc_gclr += top_gclr * wgtTR;
07531             acc_bclr += top_bclr * wgtTR;
07532        
07533 #ifdef DEBUG
07534     if (ipixel == trace_pixel_ptr) {
07535         trace_opcTR = top_opc;
07536         trace_rclrTR = top_rclr;
07537                      trace_gclrTR = top_gclr;
07538                      trace_bclrTR = top_bclr;
07539         
07540     }
07541 #endif
07542 ;
07543                     topRLEdata += 1 * voxel_istride;
07544                 } else {
07545                     if (i != -1) {
07546                         topRLEdata += 1 * voxel_istride;
07547                     }
07548                 }
07549                 if (run_state & BOT_NONZERO) {
07550                     
07551     
07552             opac_param = VoxelField(botRLEdata, param0_offset, param0_size);
07553             opacity = param0_table[opac_param];
07554             if (param1_size != 0) {
07555                 opac_param = VoxelField(botRLEdata, param1_offset, param1_size);
07556                 opacity *= param1_table[opac_param];
07557                 if (param2_size != 0) {
07558                     opac_param = VoxelField(botRLEdata, param2_offset, param2_size);
07559                     opacity *= param2_table[opac_param];
07560                 }
07561             }
07562             if (opacity > min_opacity) {
07563                 opacity_int = opacity*255.;
07564                 bot_opc = opac_correct[opacity_int];
07565             } else {
07566                 bot_opc = (float)0.;
07567             };
07568     
07569     
07570     shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
07571     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
07572     
07573         
07574         
07575     bot_rclr = 
07576     shade_table[shade_index + 3*0 + 0] * 
07577         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07578         
07579     bot_gclr = 
07580     shade_table[shade_index + 3*0 + 1] * 
07581         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07582         
07583     bot_bclr = 
07584     shade_table[shade_index + 3*0 + 2] * 
07585         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07586         ;
07587         ;
07588         ;
07589         for (m = 1; m < num_materials; m++) {
07590              
07591         
07592     bot_rclr += 
07593     shade_table[shade_index + 3*m + 0] * 
07594         weight_table[weight_index + m];
07595         
07596     bot_gclr += 
07597     shade_table[shade_index + 3*m + 1] * 
07598         weight_table[weight_index + m];
07599         
07600     bot_bclr += 
07601     shade_table[shade_index + 3*m + 2] * 
07602         weight_table[weight_index + m];
07603         ;
07604         ;
07605         ;
07606         };
07607     shade_factor = bot_opc * slice_depth_cueing;
07608     
07609         bot_rclr *= shade_factor;
07610         bot_gclr *= shade_factor;
07611         bot_bclr *= shade_factor;
07612     ;
07613                     
07614        acc_opc += bot_opc * wgtBR;
07615        
07616             acc_rclr += bot_rclr * wgtBR;
07617             acc_gclr += bot_gclr * wgtBR;
07618             acc_bclr += bot_bclr * wgtBR;
07619        
07620 #ifdef DEBUG
07621     if (ipixel == trace_pixel_ptr) {
07622         trace_opcBR = bot_opc;
07623         trace_rclrBR = bot_rclr;
07624                      trace_gclrBR = bot_gclr;
07625                      trace_bclrBR = bot_bclr;
07626         
07627     }
07628 #endif
07629 ;
07630                     botRLEdata += 1 * voxel_istride;
07631                 } else {
07632                     if (i != -1) {
07633                         botRLEdata += 1 * voxel_istride;
07634                     }
07635                 }
07636                 
07637         COUNT_RESAMPLE;
07638         if (acc_opc > min_opacity) {
07639             COUNT_COMPOSITE;
07640             iopc = ipixel->opcflt;
07641 #           ifndef SKIP_ERT
07642                 ASSERT(iopc < max_opacity);
07643 #           endif
07644             iopc_inv = (float)1. - iopc;
07645             
07646         ipixel->rclrflt += acc_rclr * iopc_inv;
07647         ipixel->gclrflt += acc_gclr * iopc_inv;
07648         ipixel->bclrflt += acc_bclr * iopc_inv;
07649             iopc += acc_opc * iopc_inv;
07650             ipixel->opcflt = iopc;
07651             
07652 #ifdef DEBUG
07653     if (ipixel == trace_pixel_ptr) {
07654 #ifdef COMPUTE_SHADOW_BUFFER
07655         printf("{%3d}  %3d %3d", k, icount-i-count, j);
07656 #else
07657         printf("[%3d]  %3d %3d", k, icount-i-count, j);
07658 #endif
07659         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
07660         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
07661         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
07662         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
07663         printf("  %3.0f %3.0f\n", iopc*255., 
07664                ipixel->rclrflt);
07665         
07666         
07667         printf("              ");
07668         printf("      %3.0f    ",trace_gclrTL);
07669         printf("      %3.0f    ",trace_gclrBL);
07670         printf("      %3.0f    ",trace_gclrTR);
07671         printf("      %3.0f    ",trace_gclrBR);
07672         printf("      %3.0f\n", ipixel->gclrflt);
07673         printf("              ");
07674         printf("      %3.0f    ",trace_bclrTL);
07675         printf("      %3.0f    ",trace_bclrBL);
07676         printf("      %3.0f    ",trace_bclrTR);
07677         printf("      %3.0f    ",trace_bclrBR);
07678         printf("      %3.0f\n", ipixel->bclrflt);
07679     }
07680 #endif /* DEBUG */
07681 ;
07682 #           ifndef SKIP_ERT
07683                 if (iopc >= max_opacity) {
07684                     ASSERT(ipixel->lnk == 0);
07685                     ipixel->lnk = 1;
07686                 }
07687 #           endif
07688         };
07689                 ipixel += 1;
07690                 count--;
07691                 SET_VOXELS_LOADED;
07692                 last_run_state = run_state;
07693             }
07694 #endif /* UNROLL_RUN_LOOP */
07695 
07696             GET_HIRES_TIME(vpc, t1);
07697             STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
07698             COPY_HIRES_TIME(t0, t1);
07699 
07700             if (count > 0) {
07701                 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
07702                 toprun_count += count;
07703                 botrun_count += count;
07704                 i += count;
07705             }
07706 #endif /* SKIP_COMPOSITE */
07707 
07708             /***********************************************************
07709              * Go on to next voxel run.
07710              ***********************************************************/
07711 
07712             last_run_state = run_state;
07713         } /* while (i > 0) */
07714 
07715         /***************************************************************
07716          * Finish processing voxel scanline and go on to next one.
07717          ***************************************************************/
07718 
07719 #ifdef UNROLL_RUN_LOOP
07720         ASSERT(i == 0);
07721 #else
07722         ASSERT(i == -1);
07723 #endif
07724 
07725 #ifndef SKIP_COMPOSITE
07726 #ifdef UNROLL_RUN_LOOP
07727         /* do the last pixel (to the right of the last voxel) */
07728         if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
07729             /* last voxels are nonzero and the pixel is not opaque yet
07730                so there is work to be done */
07731             Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
07732             switch (last_run_state) {
07733             case TOP_NONZERO:
07734                 /* only the top-left voxel contributes */
07735                 if (!voxels_loaded) {
07736                     
07737     
07738             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
07739             opacity = param0_table[opac_param];
07740             if (param1_size != 0) {
07741                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
07742                 opacity *= param1_table[opac_param];
07743                 if (param2_size != 0) {
07744                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
07745                     opacity *= param2_table[opac_param];
07746                 }
07747             }
07748             if (opacity > min_opacity) {
07749                 opacity_int = opacity*255.;
07750                 top_opc = opac_correct[opacity_int];
07751             } else {
07752                 top_opc = (float)0.;
07753             };
07754     
07755     
07756     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
07757     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
07758     
07759         
07760         
07761     top_rclr = 
07762     shade_table[shade_index + 3*0 + 0] * 
07763         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07764         
07765     top_gclr = 
07766     shade_table[shade_index + 3*0 + 1] * 
07767         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07768         
07769     top_bclr = 
07770     shade_table[shade_index + 3*0 + 2] * 
07771         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07772         ;
07773         ;
07774         ;
07775         for (m = 1; m < num_materials; m++) {
07776              
07777         
07778     top_rclr += 
07779     shade_table[shade_index + 3*m + 0] * 
07780         weight_table[weight_index + m];
07781         
07782     top_gclr += 
07783     shade_table[shade_index + 3*m + 1] * 
07784         weight_table[weight_index + m];
07785         
07786     top_bclr += 
07787     shade_table[shade_index + 3*m + 2] * 
07788         weight_table[weight_index + m];
07789         ;
07790         ;
07791         ;
07792         };
07793     shade_factor = top_opc * slice_depth_cueing;
07794     
07795         top_rclr *= shade_factor;
07796         top_gclr *= shade_factor;
07797         top_bclr *= shade_factor;
07798     ;
07799                 }
07800                 
07801 #ifdef DEBUG
07802     if (ipixel == trace_pixel_ptr) {
07803         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07804         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07805         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07806         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07807         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07808     }
07809 #endif
07810 ;
07811                 
07812        acc_opc = top_opc * wgtTL;
07813        
07814             acc_rclr = top_rclr * wgtTL;
07815             acc_gclr = top_gclr * wgtTL;
07816             acc_bclr = top_bclr * wgtTL;
07817        
07818 #ifdef DEBUG
07819     if (ipixel == trace_pixel_ptr) {
07820         trace_opcTL = top_opc;
07821         trace_rclrTL = top_rclr;
07822                      trace_gclrTL = top_gclr;
07823                      trace_bclrTL = top_bclr;
07824         
07825     }
07826 #endif
07827 ;
07828                 
07829         COUNT_RESAMPLE;
07830         if (acc_opc > min_opacity) {
07831             COUNT_COMPOSITE;
07832             iopc = ipixel->opcflt;
07833 #           ifndef SKIP_ERT
07834                 ASSERT(iopc < max_opacity);
07835 #           endif
07836             iopc_inv = (float)1. - iopc;
07837             
07838         ipixel->rclrflt += acc_rclr * iopc_inv;
07839         ipixel->gclrflt += acc_gclr * iopc_inv;
07840         ipixel->bclrflt += acc_bclr * iopc_inv;
07841             iopc += acc_opc * iopc_inv;
07842             ipixel->opcflt = iopc;
07843             
07844 #ifdef DEBUG
07845     if (ipixel == trace_pixel_ptr) {
07846 #ifdef COMPUTE_SHADOW_BUFFER
07847         printf("{%3d}  %3d %3d", k, icount-i-count, j);
07848 #else
07849         printf("[%3d]  %3d %3d", k, icount-i-count, j);
07850 #endif
07851         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
07852         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
07853         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
07854         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
07855         printf("  %3.0f %3.0f\n", iopc*255., 
07856                ipixel->rclrflt);
07857         
07858         
07859         printf("              ");
07860         printf("      %3.0f    ",trace_gclrTL);
07861         printf("      %3.0f    ",trace_gclrBL);
07862         printf("      %3.0f    ",trace_gclrTR);
07863         printf("      %3.0f    ",trace_gclrBR);
07864         printf("      %3.0f\n", ipixel->gclrflt);
07865         printf("              ");
07866         printf("      %3.0f    ",trace_bclrTL);
07867         printf("      %3.0f    ",trace_bclrBL);
07868         printf("      %3.0f    ",trace_bclrTR);
07869         printf("      %3.0f    ",trace_bclrBR);
07870         printf("      %3.0f\n", ipixel->bclrflt);
07871     }
07872 #endif /* DEBUG */
07873 ;
07874 #           ifndef SKIP_ERT
07875                 if (iopc >= max_opacity) {
07876                     ASSERT(ipixel->lnk == 0);
07877                     ipixel->lnk = 1;
07878                 }
07879 #           endif
07880         };
07881                 break;
07882             case BOT_NONZERO:
07883                 /* only the bottom left voxel contributes */
07884                 if (!voxels_loaded) {
07885                     
07886     
07887             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
07888             opacity = param0_table[opac_param];
07889             if (param1_size != 0) {
07890                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
07891                 opacity *= param1_table[opac_param];
07892                 if (param2_size != 0) {
07893                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
07894                     opacity *= param2_table[opac_param];
07895                 }
07896             }
07897             if (opacity > min_opacity) {
07898                 opacity_int = opacity*255.;
07899                 bot_opc = opac_correct[opacity_int];
07900             } else {
07901                 bot_opc = (float)0.;
07902             };
07903     
07904     
07905     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
07906     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
07907     
07908         
07909         
07910     bot_rclr = 
07911     shade_table[shade_index + 3*0 + 0] * 
07912         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07913         
07914     bot_gclr = 
07915     shade_table[shade_index + 3*0 + 1] * 
07916         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07917         
07918     bot_bclr = 
07919     shade_table[shade_index + 3*0 + 2] * 
07920         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07921         ;
07922         ;
07923         ;
07924         for (m = 1; m < num_materials; m++) {
07925              
07926         
07927     bot_rclr += 
07928     shade_table[shade_index + 3*m + 0] * 
07929         weight_table[weight_index + m];
07930         
07931     bot_gclr += 
07932     shade_table[shade_index + 3*m + 1] * 
07933         weight_table[weight_index + m];
07934         
07935     bot_bclr += 
07936     shade_table[shade_index + 3*m + 2] * 
07937         weight_table[weight_index + m];
07938         ;
07939         ;
07940         ;
07941         };
07942     shade_factor = bot_opc * slice_depth_cueing;
07943     
07944         bot_rclr *= shade_factor;
07945         bot_gclr *= shade_factor;
07946         bot_bclr *= shade_factor;
07947     ;
07948                 }
07949                 
07950 #ifdef DEBUG
07951     if (ipixel == trace_pixel_ptr) {
07952         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07953         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07954         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07955         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07956         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07957     }
07958 #endif
07959 ;
07960                 
07961        acc_opc = bot_opc * wgtBL;
07962        
07963             acc_rclr = bot_rclr * wgtBL;
07964             acc_gclr = bot_gclr * wgtBL;
07965             acc_bclr = bot_bclr * wgtBL;
07966        
07967 #ifdef DEBUG
07968     if (ipixel == trace_pixel_ptr) {
07969         trace_opcBL = bot_opc;
07970         trace_rclrBL = bot_rclr;
07971                      trace_gclrBL = bot_gclr;
07972                      trace_bclrBL = bot_bclr;
07973         
07974     }
07975 #endif
07976 ;
07977                 
07978         COUNT_RESAMPLE;
07979         if (acc_opc > min_opacity) {
07980             COUNT_COMPOSITE;
07981             iopc = ipixel->opcflt;
07982 #           ifndef SKIP_ERT
07983                 ASSERT(iopc < max_opacity);
07984 #           endif
07985             iopc_inv = (float)1. - iopc;
07986             
07987         ipixel->rclrflt += acc_rclr * iopc_inv;
07988         ipixel->gclrflt += acc_gclr * iopc_inv;
07989         ipixel->bclrflt += acc_bclr * iopc_inv;
07990             iopc += acc_opc * iopc_inv;
07991             ipixel->opcflt = iopc;
07992             
07993 #ifdef DEBUG
07994     if (ipixel == trace_pixel_ptr) {
07995 #ifdef COMPUTE_SHADOW_BUFFER
07996         printf("{%3d}  %3d %3d", k, icount-i-count, j);
07997 #else
07998         printf("[%3d]  %3d %3d", k, icount-i-count, j);
07999 #endif
08000         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
08001         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
08002         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
08003         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
08004         printf("  %3.0f %3.0f\n", iopc*255., 
08005                ipixel->rclrflt);
08006         
08007         
08008         printf("              ");
08009         printf("      %3.0f    ",trace_gclrTL);
08010         printf("      %3.0f    ",trace_gclrBL);
08011         printf("      %3.0f    ",trace_gclrTR);
08012         printf("      %3.0f    ",trace_gclrBR);
08013         printf("      %3.0f\n", ipixel->gclrflt);
08014         printf("              ");
08015         printf("      %3.0f    ",trace_bclrTL);
08016         printf("      %3.0f    ",trace_bclrBL);
08017         printf("      %3.0f    ",trace_bclrTR);
08018         printf("      %3.0f    ",trace_bclrBR);
08019         printf("      %3.0f\n", ipixel->bclrflt);
08020     }
08021 #endif /* DEBUG */
08022 ;
08023 #           ifndef SKIP_ERT
08024                 if (iopc >= max_opacity) {
08025                     ASSERT(ipixel->lnk == 0);
08026                     ipixel->lnk = 1;
08027                 }
08028 #           endif
08029         };
08030                 break;
08031             case ALL_NONZERO:
08032                 /* the top and bottom left voxels contribute */
08033                 if (!voxels_loaded) {
08034                     
08035     
08036             opac_param = VoxelField(topRLEdata - voxel_istride, param0_offset, param0_size);
08037             opacity = param0_table[opac_param];
08038             if (param1_size != 0) {
08039                 opac_param = VoxelField(topRLEdata - voxel_istride, param1_offset, param1_size);
08040                 opacity *= param1_table[opac_param];
08041                 if (param2_size != 0) {
08042                     opac_param = VoxelField(topRLEdata - voxel_istride, param2_offset, param2_size);
08043                     opacity *= param2_table[opac_param];
08044                 }
08045             }
08046             if (opacity > min_opacity) {
08047                 opacity_int = opacity*255.;
08048                 top_opc = opac_correct[opacity_int];
08049             } else {
08050                 top_opc = (float)0.;
08051             };
08052     
08053     
08054     shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
08055     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
08056     
08057         
08058         
08059     top_rclr = 
08060     shade_table[shade_index + 3*0 + 0] * 
08061         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08062         
08063     top_gclr = 
08064     shade_table[shade_index + 3*0 + 1] * 
08065         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08066         
08067     top_bclr = 
08068     shade_table[shade_index + 3*0 + 2] * 
08069         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08070         ;
08071         ;
08072         ;
08073         for (m = 1; m < num_materials; m++) {
08074              
08075         
08076     top_rclr += 
08077     shade_table[shade_index + 3*m + 0] * 
08078         weight_table[weight_index + m];
08079         
08080     top_gclr += 
08081     shade_table[shade_index + 3*m + 1] * 
08082         weight_table[weight_index + m];
08083         
08084     top_bclr += 
08085     shade_table[shade_index + 3*m + 2] * 
08086         weight_table[weight_index + m];
08087         ;
08088         ;
08089         ;
08090         };
08091     shade_factor = top_opc * slice_depth_cueing;
08092     
08093         top_rclr *= shade_factor;
08094         top_gclr *= shade_factor;
08095         top_bclr *= shade_factor;
08096     ;
08097                     
08098     
08099             opac_param = VoxelField(botRLEdata - voxel_istride, param0_offset, param0_size);
08100             opacity = param0_table[opac_param];
08101             if (param1_size != 0) {
08102                 opac_param = VoxelField(botRLEdata - voxel_istride, param1_offset, param1_size);
08103                 opacity *= param1_table[opac_param];
08104                 if (param2_size != 0) {
08105                     opac_param = VoxelField(botRLEdata - voxel_istride, param2_offset, param2_size);
08106                     opacity *= param2_table[opac_param];
08107                 }
08108             }
08109             if (opacity > min_opacity) {
08110                 opacity_int = opacity*255.;
08111                 bot_opc = opac_correct[opacity_int];
08112             } else {
08113                 bot_opc = (float)0.;
08114             };
08115     
08116     
08117     shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
08118     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
08119     
08120         
08121         
08122     bot_rclr = 
08123     shade_table[shade_index + 3*0 + 0] * 
08124         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08125         
08126     bot_gclr = 
08127     shade_table[shade_index + 3*0 + 1] * 
08128         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08129         
08130     bot_bclr = 
08131     shade_table[shade_index + 3*0 + 2] * 
08132         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08133         ;
08134         ;
08135         ;
08136         for (m = 1; m < num_materials; m++) {
08137              
08138         
08139     bot_rclr += 
08140     shade_table[shade_index + 3*m + 0] * 
08141         weight_table[weight_index + m];
08142         
08143     bot_gclr += 
08144     shade_table[shade_index + 3*m + 1] * 
08145         weight_table[weight_index + m];
08146         
08147     bot_bclr += 
08148     shade_table[shade_index + 3*m + 2] * 
08149         weight_table[weight_index + m];
08150         ;
08151         ;
08152         ;
08153         };
08154     shade_factor = bot_opc * slice_depth_cueing;
08155     
08156         bot_rclr *= shade_factor;
08157         bot_gclr *= shade_factor;
08158         bot_bclr *= shade_factor;
08159     ;
08160                 }
08161                 
08162 #ifdef DEBUG
08163     if (ipixel == trace_pixel_ptr) {
08164         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
08165         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
08166         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
08167         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
08168         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
08169     }
08170 #endif
08171 ;
08172                 
08173        acc_opc = top_opc * wgtTL;
08174        
08175             acc_rclr = top_rclr * wgtTL;
08176             acc_gclr = top_gclr * wgtTL;
08177             acc_bclr = top_bclr * wgtTL;
08178        
08179 #ifdef DEBUG
08180     if (ipixel == trace_pixel_ptr) {
08181         trace_opcTL = top_opc;
08182         trace_rclrTL = top_rclr;
08183                      trace_gclrTL = top_gclr;
08184                      trace_bclrTL = top_bclr;
08185         
08186     }
08187 #endif
08188 ;
08189                 
08190        acc_opc += bot_opc * wgtBL;
08191        
08192             acc_rclr += bot_rclr * wgtBL;
08193             acc_gclr += bot_gclr * wgtBL;
08194             acc_bclr += bot_bclr * wgtBL;
08195        
08196 #ifdef DEBUG
08197     if (ipixel == trace_pixel_ptr) {
08198         trace_opcBL = bot_opc;
08199         trace_rclrBL = bot_rclr;
08200                      trace_gclrBL = bot_gclr;
08201                      trace_bclrBL = bot_bclr;
08202         
08203     }
08204 #endif
08205 ;
08206                 
08207         COUNT_RESAMPLE;
08208         if (acc_opc > min_opacity) {
08209             COUNT_COMPOSITE;
08210             iopc = ipixel->opcflt;
08211 #           ifndef SKIP_ERT
08212                 ASSERT(iopc < max_opacity);
08213 #           endif
08214             iopc_inv = (float)1. - iopc;
08215             
08216         ipixel->rclrflt += acc_rclr * iopc_inv;
08217         ipixel->gclrflt += acc_gclr * iopc_inv;
08218         ipixel->bclrflt += acc_bclr * iopc_inv;
08219             iopc += acc_opc * iopc_inv;
08220             ipixel->opcflt = iopc;
08221             
08222 #ifdef DEBUG
08223     if (ipixel == trace_pixel_ptr) {
08224 #ifdef COMPUTE_SHADOW_BUFFER
08225         printf("{%3d}  %3d %3d", k, icount-i-count, j);
08226 #else
08227         printf("[%3d]  %3d %3d", k, icount-i-count, j);
08228 #endif
08229         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
08230         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
08231         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
08232         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
08233         printf("  %3.0f %3.0f\n", iopc*255., 
08234                ipixel->rclrflt);
08235         
08236         
08237         printf("              ");
08238         printf("      %3.0f    ",trace_gclrTL);
08239         printf("      %3.0f    ",trace_gclrBL);
08240         printf("      %3.0f    ",trace_gclrTR);
08241         printf("      %3.0f    ",trace_gclrBR);
08242         printf("      %3.0f\n", ipixel->gclrflt);
08243         printf("              ");
08244         printf("      %3.0f    ",trace_bclrTL);
08245         printf("      %3.0f    ",trace_bclrBL);
08246         printf("      %3.0f    ",trace_bclrTR);
08247         printf("      %3.0f    ",trace_bclrBR);
08248         printf("      %3.0f\n", ipixel->bclrflt);
08249     }
08250 #endif /* DEBUG */
08251 ;
08252 #           ifndef SKIP_ERT
08253                 if (iopc >= max_opacity) {
08254                     ASSERT(ipixel->lnk == 0);
08255                     ipixel->lnk = 1;
08256                 }
08257 #           endif
08258         };
08259                 break;
08260             default:
08261                 VPBug("illegal value for run state at end of scanline");
08262             }
08263         } else if (last_run_state == ALL_ZERO) {
08264             Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
08265         } else {
08266             Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
08267         }
08268 #endif /* UNROLL_RUN_LOOP */
08269 #endif /* SKIP_COMPOSITE */
08270 
08271 #ifndef UNROLL_RUN_LOOP
08272         run_state = final_run_state;
08273 #endif
08274         /* skip over any zero-length runs remaining in this scanline */
08275         if (j != 0 && ((run_state & 1) == 0)) {
08276             toprun_count = *topRLElen++;
08277             ASSERT(toprun_count == 0);
08278         }
08279         if (j != jcount && ((run_state & 2) == 0)) {
08280             botrun_count = *botRLElen++;
08281             ASSERT(botrun_count == 0);
08282         }
08283 
08284         /* go to next intermediate image scanline */
08285 #ifdef UNROLL_RUN_LOOP
08286         ipixel += intermediate_width - icount;
08287 #ifdef USE_SHADOW_BUFFER
08288         shadow_pixel += shadow_width - icount;
08289 #endif
08290 #else /* UNROLL_RUN_LOOP */
08291         ipixel += intermediate_width - (icount+1);
08292 #ifdef USE_SHADOW_BUFFER
08293         shadow_pixel += shadow_width - (icount+1);
08294 #endif
08295 #endif /* UNROLL_RUN_LOOP */
08296 
08297         Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
08298     } /* for j */
08299 
08300     /***************************************************************
08301      * Finish processing the voxel slice.
08302      ***************************************************************/
08303 
08304     GET_HIRES_TIME(vpc, t1);
08305     STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
08306 
08307     Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
08308 }
 

Powered by Plone

This site conforms to the following standards: