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_compAC1NS.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:21 $
00052  * $Revision: 1.1 $
00053  */
00054 
00055 #include "vp_global.h"
00056 
00057 
00058 
00059     
00060     
00061     
00062     
00063     
00064 
00065     
00066     
00067     
00068 #define USE_SHADOW_BUFFER
00069             
00070     
00071     
00072 
00073 
00074 #undef UNROLL_RUN_LOOP
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 #define MULTIPLE_MATERIALS
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 GRAYSCALE
00126     
00127     
00128     
00129     
00130 
00131 
00132 
00133 
00134 
00135 #define RLEVOLUME
00136         
00137         
00138         
00139         
00140         
00141         
00142         
00143 
00144 
00145 
00146 
00147 #undef INDEX_VOLUME
00148 
00149 
00150     
00151     
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 /* codes indicating the types of a pair of runs in adjacent scanlines */
00161 #define ALL_ZERO        0       /* both runs are runs of zeros */
00162 #define TOP_NONZERO     1       /* run for top scanline has nonzero data */
00163 #define BOT_NONZERO     2       /* run for bottom scanline has nonzero data */
00164 #define ALL_NONZERO     3       /* both runs have nonzero data */
00165 
00166 /* codes indicating the types for the current left and right voxel pairs */
00167 #define ALL_ZERO__ALL_ZERO              ((ALL_ZERO << 2) | ALL_ZERO)
00168 #define ALL_ZERO__TOP_NONZERO           ((ALL_ZERO << 2) | TOP_NONZERO)
00169 #define ALL_ZERO__BOT_NONZERO           ((ALL_ZERO << 2) | BOT_NONZERO)
00170 #define ALL_ZERO__ALL_NONZERO           ((ALL_ZERO << 2) | ALL_NONZERO)
00171 #define TOP_NONZERO__ALL_ZERO           ((TOP_NONZERO << 2) | ALL_ZERO)
00172 #define TOP_NONZERO__TOP_NONZERO        ((TOP_NONZERO << 2) | TOP_NONZERO)
00173 #define TOP_NONZERO__BOT_NONZERO        ((TOP_NONZERO << 2) | BOT_NONZERO)
00174 #define TOP_NONZERO__ALL_NONZERO        ((TOP_NONZERO << 2) | ALL_NONZERO)
00175 #define BOT_NONZERO__ALL_ZERO           ((BOT_NONZERO << 2) | ALL_ZERO)
00176 #define BOT_NONZERO__TOP_NONZERO        ((BOT_NONZERO << 2) | TOP_NONZERO)
00177 #define BOT_NONZERO__BOT_NONZERO        ((BOT_NONZERO << 2) | BOT_NONZERO)
00178 #define BOT_NONZERO__ALL_NONZERO        ((BOT_NONZERO << 2) | ALL_NONZERO)
00179 #define ALL_NONZERO__ALL_ZERO           ((ALL_NONZERO << 2) | ALL_ZERO)
00180 #define ALL_NONZERO__TOP_NONZERO        ((ALL_NONZERO << 2) | TOP_NONZERO)
00181 #define ALL_NONZERO__BOT_NONZERO        ((ALL_NONZERO << 2) | BOT_NONZERO)
00182 #define ALL_NONZERO__ALL_NONZERO        ((ALL_NONZERO << 2) | ALL_NONZERO)
00183 
00184 #ifdef SKIP_ERT
00185 #define PIXEL_IS_OPAQUE(ipixel) 0
00186 #else
00187 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00188 #endif
00189 
00190 #ifdef STATISTICS
00191 extern int vpResampleCount;
00192 extern int vpCompositeCount;
00193 extern int vpERTSkipCount;
00194 extern int vpERTSkipAgainCount;
00195 extern int vpERTUpdateCount;
00196 extern int vpSpecialZeroSkipCount;
00197 extern int vpRunFragmentCount;
00198 #define COUNT_RESAMPLE          vpResampleCount++
00199 #define COUNT_COMPOSITE         vpCompositeCount++
00200 #define COUNT_ERT_SKIP          vpERTSkipCount++
00201 #define COUNT_ERT_SKIP_AGAIN    vpERTSkipAgainCount++
00202 #define COUNT_ERT_UPDATE        vpERTUpdateCount++
00203 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00204 #define COUNT_RUN_FRAGMENT      vpRunFragmentCount++
00205 #else
00206 #define COUNT_RESAMPLE
00207 #define COUNT_COMPOSITE
00208 #define COUNT_ERT_SKIP
00209 #define COUNT_ERT_SKIP_AGAIN
00210 #define COUNT_ERT_UPDATE
00211 #define COUNT_SPECIAL_ZERO_SKIP
00212 #define COUNT_RUN_FRAGMENT
00213 #endif /* STATISTICS */
00214 
00215 /*
00216  * VPCompAC1NS
00217  *
00218  * Compositing routine for run-length encoded volume data slices.
00219  * Decode and resample one slice of volume data, and composite
00220  * it into the intermediate image.  The resampling filter is a bilirp.
00221  */
00222 
00223 void
00224 VPCompAC1NS (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00225           weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00226           run_lengths, voxel_data , shadow_buffer)
00227 vpContext *vpc;                 /* context */
00228 int icount;                     /* slice size */
00229 int jcount;
00230 int k;                          /* slice number */
00231 double slice_depth_cueing_dbl;  /* depth cueing factor for slice */
00232 GrayIntPixel *intimage;         /* intermediate image pixels */
00233 double weightTLdbl;             /* resampling weights */
00234 double weightBLdbl;
00235 double weightTRdbl;
00236 double weightBRdbl;
00237 
00238                 unsigned char *run_lengths;     /* run lengths for slice */
00239                 void *voxel_data;               /* voxel data for slice */
00240 GrayIntPixel *shadow_buffer;
00241 {
00242     int i, j;                   /* voxel index in rotated object space */
00243     GrayIntPixel *ipixel;       /* current intermediate image pixel */
00244     GrayIntPixel *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     GrayIntPixel *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(GrayIntPixel)) % vpc->intermediate_width,
00616                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00617                 sizeof(GrayIntPixel)) / 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; shadow_pixel += 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; shadow_pixel += count;
00656                     ;
00657                     ;
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; shadow_pixel += 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; shadow_pixel += 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                         ;
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                         ;
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                             ;
00804                         }
00805                         break;
00806                     } else {
00807                         count -= toprun_count;
00808                         if (run_state & 1) {
00809                             topRLEdata += toprun_count * voxel_istride;
00810                         } else {
00811                             ;
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                             ;
00830                         }
00831                         break;
00832                     } else {
00833                         count -= botrun_count;
00834                         if (run_state & 2) {
00835                             botRLEdata += botrun_count * voxel_istride;
00836                         } else {
00837                             ;
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; shadow_pixel += 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; shadow_pixel += 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; shadow_pixel += count;
00924                 ;
00925                 ;
00926                 count = 0;
00927                 break;
00928             case TOP_NONZERO:
00929                 ipixel += count; shadow_pixel += count;
00930                 topRLEdata += count * voxel_istride;
00931                 ;
00932                 count = 0;
00933                 break;
00934             case BOT_NONZERO:
00935                 ipixel += count; shadow_pixel += count;
00936                 ;
00937                 botRLEdata += count * voxel_istride;
00938                 count = 0;
00939                 break;
00940             case ALL_NONZERO:
00941                 ipixel += count; shadow_pixel += 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; shadow_pixel += count;
00954                 ;
00955                 ;
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     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
00964     
00965     
00966     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
00967     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
00968     
00969         
00970         
00971     top_clr = 
00972     shade_table[shade_index + 1*0 + 0] * 
00973         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00974         
00975         top_sclr = 
00976     shadow_table[shade_index + 1*0 + 0] * 
00977         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00978         for (m = 1; m < num_materials; m++) {
00979              
00980         
00981     top_clr += 
00982     shade_table[shade_index + 1*m + 0] * 
00983         weight_table[weight_index + m];
00984         
00985         top_sclr += 
00986     shadow_table[shade_index + 1*m + 0] * 
00987         weight_table[weight_index + m];
00988         };
00989     shade_factor = top_opc * slice_depth_cueing;
00990     
00991         top_clr *= shade_factor;
00992     
00993             top_sclr *= shade_factor;
00994                 }
00995                 
00996 #ifdef DEBUG
00997     if (ipixel == trace_pixel_ptr) {
00998         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
00999         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01000         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01001         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01002         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01003     }
01004 #endif
01005 ;
01006                 
01007        acc_opc = top_opc * wgtTL;
01008        acc_clr = (top_clr + top_sclr *
01009                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01010        
01011 #ifdef DEBUG
01012     if (ipixel == trace_pixel_ptr) {
01013         trace_opcTL = top_opc;
01014         trace_rclrTL = top_clr;
01015         trace_rsclrTL = top_sclr;
01016     }
01017 #endif
01018 ;
01019                 
01020         COUNT_RESAMPLE;
01021         if (acc_opc > min_opacity) {
01022             COUNT_COMPOSITE;
01023             iopc = ipixel->opcflt;
01024 #           ifndef SKIP_ERT
01025                 ASSERT(iopc < max_opacity);
01026 #           endif
01027             iopc_inv = (float)1. - iopc;
01028             ipixel->clrflt += acc_clr * iopc_inv;
01029             iopc += acc_opc * iopc_inv;
01030             ipixel->opcflt = iopc;
01031             
01032 #ifdef DEBUG
01033     if (ipixel == trace_pixel_ptr) {
01034 #ifdef COMPUTE_SHADOW_BUFFER
01035         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01036 #else
01037         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01038 #endif
01039         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01040         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01041         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01042         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01043         printf("  %3.0f %3.0f\n", iopc*255., 
01044                ipixel->clrflt);
01045         
01046         printf("              ");
01047         printf("      %3.0f    ",trace_rsclrTL);
01048         printf("      %3.0f    ",trace_rsclrBL);
01049         printf("      %3.0f    ",trace_rsclrTR);
01050         printf("      %3.0f    ",trace_rsclrBR);
01051         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01052         
01053     }
01054 #endif /* DEBUG */
01055 ;
01056 #           ifndef SKIP_ERT
01057                 if (iopc >= max_opacity) {
01058                     ASSERT(ipixel->lnk == 0);
01059                     ipixel->lnk = 1;
01060                 }
01061 #           endif
01062         };
01063                 ipixel += count; shadow_pixel += count;
01064                 ;
01065                 ;
01066                 count = 0;
01067                 break;
01068             case BOT_NONZERO__ALL_ZERO:
01069                 /* only the bottom left voxel contributes to the first
01070                    pixel of the run, and the rest are zero */
01071                 if (!voxels_loaded) {
01072                     
01073     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01074     
01075     
01076     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01077     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01078     
01079         
01080         
01081     bot_clr = 
01082     shade_table[shade_index + 1*0 + 0] * 
01083         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01084         
01085         bot_sclr = 
01086     shadow_table[shade_index + 1*0 + 0] * 
01087         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01088         for (m = 1; m < num_materials; m++) {
01089              
01090         
01091     bot_clr += 
01092     shade_table[shade_index + 1*m + 0] * 
01093         weight_table[weight_index + m];
01094         
01095         bot_sclr += 
01096     shadow_table[shade_index + 1*m + 0] * 
01097         weight_table[weight_index + m];
01098         };
01099     shade_factor = bot_opc * slice_depth_cueing;
01100     
01101         bot_clr *= shade_factor;
01102     
01103             bot_sclr *= shade_factor;
01104                 }
01105                 
01106 #ifdef DEBUG
01107     if (ipixel == trace_pixel_ptr) {
01108         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01109         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01110         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01111         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01112         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01113     }
01114 #endif
01115 ;
01116                 
01117        acc_opc = bot_opc * wgtBL;
01118        acc_clr = (bot_clr + bot_sclr *
01119                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01120        
01121 #ifdef DEBUG
01122     if (ipixel == trace_pixel_ptr) {
01123         trace_opcBL = bot_opc;
01124         trace_rclrBL = bot_clr;
01125         trace_rsclrBL = bot_sclr;
01126     }
01127 #endif
01128 ;
01129                 
01130         COUNT_RESAMPLE;
01131         if (acc_opc > min_opacity) {
01132             COUNT_COMPOSITE;
01133             iopc = ipixel->opcflt;
01134 #           ifndef SKIP_ERT
01135                 ASSERT(iopc < max_opacity);
01136 #           endif
01137             iopc_inv = (float)1. - iopc;
01138             ipixel->clrflt += acc_clr * iopc_inv;
01139             iopc += acc_opc * iopc_inv;
01140             ipixel->opcflt = iopc;
01141             
01142 #ifdef DEBUG
01143     if (ipixel == trace_pixel_ptr) {
01144 #ifdef COMPUTE_SHADOW_BUFFER
01145         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01146 #else
01147         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01148 #endif
01149         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01150         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01151         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01152         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01153         printf("  %3.0f %3.0f\n", iopc*255., 
01154                ipixel->clrflt);
01155         
01156         printf("              ");
01157         printf("      %3.0f    ",trace_rsclrTL);
01158         printf("      %3.0f    ",trace_rsclrBL);
01159         printf("      %3.0f    ",trace_rsclrTR);
01160         printf("      %3.0f    ",trace_rsclrBR);
01161         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01162         
01163     }
01164 #endif /* DEBUG */
01165 ;
01166 #           ifndef SKIP_ERT
01167                 if (iopc >= max_opacity) {
01168                     ASSERT(ipixel->lnk == 0);
01169                     ipixel->lnk = 1;
01170                 }
01171 #           endif
01172         };
01173                 ipixel += count; shadow_pixel += count;
01174                 ;
01175                 ;
01176                 count = 0;
01177                 break;
01178             case ALL_NONZERO__ALL_ZERO:
01179                 /* the top and bottom left voxels contribute to the
01180                    first pixel of the run, and the rest are zero */
01181                 if (!voxels_loaded) {
01182                     
01183     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01184     
01185     
01186     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01187     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01188     
01189         
01190         
01191     top_clr = 
01192     shade_table[shade_index + 1*0 + 0] * 
01193         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01194         
01195         top_sclr = 
01196     shadow_table[shade_index + 1*0 + 0] * 
01197         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01198         for (m = 1; m < num_materials; m++) {
01199              
01200         
01201     top_clr += 
01202     shade_table[shade_index + 1*m + 0] * 
01203         weight_table[weight_index + m];
01204         
01205         top_sclr += 
01206     shadow_table[shade_index + 1*m + 0] * 
01207         weight_table[weight_index + m];
01208         };
01209     shade_factor = top_opc * slice_depth_cueing;
01210     
01211         top_clr *= shade_factor;
01212     
01213             top_sclr *= shade_factor;
01214                     
01215     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01216     
01217     
01218     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01219     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01220     
01221         
01222         
01223     bot_clr = 
01224     shade_table[shade_index + 1*0 + 0] * 
01225         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01226         
01227         bot_sclr = 
01228     shadow_table[shade_index + 1*0 + 0] * 
01229         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01230         for (m = 1; m < num_materials; m++) {
01231              
01232         
01233     bot_clr += 
01234     shade_table[shade_index + 1*m + 0] * 
01235         weight_table[weight_index + m];
01236         
01237         bot_sclr += 
01238     shadow_table[shade_index + 1*m + 0] * 
01239         weight_table[weight_index + m];
01240         };
01241     shade_factor = bot_opc * slice_depth_cueing;
01242     
01243         bot_clr *= shade_factor;
01244     
01245             bot_sclr *= shade_factor;
01246                 }
01247                 
01248 #ifdef DEBUG
01249     if (ipixel == trace_pixel_ptr) {
01250         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01251         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01252         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01253         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01254         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01255     }
01256 #endif
01257 ;
01258                 
01259        acc_opc = top_opc * wgtTL;
01260        acc_clr = (top_clr + top_sclr *
01261                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01262        
01263 #ifdef DEBUG
01264     if (ipixel == trace_pixel_ptr) {
01265         trace_opcTL = top_opc;
01266         trace_rclrTL = top_clr;
01267         trace_rsclrTL = top_sclr;
01268     }
01269 #endif
01270 ;
01271                 
01272        acc_opc += bot_opc * wgtBL;
01273        acc_clr += (bot_clr + bot_sclr *
01274                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01275        
01276 #ifdef DEBUG
01277     if (ipixel == trace_pixel_ptr) {
01278         trace_opcBL = bot_opc;
01279         trace_rclrBL = bot_clr;
01280         trace_rsclrBL = bot_sclr;
01281     }
01282 #endif
01283 ;
01284                 
01285         COUNT_RESAMPLE;
01286         if (acc_opc > min_opacity) {
01287             COUNT_COMPOSITE;
01288             iopc = ipixel->opcflt;
01289 #           ifndef SKIP_ERT
01290                 ASSERT(iopc < max_opacity);
01291 #           endif
01292             iopc_inv = (float)1. - iopc;
01293             ipixel->clrflt += acc_clr * iopc_inv;
01294             iopc += acc_opc * iopc_inv;
01295             ipixel->opcflt = iopc;
01296             
01297 #ifdef DEBUG
01298     if (ipixel == trace_pixel_ptr) {
01299 #ifdef COMPUTE_SHADOW_BUFFER
01300         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01301 #else
01302         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01303 #endif
01304         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01305         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01306         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01307         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01308         printf("  %3.0f %3.0f\n", iopc*255., 
01309                ipixel->clrflt);
01310         
01311         printf("              ");
01312         printf("      %3.0f    ",trace_rsclrTL);
01313         printf("      %3.0f    ",trace_rsclrBL);
01314         printf("      %3.0f    ",trace_rsclrTR);
01315         printf("      %3.0f    ",trace_rsclrBR);
01316         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01317         
01318     }
01319 #endif /* DEBUG */
01320 ;
01321 #           ifndef SKIP_ERT
01322                 if (iopc >= max_opacity) {
01323                     ASSERT(ipixel->lnk == 0);
01324                     ipixel->lnk = 1;
01325                 }
01326 #           endif
01327         };
01328                 ipixel += count; shadow_pixel += count;
01329                 ;
01330                 ;
01331                 count = 0;
01332                 break;
01333             case ALL_ZERO__TOP_NONZERO:
01334                 /* first pixel: only the top-right voxel contributes */
01335                 
01336     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01337     
01338     
01339     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01340     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01341     
01342         
01343         
01344     top_clr = 
01345     shade_table[shade_index + 1*0 + 0] * 
01346         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01347         
01348         top_sclr = 
01349     shadow_table[shade_index + 1*0 + 0] * 
01350         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01351         for (m = 1; m < num_materials; m++) {
01352              
01353         
01354     top_clr += 
01355     shade_table[shade_index + 1*m + 0] * 
01356         weight_table[weight_index + m];
01357         
01358         top_sclr += 
01359     shadow_table[shade_index + 1*m + 0] * 
01360         weight_table[weight_index + m];
01361         };
01362     shade_factor = top_opc * slice_depth_cueing;
01363     
01364         top_clr *= shade_factor;
01365     
01366             top_sclr *= shade_factor;
01367                 
01368 #ifdef DEBUG
01369     if (ipixel == trace_pixel_ptr) {
01370         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01371         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01372         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01373         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01374         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01375     }
01376 #endif
01377 ;
01378                 
01379        acc_opc = top_opc * wgtTR;
01380        acc_clr = (top_clr + top_sclr *
01381                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01382        
01383 #ifdef DEBUG
01384     if (ipixel == trace_pixel_ptr) {
01385         trace_opcTR = top_opc;
01386         trace_rclrTR = top_clr;
01387         trace_rsclrTR = top_sclr;
01388     }
01389 #endif
01390 ;
01391                 
01392         COUNT_RESAMPLE;
01393         if (acc_opc > min_opacity) {
01394             COUNT_COMPOSITE;
01395             iopc = ipixel->opcflt;
01396 #           ifndef SKIP_ERT
01397                 ASSERT(iopc < max_opacity);
01398 #           endif
01399             iopc_inv = (float)1. - iopc;
01400             ipixel->clrflt += acc_clr * iopc_inv;
01401             iopc += acc_opc * iopc_inv;
01402             ipixel->opcflt = iopc;
01403             
01404 #ifdef DEBUG
01405     if (ipixel == trace_pixel_ptr) {
01406 #ifdef COMPUTE_SHADOW_BUFFER
01407         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01408 #else
01409         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01410 #endif
01411         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01412         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01413         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01414         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01415         printf("  %3.0f %3.0f\n", iopc*255., 
01416                ipixel->clrflt);
01417         
01418         printf("              ");
01419         printf("      %3.0f    ",trace_rsclrTL);
01420         printf("      %3.0f    ",trace_rsclrBL);
01421         printf("      %3.0f    ",trace_rsclrTR);
01422         printf("      %3.0f    ",trace_rsclrBR);
01423         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01424         
01425     }
01426 #endif /* DEBUG */
01427 ;
01428 #           ifndef SKIP_ERT
01429                 if (iopc >= max_opacity) {
01430                     ASSERT(ipixel->lnk == 0);
01431                     ipixel->lnk = 1;
01432                 }
01433 #           endif
01434         };
01435                 ipixel += 1; shadow_pixel += 1;
01436                 topRLEdata += 1 * voxel_istride;
01437                 ;
01438                 count--;
01439                 SET_VOXELS_LOADED;
01440 
01441                 /* do the rest of the pixels in this run;
01442                    the top-left and top-right voxels contribute */
01443                 while (count > 0) {
01444                     if (PIXEL_IS_OPAQUE(ipixel))
01445                         break;
01446                     if (!voxels_loaded) {
01447                         
01448     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01449     
01450     
01451     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01452     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01453     
01454         
01455         
01456     top_clr = 
01457     shade_table[shade_index + 1*0 + 0] * 
01458         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01459         
01460         top_sclr = 
01461     shadow_table[shade_index + 1*0 + 0] * 
01462         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01463         for (m = 1; m < num_materials; m++) {
01464              
01465         
01466     top_clr += 
01467     shade_table[shade_index + 1*m + 0] * 
01468         weight_table[weight_index + m];
01469         
01470         top_sclr += 
01471     shadow_table[shade_index + 1*m + 0] * 
01472         weight_table[weight_index + m];
01473         };
01474     shade_factor = top_opc * slice_depth_cueing;
01475     
01476         top_clr *= shade_factor;
01477     
01478             top_sclr *= shade_factor;
01479                     }
01480                     
01481 #ifdef DEBUG
01482     if (ipixel == trace_pixel_ptr) {
01483         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01484         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01485         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01486         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01487         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01488     }
01489 #endif
01490 ;
01491                     
01492        acc_opc = top_opc * wgtTL;
01493        acc_clr = (top_clr + top_sclr *
01494                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01495        
01496 #ifdef DEBUG
01497     if (ipixel == trace_pixel_ptr) {
01498         trace_opcTL = top_opc;
01499         trace_rclrTL = top_clr;
01500         trace_rsclrTL = top_sclr;
01501     }
01502 #endif
01503 ;
01504                     
01505     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01506     
01507     
01508     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01509     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01510     
01511         
01512         
01513     top_clr = 
01514     shade_table[shade_index + 1*0 + 0] * 
01515         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01516         
01517         top_sclr = 
01518     shadow_table[shade_index + 1*0 + 0] * 
01519         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01520         for (m = 1; m < num_materials; m++) {
01521              
01522         
01523     top_clr += 
01524     shade_table[shade_index + 1*m + 0] * 
01525         weight_table[weight_index + m];
01526         
01527         top_sclr += 
01528     shadow_table[shade_index + 1*m + 0] * 
01529         weight_table[weight_index + m];
01530         };
01531     shade_factor = top_opc * slice_depth_cueing;
01532     
01533         top_clr *= shade_factor;
01534     
01535             top_sclr *= shade_factor;
01536                     
01537        acc_opc += top_opc * wgtTR;
01538        acc_clr += (top_clr + top_sclr *
01539                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01540        
01541 #ifdef DEBUG
01542     if (ipixel == trace_pixel_ptr) {
01543         trace_opcTR = top_opc;
01544         trace_rclrTR = top_clr;
01545         trace_rsclrTR = top_sclr;
01546     }
01547 #endif
01548 ;
01549                     
01550         COUNT_RESAMPLE;
01551         if (acc_opc > min_opacity) {
01552             COUNT_COMPOSITE;
01553             iopc = ipixel->opcflt;
01554 #           ifndef SKIP_ERT
01555                 ASSERT(iopc < max_opacity);
01556 #           endif
01557             iopc_inv = (float)1. - iopc;
01558             ipixel->clrflt += acc_clr * iopc_inv;
01559             iopc += acc_opc * iopc_inv;
01560             ipixel->opcflt = iopc;
01561             
01562 #ifdef DEBUG
01563     if (ipixel == trace_pixel_ptr) {
01564 #ifdef COMPUTE_SHADOW_BUFFER
01565         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01566 #else
01567         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01568 #endif
01569         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01570         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01571         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01572         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01573         printf("  %3.0f %3.0f\n", iopc*255., 
01574                ipixel->clrflt);
01575         
01576         printf("              ");
01577         printf("      %3.0f    ",trace_rsclrTL);
01578         printf("      %3.0f    ",trace_rsclrBL);
01579         printf("      %3.0f    ",trace_rsclrTR);
01580         printf("      %3.0f    ",trace_rsclrBR);
01581         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01582         
01583     }
01584 #endif /* DEBUG */
01585 ;
01586 #           ifndef SKIP_ERT
01587                 if (iopc >= max_opacity) {
01588                     ASSERT(ipixel->lnk == 0);
01589                     ipixel->lnk = 1;
01590                 }
01591 #           endif
01592         };
01593                     ipixel += 1; shadow_pixel += 1;
01594                     topRLEdata += 1 * voxel_istride;
01595                     ;
01596                     count--;
01597                     SET_VOXELS_LOADED;
01598                 }
01599                 break;
01600             case TOP_NONZERO__TOP_NONZERO:
01601                 /* do the pixels in this run; the top-left and
01602                    top-right voxels contribute */
01603                 while (count > 0) {
01604                     if (PIXEL_IS_OPAQUE(ipixel))
01605                         break;
01606                     if (!voxels_loaded) {
01607                         
01608     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01609     
01610     
01611     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01612     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01613     
01614         
01615         
01616     top_clr = 
01617     shade_table[shade_index + 1*0 + 0] * 
01618         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01619         
01620         top_sclr = 
01621     shadow_table[shade_index + 1*0 + 0] * 
01622         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01623         for (m = 1; m < num_materials; m++) {
01624              
01625         
01626     top_clr += 
01627     shade_table[shade_index + 1*m + 0] * 
01628         weight_table[weight_index + m];
01629         
01630         top_sclr += 
01631     shadow_table[shade_index + 1*m + 0] * 
01632         weight_table[weight_index + m];
01633         };
01634     shade_factor = top_opc * slice_depth_cueing;
01635     
01636         top_clr *= shade_factor;
01637     
01638             top_sclr *= shade_factor;
01639                     }
01640                     
01641 #ifdef DEBUG
01642     if (ipixel == trace_pixel_ptr) {
01643         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01644         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01645         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01646         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01647         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01648     }
01649 #endif
01650 ;
01651                     
01652        acc_opc = top_opc * wgtTL;
01653        acc_clr = (top_clr + top_sclr *
01654                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01655        
01656 #ifdef DEBUG
01657     if (ipixel == trace_pixel_ptr) {
01658         trace_opcTL = top_opc;
01659         trace_rclrTL = top_clr;
01660         trace_rsclrTL = top_sclr;
01661     }
01662 #endif
01663 ;
01664                     
01665     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01666     
01667     
01668     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01669     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01670     
01671         
01672         
01673     top_clr = 
01674     shade_table[shade_index + 1*0 + 0] * 
01675         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01676         
01677         top_sclr = 
01678     shadow_table[shade_index + 1*0 + 0] * 
01679         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01680         for (m = 1; m < num_materials; m++) {
01681              
01682         
01683     top_clr += 
01684     shade_table[shade_index + 1*m + 0] * 
01685         weight_table[weight_index + m];
01686         
01687         top_sclr += 
01688     shadow_table[shade_index + 1*m + 0] * 
01689         weight_table[weight_index + m];
01690         };
01691     shade_factor = top_opc * slice_depth_cueing;
01692     
01693         top_clr *= shade_factor;
01694     
01695             top_sclr *= shade_factor;
01696                     
01697        acc_opc += top_opc * wgtTR;
01698        acc_clr += (top_clr + top_sclr *
01699                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01700        
01701 #ifdef DEBUG
01702     if (ipixel == trace_pixel_ptr) {
01703         trace_opcTR = top_opc;
01704         trace_rclrTR = top_clr;
01705         trace_rsclrTR = top_sclr;
01706     }
01707 #endif
01708 ;
01709                     
01710         COUNT_RESAMPLE;
01711         if (acc_opc > min_opacity) {
01712             COUNT_COMPOSITE;
01713             iopc = ipixel->opcflt;
01714 #           ifndef SKIP_ERT
01715                 ASSERT(iopc < max_opacity);
01716 #           endif
01717             iopc_inv = (float)1. - iopc;
01718             ipixel->clrflt += acc_clr * iopc_inv;
01719             iopc += acc_opc * iopc_inv;
01720             ipixel->opcflt = iopc;
01721             
01722 #ifdef DEBUG
01723     if (ipixel == trace_pixel_ptr) {
01724 #ifdef COMPUTE_SHADOW_BUFFER
01725         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01726 #else
01727         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01728 #endif
01729         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01730         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01731         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01732         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01733         printf("  %3.0f %3.0f\n", iopc*255., 
01734                ipixel->clrflt);
01735         
01736         printf("              ");
01737         printf("      %3.0f    ",trace_rsclrTL);
01738         printf("      %3.0f    ",trace_rsclrBL);
01739         printf("      %3.0f    ",trace_rsclrTR);
01740         printf("      %3.0f    ",trace_rsclrBR);
01741         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01742         
01743     }
01744 #endif /* DEBUG */
01745 ;
01746 #           ifndef SKIP_ERT
01747                 if (iopc >= max_opacity) {
01748                     ASSERT(ipixel->lnk == 0);
01749                     ipixel->lnk = 1;
01750                 }
01751 #           endif
01752         };
01753                     ipixel += 1; shadow_pixel += 1;
01754                     topRLEdata += 1 * voxel_istride;
01755                     ;
01756                     count--;
01757                     SET_VOXELS_LOADED;
01758                 }
01759                 break;
01760             case BOT_NONZERO__TOP_NONZERO:
01761                 /* first pixel: bottom-left and top-right voxels
01762                    contribute */
01763                 if (!voxels_loaded) {
01764                     
01765     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01766     
01767     
01768     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
01769     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01770     
01771         
01772         
01773     bot_clr = 
01774     shade_table[shade_index + 1*0 + 0] * 
01775         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01776         
01777         bot_sclr = 
01778     shadow_table[shade_index + 1*0 + 0] * 
01779         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01780         for (m = 1; m < num_materials; m++) {
01781              
01782         
01783     bot_clr += 
01784     shade_table[shade_index + 1*m + 0] * 
01785         weight_table[weight_index + m];
01786         
01787         bot_sclr += 
01788     shadow_table[shade_index + 1*m + 0] * 
01789         weight_table[weight_index + m];
01790         };
01791     shade_factor = bot_opc * slice_depth_cueing;
01792     
01793         bot_clr *= shade_factor;
01794     
01795             bot_sclr *= shade_factor;
01796                 }
01797                 
01798 #ifdef DEBUG
01799     if (ipixel == trace_pixel_ptr) {
01800         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01801         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01802         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01803         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01804         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01805     }
01806 #endif
01807 ;
01808                 
01809        acc_opc = bot_opc * wgtBL;
01810        acc_clr = (bot_clr + bot_sclr *
01811                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01812        
01813 #ifdef DEBUG
01814     if (ipixel == trace_pixel_ptr) {
01815         trace_opcBL = bot_opc;
01816         trace_rclrBL = bot_clr;
01817         trace_rsclrBL = bot_sclr;
01818     }
01819 #endif
01820 ;
01821                 
01822     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01823     
01824     
01825     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01826     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01827     
01828         
01829         
01830     top_clr = 
01831     shade_table[shade_index + 1*0 + 0] * 
01832         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01833         
01834         top_sclr = 
01835     shadow_table[shade_index + 1*0 + 0] * 
01836         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01837         for (m = 1; m < num_materials; m++) {
01838              
01839         
01840     top_clr += 
01841     shade_table[shade_index + 1*m + 0] * 
01842         weight_table[weight_index + m];
01843         
01844         top_sclr += 
01845     shadow_table[shade_index + 1*m + 0] * 
01846         weight_table[weight_index + m];
01847         };
01848     shade_factor = top_opc * slice_depth_cueing;
01849     
01850         top_clr *= shade_factor;
01851     
01852             top_sclr *= shade_factor;
01853                 
01854        acc_opc += top_opc * wgtTR;
01855        acc_clr += (top_clr + top_sclr *
01856                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01857        
01858 #ifdef DEBUG
01859     if (ipixel == trace_pixel_ptr) {
01860         trace_opcTR = top_opc;
01861         trace_rclrTR = top_clr;
01862         trace_rsclrTR = top_sclr;
01863     }
01864 #endif
01865 ;
01866                 
01867         COUNT_RESAMPLE;
01868         if (acc_opc > min_opacity) {
01869             COUNT_COMPOSITE;
01870             iopc = ipixel->opcflt;
01871 #           ifndef SKIP_ERT
01872                 ASSERT(iopc < max_opacity);
01873 #           endif
01874             iopc_inv = (float)1. - iopc;
01875             ipixel->clrflt += acc_clr * iopc_inv;
01876             iopc += acc_opc * iopc_inv;
01877             ipixel->opcflt = iopc;
01878             
01879 #ifdef DEBUG
01880     if (ipixel == trace_pixel_ptr) {
01881 #ifdef COMPUTE_SHADOW_BUFFER
01882         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01883 #else
01884         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01885 #endif
01886         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01887         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01888         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01889         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01890         printf("  %3.0f %3.0f\n", iopc*255., 
01891                ipixel->clrflt);
01892         
01893         printf("              ");
01894         printf("      %3.0f    ",trace_rsclrTL);
01895         printf("      %3.0f    ",trace_rsclrBL);
01896         printf("      %3.0f    ",trace_rsclrTR);
01897         printf("      %3.0f    ",trace_rsclrBR);
01898         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
01899         
01900     }
01901 #endif /* DEBUG */
01902 ;
01903 #           ifndef SKIP_ERT
01904                 if (iopc >= max_opacity) {
01905                     ASSERT(ipixel->lnk == 0);
01906                     ipixel->lnk = 1;
01907                 }
01908 #           endif
01909         };
01910                 ipixel += 1; shadow_pixel += 1;
01911                 topRLEdata += 1 * voxel_istride;
01912                 ;
01913                 count--;
01914                 SET_VOXELS_LOADED;
01915 
01916                 /* do the rest of the pixels in this run;
01917                    the top-left and top-right voxels contribute */
01918                 while (count > 0) {
01919                     if (PIXEL_IS_OPAQUE(ipixel))
01920                         break;
01921                     if (!voxels_loaded) {
01922                         
01923     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01924     
01925     
01926     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
01927     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01928     
01929         
01930         
01931     top_clr = 
01932     shade_table[shade_index + 1*0 + 0] * 
01933         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01934         
01935         top_sclr = 
01936     shadow_table[shade_index + 1*0 + 0] * 
01937         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01938         for (m = 1; m < num_materials; m++) {
01939              
01940         
01941     top_clr += 
01942     shade_table[shade_index + 1*m + 0] * 
01943         weight_table[weight_index + m];
01944         
01945         top_sclr += 
01946     shadow_table[shade_index + 1*m + 0] * 
01947         weight_table[weight_index + m];
01948         };
01949     shade_factor = top_opc * slice_depth_cueing;
01950     
01951         top_clr *= shade_factor;
01952     
01953             top_sclr *= shade_factor;
01954                     }
01955                     
01956 #ifdef DEBUG
01957     if (ipixel == trace_pixel_ptr) {
01958         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01959         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01960         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01961         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01962         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01963     }
01964 #endif
01965 ;
01966                     
01967        acc_opc = top_opc * wgtTL;
01968        acc_clr = (top_clr + top_sclr *
01969                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01970        
01971 #ifdef DEBUG
01972     if (ipixel == trace_pixel_ptr) {
01973         trace_opcTL = top_opc;
01974         trace_rclrTL = top_clr;
01975         trace_rsclrTL = top_sclr;
01976     }
01977 #endif
01978 ;
01979                     
01980     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01981     
01982     
01983     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
01984     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01985     
01986         
01987         
01988     top_clr = 
01989     shade_table[shade_index + 1*0 + 0] * 
01990         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01991         
01992         top_sclr = 
01993     shadow_table[shade_index + 1*0 + 0] * 
01994         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01995         for (m = 1; m < num_materials; m++) {
01996              
01997         
01998     top_clr += 
01999     shade_table[shade_index + 1*m + 0] * 
02000         weight_table[weight_index + m];
02001         
02002         top_sclr += 
02003     shadow_table[shade_index + 1*m + 0] * 
02004         weight_table[weight_index + m];
02005         };
02006     shade_factor = top_opc * slice_depth_cueing;
02007     
02008         top_clr *= shade_factor;
02009     
02010             top_sclr *= shade_factor;
02011                     
02012        acc_opc += top_opc * wgtTR;
02013        acc_clr += (top_clr + top_sclr *
02014                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02015        
02016 #ifdef DEBUG
02017     if (ipixel == trace_pixel_ptr) {
02018         trace_opcTR = top_opc;
02019         trace_rclrTR = top_clr;
02020         trace_rsclrTR = top_sclr;
02021     }
02022 #endif
02023 ;
02024                     
02025         COUNT_RESAMPLE;
02026         if (acc_opc > min_opacity) {
02027             COUNT_COMPOSITE;
02028             iopc = ipixel->opcflt;
02029 #           ifndef SKIP_ERT
02030                 ASSERT(iopc < max_opacity);
02031 #           endif
02032             iopc_inv = (float)1. - iopc;
02033             ipixel->clrflt += acc_clr * iopc_inv;
02034             iopc += acc_opc * iopc_inv;
02035             ipixel->opcflt = iopc;
02036             
02037 #ifdef DEBUG
02038     if (ipixel == trace_pixel_ptr) {
02039 #ifdef COMPUTE_SHADOW_BUFFER
02040         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02041 #else
02042         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02043 #endif
02044         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02045         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02046         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02047         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02048         printf("  %3.0f %3.0f\n", iopc*255., 
02049                ipixel->clrflt);
02050         
02051         printf("              ");
02052         printf("      %3.0f    ",trace_rsclrTL);
02053         printf("      %3.0f    ",trace_rsclrBL);
02054         printf("      %3.0f    ",trace_rsclrTR);
02055         printf("      %3.0f    ",trace_rsclrBR);
02056         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02057         
02058     }
02059 #endif /* DEBUG */
02060 ;
02061 #           ifndef SKIP_ERT
02062                 if (iopc >= max_opacity) {
02063                     ASSERT(ipixel->lnk == 0);
02064                     ipixel->lnk = 1;
02065                 }
02066 #           endif
02067         };
02068                     ipixel += 1; shadow_pixel += 1;
02069                     topRLEdata += 1 * voxel_istride;
02070                     ;
02071                     count--;
02072                     SET_VOXELS_LOADED;
02073                 }
02074                 break;
02075             case ALL_NONZERO__TOP_NONZERO:
02076                 /* first pixel: top-left, bottom-left and top-right voxels
02077                    contribute */
02078                 if (!voxels_loaded) {
02079                     
02080     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02081     
02082     
02083     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02084     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02085     
02086         
02087         
02088     top_clr = 
02089     shade_table[shade_index + 1*0 + 0] * 
02090         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02091         
02092         top_sclr = 
02093     shadow_table[shade_index + 1*0 + 0] * 
02094         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02095         for (m = 1; m < num_materials; m++) {
02096              
02097         
02098     top_clr += 
02099     shade_table[shade_index + 1*m + 0] * 
02100         weight_table[weight_index + m];
02101         
02102         top_sclr += 
02103     shadow_table[shade_index + 1*m + 0] * 
02104         weight_table[weight_index + m];
02105         };
02106     shade_factor = top_opc * slice_depth_cueing;
02107     
02108         top_clr *= shade_factor;
02109     
02110             top_sclr *= shade_factor;
02111                     
02112     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02113     
02114     
02115     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02116     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02117     
02118         
02119         
02120     bot_clr = 
02121     shade_table[shade_index + 1*0 + 0] * 
02122         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02123         
02124         bot_sclr = 
02125     shadow_table[shade_index + 1*0 + 0] * 
02126         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02127         for (m = 1; m < num_materials; m++) {
02128              
02129         
02130     bot_clr += 
02131     shade_table[shade_index + 1*m + 0] * 
02132         weight_table[weight_index + m];
02133         
02134         bot_sclr += 
02135     shadow_table[shade_index + 1*m + 0] * 
02136         weight_table[weight_index + m];
02137         };
02138     shade_factor = bot_opc * slice_depth_cueing;
02139     
02140         bot_clr *= shade_factor;
02141     
02142             bot_sclr *= shade_factor;
02143                 }
02144                 
02145 #ifdef DEBUG
02146     if (ipixel == trace_pixel_ptr) {
02147         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02148         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02149         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02150         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02151         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02152     }
02153 #endif
02154 ;
02155                 
02156        acc_opc = top_opc * wgtTL;
02157        acc_clr = (top_clr + top_sclr *
02158                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02159        
02160 #ifdef DEBUG
02161     if (ipixel == trace_pixel_ptr) {
02162         trace_opcTL = top_opc;
02163         trace_rclrTL = top_clr;
02164         trace_rsclrTL = top_sclr;
02165     }
02166 #endif
02167 ;
02168                 
02169        acc_opc += bot_opc * wgtBL;
02170        acc_clr += (bot_clr + bot_sclr *
02171                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02172        
02173 #ifdef DEBUG
02174     if (ipixel == trace_pixel_ptr) {
02175         trace_opcBL = bot_opc;
02176         trace_rclrBL = bot_clr;
02177         trace_rsclrBL = bot_sclr;
02178     }
02179 #endif
02180 ;
02181                 
02182     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02183     
02184     
02185     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
02186     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02187     
02188         
02189         
02190     top_clr = 
02191     shade_table[shade_index + 1*0 + 0] * 
02192         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02193         
02194         top_sclr = 
02195     shadow_table[shade_index + 1*0 + 0] * 
02196         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02197         for (m = 1; m < num_materials; m++) {
02198              
02199         
02200     top_clr += 
02201     shade_table[shade_index + 1*m + 0] * 
02202         weight_table[weight_index + m];
02203         
02204         top_sclr += 
02205     shadow_table[shade_index + 1*m + 0] * 
02206         weight_table[weight_index + m];
02207         };
02208     shade_factor = top_opc * slice_depth_cueing;
02209     
02210         top_clr *= shade_factor;
02211     
02212             top_sclr *= shade_factor;
02213                 
02214        acc_opc += top_opc * wgtTR;
02215        acc_clr += (top_clr + top_sclr *
02216                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02217        
02218 #ifdef DEBUG
02219     if (ipixel == trace_pixel_ptr) {
02220         trace_opcTR = top_opc;
02221         trace_rclrTR = top_clr;
02222         trace_rsclrTR = top_sclr;
02223     }
02224 #endif
02225 ;
02226                 
02227         COUNT_RESAMPLE;
02228         if (acc_opc > min_opacity) {
02229             COUNT_COMPOSITE;
02230             iopc = ipixel->opcflt;
02231 #           ifndef SKIP_ERT
02232                 ASSERT(iopc < max_opacity);
02233 #           endif
02234             iopc_inv = (float)1. - iopc;
02235             ipixel->clrflt += acc_clr * iopc_inv;
02236             iopc += acc_opc * iopc_inv;
02237             ipixel->opcflt = iopc;
02238             
02239 #ifdef DEBUG
02240     if (ipixel == trace_pixel_ptr) {
02241 #ifdef COMPUTE_SHADOW_BUFFER
02242         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02243 #else
02244         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02245 #endif
02246         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02247         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02248         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02249         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02250         printf("  %3.0f %3.0f\n", iopc*255., 
02251                ipixel->clrflt);
02252         
02253         printf("              ");
02254         printf("      %3.0f    ",trace_rsclrTL);
02255         printf("      %3.0f    ",trace_rsclrBL);
02256         printf("      %3.0f    ",trace_rsclrTR);
02257         printf("      %3.0f    ",trace_rsclrBR);
02258         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02259         
02260     }
02261 #endif /* DEBUG */
02262 ;
02263 #           ifndef SKIP_ERT
02264                 if (iopc >= max_opacity) {
02265                     ASSERT(ipixel->lnk == 0);
02266                     ipixel->lnk = 1;
02267                 }
02268 #           endif
02269         };
02270                 ipixel += 1; shadow_pixel += 1;
02271                 topRLEdata += 1 * voxel_istride;
02272                 ;
02273                 count--;
02274                 SET_VOXELS_LOADED;
02275 
02276                 /* do the rest of the pixels in this run;
02277                    the top-left and top-right voxels contribute */
02278                 while (count > 0) {
02279                     if (PIXEL_IS_OPAQUE(ipixel))
02280                         break;
02281                     if (!voxels_loaded) {
02282                         
02283     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02284     
02285     
02286     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02287     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02288     
02289         
02290         
02291     top_clr = 
02292     shade_table[shade_index + 1*0 + 0] * 
02293         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02294         
02295         top_sclr = 
02296     shadow_table[shade_index + 1*0 + 0] * 
02297         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02298         for (m = 1; m < num_materials; m++) {
02299              
02300         
02301     top_clr += 
02302     shade_table[shade_index + 1*m + 0] * 
02303         weight_table[weight_index + m];
02304         
02305         top_sclr += 
02306     shadow_table[shade_index + 1*m + 0] * 
02307         weight_table[weight_index + m];
02308         };
02309     shade_factor = top_opc * slice_depth_cueing;
02310     
02311         top_clr *= shade_factor;
02312     
02313             top_sclr *= shade_factor;
02314                     }
02315                     
02316 #ifdef DEBUG
02317     if (ipixel == trace_pixel_ptr) {
02318         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02319         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02320         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02321         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02322         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02323     }
02324 #endif
02325 ;
02326                     
02327        acc_opc = top_opc * wgtTL;
02328        acc_clr = (top_clr + top_sclr *
02329                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02330        
02331 #ifdef DEBUG
02332     if (ipixel == trace_pixel_ptr) {
02333         trace_opcTL = top_opc;
02334         trace_rclrTL = top_clr;
02335         trace_rsclrTL = top_sclr;
02336     }
02337 #endif
02338 ;
02339                     
02340     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02341     
02342     
02343     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
02344     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02345     
02346         
02347         
02348     top_clr = 
02349     shade_table[shade_index + 1*0 + 0] * 
02350         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02351         
02352         top_sclr = 
02353     shadow_table[shade_index + 1*0 + 0] * 
02354         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02355         for (m = 1; m < num_materials; m++) {
02356              
02357         
02358     top_clr += 
02359     shade_table[shade_index + 1*m + 0] * 
02360         weight_table[weight_index + m];
02361         
02362         top_sclr += 
02363     shadow_table[shade_index + 1*m + 0] * 
02364         weight_table[weight_index + m];
02365         };
02366     shade_factor = top_opc * slice_depth_cueing;
02367     
02368         top_clr *= shade_factor;
02369     
02370             top_sclr *= shade_factor;
02371                     
02372        acc_opc += top_opc * wgtTR;
02373        acc_clr += (top_clr + top_sclr *
02374                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02375        
02376 #ifdef DEBUG
02377     if (ipixel == trace_pixel_ptr) {
02378         trace_opcTR = top_opc;
02379         trace_rclrTR = top_clr;
02380         trace_rsclrTR = top_sclr;
02381     }
02382 #endif
02383 ;
02384                     
02385         COUNT_RESAMPLE;
02386         if (acc_opc > min_opacity) {
02387             COUNT_COMPOSITE;
02388             iopc = ipixel->opcflt;
02389 #           ifndef SKIP_ERT
02390                 ASSERT(iopc < max_opacity);
02391 #           endif
02392             iopc_inv = (float)1. - iopc;
02393             ipixel->clrflt += acc_clr * iopc_inv;
02394             iopc += acc_opc * iopc_inv;
02395             ipixel->opcflt = iopc;
02396             
02397 #ifdef DEBUG
02398     if (ipixel == trace_pixel_ptr) {
02399 #ifdef COMPUTE_SHADOW_BUFFER
02400         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02401 #else
02402         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02403 #endif
02404         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02405         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02406         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02407         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02408         printf("  %3.0f %3.0f\n", iopc*255., 
02409                ipixel->clrflt);
02410         
02411         printf("              ");
02412         printf("      %3.0f    ",trace_rsclrTL);
02413         printf("      %3.0f    ",trace_rsclrBL);
02414         printf("      %3.0f    ",trace_rsclrTR);
02415         printf("      %3.0f    ",trace_rsclrBR);
02416         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02417         
02418     }
02419 #endif /* DEBUG */
02420 ;
02421 #           ifndef SKIP_ERT
02422                 if (iopc >= max_opacity) {
02423                     ASSERT(ipixel->lnk == 0);
02424                     ipixel->lnk = 1;
02425                 }
02426 #           endif
02427         };
02428                     ipixel += 1; shadow_pixel += 1;
02429                     topRLEdata += 1 * voxel_istride;
02430                     ;
02431                     count--;
02432                     SET_VOXELS_LOADED;
02433                 }
02434                 break;
02435             case ALL_ZERO__BOT_NONZERO:
02436                 /* first pixel: only the bottom-right voxel contributes */
02437                 
02438     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02439     
02440     
02441     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02442     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02443     
02444         
02445         
02446     bot_clr = 
02447     shade_table[shade_index + 1*0 + 0] * 
02448         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02449         
02450         bot_sclr = 
02451     shadow_table[shade_index + 1*0 + 0] * 
02452         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02453         for (m = 1; m < num_materials; m++) {
02454              
02455         
02456     bot_clr += 
02457     shade_table[shade_index + 1*m + 0] * 
02458         weight_table[weight_index + m];
02459         
02460         bot_sclr += 
02461     shadow_table[shade_index + 1*m + 0] * 
02462         weight_table[weight_index + m];
02463         };
02464     shade_factor = bot_opc * slice_depth_cueing;
02465     
02466         bot_clr *= shade_factor;
02467     
02468             bot_sclr *= shade_factor;
02469                 
02470 #ifdef DEBUG
02471     if (ipixel == trace_pixel_ptr) {
02472         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02473         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02474         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02475         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02476         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02477     }
02478 #endif
02479 ;
02480                 
02481        acc_opc = bot_opc * wgtBR;
02482        acc_clr = (bot_clr + bot_sclr *
02483                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
02484        
02485 #ifdef DEBUG
02486     if (ipixel == trace_pixel_ptr) {
02487         trace_opcBR = bot_opc;
02488         trace_rclrBR = bot_clr;
02489         trace_rsclrBR = bot_sclr;
02490     }
02491 #endif
02492 ;
02493                 
02494         COUNT_RESAMPLE;
02495         if (acc_opc > min_opacity) {
02496             COUNT_COMPOSITE;
02497             iopc = ipixel->opcflt;
02498 #           ifndef SKIP_ERT
02499                 ASSERT(iopc < max_opacity);
02500 #           endif
02501             iopc_inv = (float)1. - iopc;
02502             ipixel->clrflt += acc_clr * iopc_inv;
02503             iopc += acc_opc * iopc_inv;
02504             ipixel->opcflt = iopc;
02505             
02506 #ifdef DEBUG
02507     if (ipixel == trace_pixel_ptr) {
02508 #ifdef COMPUTE_SHADOW_BUFFER
02509         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02510 #else
02511         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02512 #endif
02513         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02514         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02515         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02516         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02517         printf("  %3.0f %3.0f\n", iopc*255., 
02518                ipixel->clrflt);
02519         
02520         printf("              ");
02521         printf("      %3.0f    ",trace_rsclrTL);
02522         printf("      %3.0f    ",trace_rsclrBL);
02523         printf("      %3.0f    ",trace_rsclrTR);
02524         printf("      %3.0f    ",trace_rsclrBR);
02525         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02526         
02527     }
02528 #endif /* DEBUG */
02529 ;
02530 #           ifndef SKIP_ERT
02531                 if (iopc >= max_opacity) {
02532                     ASSERT(ipixel->lnk == 0);
02533                     ipixel->lnk = 1;
02534                 }
02535 #           endif
02536         };      
02537                 ipixel += 1; shadow_pixel += 1;
02538                 ;
02539                 botRLEdata += 1 * voxel_istride;
02540                 count--;
02541                 SET_VOXELS_LOADED;
02542 
02543                 /* do the rest of the pixels in this run;
02544                    bottom-left and bottom-right voxels contribute */
02545                 while (count > 0) {
02546                     if (PIXEL_IS_OPAQUE(ipixel))
02547                         break;
02548                     if (!voxels_loaded) {
02549                         
02550     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02551     
02552     
02553     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02554     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02555     
02556         
02557         
02558     bot_clr = 
02559     shade_table[shade_index + 1*0 + 0] * 
02560         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02561         
02562         bot_sclr = 
02563     shadow_table[shade_index + 1*0 + 0] * 
02564         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02565         for (m = 1; m < num_materials; m++) {
02566              
02567         
02568     bot_clr += 
02569     shade_table[shade_index + 1*m + 0] * 
02570         weight_table[weight_index + m];
02571         
02572         bot_sclr += 
02573     shadow_table[shade_index + 1*m + 0] * 
02574         weight_table[weight_index + m];
02575         };
02576     shade_factor = bot_opc * slice_depth_cueing;
02577     
02578         bot_clr *= shade_factor;
02579     
02580             bot_sclr *= shade_factor;
02581                     }
02582                     
02583 #ifdef DEBUG
02584     if (ipixel == trace_pixel_ptr) {
02585         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02586         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02587         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02588         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02589         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02590     }
02591 #endif
02592 ;
02593                     
02594        acc_opc = bot_opc * wgtBL;
02595        acc_clr = (bot_clr + bot_sclr *
02596                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02597        
02598 #ifdef DEBUG
02599     if (ipixel == trace_pixel_ptr) {
02600         trace_opcBL = bot_opc;
02601         trace_rclrBL = bot_clr;
02602         trace_rsclrBL = bot_sclr;
02603     }
02604 #endif
02605 ;
02606                     
02607     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02608     
02609     
02610     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02611     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02612     
02613         
02614         
02615     bot_clr = 
02616     shade_table[shade_index + 1*0 + 0] * 
02617         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02618         
02619         bot_sclr = 
02620     shadow_table[shade_index + 1*0 + 0] * 
02621         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02622         for (m = 1; m < num_materials; m++) {
02623              
02624         
02625     bot_clr += 
02626     shade_table[shade_index + 1*m + 0] * 
02627         weight_table[weight_index + m];
02628         
02629         bot_sclr += 
02630     shadow_table[shade_index + 1*m + 0] * 
02631         weight_table[weight_index + m];
02632         };
02633     shade_factor = bot_opc * slice_depth_cueing;
02634     
02635         bot_clr *= shade_factor;
02636     
02637             bot_sclr *= shade_factor;
02638                     
02639        acc_opc += bot_opc * wgtBR;
02640        acc_clr += (bot_clr + bot_sclr *
02641                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
02642        
02643 #ifdef DEBUG
02644     if (ipixel == trace_pixel_ptr) {
02645         trace_opcBR = bot_opc;
02646         trace_rclrBR = bot_clr;
02647         trace_rsclrBR = bot_sclr;
02648     }
02649 #endif
02650 ;
02651                     
02652         COUNT_RESAMPLE;
02653         if (acc_opc > min_opacity) {
02654             COUNT_COMPOSITE;
02655             iopc = ipixel->opcflt;
02656 #           ifndef SKIP_ERT
02657                 ASSERT(iopc < max_opacity);
02658 #           endif
02659             iopc_inv = (float)1. - iopc;
02660             ipixel->clrflt += acc_clr * iopc_inv;
02661             iopc += acc_opc * iopc_inv;
02662             ipixel->opcflt = iopc;
02663             
02664 #ifdef DEBUG
02665     if (ipixel == trace_pixel_ptr) {
02666 #ifdef COMPUTE_SHADOW_BUFFER
02667         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02668 #else
02669         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02670 #endif
02671         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02672         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02673         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02674         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02675         printf("  %3.0f %3.0f\n", iopc*255., 
02676                ipixel->clrflt);
02677         
02678         printf("              ");
02679         printf("      %3.0f    ",trace_rsclrTL);
02680         printf("      %3.0f    ",trace_rsclrBL);
02681         printf("      %3.0f    ",trace_rsclrTR);
02682         printf("      %3.0f    ",trace_rsclrBR);
02683         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02684         
02685     }
02686 #endif /* DEBUG */
02687 ;
02688 #           ifndef SKIP_ERT
02689                 if (iopc >= max_opacity) {
02690                     ASSERT(ipixel->lnk == 0);
02691                     ipixel->lnk = 1;
02692                 }
02693 #           endif
02694         };
02695                     ipixel += 1; shadow_pixel += 1;
02696                     ;
02697                     botRLEdata += 1 * voxel_istride;
02698                     count--;
02699                     SET_VOXELS_LOADED;
02700                 }
02701                 break;
02702             case TOP_NONZERO__BOT_NONZERO:
02703                 /* first pixel: top-left and bottom-right voxels contribute */
02704                 if (!voxels_loaded) {
02705                     
02706     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02707     
02708     
02709     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
02710     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02711     
02712         
02713         
02714     top_clr = 
02715     shade_table[shade_index + 1*0 + 0] * 
02716         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02717         
02718         top_sclr = 
02719     shadow_table[shade_index + 1*0 + 0] * 
02720         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02721         for (m = 1; m < num_materials; m++) {
02722              
02723         
02724     top_clr += 
02725     shade_table[shade_index + 1*m + 0] * 
02726         weight_table[weight_index + m];
02727         
02728         top_sclr += 
02729     shadow_table[shade_index + 1*m + 0] * 
02730         weight_table[weight_index + m];
02731         };
02732     shade_factor = top_opc * slice_depth_cueing;
02733     
02734         top_clr *= shade_factor;
02735     
02736             top_sclr *= shade_factor;
02737                 }
02738                 
02739 #ifdef DEBUG
02740     if (ipixel == trace_pixel_ptr) {
02741         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02742         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02743         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02744         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02745         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02746     }
02747 #endif
02748 ;
02749                 
02750        acc_opc = top_opc * wgtTL;
02751        acc_clr = (top_clr + top_sclr *
02752                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02753        
02754 #ifdef DEBUG
02755     if (ipixel == trace_pixel_ptr) {
02756         trace_opcTL = top_opc;
02757         trace_rclrTL = top_clr;
02758         trace_rsclrTL = top_sclr;
02759     }
02760 #endif
02761 ;
02762                 
02763     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02764     
02765     
02766     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02767     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02768     
02769         
02770         
02771     bot_clr = 
02772     shade_table[shade_index + 1*0 + 0] * 
02773         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02774         
02775         bot_sclr = 
02776     shadow_table[shade_index + 1*0 + 0] * 
02777         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02778         for (m = 1; m < num_materials; m++) {
02779              
02780         
02781     bot_clr += 
02782     shade_table[shade_index + 1*m + 0] * 
02783         weight_table[weight_index + m];
02784         
02785         bot_sclr += 
02786     shadow_table[shade_index + 1*m + 0] * 
02787         weight_table[weight_index + m];
02788         };
02789     shade_factor = bot_opc * slice_depth_cueing;
02790     
02791         bot_clr *= shade_factor;
02792     
02793             bot_sclr *= shade_factor;
02794                 
02795        acc_opc += bot_opc * wgtBR;
02796        acc_clr += (bot_clr + bot_sclr *
02797                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
02798        
02799 #ifdef DEBUG
02800     if (ipixel == trace_pixel_ptr) {
02801         trace_opcBR = bot_opc;
02802         trace_rclrBR = bot_clr;
02803         trace_rsclrBR = bot_sclr;
02804     }
02805 #endif
02806 ;
02807                 
02808         COUNT_RESAMPLE;
02809         if (acc_opc > min_opacity) {
02810             COUNT_COMPOSITE;
02811             iopc = ipixel->opcflt;
02812 #           ifndef SKIP_ERT
02813                 ASSERT(iopc < max_opacity);
02814 #           endif
02815             iopc_inv = (float)1. - iopc;
02816             ipixel->clrflt += acc_clr * iopc_inv;
02817             iopc += acc_opc * iopc_inv;
02818             ipixel->opcflt = iopc;
02819             
02820 #ifdef DEBUG
02821     if (ipixel == trace_pixel_ptr) {
02822 #ifdef COMPUTE_SHADOW_BUFFER
02823         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02824 #else
02825         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02826 #endif
02827         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02828         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02829         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02830         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02831         printf("  %3.0f %3.0f\n", iopc*255., 
02832                ipixel->clrflt);
02833         
02834         printf("              ");
02835         printf("      %3.0f    ",trace_rsclrTL);
02836         printf("      %3.0f    ",trace_rsclrBL);
02837         printf("      %3.0f    ",trace_rsclrTR);
02838         printf("      %3.0f    ",trace_rsclrBR);
02839         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02840         
02841     }
02842 #endif /* DEBUG */
02843 ;
02844 #           ifndef SKIP_ERT
02845                 if (iopc >= max_opacity) {
02846                     ASSERT(ipixel->lnk == 0);
02847                     ipixel->lnk = 1;
02848                 }
02849 #           endif
02850         };
02851                 ipixel += 1; shadow_pixel += 1;
02852                 ;
02853                 botRLEdata += 1 * voxel_istride;
02854                 count--;
02855                 SET_VOXELS_LOADED;
02856 
02857                 /* do the rest of the pixels in this run;
02858                    bottom-left and bottom-right voxels contribute */
02859                 while (count > 0) {
02860                     if (PIXEL_IS_OPAQUE(ipixel))
02861                         break;
02862                     if (!voxels_loaded) {
02863                         
02864     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02865     
02866     
02867     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
02868     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02869     
02870         
02871         
02872     bot_clr = 
02873     shade_table[shade_index + 1*0 + 0] * 
02874         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02875         
02876         bot_sclr = 
02877     shadow_table[shade_index + 1*0 + 0] * 
02878         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02879         for (m = 1; m < num_materials; m++) {
02880              
02881         
02882     bot_clr += 
02883     shade_table[shade_index + 1*m + 0] * 
02884         weight_table[weight_index + m];
02885         
02886         bot_sclr += 
02887     shadow_table[shade_index + 1*m + 0] * 
02888         weight_table[weight_index + m];
02889         };
02890     shade_factor = bot_opc * slice_depth_cueing;
02891     
02892         bot_clr *= shade_factor;
02893     
02894             bot_sclr *= shade_factor;
02895                     }
02896                     
02897 #ifdef DEBUG
02898     if (ipixel == trace_pixel_ptr) {
02899         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02900         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02901         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02902         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02903         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02904     }
02905 #endif
02906 ;
02907                     
02908        acc_opc = bot_opc * wgtBL;
02909        acc_clr = (bot_clr + bot_sclr *
02910                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02911        
02912 #ifdef DEBUG
02913     if (ipixel == trace_pixel_ptr) {
02914         trace_opcBL = bot_opc;
02915         trace_rclrBL = bot_clr;
02916         trace_rsclrBL = bot_sclr;
02917     }
02918 #endif
02919 ;
02920                     
02921     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02922     
02923     
02924     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
02925     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
02926     
02927         
02928         
02929     bot_clr = 
02930     shade_table[shade_index + 1*0 + 0] * 
02931         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02932         
02933         bot_sclr = 
02934     shadow_table[shade_index + 1*0 + 0] * 
02935         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02936         for (m = 1; m < num_materials; m++) {
02937              
02938         
02939     bot_clr += 
02940     shade_table[shade_index + 1*m + 0] * 
02941         weight_table[weight_index + m];
02942         
02943         bot_sclr += 
02944     shadow_table[shade_index + 1*m + 0] * 
02945         weight_table[weight_index + m];
02946         };
02947     shade_factor = bot_opc * slice_depth_cueing;
02948     
02949         bot_clr *= shade_factor;
02950     
02951             bot_sclr *= shade_factor;
02952                     
02953        acc_opc += bot_opc * wgtBR;
02954        acc_clr += (bot_clr + bot_sclr *
02955                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
02956        
02957 #ifdef DEBUG
02958     if (ipixel == trace_pixel_ptr) {
02959         trace_opcBR = bot_opc;
02960         trace_rclrBR = bot_clr;
02961         trace_rsclrBR = bot_sclr;
02962     }
02963 #endif
02964 ;
02965                     
02966         COUNT_RESAMPLE;
02967         if (acc_opc > min_opacity) {
02968             COUNT_COMPOSITE;
02969             iopc = ipixel->opcflt;
02970 #           ifndef SKIP_ERT
02971                 ASSERT(iopc < max_opacity);
02972 #           endif
02973             iopc_inv = (float)1. - iopc;
02974             ipixel->clrflt += acc_clr * iopc_inv;
02975             iopc += acc_opc * iopc_inv;
02976             ipixel->opcflt = iopc;
02977             
02978 #ifdef DEBUG
02979     if (ipixel == trace_pixel_ptr) {
02980 #ifdef COMPUTE_SHADOW_BUFFER
02981         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02982 #else
02983         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02984 #endif
02985         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02986         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02987         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02988         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02989         printf("  %3.0f %3.0f\n", iopc*255., 
02990                ipixel->clrflt);
02991         
02992         printf("              ");
02993         printf("      %3.0f    ",trace_rsclrTL);
02994         printf("      %3.0f    ",trace_rsclrBL);
02995         printf("      %3.0f    ",trace_rsclrTR);
02996         printf("      %3.0f    ",trace_rsclrBR);
02997         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
02998         
02999     }
03000 #endif /* DEBUG */
03001 ;
03002 #           ifndef SKIP_ERT
03003                 if (iopc >= max_opacity) {
03004                     ASSERT(ipixel->lnk == 0);
03005                     ipixel->lnk = 1;
03006                 }
03007 #           endif
03008         };
03009                     ipixel += 1; shadow_pixel += 1;
03010                     ;
03011                     botRLEdata += 1 * voxel_istride;
03012                     count--;
03013                     SET_VOXELS_LOADED;
03014                 }
03015                 break;
03016             case BOT_NONZERO__BOT_NONZERO:
03017                 /* do the pixels in this run; bottom-left and
03018                    bottom-right voxels contribute */
03019                 while (count > 0) {
03020                     if (PIXEL_IS_OPAQUE(ipixel))
03021                         break;
03022                     if (!voxels_loaded) {
03023                         
03024     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03025     
03026     
03027     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03028     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03029     
03030         
03031         
03032     bot_clr = 
03033     shade_table[shade_index + 1*0 + 0] * 
03034         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03035         
03036         bot_sclr = 
03037     shadow_table[shade_index + 1*0 + 0] * 
03038         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03039         for (m = 1; m < num_materials; m++) {
03040              
03041         
03042     bot_clr += 
03043     shade_table[shade_index + 1*m + 0] * 
03044         weight_table[weight_index + m];
03045         
03046         bot_sclr += 
03047     shadow_table[shade_index + 1*m + 0] * 
03048         weight_table[weight_index + m];
03049         };
03050     shade_factor = bot_opc * slice_depth_cueing;
03051     
03052         bot_clr *= shade_factor;
03053     
03054             bot_sclr *= shade_factor;
03055                     }
03056                     
03057 #ifdef DEBUG
03058     if (ipixel == trace_pixel_ptr) {
03059         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03060         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03061         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03062         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03063         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03064     }
03065 #endif
03066 ;
03067                     
03068        acc_opc = bot_opc * wgtBL;
03069        acc_clr = (bot_clr + bot_sclr *
03070                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03071        
03072 #ifdef DEBUG
03073     if (ipixel == trace_pixel_ptr) {
03074         trace_opcBL = bot_opc;
03075         trace_rclrBL = bot_clr;
03076         trace_rsclrBL = bot_sclr;
03077     }
03078 #endif
03079 ;
03080                     
03081     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03082     
03083     
03084     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03085     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03086     
03087         
03088         
03089     bot_clr = 
03090     shade_table[shade_index + 1*0 + 0] * 
03091         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03092         
03093         bot_sclr = 
03094     shadow_table[shade_index + 1*0 + 0] * 
03095         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03096         for (m = 1; m < num_materials; m++) {
03097              
03098         
03099     bot_clr += 
03100     shade_table[shade_index + 1*m + 0] * 
03101         weight_table[weight_index + m];
03102         
03103         bot_sclr += 
03104     shadow_table[shade_index + 1*m + 0] * 
03105         weight_table[weight_index + m];
03106         };
03107     shade_factor = bot_opc * slice_depth_cueing;
03108     
03109         bot_clr *= shade_factor;
03110     
03111             bot_sclr *= shade_factor;
03112                     
03113        acc_opc += bot_opc * wgtBR;
03114        acc_clr += (bot_clr + bot_sclr *
03115                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03116        
03117 #ifdef DEBUG
03118     if (ipixel == trace_pixel_ptr) {
03119         trace_opcBR = bot_opc;
03120         trace_rclrBR = bot_clr;
03121         trace_rsclrBR = bot_sclr;
03122     }
03123 #endif
03124 ;
03125                     
03126         COUNT_RESAMPLE;
03127         if (acc_opc > min_opacity) {
03128             COUNT_COMPOSITE;
03129             iopc = ipixel->opcflt;
03130 #           ifndef SKIP_ERT
03131                 ASSERT(iopc < max_opacity);
03132 #           endif
03133             iopc_inv = (float)1. - iopc;
03134             ipixel->clrflt += acc_clr * iopc_inv;
03135             iopc += acc_opc * iopc_inv;
03136             ipixel->opcflt = iopc;
03137             
03138 #ifdef DEBUG
03139     if (ipixel == trace_pixel_ptr) {
03140 #ifdef COMPUTE_SHADOW_BUFFER
03141         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03142 #else
03143         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03144 #endif
03145         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03146         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03147         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03148         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03149         printf("  %3.0f %3.0f\n", iopc*255., 
03150                ipixel->clrflt);
03151         
03152         printf("              ");
03153         printf("      %3.0f    ",trace_rsclrTL);
03154         printf("      %3.0f    ",trace_rsclrBL);
03155         printf("      %3.0f    ",trace_rsclrTR);
03156         printf("      %3.0f    ",trace_rsclrBR);
03157         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
03158         
03159     }
03160 #endif /* DEBUG */
03161 ;
03162 #           ifndef SKIP_ERT
03163                 if (iopc >= max_opacity) {
03164                     ASSERT(ipixel->lnk == 0);
03165                     ipixel->lnk = 1;
03166                 }
03167 #           endif
03168         };
03169                     ipixel += 1; shadow_pixel += 1;
03170                     ;
03171                     botRLEdata += 1 * voxel_istride;
03172                     count--;
03173                     SET_VOXELS_LOADED;
03174                 }
03175                 break;
03176             case ALL_NONZERO__BOT_NONZERO:
03177                 /* first pixel: top-left, bottom-left and bottom-right
03178                    voxels contribute */
03179                 if (!voxels_loaded) {
03180                     
03181     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03182     
03183     
03184     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03185     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03186     
03187         
03188         
03189     top_clr = 
03190     shade_table[shade_index + 1*0 + 0] * 
03191         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03192         
03193         top_sclr = 
03194     shadow_table[shade_index + 1*0 + 0] * 
03195         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03196         for (m = 1; m < num_materials; m++) {
03197              
03198         
03199     top_clr += 
03200     shade_table[shade_index + 1*m + 0] * 
03201         weight_table[weight_index + m];
03202         
03203         top_sclr += 
03204     shadow_table[shade_index + 1*m + 0] * 
03205         weight_table[weight_index + m];
03206         };
03207     shade_factor = top_opc * slice_depth_cueing;
03208     
03209         top_clr *= shade_factor;
03210     
03211             top_sclr *= shade_factor;
03212                     
03213     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03214     
03215     
03216     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03217     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03218     
03219         
03220         
03221     bot_clr = 
03222     shade_table[shade_index + 1*0 + 0] * 
03223         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03224         
03225         bot_sclr = 
03226     shadow_table[shade_index + 1*0 + 0] * 
03227         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03228         for (m = 1; m < num_materials; m++) {
03229              
03230         
03231     bot_clr += 
03232     shade_table[shade_index + 1*m + 0] * 
03233         weight_table[weight_index + m];
03234         
03235         bot_sclr += 
03236     shadow_table[shade_index + 1*m + 0] * 
03237         weight_table[weight_index + m];
03238         };
03239     shade_factor = bot_opc * slice_depth_cueing;
03240     
03241         bot_clr *= shade_factor;
03242     
03243             bot_sclr *= shade_factor;
03244                 }
03245                 
03246 #ifdef DEBUG
03247     if (ipixel == trace_pixel_ptr) {
03248         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03249         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03250         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03251         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03252         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03253     }
03254 #endif
03255 ;
03256                 
03257        acc_opc = top_opc * wgtTL;
03258        acc_clr = (top_clr + top_sclr *
03259                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03260        
03261 #ifdef DEBUG
03262     if (ipixel == trace_pixel_ptr) {
03263         trace_opcTL = top_opc;
03264         trace_rclrTL = top_clr;
03265         trace_rsclrTL = top_sclr;
03266     }
03267 #endif
03268 ;
03269                 
03270        acc_opc += bot_opc * wgtBL;
03271        acc_clr += (bot_clr + bot_sclr *
03272                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03273        
03274 #ifdef DEBUG
03275     if (ipixel == trace_pixel_ptr) {
03276         trace_opcBL = bot_opc;
03277         trace_rclrBL = bot_clr;
03278         trace_rsclrBL = bot_sclr;
03279     }
03280 #endif
03281 ;
03282                 
03283     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03284     
03285     
03286     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03287     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03288     
03289         
03290         
03291     bot_clr = 
03292     shade_table[shade_index + 1*0 + 0] * 
03293         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03294         
03295         bot_sclr = 
03296     shadow_table[shade_index + 1*0 + 0] * 
03297         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03298         for (m = 1; m < num_materials; m++) {
03299              
03300         
03301     bot_clr += 
03302     shade_table[shade_index + 1*m + 0] * 
03303         weight_table[weight_index + m];
03304         
03305         bot_sclr += 
03306     shadow_table[shade_index + 1*m + 0] * 
03307         weight_table[weight_index + m];
03308         };
03309     shade_factor = bot_opc * slice_depth_cueing;
03310     
03311         bot_clr *= shade_factor;
03312     
03313             bot_sclr *= shade_factor;
03314                 
03315        acc_opc += bot_opc * wgtBR;
03316        acc_clr += (bot_clr + bot_sclr *
03317                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03318        
03319 #ifdef DEBUG
03320     if (ipixel == trace_pixel_ptr) {
03321         trace_opcBR = bot_opc;
03322         trace_rclrBR = bot_clr;
03323         trace_rsclrBR = bot_sclr;
03324     }
03325 #endif
03326 ;
03327                 
03328         COUNT_RESAMPLE;
03329         if (acc_opc > min_opacity) {
03330             COUNT_COMPOSITE;
03331             iopc = ipixel->opcflt;
03332 #           ifndef SKIP_ERT
03333                 ASSERT(iopc < max_opacity);
03334 #           endif
03335             iopc_inv = (float)1. - iopc;
03336             ipixel->clrflt += acc_clr * iopc_inv;
03337             iopc += acc_opc * iopc_inv;
03338             ipixel->opcflt = iopc;
03339             
03340 #ifdef DEBUG
03341     if (ipixel == trace_pixel_ptr) {
03342 #ifdef COMPUTE_SHADOW_BUFFER
03343         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03344 #else
03345         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03346 #endif
03347         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03348         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03349         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03350         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03351         printf("  %3.0f %3.0f\n", iopc*255., 
03352                ipixel->clrflt);
03353         
03354         printf("              ");
03355         printf("      %3.0f    ",trace_rsclrTL);
03356         printf("      %3.0f    ",trace_rsclrBL);
03357         printf("      %3.0f    ",trace_rsclrTR);
03358         printf("      %3.0f    ",trace_rsclrBR);
03359         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
03360         
03361     }
03362 #endif /* DEBUG */
03363 ;
03364 #           ifndef SKIP_ERT
03365                 if (iopc >= max_opacity) {
03366                     ASSERT(ipixel->lnk == 0);
03367                     ipixel->lnk = 1;
03368                 }
03369 #           endif
03370         };
03371                 ipixel += 1; shadow_pixel += 1;
03372                 ;
03373                 botRLEdata += 1 * voxel_istride;
03374                 count--;
03375                 SET_VOXELS_LOADED;
03376 
03377                 /* do the rest of the pixels in this run;
03378                    bottom-left and bottom-right voxels contribute */
03379                 while (count > 0) {
03380                     if (PIXEL_IS_OPAQUE(ipixel))
03381                         break;
03382                     if (!voxels_loaded) {
03383                         
03384     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03385     
03386     
03387     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03388     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03389     
03390         
03391         
03392     bot_clr = 
03393     shade_table[shade_index + 1*0 + 0] * 
03394         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03395         
03396         bot_sclr = 
03397     shadow_table[shade_index + 1*0 + 0] * 
03398         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03399         for (m = 1; m < num_materials; m++) {
03400              
03401         
03402     bot_clr += 
03403     shade_table[shade_index + 1*m + 0] * 
03404         weight_table[weight_index + m];
03405         
03406         bot_sclr += 
03407     shadow_table[shade_index + 1*m + 0] * 
03408         weight_table[weight_index + m];
03409         };
03410     shade_factor = bot_opc * slice_depth_cueing;
03411     
03412         bot_clr *= shade_factor;
03413     
03414             bot_sclr *= shade_factor;
03415                     }
03416                     
03417 #ifdef DEBUG
03418     if (ipixel == trace_pixel_ptr) {
03419         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03420         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03421         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03422         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03423         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03424     }
03425 #endif
03426 ;
03427                     
03428        acc_opc = bot_opc * wgtBL;
03429        acc_clr = (bot_clr + bot_sclr *
03430                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03431        
03432 #ifdef DEBUG
03433     if (ipixel == trace_pixel_ptr) {
03434         trace_opcBL = bot_opc;
03435         trace_rclrBL = bot_clr;
03436         trace_rsclrBL = bot_sclr;
03437     }
03438 #endif
03439 ;
03440                     
03441     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03442     
03443     
03444     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03445     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03446     
03447         
03448         
03449     bot_clr = 
03450     shade_table[shade_index + 1*0 + 0] * 
03451         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03452         
03453         bot_sclr = 
03454     shadow_table[shade_index + 1*0 + 0] * 
03455         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03456         for (m = 1; m < num_materials; m++) {
03457              
03458         
03459     bot_clr += 
03460     shade_table[shade_index + 1*m + 0] * 
03461         weight_table[weight_index + m];
03462         
03463         bot_sclr += 
03464     shadow_table[shade_index + 1*m + 0] * 
03465         weight_table[weight_index + m];
03466         };
03467     shade_factor = bot_opc * slice_depth_cueing;
03468     
03469         bot_clr *= shade_factor;
03470     
03471             bot_sclr *= shade_factor;
03472                     
03473        acc_opc += bot_opc * wgtBR;
03474        acc_clr += (bot_clr + bot_sclr *
03475                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03476        
03477 #ifdef DEBUG
03478     if (ipixel == trace_pixel_ptr) {
03479         trace_opcBR = bot_opc;
03480         trace_rclrBR = bot_clr;
03481         trace_rsclrBR = bot_sclr;
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             ipixel->clrflt += acc_clr * iopc_inv;
03495             iopc += acc_opc * iopc_inv;
03496             ipixel->opcflt = iopc;
03497             
03498 #ifdef DEBUG
03499     if (ipixel == trace_pixel_ptr) {
03500 #ifdef COMPUTE_SHADOW_BUFFER
03501         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03502 #else
03503         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03504 #endif
03505         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03506         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03507         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03508         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03509         printf("  %3.0f %3.0f\n", iopc*255., 
03510                ipixel->clrflt);
03511         
03512         printf("              ");
03513         printf("      %3.0f    ",trace_rsclrTL);
03514         printf("      %3.0f    ",trace_rsclrBL);
03515         printf("      %3.0f    ",trace_rsclrTR);
03516         printf("      %3.0f    ",trace_rsclrBR);
03517         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
03518         
03519     }
03520 #endif /* DEBUG */
03521 ;
03522 #           ifndef SKIP_ERT
03523                 if (iopc >= max_opacity) {
03524                     ASSERT(ipixel->lnk == 0);
03525                     ipixel->lnk = 1;
03526                 }
03527 #           endif
03528         };
03529                     ipixel += 1; shadow_pixel += 1;
03530                     ;
03531                     botRLEdata += 1 * voxel_istride;
03532                     count--;
03533                     SET_VOXELS_LOADED;
03534                 }
03535                 break;
03536             case ALL_ZERO__ALL_NONZERO:
03537                 /* first pixel: top-right and bottom-right voxels contribute */
03538                 
03539     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03540     
03541     
03542     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03543     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03544     
03545         
03546         
03547     top_clr = 
03548     shade_table[shade_index + 1*0 + 0] * 
03549         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03550         
03551         top_sclr = 
03552     shadow_table[shade_index + 1*0 + 0] * 
03553         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03554         for (m = 1; m < num_materials; m++) {
03555              
03556         
03557     top_clr += 
03558     shade_table[shade_index + 1*m + 0] * 
03559         weight_table[weight_index + m];
03560         
03561         top_sclr += 
03562     shadow_table[shade_index + 1*m + 0] * 
03563         weight_table[weight_index + m];
03564         };
03565     shade_factor = top_opc * slice_depth_cueing;
03566     
03567         top_clr *= shade_factor;
03568     
03569             top_sclr *= shade_factor;
03570                 
03571     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03572     
03573     
03574     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03575     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03576     
03577         
03578         
03579     bot_clr = 
03580     shade_table[shade_index + 1*0 + 0] * 
03581         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03582         
03583         bot_sclr = 
03584     shadow_table[shade_index + 1*0 + 0] * 
03585         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03586         for (m = 1; m < num_materials; m++) {
03587              
03588         
03589     bot_clr += 
03590     shade_table[shade_index + 1*m + 0] * 
03591         weight_table[weight_index + m];
03592         
03593         bot_sclr += 
03594     shadow_table[shade_index + 1*m + 0] * 
03595         weight_table[weight_index + m];
03596         };
03597     shade_factor = bot_opc * slice_depth_cueing;
03598     
03599         bot_clr *= shade_factor;
03600     
03601             bot_sclr *= shade_factor;
03602                 
03603 #ifdef DEBUG
03604     if (ipixel == trace_pixel_ptr) {
03605         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03606         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03607         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03608         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03609         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03610     }
03611 #endif
03612 ;
03613                 
03614        acc_opc = top_opc * wgtTR;
03615        acc_clr = (top_clr + top_sclr *
03616                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03617        
03618 #ifdef DEBUG
03619     if (ipixel == trace_pixel_ptr) {
03620         trace_opcTR = top_opc;
03621         trace_rclrTR = top_clr;
03622         trace_rsclrTR = top_sclr;
03623     }
03624 #endif
03625 ;
03626                 
03627        acc_opc += bot_opc * wgtBR;
03628        acc_clr += (bot_clr + bot_sclr *
03629                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03630        
03631 #ifdef DEBUG
03632     if (ipixel == trace_pixel_ptr) {
03633         trace_opcBR = bot_opc;
03634         trace_rclrBR = bot_clr;
03635         trace_rsclrBR = bot_sclr;
03636     }
03637 #endif
03638 ;
03639                 
03640         COUNT_RESAMPLE;
03641         if (acc_opc > min_opacity) {
03642             COUNT_COMPOSITE;
03643             iopc = ipixel->opcflt;
03644 #           ifndef SKIP_ERT
03645                 ASSERT(iopc < max_opacity);
03646 #           endif
03647             iopc_inv = (float)1. - iopc;
03648             ipixel->clrflt += acc_clr * iopc_inv;
03649             iopc += acc_opc * iopc_inv;
03650             ipixel->opcflt = iopc;
03651             
03652 #ifdef DEBUG
03653     if (ipixel == trace_pixel_ptr) {
03654 #ifdef COMPUTE_SHADOW_BUFFER
03655         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03656 #else
03657         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03658 #endif
03659         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03660         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03661         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03662         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03663         printf("  %3.0f %3.0f\n", iopc*255., 
03664                ipixel->clrflt);
03665         
03666         printf("              ");
03667         printf("      %3.0f    ",trace_rsclrTL);
03668         printf("      %3.0f    ",trace_rsclrBL);
03669         printf("      %3.0f    ",trace_rsclrTR);
03670         printf("      %3.0f    ",trace_rsclrBR);
03671         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
03672         
03673     }
03674 #endif /* DEBUG */
03675 ;
03676 #           ifndef SKIP_ERT
03677                 if (iopc >= max_opacity) {
03678                     ASSERT(ipixel->lnk == 0);
03679                     ipixel->lnk = 1;
03680                 }
03681 #           endif
03682         };
03683                 ipixel += 1; shadow_pixel += 1;
03684                 topRLEdata += 1 * voxel_istride;
03685                 botRLEdata += 1 * voxel_istride;
03686                 count--;
03687                 SET_VOXELS_LOADED;
03688 
03689                 /* do the rest of the pixels in this run;
03690                    all four voxels contribute */
03691                 while (count > 0) {
03692                     if (PIXEL_IS_OPAQUE(ipixel))
03693                         break;
03694                     if (!voxels_loaded) {
03695                         
03696     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03697     
03698     
03699     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03700     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03701     
03702         
03703         
03704     top_clr = 
03705     shade_table[shade_index + 1*0 + 0] * 
03706         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03707         
03708         top_sclr = 
03709     shadow_table[shade_index + 1*0 + 0] * 
03710         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03711         for (m = 1; m < num_materials; m++) {
03712              
03713         
03714     top_clr += 
03715     shade_table[shade_index + 1*m + 0] * 
03716         weight_table[weight_index + m];
03717         
03718         top_sclr += 
03719     shadow_table[shade_index + 1*m + 0] * 
03720         weight_table[weight_index + m];
03721         };
03722     shade_factor = top_opc * slice_depth_cueing;
03723     
03724         top_clr *= shade_factor;
03725     
03726             top_sclr *= shade_factor;
03727                         
03728     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03729     
03730     
03731     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
03732     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03733     
03734         
03735         
03736     bot_clr = 
03737     shade_table[shade_index + 1*0 + 0] * 
03738         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03739         
03740         bot_sclr = 
03741     shadow_table[shade_index + 1*0 + 0] * 
03742         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03743         for (m = 1; m < num_materials; m++) {
03744              
03745         
03746     bot_clr += 
03747     shade_table[shade_index + 1*m + 0] * 
03748         weight_table[weight_index + m];
03749         
03750         bot_sclr += 
03751     shadow_table[shade_index + 1*m + 0] * 
03752         weight_table[weight_index + m];
03753         };
03754     shade_factor = bot_opc * slice_depth_cueing;
03755     
03756         bot_clr *= shade_factor;
03757     
03758             bot_sclr *= shade_factor;
03759                     }
03760                     
03761 #ifdef DEBUG
03762     if (ipixel == trace_pixel_ptr) {
03763         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03764         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03765         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03766         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03767         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03768     }
03769 #endif
03770 ;
03771                     
03772        acc_opc = top_opc * wgtTL;
03773        acc_clr = (top_clr + top_sclr *
03774                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03775        
03776 #ifdef DEBUG
03777     if (ipixel == trace_pixel_ptr) {
03778         trace_opcTL = top_opc;
03779         trace_rclrTL = top_clr;
03780         trace_rsclrTL = top_sclr;
03781     }
03782 #endif
03783 ;
03784                     
03785        acc_opc += bot_opc * wgtBL;
03786        acc_clr += (bot_clr + bot_sclr *
03787                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03788        
03789 #ifdef DEBUG
03790     if (ipixel == trace_pixel_ptr) {
03791         trace_opcBL = bot_opc;
03792         trace_rclrBL = bot_clr;
03793         trace_rsclrBL = bot_sclr;
03794     }
03795 #endif
03796 ;
03797                     
03798     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03799     
03800     
03801     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
03802     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03803     
03804         
03805         
03806     top_clr = 
03807     shade_table[shade_index + 1*0 + 0] * 
03808         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03809         
03810         top_sclr = 
03811     shadow_table[shade_index + 1*0 + 0] * 
03812         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03813         for (m = 1; m < num_materials; m++) {
03814              
03815         
03816     top_clr += 
03817     shade_table[shade_index + 1*m + 0] * 
03818         weight_table[weight_index + m];
03819         
03820         top_sclr += 
03821     shadow_table[shade_index + 1*m + 0] * 
03822         weight_table[weight_index + m];
03823         };
03824     shade_factor = top_opc * slice_depth_cueing;
03825     
03826         top_clr *= shade_factor;
03827     
03828             top_sclr *= shade_factor;
03829                     
03830     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03831     
03832     
03833     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
03834     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03835     
03836         
03837         
03838     bot_clr = 
03839     shade_table[shade_index + 1*0 + 0] * 
03840         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03841         
03842         bot_sclr = 
03843     shadow_table[shade_index + 1*0 + 0] * 
03844         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03845         for (m = 1; m < num_materials; m++) {
03846              
03847         
03848     bot_clr += 
03849     shade_table[shade_index + 1*m + 0] * 
03850         weight_table[weight_index + m];
03851         
03852         bot_sclr += 
03853     shadow_table[shade_index + 1*m + 0] * 
03854         weight_table[weight_index + m];
03855         };
03856     shade_factor = bot_opc * slice_depth_cueing;
03857     
03858         bot_clr *= shade_factor;
03859     
03860             bot_sclr *= shade_factor;
03861                     
03862        acc_opc += top_opc * wgtTR;
03863        acc_clr += (top_clr + top_sclr *
03864                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03865        
03866 #ifdef DEBUG
03867     if (ipixel == trace_pixel_ptr) {
03868         trace_opcTR = top_opc;
03869         trace_rclrTR = top_clr;
03870         trace_rsclrTR = top_sclr;
03871     }
03872 #endif
03873 ;
03874                     
03875        acc_opc += bot_opc * wgtBR;
03876        acc_clr += (bot_clr + bot_sclr *
03877                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03878        
03879 #ifdef DEBUG
03880     if (ipixel == trace_pixel_ptr) {
03881         trace_opcBR = bot_opc;
03882         trace_rclrBR = bot_clr;
03883         trace_rsclrBR = bot_sclr;
03884     }
03885 #endif
03886 ;
03887                     
03888         COUNT_RESAMPLE;
03889         if (acc_opc > min_opacity) {
03890             COUNT_COMPOSITE;
03891             iopc = ipixel->opcflt;
03892 #           ifndef SKIP_ERT
03893                 ASSERT(iopc < max_opacity);
03894 #           endif
03895             iopc_inv = (float)1. - iopc;
03896             ipixel->clrflt += acc_clr * iopc_inv;
03897             iopc += acc_opc * iopc_inv;
03898             ipixel->opcflt = iopc;
03899             
03900 #ifdef DEBUG
03901     if (ipixel == trace_pixel_ptr) {
03902 #ifdef COMPUTE_SHADOW_BUFFER
03903         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03904 #else
03905         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03906 #endif
03907         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03908         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03909         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03910         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03911         printf("  %3.0f %3.0f\n", iopc*255., 
03912                ipixel->clrflt);
03913         
03914         printf("              ");
03915         printf("      %3.0f    ",trace_rsclrTL);
03916         printf("      %3.0f    ",trace_rsclrBL);
03917         printf("      %3.0f    ",trace_rsclrTR);
03918         printf("      %3.0f    ",trace_rsclrBR);
03919         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
03920         
03921     }
03922 #endif /* DEBUG */
03923 ;
03924 #           ifndef SKIP_ERT
03925                 if (iopc >= max_opacity) {
03926                     ASSERT(ipixel->lnk == 0);
03927                     ipixel->lnk = 1;
03928                 }
03929 #           endif
03930         };
03931                     ipixel += 1; shadow_pixel += 1;
03932                     topRLEdata += 1 * voxel_istride;
03933                     botRLEdata += 1 * voxel_istride;
03934                     count--;
03935                     SET_VOXELS_LOADED;
03936                 }
03937                 break;
03938             case TOP_NONZERO__ALL_NONZERO:
03939                 /* first pixel: top-left, top-right and bottom-right
03940                    voxels contribute */
03941                 if (!voxels_loaded) {
03942                     
03943     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03944     
03945     
03946     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
03947     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03948     
03949         
03950         
03951     top_clr = 
03952     shade_table[shade_index + 1*0 + 0] * 
03953         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03954         
03955         top_sclr = 
03956     shadow_table[shade_index + 1*0 + 0] * 
03957         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03958         for (m = 1; m < num_materials; m++) {
03959              
03960         
03961     top_clr += 
03962     shade_table[shade_index + 1*m + 0] * 
03963         weight_table[weight_index + m];
03964         
03965         top_sclr += 
03966     shadow_table[shade_index + 1*m + 0] * 
03967         weight_table[weight_index + m];
03968         };
03969     shade_factor = top_opc * slice_depth_cueing;
03970     
03971         top_clr *= shade_factor;
03972     
03973             top_sclr *= shade_factor;
03974                 }
03975                 
03976 #ifdef DEBUG
03977     if (ipixel == trace_pixel_ptr) {
03978         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03979         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03980         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03981         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03982         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03983     }
03984 #endif
03985 ;
03986                 
03987        acc_opc = top_opc * wgtTL;
03988        acc_clr = (top_clr + top_sclr *
03989                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03990        
03991 #ifdef DEBUG
03992     if (ipixel == trace_pixel_ptr) {
03993         trace_opcTL = top_opc;
03994         trace_rclrTL = top_clr;
03995         trace_rsclrTL = top_sclr;
03996     }
03997 #endif
03998 ;
03999                 
04000     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04001     
04002     
04003     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04004     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04005     
04006         
04007         
04008     top_clr = 
04009     shade_table[shade_index + 1*0 + 0] * 
04010         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04011         
04012         top_sclr = 
04013     shadow_table[shade_index + 1*0 + 0] * 
04014         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04015         for (m = 1; m < num_materials; m++) {
04016              
04017         
04018     top_clr += 
04019     shade_table[shade_index + 1*m + 0] * 
04020         weight_table[weight_index + m];
04021         
04022         top_sclr += 
04023     shadow_table[shade_index + 1*m + 0] * 
04024         weight_table[weight_index + m];
04025         };
04026     shade_factor = top_opc * slice_depth_cueing;
04027     
04028         top_clr *= shade_factor;
04029     
04030             top_sclr *= shade_factor;
04031                 
04032     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04033     
04034     
04035     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04036     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04037     
04038         
04039         
04040     bot_clr = 
04041     shade_table[shade_index + 1*0 + 0] * 
04042         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04043         
04044         bot_sclr = 
04045     shadow_table[shade_index + 1*0 + 0] * 
04046         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04047         for (m = 1; m < num_materials; m++) {
04048              
04049         
04050     bot_clr += 
04051     shade_table[shade_index + 1*m + 0] * 
04052         weight_table[weight_index + m];
04053         
04054         bot_sclr += 
04055     shadow_table[shade_index + 1*m + 0] * 
04056         weight_table[weight_index + m];
04057         };
04058     shade_factor = bot_opc * slice_depth_cueing;
04059     
04060         bot_clr *= shade_factor;
04061     
04062             bot_sclr *= shade_factor;
04063                 
04064        acc_opc += top_opc * wgtTR;
04065        acc_clr += (top_clr + top_sclr *
04066                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
04067        
04068 #ifdef DEBUG
04069     if (ipixel == trace_pixel_ptr) {
04070         trace_opcTR = top_opc;
04071         trace_rclrTR = top_clr;
04072         trace_rsclrTR = top_sclr;
04073     }
04074 #endif
04075 ;
04076                 
04077        acc_opc += bot_opc * wgtBR;
04078        acc_clr += (bot_clr + bot_sclr *
04079                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04080        
04081 #ifdef DEBUG
04082     if (ipixel == trace_pixel_ptr) {
04083         trace_opcBR = bot_opc;
04084         trace_rclrBR = bot_clr;
04085         trace_rsclrBR = bot_sclr;
04086     }
04087 #endif
04088 ;
04089                 
04090         COUNT_RESAMPLE;
04091         if (acc_opc > min_opacity) {
04092             COUNT_COMPOSITE;
04093             iopc = ipixel->opcflt;
04094 #           ifndef SKIP_ERT
04095                 ASSERT(iopc < max_opacity);
04096 #           endif
04097             iopc_inv = (float)1. - iopc;
04098             ipixel->clrflt += acc_clr * iopc_inv;
04099             iopc += acc_opc * iopc_inv;
04100             ipixel->opcflt = iopc;
04101             
04102 #ifdef DEBUG
04103     if (ipixel == trace_pixel_ptr) {
04104 #ifdef COMPUTE_SHADOW_BUFFER
04105         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04106 #else
04107         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04108 #endif
04109         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04110         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04111         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04112         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04113         printf("  %3.0f %3.0f\n", iopc*255., 
04114                ipixel->clrflt);
04115         
04116         printf("              ");
04117         printf("      %3.0f    ",trace_rsclrTL);
04118         printf("      %3.0f    ",trace_rsclrBL);
04119         printf("      %3.0f    ",trace_rsclrTR);
04120         printf("      %3.0f    ",trace_rsclrBR);
04121         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
04122         
04123     }
04124 #endif /* DEBUG */
04125 ;
04126 #           ifndef SKIP_ERT
04127                 if (iopc >= max_opacity) {
04128                     ASSERT(ipixel->lnk == 0);
04129                     ipixel->lnk = 1;
04130                 }
04131 #           endif
04132         };
04133                 ipixel += 1; shadow_pixel += 1;
04134                 topRLEdata += 1 * voxel_istride;
04135                 botRLEdata += 1 * voxel_istride;
04136                 count--;
04137                 SET_VOXELS_LOADED;
04138                     
04139                 /* do the rest of the pixels in this run;
04140                    all four voxels contribute */
04141                 while (count > 0) {
04142                     if (PIXEL_IS_OPAQUE(ipixel))
04143                         break;
04144                     if (!voxels_loaded) {
04145                         
04146     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04147     
04148     
04149     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04150     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04151     
04152         
04153         
04154     top_clr = 
04155     shade_table[shade_index + 1*0 + 0] * 
04156         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04157         
04158         top_sclr = 
04159     shadow_table[shade_index + 1*0 + 0] * 
04160         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04161         for (m = 1; m < num_materials; m++) {
04162              
04163         
04164     top_clr += 
04165     shade_table[shade_index + 1*m + 0] * 
04166         weight_table[weight_index + m];
04167         
04168         top_sclr += 
04169     shadow_table[shade_index + 1*m + 0] * 
04170         weight_table[weight_index + m];
04171         };
04172     shade_factor = top_opc * slice_depth_cueing;
04173     
04174         top_clr *= shade_factor;
04175     
04176             top_sclr *= shade_factor;
04177                         
04178     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04179     
04180     
04181     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04182     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04183     
04184         
04185         
04186     bot_clr = 
04187     shade_table[shade_index + 1*0 + 0] * 
04188         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04189         
04190         bot_sclr = 
04191     shadow_table[shade_index + 1*0 + 0] * 
04192         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04193         for (m = 1; m < num_materials; m++) {
04194              
04195         
04196     bot_clr += 
04197     shade_table[shade_index + 1*m + 0] * 
04198         weight_table[weight_index + m];
04199         
04200         bot_sclr += 
04201     shadow_table[shade_index + 1*m + 0] * 
04202         weight_table[weight_index + m];
04203         };
04204     shade_factor = bot_opc * slice_depth_cueing;
04205     
04206         bot_clr *= shade_factor;
04207     
04208             bot_sclr *= shade_factor;
04209                     }
04210                     
04211 #ifdef DEBUG
04212     if (ipixel == trace_pixel_ptr) {
04213         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04214         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04215         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04216         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04217         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04218     }
04219 #endif
04220 ;
04221                     
04222        acc_opc = top_opc * wgtTL;
04223        acc_clr = (top_clr + top_sclr *
04224                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
04225        
04226 #ifdef DEBUG
04227     if (ipixel == trace_pixel_ptr) {
04228         trace_opcTL = top_opc;
04229         trace_rclrTL = top_clr;
04230         trace_rsclrTL = top_sclr;
04231     }
04232 #endif
04233 ;
04234                     
04235        acc_opc += bot_opc * wgtBL;
04236        acc_clr += (bot_clr + bot_sclr *
04237                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04238        
04239 #ifdef DEBUG
04240     if (ipixel == trace_pixel_ptr) {
04241         trace_opcBL = bot_opc;
04242         trace_rclrBL = bot_clr;
04243         trace_rsclrBL = bot_sclr;
04244     }
04245 #endif
04246 ;
04247                     
04248     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04249     
04250     
04251     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04252     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04253     
04254         
04255         
04256     top_clr = 
04257     shade_table[shade_index + 1*0 + 0] * 
04258         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04259         
04260         top_sclr = 
04261     shadow_table[shade_index + 1*0 + 0] * 
04262         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04263         for (m = 1; m < num_materials; m++) {
04264              
04265         
04266     top_clr += 
04267     shade_table[shade_index + 1*m + 0] * 
04268         weight_table[weight_index + m];
04269         
04270         top_sclr += 
04271     shadow_table[shade_index + 1*m + 0] * 
04272         weight_table[weight_index + m];
04273         };
04274     shade_factor = top_opc * slice_depth_cueing;
04275     
04276         top_clr *= shade_factor;
04277     
04278             top_sclr *= shade_factor;
04279                     
04280     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04281     
04282     
04283     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04284     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04285     
04286         
04287         
04288     bot_clr = 
04289     shade_table[shade_index + 1*0 + 0] * 
04290         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04291         
04292         bot_sclr = 
04293     shadow_table[shade_index + 1*0 + 0] * 
04294         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04295         for (m = 1; m < num_materials; m++) {
04296              
04297         
04298     bot_clr += 
04299     shade_table[shade_index + 1*m + 0] * 
04300         weight_table[weight_index + m];
04301         
04302         bot_sclr += 
04303     shadow_table[shade_index + 1*m + 0] * 
04304         weight_table[weight_index + m];
04305         };
04306     shade_factor = bot_opc * slice_depth_cueing;
04307     
04308         bot_clr *= shade_factor;
04309     
04310             bot_sclr *= shade_factor;
04311                     
04312        acc_opc += top_opc * wgtTR;
04313        acc_clr += (top_clr + top_sclr *
04314                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
04315        
04316 #ifdef DEBUG
04317     if (ipixel == trace_pixel_ptr) {
04318         trace_opcTR = top_opc;
04319         trace_rclrTR = top_clr;
04320         trace_rsclrTR = top_sclr;
04321     }
04322 #endif
04323 ;
04324                     
04325        acc_opc += bot_opc * wgtBR;
04326        acc_clr += (bot_clr + bot_sclr *
04327                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04328        
04329 #ifdef DEBUG
04330     if (ipixel == trace_pixel_ptr) {
04331         trace_opcBR = bot_opc;
04332         trace_rclrBR = bot_clr;
04333         trace_rsclrBR = bot_sclr;
04334     }
04335 #endif
04336 ;
04337                     
04338         COUNT_RESAMPLE;
04339         if (acc_opc > min_opacity) {
04340             COUNT_COMPOSITE;
04341             iopc = ipixel->opcflt;
04342 #           ifndef SKIP_ERT
04343                 ASSERT(iopc < max_opacity);
04344 #           endif
04345             iopc_inv = (float)1. - iopc;
04346             ipixel->clrflt += acc_clr * iopc_inv;
04347             iopc += acc_opc * iopc_inv;
04348             ipixel->opcflt = iopc;
04349             
04350 #ifdef DEBUG
04351     if (ipixel == trace_pixel_ptr) {
04352 #ifdef COMPUTE_SHADOW_BUFFER
04353         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04354 #else
04355         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04356 #endif
04357         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04358         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04359         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04360         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04361         printf("  %3.0f %3.0f\n", iopc*255., 
04362                ipixel->clrflt);
04363         
04364         printf("              ");
04365         printf("      %3.0f    ",trace_rsclrTL);
04366         printf("      %3.0f    ",trace_rsclrBL);
04367         printf("      %3.0f    ",trace_rsclrTR);
04368         printf("      %3.0f    ",trace_rsclrBR);
04369         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
04370         
04371     }
04372 #endif /* DEBUG */
04373 ;
04374 #           ifndef SKIP_ERT
04375                 if (iopc >= max_opacity) {
04376                     ASSERT(ipixel->lnk == 0);
04377                     ipixel->lnk = 1;
04378                 }
04379 #           endif
04380         };
04381                     ipixel += 1; shadow_pixel += 1;
04382                     topRLEdata += 1 * voxel_istride;
04383                     botRLEdata += 1 * voxel_istride;
04384                     count--;
04385                     SET_VOXELS_LOADED;
04386                 }
04387                 break;
04388             case BOT_NONZERO__ALL_NONZERO:
04389                 /* first pixel: bottom-left, top-right and bottom-right
04390                    voxels contribute */
04391                 if (!voxels_loaded) {
04392                     
04393     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04394     
04395     
04396     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04397     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04398     
04399         
04400         
04401     bot_clr = 
04402     shade_table[shade_index + 1*0 + 0] * 
04403         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04404         
04405         bot_sclr = 
04406     shadow_table[shade_index + 1*0 + 0] * 
04407         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04408         for (m = 1; m < num_materials; m++) {
04409              
04410         
04411     bot_clr += 
04412     shade_table[shade_index + 1*m + 0] * 
04413         weight_table[weight_index + m];
04414         
04415         bot_sclr += 
04416     shadow_table[shade_index + 1*m + 0] * 
04417         weight_table[weight_index + m];
04418         };
04419     shade_factor = bot_opc * slice_depth_cueing;
04420     
04421         bot_clr *= shade_factor;
04422     
04423             bot_sclr *= shade_factor;
04424                 }
04425                 
04426 #ifdef DEBUG
04427     if (ipixel == trace_pixel_ptr) {
04428         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04429         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04430         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04431         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04432         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04433     }
04434 #endif
04435 ;
04436                 
04437        acc_opc = bot_opc * wgtBL;
04438        acc_clr = (bot_clr + bot_sclr *
04439                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04440        
04441 #ifdef DEBUG
04442     if (ipixel == trace_pixel_ptr) {
04443         trace_opcBL = bot_opc;
04444         trace_rclrBL = bot_clr;
04445         trace_rsclrBL = bot_sclr;
04446     }
04447 #endif
04448 ;
04449                 
04450     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04451     
04452     
04453     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04454     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04455     
04456         
04457         
04458     top_clr = 
04459     shade_table[shade_index + 1*0 + 0] * 
04460         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04461         
04462         top_sclr = 
04463     shadow_table[shade_index + 1*0 + 0] * 
04464         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04465         for (m = 1; m < num_materials; m++) {
04466              
04467         
04468     top_clr += 
04469     shade_table[shade_index + 1*m + 0] * 
04470         weight_table[weight_index + m];
04471         
04472         top_sclr += 
04473     shadow_table[shade_index + 1*m + 0] * 
04474         weight_table[weight_index + m];
04475         };
04476     shade_factor = top_opc * slice_depth_cueing;
04477     
04478         top_clr *= shade_factor;
04479     
04480             top_sclr *= shade_factor;
04481                 
04482     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04483     
04484     
04485     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04486     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04487     
04488         
04489         
04490     bot_clr = 
04491     shade_table[shade_index + 1*0 + 0] * 
04492         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04493         
04494         bot_sclr = 
04495     shadow_table[shade_index + 1*0 + 0] * 
04496         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04497         for (m = 1; m < num_materials; m++) {
04498              
04499         
04500     bot_clr += 
04501     shade_table[shade_index + 1*m + 0] * 
04502         weight_table[weight_index + m];
04503         
04504         bot_sclr += 
04505     shadow_table[shade_index + 1*m + 0] * 
04506         weight_table[weight_index + m];
04507         };
04508     shade_factor = bot_opc * slice_depth_cueing;
04509     
04510         bot_clr *= shade_factor;
04511     
04512             bot_sclr *= shade_factor;
04513                 
04514        acc_opc += top_opc * wgtTR;
04515        acc_clr += (top_clr + top_sclr *
04516                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
04517        
04518 #ifdef DEBUG
04519     if (ipixel == trace_pixel_ptr) {
04520         trace_opcTR = top_opc;
04521         trace_rclrTR = top_clr;
04522         trace_rsclrTR = top_sclr;
04523     }
04524 #endif
04525 ;
04526                 
04527        acc_opc += bot_opc * wgtBR;
04528        acc_clr += (bot_clr + bot_sclr *
04529                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04530        
04531 #ifdef DEBUG
04532     if (ipixel == trace_pixel_ptr) {
04533         trace_opcBR = bot_opc;
04534         trace_rclrBR = bot_clr;
04535         trace_rsclrBR = bot_sclr;
04536     }
04537 #endif
04538 ;
04539                 
04540         COUNT_RESAMPLE;
04541         if (acc_opc > min_opacity) {
04542             COUNT_COMPOSITE;
04543             iopc = ipixel->opcflt;
04544 #           ifndef SKIP_ERT
04545                 ASSERT(iopc < max_opacity);
04546 #           endif
04547             iopc_inv = (float)1. - iopc;
04548             ipixel->clrflt += acc_clr * iopc_inv;
04549             iopc += acc_opc * iopc_inv;
04550             ipixel->opcflt = iopc;
04551             
04552 #ifdef DEBUG
04553     if (ipixel == trace_pixel_ptr) {
04554 #ifdef COMPUTE_SHADOW_BUFFER
04555         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04556 #else
04557         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04558 #endif
04559         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04560         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04561         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04562         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04563         printf("  %3.0f %3.0f\n", iopc*255., 
04564                ipixel->clrflt);
04565         
04566         printf("              ");
04567         printf("      %3.0f    ",trace_rsclrTL);
04568         printf("      %3.0f    ",trace_rsclrBL);
04569         printf("      %3.0f    ",trace_rsclrTR);
04570         printf("      %3.0f    ",trace_rsclrBR);
04571         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
04572         
04573     }
04574 #endif /* DEBUG */
04575 ;
04576 #           ifndef SKIP_ERT
04577                 if (iopc >= max_opacity) {
04578                     ASSERT(ipixel->lnk == 0);
04579                     ipixel->lnk = 1;
04580                 }
04581 #           endif
04582         };
04583                 ipixel += 1; shadow_pixel += 1;
04584                 topRLEdata += 1 * voxel_istride;
04585                 botRLEdata += 1 * voxel_istride;
04586                 count--;
04587                 SET_VOXELS_LOADED;
04588                     
04589                 /* do the rest of the pixels in this run;
04590                    all four voxels contribute */
04591                 while (count > 0) {
04592                     if (PIXEL_IS_OPAQUE(ipixel))
04593                         break;
04594                     if (!voxels_loaded) {
04595                         
04596     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04597     
04598     
04599     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04600     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04601     
04602         
04603         
04604     top_clr = 
04605     shade_table[shade_index + 1*0 + 0] * 
04606         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04607         
04608         top_sclr = 
04609     shadow_table[shade_index + 1*0 + 0] * 
04610         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04611         for (m = 1; m < num_materials; m++) {
04612              
04613         
04614     top_clr += 
04615     shade_table[shade_index + 1*m + 0] * 
04616         weight_table[weight_index + m];
04617         
04618         top_sclr += 
04619     shadow_table[shade_index + 1*m + 0] * 
04620         weight_table[weight_index + m];
04621         };
04622     shade_factor = top_opc * slice_depth_cueing;
04623     
04624         top_clr *= shade_factor;
04625     
04626             top_sclr *= shade_factor;
04627                         
04628     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04629     
04630     
04631     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04632     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04633     
04634         
04635         
04636     bot_clr = 
04637     shade_table[shade_index + 1*0 + 0] * 
04638         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04639         
04640         bot_sclr = 
04641     shadow_table[shade_index + 1*0 + 0] * 
04642         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04643         for (m = 1; m < num_materials; m++) {
04644              
04645         
04646     bot_clr += 
04647     shade_table[shade_index + 1*m + 0] * 
04648         weight_table[weight_index + m];
04649         
04650         bot_sclr += 
04651     shadow_table[shade_index + 1*m + 0] * 
04652         weight_table[weight_index + m];
04653         };
04654     shade_factor = bot_opc * slice_depth_cueing;
04655     
04656         bot_clr *= shade_factor;
04657     
04658             bot_sclr *= shade_factor;
04659                     }
04660                     
04661 #ifdef DEBUG
04662     if (ipixel == trace_pixel_ptr) {
04663         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04664         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04665         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04666         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04667         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04668     }
04669 #endif
04670 ;
04671                     
04672        acc_opc = top_opc * wgtTL;
04673        acc_clr = (top_clr + top_sclr *
04674                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
04675        
04676 #ifdef DEBUG
04677     if (ipixel == trace_pixel_ptr) {
04678         trace_opcTL = top_opc;
04679         trace_rclrTL = top_clr;
04680         trace_rsclrTL = top_sclr;
04681     }
04682 #endif
04683 ;
04684                     
04685        acc_opc += bot_opc * wgtBL;
04686        acc_clr += (bot_clr + bot_sclr *
04687                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04688        
04689 #ifdef DEBUG
04690     if (ipixel == trace_pixel_ptr) {
04691         trace_opcBL = bot_opc;
04692         trace_rclrBL = bot_clr;
04693         trace_rsclrBL = bot_sclr;
04694     }
04695 #endif
04696 ;
04697                     
04698     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04699     
04700     
04701     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04702     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04703     
04704         
04705         
04706     top_clr = 
04707     shade_table[shade_index + 1*0 + 0] * 
04708         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04709         
04710         top_sclr = 
04711     shadow_table[shade_index + 1*0 + 0] * 
04712         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04713         for (m = 1; m < num_materials; m++) {
04714              
04715         
04716     top_clr += 
04717     shade_table[shade_index + 1*m + 0] * 
04718         weight_table[weight_index + m];
04719         
04720         top_sclr += 
04721     shadow_table[shade_index + 1*m + 0] * 
04722         weight_table[weight_index + m];
04723         };
04724     shade_factor = top_opc * slice_depth_cueing;
04725     
04726         top_clr *= shade_factor;
04727     
04728             top_sclr *= shade_factor;
04729                     
04730     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04731     
04732     
04733     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04734     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04735     
04736         
04737         
04738     bot_clr = 
04739     shade_table[shade_index + 1*0 + 0] * 
04740         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04741         
04742         bot_sclr = 
04743     shadow_table[shade_index + 1*0 + 0] * 
04744         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04745         for (m = 1; m < num_materials; m++) {
04746              
04747         
04748     bot_clr += 
04749     shade_table[shade_index + 1*m + 0] * 
04750         weight_table[weight_index + m];
04751         
04752         bot_sclr += 
04753     shadow_table[shade_index + 1*m + 0] * 
04754         weight_table[weight_index + m];
04755         };
04756     shade_factor = bot_opc * slice_depth_cueing;
04757     
04758         bot_clr *= shade_factor;
04759     
04760             bot_sclr *= shade_factor;
04761                     
04762        acc_opc += top_opc * wgtTR;
04763        acc_clr += (top_clr + top_sclr *
04764                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
04765        
04766 #ifdef DEBUG
04767     if (ipixel == trace_pixel_ptr) {
04768         trace_opcTR = top_opc;
04769         trace_rclrTR = top_clr;
04770         trace_rsclrTR = top_sclr;
04771     }
04772 #endif
04773 ;
04774                     
04775        acc_opc += bot_opc * wgtBR;
04776        acc_clr += (bot_clr + bot_sclr *
04777                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04778        
04779 #ifdef DEBUG
04780     if (ipixel == trace_pixel_ptr) {
04781         trace_opcBR = bot_opc;
04782         trace_rclrBR = bot_clr;
04783         trace_rsclrBR = bot_sclr;
04784     }
04785 #endif
04786 ;
04787                     
04788         COUNT_RESAMPLE;
04789         if (acc_opc > min_opacity) {
04790             COUNT_COMPOSITE;
04791             iopc = ipixel->opcflt;
04792 #           ifndef SKIP_ERT
04793                 ASSERT(iopc < max_opacity);
04794 #           endif
04795             iopc_inv = (float)1. - iopc;
04796             ipixel->clrflt += acc_clr * iopc_inv;
04797             iopc += acc_opc * iopc_inv;
04798             ipixel->opcflt = iopc;
04799             
04800 #ifdef DEBUG
04801     if (ipixel == trace_pixel_ptr) {
04802 #ifdef COMPUTE_SHADOW_BUFFER
04803         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04804 #else
04805         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04806 #endif
04807         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04808         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04809         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04810         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04811         printf("  %3.0f %3.0f\n", iopc*255., 
04812                ipixel->clrflt);
04813         
04814         printf("              ");
04815         printf("      %3.0f    ",trace_rsclrTL);
04816         printf("      %3.0f    ",trace_rsclrBL);
04817         printf("      %3.0f    ",trace_rsclrTR);
04818         printf("      %3.0f    ",trace_rsclrBR);
04819         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
04820         
04821     }
04822 #endif /* DEBUG */
04823 ;
04824 #           ifndef SKIP_ERT
04825                 if (iopc >= max_opacity) {
04826                     ASSERT(ipixel->lnk == 0);
04827                     ipixel->lnk = 1;
04828                 }
04829 #           endif
04830         };
04831                     ipixel += 1; shadow_pixel += 1;
04832                     topRLEdata += 1 * voxel_istride;
04833                     botRLEdata += 1 * voxel_istride;
04834                     count--;
04835                     SET_VOXELS_LOADED;
04836                 }
04837                 break;
04838             case ALL_NONZERO__ALL_NONZERO:
04839                 /* do the pixels in this run; all four voxels contribute */
04840                 while (count > 0) {
04841                     if (PIXEL_IS_OPAQUE(ipixel))
04842                         break;
04843                     if (!voxels_loaded) {
04844                         
04845     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04846     
04847     
04848     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
04849     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04850     
04851         
04852         
04853     top_clr = 
04854     shade_table[shade_index + 1*0 + 0] * 
04855         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04856         
04857         top_sclr = 
04858     shadow_table[shade_index + 1*0 + 0] * 
04859         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04860         for (m = 1; m < num_materials; m++) {
04861              
04862         
04863     top_clr += 
04864     shade_table[shade_index + 1*m + 0] * 
04865         weight_table[weight_index + m];
04866         
04867         top_sclr += 
04868     shadow_table[shade_index + 1*m + 0] * 
04869         weight_table[weight_index + m];
04870         };
04871     shade_factor = top_opc * slice_depth_cueing;
04872     
04873         top_clr *= shade_factor;
04874     
04875             top_sclr *= shade_factor;
04876                         
04877     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04878     
04879     
04880     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
04881     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04882     
04883         
04884         
04885     bot_clr = 
04886     shade_table[shade_index + 1*0 + 0] * 
04887         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04888         
04889         bot_sclr = 
04890     shadow_table[shade_index + 1*0 + 0] * 
04891         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04892         for (m = 1; m < num_materials; m++) {
04893              
04894         
04895     bot_clr += 
04896     shade_table[shade_index + 1*m + 0] * 
04897         weight_table[weight_index + m];
04898         
04899         bot_sclr += 
04900     shadow_table[shade_index + 1*m + 0] * 
04901         weight_table[weight_index + m];
04902         };
04903     shade_factor = bot_opc * slice_depth_cueing;
04904     
04905         bot_clr *= shade_factor;
04906     
04907             bot_sclr *= shade_factor;
04908                     }
04909                     
04910 #ifdef DEBUG
04911     if (ipixel == trace_pixel_ptr) {
04912         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04913         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04914         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04915         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04916         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04917     }
04918 #endif
04919 ;
04920                     
04921        acc_opc = top_opc * wgtTL;
04922        acc_clr = (top_clr + top_sclr *
04923                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
04924        
04925 #ifdef DEBUG
04926     if (ipixel == trace_pixel_ptr) {
04927         trace_opcTL = top_opc;
04928         trace_rclrTL = top_clr;
04929         trace_rsclrTL = top_sclr;
04930     }
04931 #endif
04932 ;
04933                     
04934        acc_opc += bot_opc * wgtBL;
04935        acc_clr += (bot_clr + bot_sclr *
04936                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04937        
04938 #ifdef DEBUG
04939     if (ipixel == trace_pixel_ptr) {
04940         trace_opcBL = bot_opc;
04941         trace_rclrBL = bot_clr;
04942         trace_rsclrBL = bot_sclr;
04943     }
04944 #endif
04945 ;
04946                     
04947     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04948     
04949     
04950     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
04951     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
04952     
04953         
04954         
04955     top_clr = 
04956     shade_table[shade_index + 1*0 + 0] * 
04957         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04958         
04959         top_sclr = 
04960     shadow_table[shade_index + 1*0 + 0] * 
04961         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04962         for (m = 1; m < num_materials; m++) {
04963              
04964         
04965     top_clr += 
04966     shade_table[shade_index + 1*m + 0] * 
04967         weight_table[weight_index + m];
04968         
04969         top_sclr += 
04970     shadow_table[shade_index + 1*m + 0] * 
04971         weight_table[weight_index + m];
04972         };
04973     shade_factor = top_opc * slice_depth_cueing;
04974     
04975         top_clr *= shade_factor;
04976     
04977             top_sclr *= shade_factor;
04978                     
04979     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04980     
04981     
04982     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
04983     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04984     
04985         
04986         
04987     bot_clr = 
04988     shade_table[shade_index + 1*0 + 0] * 
04989         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04990         
04991         bot_sclr = 
04992     shadow_table[shade_index + 1*0 + 0] * 
04993         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04994         for (m = 1; m < num_materials; m++) {
04995              
04996         
04997     bot_clr += 
04998     shade_table[shade_index + 1*m + 0] * 
04999         weight_table[weight_index + m];
05000         
05001         bot_sclr += 
05002     shadow_table[shade_index + 1*m + 0] * 
05003         weight_table[weight_index + m];
05004         };
05005     shade_factor = bot_opc * slice_depth_cueing;
05006     
05007         bot_clr *= shade_factor;
05008     
05009             bot_sclr *= shade_factor;
05010                     
05011        acc_opc += top_opc * wgtTR;
05012        acc_clr += (top_clr + top_sclr *
05013                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05014        
05015 #ifdef DEBUG
05016     if (ipixel == trace_pixel_ptr) {
05017         trace_opcTR = top_opc;
05018         trace_rclrTR = top_clr;
05019         trace_rsclrTR = top_sclr;
05020     }
05021 #endif
05022 ;
05023                     
05024        acc_opc += bot_opc * wgtBR;
05025        acc_clr += (bot_clr + bot_sclr *
05026                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05027        
05028 #ifdef DEBUG
05029     if (ipixel == trace_pixel_ptr) {
05030         trace_opcBR = bot_opc;
05031         trace_rclrBR = bot_clr;
05032         trace_rsclrBR = bot_sclr;
05033     }
05034 #endif
05035 ;
05036                     
05037         COUNT_RESAMPLE;
05038         if (acc_opc > min_opacity) {
05039             COUNT_COMPOSITE;
05040             iopc = ipixel->opcflt;
05041 #           ifndef SKIP_ERT
05042                 ASSERT(iopc < max_opacity);
05043 #           endif
05044             iopc_inv = (float)1. - iopc;
05045             ipixel->clrflt += acc_clr * iopc_inv;
05046             iopc += acc_opc * iopc_inv;
05047             ipixel->opcflt = iopc;
05048             
05049 #ifdef DEBUG
05050     if (ipixel == trace_pixel_ptr) {
05051 #ifdef COMPUTE_SHADOW_BUFFER
05052         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05053 #else
05054         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05055 #endif
05056         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05057         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05058         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05059         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05060         printf("  %3.0f %3.0f\n", iopc*255., 
05061                ipixel->clrflt);
05062         
05063         printf("              ");
05064         printf("      %3.0f    ",trace_rsclrTL);
05065         printf("      %3.0f    ",trace_rsclrBL);
05066         printf("      %3.0f    ",trace_rsclrTR);
05067         printf("      %3.0f    ",trace_rsclrBR);
05068         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
05069         
05070     }
05071 #endif /* DEBUG */
05072 ;
05073 #           ifndef SKIP_ERT
05074                 if (iopc >= max_opacity) {
05075                     ASSERT(ipixel->lnk == 0);
05076                     ipixel->lnk = 1;
05077                 }
05078 #           endif
05079         };
05080                     ipixel += 1; shadow_pixel += 1;
05081                     topRLEdata += 1 * voxel_istride;
05082                     botRLEdata += 1 * voxel_istride;
05083                     count--;
05084                     SET_VOXELS_LOADED;
05085                 }
05086                 break;
05087             default:
05088                 VPBug("illegal value for run states in compositing loop");
05089             }
05090 #else /* UNROLL_RUN_LOOP */
05091             /* this run contains pixels, so process them */
05092             while (count > 0) {
05093                 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
05094                     ipixel += count; shadow_pixel += count;
05095                     if (i != -1) {
05096                         ;
05097                         ;
05098                     }
05099                     count = 0;
05100                     break;
05101                 }
05102                 if (ipixel->lnk != 0)
05103                     break;
05104                 
05105 #ifdef DEBUG
05106     if (ipixel == trace_pixel_ptr) {
05107         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05108         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05109         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05110         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05111         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05112     }
05113 #endif
05114 ;
05115                 
05116        acc_opc = 0;
05117        acc_clr = 0;
05118                 if (last_run_state & TOP_NONZERO) {
05119                     if (!voxels_loaded) {
05120                         
05121     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05122     
05123     
05124     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
05125     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05126     
05127         
05128         
05129     top_clr = 
05130     shade_table[shade_index + 1*0 + 0] * 
05131         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05132         
05133         top_sclr = 
05134     shadow_table[shade_index + 1*0 + 0] * 
05135         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05136         for (m = 1; m < num_materials; m++) {
05137              
05138         
05139     top_clr += 
05140     shade_table[shade_index + 1*m + 0] * 
05141         weight_table[weight_index + m];
05142         
05143         top_sclr += 
05144     shadow_table[shade_index + 1*m + 0] * 
05145         weight_table[weight_index + m];
05146         };
05147     shade_factor = top_opc * slice_depth_cueing;
05148     
05149         top_clr *= shade_factor;
05150     
05151             top_sclr *= shade_factor;
05152                     }
05153                     
05154        acc_opc += top_opc * wgtTL;
05155        acc_clr += (top_clr + top_sclr *
05156                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05157        
05158 #ifdef DEBUG
05159     if (ipixel == trace_pixel_ptr) {
05160         trace_opcTL = top_opc;
05161         trace_rclrTL = top_clr;
05162         trace_rsclrTL = top_sclr;
05163     }
05164 #endif
05165 ;
05166                 }
05167                 if (last_run_state & BOT_NONZERO) {
05168                     if (!voxels_loaded) {
05169                         
05170     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05171     
05172     
05173     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
05174     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
05175     
05176         
05177         
05178     bot_clr = 
05179     shade_table[shade_index + 1*0 + 0] * 
05180         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05181         
05182         bot_sclr = 
05183     shadow_table[shade_index + 1*0 + 0] * 
05184         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05185         for (m = 1; m < num_materials; m++) {
05186              
05187         
05188     bot_clr += 
05189     shade_table[shade_index + 1*m + 0] * 
05190         weight_table[weight_index + m];
05191         
05192         bot_sclr += 
05193     shadow_table[shade_index + 1*m + 0] * 
05194         weight_table[weight_index + m];
05195         };
05196     shade_factor = bot_opc * slice_depth_cueing;
05197     
05198         bot_clr *= shade_factor;
05199     
05200             bot_sclr *= shade_factor;
05201                     }
05202                     
05203        acc_opc += bot_opc * wgtBL;
05204        acc_clr += (bot_clr + bot_sclr *
05205                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05206        
05207 #ifdef DEBUG
05208     if (ipixel == trace_pixel_ptr) {
05209         trace_opcBL = bot_opc;
05210         trace_rclrBL = bot_clr;
05211         trace_rsclrBL = bot_sclr;
05212     }
05213 #endif
05214 ;
05215                 }
05216                 if (run_state & TOP_NONZERO) {
05217                     
05218     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05219     
05220     
05221     shade_index=num_materials*1*ShortField(topRLEdata,norm_offset);
05222     weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05223     
05224         
05225         
05226     top_clr = 
05227     shade_table[shade_index + 1*0 + 0] * 
05228         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05229         
05230         top_sclr = 
05231     shadow_table[shade_index + 1*0 + 0] * 
05232         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05233         for (m = 1; m < num_materials; m++) {
05234              
05235         
05236     top_clr += 
05237     shade_table[shade_index + 1*m + 0] * 
05238         weight_table[weight_index + m];
05239         
05240         top_sclr += 
05241     shadow_table[shade_index + 1*m + 0] * 
05242         weight_table[weight_index + m];
05243         };
05244     shade_factor = top_opc * slice_depth_cueing;
05245     
05246         top_clr *= shade_factor;
05247     
05248             top_sclr *= shade_factor;
05249                     
05250        acc_opc += top_opc * wgtTR;
05251        acc_clr += (top_clr + top_sclr *
05252                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05253        
05254 #ifdef DEBUG
05255     if (ipixel == trace_pixel_ptr) {
05256         trace_opcTR = top_opc;
05257         trace_rclrTR = top_clr;
05258         trace_rsclrTR = top_sclr;
05259     }
05260 #endif
05261 ;
05262                     topRLEdata += 1 * voxel_istride;
05263                 } else {
05264                     if (i != -1) {
05265                         ;
05266                     }
05267                 }
05268                 if (run_state & BOT_NONZERO) {
05269                     
05270     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05271     
05272     
05273     shade_index=num_materials*1*ShortField(botRLEdata,norm_offset);
05274     weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
05275     
05276         
05277         
05278     bot_clr = 
05279     shade_table[shade_index + 1*0 + 0] * 
05280         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05281         
05282         bot_sclr = 
05283     shadow_table[shade_index + 1*0 + 0] * 
05284         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05285         for (m = 1; m < num_materials; m++) {
05286              
05287         
05288     bot_clr += 
05289     shade_table[shade_index + 1*m + 0] * 
05290         weight_table[weight_index + m];
05291         
05292         bot_sclr += 
05293     shadow_table[shade_index + 1*m + 0] * 
05294         weight_table[weight_index + m];
05295         };
05296     shade_factor = bot_opc * slice_depth_cueing;
05297     
05298         bot_clr *= shade_factor;
05299     
05300             bot_sclr *= shade_factor;
05301                     
05302        acc_opc += bot_opc * wgtBR;
05303        acc_clr += (bot_clr + bot_sclr *
05304                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05305        
05306 #ifdef DEBUG
05307     if (ipixel == trace_pixel_ptr) {
05308         trace_opcBR = bot_opc;
05309         trace_rclrBR = bot_clr;
05310         trace_rsclrBR = bot_sclr;
05311     }
05312 #endif
05313 ;
05314                     botRLEdata += 1 * voxel_istride;
05315                 } else {
05316                     if (i != -1) {
05317                         ;
05318                     }
05319                 }
05320                 
05321         COUNT_RESAMPLE;
05322         if (acc_opc > min_opacity) {
05323             COUNT_COMPOSITE;
05324             iopc = ipixel->opcflt;
05325 #           ifndef SKIP_ERT
05326                 ASSERT(iopc < max_opacity);
05327 #           endif
05328             iopc_inv = (float)1. - iopc;
05329             ipixel->clrflt += acc_clr * iopc_inv;
05330             iopc += acc_opc * iopc_inv;
05331             ipixel->opcflt = iopc;
05332             
05333 #ifdef DEBUG
05334     if (ipixel == trace_pixel_ptr) {
05335 #ifdef COMPUTE_SHADOW_BUFFER
05336         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05337 #else
05338         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05339 #endif
05340         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05341         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05342         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05343         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05344         printf("  %3.0f %3.0f\n", iopc*255., 
05345                ipixel->clrflt);
05346         
05347         printf("              ");
05348         printf("      %3.0f    ",trace_rsclrTL);
05349         printf("      %3.0f    ",trace_rsclrBL);
05350         printf("      %3.0f    ",trace_rsclrTR);
05351         printf("      %3.0f    ",trace_rsclrBR);
05352         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
05353         
05354     }
05355 #endif /* DEBUG */
05356 ;
05357 #           ifndef SKIP_ERT
05358                 if (iopc >= max_opacity) {
05359                     ASSERT(ipixel->lnk == 0);
05360                     ipixel->lnk = 1;
05361                 }
05362 #           endif
05363         };
05364                 ipixel += 1; shadow_pixel += 1;
05365                 count--;
05366                 SET_VOXELS_LOADED;
05367                 last_run_state = run_state;
05368             }
05369 #endif /* UNROLL_RUN_LOOP */
05370 
05371             GET_HIRES_TIME(vpc, t1);
05372             STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
05373             COPY_HIRES_TIME(t0, t1);
05374 
05375             if (count > 0) {
05376                 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
05377                 toprun_count += count;
05378                 botrun_count += count;
05379                 i += count;
05380             }
05381 #endif /* SKIP_COMPOSITE */
05382 
05383             /***********************************************************
05384              * Go on to next voxel run.
05385              ***********************************************************/
05386 
05387             last_run_state = run_state;
05388         } /* while (i > 0) */
05389 
05390         /***************************************************************
05391          * Finish processing voxel scanline and go on to next one.
05392          ***************************************************************/
05393 
05394 #ifdef UNROLL_RUN_LOOP
05395         ASSERT(i == 0);
05396 #else
05397         ASSERT(i == -1);
05398 #endif
05399 
05400 #ifndef SKIP_COMPOSITE
05401 #ifdef UNROLL_RUN_LOOP
05402         /* do the last pixel (to the right of the last voxel) */
05403         if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
05404             /* last voxels are nonzero and the pixel is not opaque yet
05405                so there is work to be done */
05406             Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
05407             switch (last_run_state) {
05408             case TOP_NONZERO:
05409                 /* only the top-left voxel contributes */
05410                 if (!voxels_loaded) {
05411                     
05412     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05413     
05414     
05415     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
05416     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05417     
05418         
05419         
05420     top_clr = 
05421     shade_table[shade_index + 1*0 + 0] * 
05422         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05423         
05424         top_sclr = 
05425     shadow_table[shade_index + 1*0 + 0] * 
05426         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05427         for (m = 1; m < num_materials; m++) {
05428              
05429         
05430     top_clr += 
05431     shade_table[shade_index + 1*m + 0] * 
05432         weight_table[weight_index + m];
05433         
05434         top_sclr += 
05435     shadow_table[shade_index + 1*m + 0] * 
05436         weight_table[weight_index + m];
05437         };
05438     shade_factor = top_opc * slice_depth_cueing;
05439     
05440         top_clr *= shade_factor;
05441     
05442             top_sclr *= shade_factor;
05443                 }
05444                 
05445 #ifdef DEBUG
05446     if (ipixel == trace_pixel_ptr) {
05447         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05448         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05449         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05450         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05451         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05452     }
05453 #endif
05454 ;
05455                 
05456        acc_opc = top_opc * wgtTL;
05457        acc_clr = (top_clr + top_sclr *
05458                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05459        
05460 #ifdef DEBUG
05461     if (ipixel == trace_pixel_ptr) {
05462         trace_opcTL = top_opc;
05463         trace_rclrTL = top_clr;
05464         trace_rsclrTL = top_sclr;
05465     }
05466 #endif
05467 ;
05468                 
05469         COUNT_RESAMPLE;
05470         if (acc_opc > min_opacity) {
05471             COUNT_COMPOSITE;
05472             iopc = ipixel->opcflt;
05473 #           ifndef SKIP_ERT
05474                 ASSERT(iopc < max_opacity);
05475 #           endif
05476             iopc_inv = (float)1. - iopc;
05477             ipixel->clrflt += acc_clr * iopc_inv;
05478             iopc += acc_opc * iopc_inv;
05479             ipixel->opcflt = iopc;
05480             
05481 #ifdef DEBUG
05482     if (ipixel == trace_pixel_ptr) {
05483 #ifdef COMPUTE_SHADOW_BUFFER
05484         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05485 #else
05486         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05487 #endif
05488         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05489         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05490         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05491         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05492         printf("  %3.0f %3.0f\n", iopc*255., 
05493                ipixel->clrflt);
05494         
05495         printf("              ");
05496         printf("      %3.0f    ",trace_rsclrTL);
05497         printf("      %3.0f    ",trace_rsclrBL);
05498         printf("      %3.0f    ",trace_rsclrTR);
05499         printf("      %3.0f    ",trace_rsclrBR);
05500         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
05501         
05502     }
05503 #endif /* DEBUG */
05504 ;
05505 #           ifndef SKIP_ERT
05506                 if (iopc >= max_opacity) {
05507                     ASSERT(ipixel->lnk == 0);
05508                     ipixel->lnk = 1;
05509                 }
05510 #           endif
05511         };
05512                 break;
05513             case BOT_NONZERO:
05514                 /* only the bottom left voxel contributes */
05515                 if (!voxels_loaded) {
05516                     
05517     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05518     
05519     
05520     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
05521     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
05522     
05523         
05524         
05525     bot_clr = 
05526     shade_table[shade_index + 1*0 + 0] * 
05527         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05528         
05529         bot_sclr = 
05530     shadow_table[shade_index + 1*0 + 0] * 
05531         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05532         for (m = 1; m < num_materials; m++) {
05533              
05534         
05535     bot_clr += 
05536     shade_table[shade_index + 1*m + 0] * 
05537         weight_table[weight_index + m];
05538         
05539         bot_sclr += 
05540     shadow_table[shade_index + 1*m + 0] * 
05541         weight_table[weight_index + m];
05542         };
05543     shade_factor = bot_opc * slice_depth_cueing;
05544     
05545         bot_clr *= shade_factor;
05546     
05547             bot_sclr *= shade_factor;
05548                 }
05549                 
05550 #ifdef DEBUG
05551     if (ipixel == trace_pixel_ptr) {
05552         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05553         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05554         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05555         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05556         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05557     }
05558 #endif
05559 ;
05560                 
05561        acc_opc = bot_opc * wgtBL;
05562        acc_clr = (bot_clr + bot_sclr *
05563                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05564        
05565 #ifdef DEBUG
05566     if (ipixel == trace_pixel_ptr) {
05567         trace_opcBL = bot_opc;
05568         trace_rclrBL = bot_clr;
05569         trace_rsclrBL = bot_sclr;
05570     }
05571 #endif
05572 ;
05573                 
05574         COUNT_RESAMPLE;
05575         if (acc_opc > min_opacity) {
05576             COUNT_COMPOSITE;
05577             iopc = ipixel->opcflt;
05578 #           ifndef SKIP_ERT
05579                 ASSERT(iopc < max_opacity);
05580 #           endif
05581             iopc_inv = (float)1. - iopc;
05582             ipixel->clrflt += acc_clr * iopc_inv;
05583             iopc += acc_opc * iopc_inv;
05584             ipixel->opcflt = iopc;
05585             
05586 #ifdef DEBUG
05587     if (ipixel == trace_pixel_ptr) {
05588 #ifdef COMPUTE_SHADOW_BUFFER
05589         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05590 #else
05591         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05592 #endif
05593         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05594         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05595         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05596         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05597         printf("  %3.0f %3.0f\n", iopc*255., 
05598                ipixel->clrflt);
05599         
05600         printf("              ");
05601         printf("      %3.0f    ",trace_rsclrTL);
05602         printf("      %3.0f    ",trace_rsclrBL);
05603         printf("      %3.0f    ",trace_rsclrTR);
05604         printf("      %3.0f    ",trace_rsclrBR);
05605         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
05606         
05607     }
05608 #endif /* DEBUG */
05609 ;
05610 #           ifndef SKIP_ERT
05611                 if (iopc >= max_opacity) {
05612                     ASSERT(ipixel->lnk == 0);
05613                     ipixel->lnk = 1;
05614                 }
05615 #           endif
05616         };
05617                 break;
05618             case ALL_NONZERO:
05619                 /* the top and bottom left voxels contribute */
05620                 if (!voxels_loaded) {
05621                     
05622     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05623     
05624     
05625     shade_index=num_materials*1*ShortField(topRLEdata - voxel_istride,norm_offset);
05626     weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05627     
05628         
05629         
05630     top_clr = 
05631     shade_table[shade_index + 1*0 + 0] * 
05632         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05633         
05634         top_sclr = 
05635     shadow_table[shade_index + 1*0 + 0] * 
05636         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05637         for (m = 1; m < num_materials; m++) {
05638              
05639         
05640     top_clr += 
05641     shade_table[shade_index + 1*m + 0] * 
05642         weight_table[weight_index + m];
05643         
05644         top_sclr += 
05645     shadow_table[shade_index + 1*m + 0] * 
05646         weight_table[weight_index + m];
05647         };
05648     shade_factor = top_opc * slice_depth_cueing;
05649     
05650         top_clr *= shade_factor;
05651     
05652             top_sclr *= shade_factor;
05653                     
05654     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05655     
05656     
05657     shade_index=num_materials*1*ShortField(botRLEdata - voxel_istride,norm_offset);
05658     weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
05659     
05660         
05661         
05662     bot_clr = 
05663     shade_table[shade_index + 1*0 + 0] * 
05664         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05665         
05666         bot_sclr = 
05667     shadow_table[shade_index + 1*0 + 0] * 
05668         ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05669         for (m = 1; m < num_materials; m++) {
05670              
05671         
05672     bot_clr += 
05673     shade_table[shade_index + 1*m + 0] * 
05674         weight_table[weight_index + m];
05675         
05676         bot_sclr += 
05677     shadow_table[shade_index + 1*m + 0] * 
05678         weight_table[weight_index + m];
05679         };
05680     shade_factor = bot_opc * slice_depth_cueing;
05681     
05682         bot_clr *= shade_factor;
05683     
05684             bot_sclr *= shade_factor;
05685                 }
05686                 
05687 #ifdef DEBUG
05688     if (ipixel == trace_pixel_ptr) {
05689         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05690         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05691         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05692         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05693         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05694     }
05695 #endif
05696 ;
05697                 
05698        acc_opc = top_opc * wgtTL;
05699        acc_clr = (top_clr + top_sclr *
05700                             ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05701        
05702 #ifdef DEBUG
05703     if (ipixel == trace_pixel_ptr) {
05704         trace_opcTL = top_opc;
05705         trace_rclrTL = top_clr;
05706         trace_rsclrTL = top_sclr;
05707     }
05708 #endif
05709 ;
05710                 
05711        acc_opc += bot_opc * wgtBL;
05712        acc_clr += (bot_clr + bot_sclr *
05713                             ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05714        
05715 #ifdef DEBUG
05716     if (ipixel == trace_pixel_ptr) {
05717         trace_opcBL = bot_opc;
05718         trace_rclrBL = bot_clr;
05719         trace_rsclrBL = bot_sclr;
05720     }
05721 #endif
05722 ;
05723                 
05724         COUNT_RESAMPLE;
05725         if (acc_opc > min_opacity) {
05726             COUNT_COMPOSITE;
05727             iopc = ipixel->opcflt;
05728 #           ifndef SKIP_ERT
05729                 ASSERT(iopc < max_opacity);
05730 #           endif
05731             iopc_inv = (float)1. - iopc;
05732             ipixel->clrflt += acc_clr * iopc_inv;
05733             iopc += acc_opc * iopc_inv;
05734             ipixel->opcflt = iopc;
05735             
05736 #ifdef DEBUG
05737     if (ipixel == trace_pixel_ptr) {
05738 #ifdef COMPUTE_SHADOW_BUFFER
05739         printf("{%3d}  %3d %3d", k, icount-i-count, j);
05740 #else
05741         printf("[%3d]  %3d %3d", k, icount-i-count, j);
05742 #endif
05743         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05744         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05745         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05746         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05747         printf("  %3.0f %3.0f\n", iopc*255., 
05748                ipixel->clrflt);
05749         
05750         printf("              ");
05751         printf("      %3.0f    ",trace_rsclrTL);
05752         printf("      %3.0f    ",trace_rsclrBL);
05753         printf("      %3.0f    ",trace_rsclrTR);
05754         printf("      %3.0f    ",trace_rsclrBR);
05755         printf("  %3.0f\n", shadow_pixel->opcflt * 255.);
05756         
05757     }
05758 #endif /* DEBUG */
05759 ;
05760 #           ifndef SKIP_ERT
05761                 if (iopc >= max_opacity) {
05762                     ASSERT(ipixel->lnk == 0);
05763                     ipixel->lnk = 1;
05764                 }
05765 #           endif
05766         };
05767                 break;
05768             default:
05769                 VPBug("illegal value for run state at end of scanline");
05770             }
05771         } else if (last_run_state == ALL_ZERO) {
05772             Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
05773         } else {
05774             Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
05775         }
05776 #endif /* UNROLL_RUN_LOOP */
05777 #endif /* SKIP_COMPOSITE */
05778 
05779 #ifndef UNROLL_RUN_LOOP
05780         run_state = final_run_state;
05781 #endif
05782         /* skip over any zero-length runs remaining in this scanline */
05783         if (j != 0 && ((run_state & 1) == 0)) {
05784             toprun_count = *topRLElen++;
05785             ASSERT(toprun_count == 0);
05786         }
05787         if (j != jcount && ((run_state & 2) == 0)) {
05788             botrun_count = *botRLElen++;
05789             ASSERT(botrun_count == 0);
05790         }
05791 
05792         /* go to next intermediate image scanline */
05793 #ifdef UNROLL_RUN_LOOP
05794         ipixel += intermediate_width - icount;
05795 #ifdef USE_SHADOW_BUFFER
05796         shadow_pixel += shadow_width - icount;
05797 #endif
05798 #else /* UNROLL_RUN_LOOP */
05799         ipixel += intermediate_width - (icount+1);
05800 #ifdef USE_SHADOW_BUFFER
05801         shadow_pixel += shadow_width - (icount+1);
05802 #endif
05803 #endif /* UNROLL_RUN_LOOP */
05804 
05805         Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
05806     } /* for j */
05807 
05808     /***************************************************************
05809      * Finish processing the voxel slice.
05810      ***************************************************************/
05811 
05812     GET_HIRES_TIME(vpc, t1);
05813     STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
05814 
05815     Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
05816 }
 

Powered by Plone

This site conforms to the following standards: