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

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

Powered by Plone

This site conforms to the following standards: