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_compAR31B.c

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

Powered by Plone

This site conforms to the following standards: