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_compAC1PB.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 CALLBACK
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 #define GRAYSCALE
00124     
00125     
00126     
00127     
00128 
00129 
00130 
00131 
00132 
00133 #define RLEVOLUME
00134         
00135         
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  * VPCompAC1PB
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 VPCompAC1PB (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00224           weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00225           run_lengths, voxel_data )
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                 unsigned char *run_lengths;     /* run lengths for slice */
00238                 void *voxel_data;               /* voxel data for slice */
00239 
00240 {
00241     int i, j;                   /* voxel index in rotated object space */
00242     GrayIntPixel *ipixel;       /* current intermediate image pixel */
00243     GrayIntPixel *ipixel2;      /* another intermediate image pixel */
00244     int update_interval;        /* # of pixels to skip when updating links */
00245     float iopc;                 /* intermediate pixel opacity (0-1) */
00246     float iopc_inv;             /* 1-iopc */
00247     float acc_opc;              /* accumulator for resampled voxel opacity */
00248     float top_opc, bot_opc;     /* voxel opacity (top and bottom scanlines) */
00249 #ifdef NO_REUSE_VOXEL
00250 #define voxels_loaded   0
00251 #define CLEAR_VOXELS_LOADED
00252 #define SET_VOXELS_LOADED
00253 #else
00254     int voxels_loaded;          /* if true, top/bot_opc contain valid
00255                                    data loaded during the last resample */
00256 #define CLEAR_VOXELS_LOADED     voxels_loaded = 0
00257 #define SET_VOXELS_LOADED       voxels_loaded = 1
00258 #endif
00259     float wgtTL, wgtBL,         /* weights in the range 0..1 which give the */
00260           wgtTR, wgtBR;         /*   fractional contribution of the */
00261                                 /*   neighboring voxels to the current */
00262                                 /*   intermediate image pixel */
00263     unsigned char *topRLElen;   /* length of current run in top scanline */
00264     unsigned char *botRLElen;   /* length of current run in bottom scanline */
00265     char *topRLEdata;           /* data for current run in top scanline */
00266     char *botRLEdata;           /* data for current run in bottom scanline */
00267     int toprun_count;           /* number of voxels left in top run */
00268     int botrun_count;           /* number of voxels left in bottom run */
00269     int last_run_state;         /* run state code for last resample */
00270     int run_state;              /* run state code for this resample */
00271     int final_run_state;        /* run state code for end of scanline */
00272     float min_opacity;          /* low opacity threshold */
00273     float max_opacity;          /* high opacity threshold */
00274     float slice_depth_cueing;   /* depth cueing factor for slice */
00275     float *opac_correct;        /* opacity correction table */
00276     int ert_skip_count;         /* number of pixels to skip for ERT */
00277     int intermediate_width;     /* width of intermediate image in pixels */
00278     int count;                  /* voxels left in current run */
00279     float *shade_table;         /* shade lookup table */
00280     int norm_offset;            /* byte offset to shade table index in voxel */
00281     int shade_index;            /* shade index */
00282     float shade_factor;         /* attenuation factor for color
00283                                    (voxel opacity * depth cueing) */
00284 
00285 #ifdef MULTIPLE_MATERIALS
00286     float *weight_table;        /* weight lookup table */
00287     int wgt_offset;             /* byte offset to weight table index */
00288     int weight_index;           /* weight index */
00289     int m, num_materials;
00290     float weight1, weight2;
00291 #endif /* MULTIPLE_MATERIALS */
00292 
00293 #ifdef GRAYSCALE
00294     float acc_clr;              /* accumulator for resampled color */
00295     float top_clr, bot_clr;     /* voxel color (top and bottom scanlines) */
00296 #endif /* GRAYSCALE */
00297 
00298 #ifdef RGB
00299     float acc_rclr;             /* accumulator for resampled color */
00300     float acc_gclr;
00301     float acc_bclr;
00302     float top_rclr;             /* voxel color (top and bottom scanlines) */
00303     float bot_rclr;
00304     float top_gclr;
00305     float bot_gclr;
00306     float top_bclr;
00307     float bot_bclr;
00308 #endif
00309 
00310 #ifdef RLEVOLUME
00311     int voxel_istride;          /* size of a voxel in bytes */
00312 #endif
00313 
00314 #ifdef RAWVOLUME
00315     int use_octree;             /* if true then use the min-max octree */
00316     MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00317                                 /* stack for traversal of min-max octree */
00318     int scans_left;             /* scanlines until next octree traversal */
00319     int best_view_axis;         /* viewing axis */
00320     unsigned char runlen_buf1[VP_MAX_VOLUME_DIM]; /* buffers for run lengths */
00321     unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00322     unsigned char *top_len_base;/* first run length for top scanline */
00323     unsigned char *bot_len_base;/* first run length for bottom scanline */
00324     int opac_param;             /* parameter to opacity transfer function */
00325     float opacity;              /* voxel opacity */
00326     int opacity_int;            /* voxel opacity truncated to an integer */
00327     int param0_offset;          /* offset to first parameter in voxel */
00328     int param0_size;            /* size of first parameter in bytes */
00329     float *param0_table;        /* lookup table for first parameter */
00330     int param1_offset;          /* offset to second parameter in voxel */
00331     int param1_size;            /* size of second parameter in bytes */
00332     float *param1_table;        /* lookup table for second parameter */
00333     int param2_offset;          /* offset to third parameter in voxel */
00334     int param2_size;            /* size of third parameter in bytes */
00335     float *param2_table;        /* lookup table for third parameter */
00336 #endif /* RAWVOLUME */
00337 
00338 #ifdef INDEX_VOLUME
00339     unsigned char *scanline_topRLElen; /* first topRLElen in scanline */
00340     unsigned char *scanline_botRLElen; /* first botRLElen in scanline */
00341     char *scanline_topRLEdata;  /* first topRLEdata in scanline */
00342     char *scanline_botRLEdata;  /* first botRLEdata in scanline */
00343     VoxelLocation *top_voxel_index; /* voxel indexes for top scanline */
00344     VoxelLocation *bot_voxel_index; /* voxel indexes for bot scanline */
00345     VoxelLocation *vindex;
00346     int next_i;                 /* i coordinate of voxel to skip to */
00347     int next_scan;              /* true if skipped to next scanline */
00348 #endif /* INDEX_VOLUME */
00349 
00350 #ifdef CALLBACK
00351                                 /* shading callback function */
00352 #ifdef GRAYSCALE
00353     void (*shade_func) ANSI_ARGS((void *, float *, void *));
00354 #endif
00355 #ifdef RGB
00356     void (*shade_func) ANSI_ARGS((void *, float *, float *, float *, void *));
00357 #endif
00358     void *client_data;          /* client data handle */
00359 #endif /* CALLBACK */
00360 
00361 #ifdef USE_SHADOW_BUFFER
00362     float *shadow_table;        /* color lookup table for shadows */
00363     int shadow_width;           /* width of shadow buffer */
00364     GrayIntPixel *shadow_pixel; /* current shadow buffer pixel */
00365 #ifdef GRAYSCALE
00366     float top_sclr, bot_sclr;   /* shadow color (top and bottom scanlines) */
00367 #endif /* GRAYSCALE */
00368 #ifdef RGB
00369     float top_rsclr;            /* shadow color (top and bottom scanlines) */
00370     float bot_rsclr;
00371     float top_gsclr;
00372     float bot_gsclr;
00373     float top_bsclr;
00374     float bot_bsclr;
00375 #endif
00376 #endif /* SHADOW_BUFFER */
00377 
00378 #ifdef DEBUG
00379     float trace_opcTL, trace_opcBL, trace_opcTR, trace_opcBR;
00380     float trace_rsclrTL, trace_rsclrBL, trace_rsclrTR, trace_rsclrBR;
00381     float trace_rclrTL, trace_rclrBL, trace_rclrTR, trace_rclrBR;
00382     float trace_gclrTL, trace_gclrBL, trace_gclrTR, trace_gclrBR;
00383     float trace_bclrTL, trace_bclrBL, trace_bclrTR, trace_bclrBR;
00384     GrayIntPixel *trace_pixel_ptr;
00385 
00386 #ifdef COMPUTE_SHADOW_BUFFER
00387     int slice_u_int, shadow_slice_u_int;
00388     int slice_v_int, shadow_slice_v_int;
00389 #endif
00390 #endif /* DEBUG */
00391 
00392     DECLARE_HIRES_TIME(t0);
00393     DECLARE_HIRES_TIME(t1);
00394 
00395     /*******************************************************************
00396      * Copy parameters from the rendering context into local variables.
00397      *******************************************************************/
00398 
00399     GET_HIRES_TIME(vpc, t0);
00400 
00401     wgtTL = weightTLdbl;
00402     wgtBL = weightBLdbl;
00403     wgtTR = weightTRdbl;
00404     wgtBR = weightBRdbl;
00405     slice_depth_cueing = slice_depth_cueing_dbl;
00406     min_opacity = vpc->min_opacity;
00407     max_opacity = vpc->max_opacity;
00408 #ifdef USE_SHADOW_BUFFER
00409     opac_correct = vpc->shadow_opac_correct;
00410 #else
00411     opac_correct = vpc->affine_opac_correct;
00412 #endif
00413 #ifdef COMPUTE_SHADOW_BUFFER
00414     intermediate_width = vpc->shadow_width;
00415 #else
00416     intermediate_width = vpc->intermediate_width;
00417 #endif
00418 #ifdef USE_SHADOW_BUFFER
00419     shadow_table = vpc->shadow_color_table;
00420     shadow_width = vpc->shadow_width;
00421     shadow_pixel = shadow_buffer;
00422 #endif
00423     ipixel = intimage;
00424     shade_table = vpc->shade_color_table;
00425     norm_offset = vpc->field_offset[vpc->color_field];
00426 
00427 #ifdef MULTIPLE_MATERIALS
00428     weight_table = vpc->shade_weight_table;
00429     wgt_offset = vpc->field_offset[vpc->weight_field];
00430     num_materials = vpc->num_materials;
00431 #endif /* MULTIPLE_MATERIALS */
00432 
00433 #ifdef RLEVOLUME
00434     topRLEdata = voxel_data;
00435     botRLEdata = voxel_data;
00436     topRLElen = run_lengths;
00437     botRLElen = run_lengths;
00438     voxel_istride = vpc->rle_bytes_per_voxel;
00439 #endif /* RLEVOLUME */
00440 
00441 #ifdef RAWVOLUME
00442     ASSERT(vpc->num_clsfy_params > 0);
00443     ASSERT(vpc->num_clsfy_params < 3);
00444     param0_offset = vpc->field_offset[vpc->param_field[0]];
00445     param0_size = vpc->field_size[vpc->param_field[0]];
00446     param0_table = vpc->clsfy_table[0];
00447     if (vpc->num_clsfy_params > 1) {
00448         param1_offset = vpc->field_offset[vpc->param_field[1]];
00449         param1_size = vpc->field_size[vpc->param_field[1]];
00450         param1_table = vpc->clsfy_table[1];
00451     } else {
00452         param1_offset = 0;
00453         param1_size = 0;
00454         param1_table = NULL;
00455     }
00456     if (vpc->num_clsfy_params > 2) {
00457         param2_offset = vpc->field_offset[vpc->param_field[2]];
00458         param2_size = vpc->field_size[vpc->param_field[2]];
00459         param2_table = vpc->clsfy_table[2];
00460     } else {
00461         param2_offset = 0;
00462         param2_size = 0;
00463         param2_table = NULL;
00464     }
00465     if (vpc->mm_octree == NULL) {
00466         use_octree = 0;
00467     } else {
00468         use_octree = 1;
00469         best_view_axis = vpc->best_view_axis;
00470         VPInitOctreeLevelStack(vpc, level_stack, best_view_axis, k);
00471         scans_left = 0;
00472         bot_len_base = runlen_buf1;
00473     }
00474 #endif /* RAWVOLUME */
00475 
00476 #ifdef CALLBACK
00477     shade_func = vpc->shade_func;
00478     client_data = vpc->client_data;
00479     ASSERT(shade_func != NULL);
00480 #endif
00481 
00482 #ifdef DEBUG
00483     trace_pixel_ptr = 0;
00484     if (vpc->trace_u >= 0 && vpc->trace_v >= 0) {
00485 #ifdef GRAYSCALE
00486         trace_pixel_ptr = &vpc->int_image.gray_intim[vpc->trace_u + 
00487                       vpc->trace_v*vpc->intermediate_width];
00488 #endif
00489 #ifdef RGB
00490         trace_pixel_ptr = &vpc->int_image.rgb_intim[vpc->trace_u + 
00491                       vpc->trace_v*vpc->intermediate_width];
00492 #endif
00493 #ifdef COMPUTE_SHADOW_BUFFER
00494         slice_u_int = (int)ceil(vpc->shear_i * vpc->trace_shadow_k +
00495                                 vpc->trans_i) - 1;
00496         shadow_slice_u_int = (int)ceil(vpc->shadow_shear_i * 
00497                              vpc->trace_shadow_k + vpc->shadow_trans_i) - 1;
00498         slice_v_int = (int)ceil(vpc->shear_j * vpc->trace_shadow_k
00499                                 + vpc->trans_j) - 1;
00500         shadow_slice_v_int = (int)ceil(vpc->shadow_shear_j *
00501                              vpc->trace_shadow_k + vpc->shadow_trans_j) - 1;
00502         trace_pixel_ptr = &vpc->shadow_buffer[vpc->trace_u +
00503                 shadow_slice_u_int - slice_u_int + 
00504                 (vpc->trace_v + shadow_slice_v_int -
00505                 slice_v_int)*vpc->shadow_width];
00506 #endif
00507     }
00508 #endif /* DEBUG */
00509 
00510     /*******************************************************************
00511      * Loop over voxel scanlines.
00512      *******************************************************************/
00513 
00514     for (j = 0; j <= jcount; j++) {
00515 
00516         /***************************************************************
00517          * Initialize counters and flags.
00518          ***************************************************************/
00519 
00520         i = icount;
00521         CLEAR_VOXELS_LOADED;
00522         last_run_state = ALL_ZERO;
00523 
00524 #ifdef RAWVOLUME
00525         botRLEdata = (char *)voxel_data + j*voxel_jstride;
00526         topRLEdata = botRLEdata - voxel_jstride;
00527         if (!use_octree) {
00528             if (j == 0) {
00529                 run_state = BOT_NONZERO;
00530                 toprun_count = icount+2;
00531                 botrun_count = icount;
00532             } else if (j == jcount) {
00533                 run_state = TOP_NONZERO;
00534                 toprun_count = icount;
00535                 botrun_count = icount+2;
00536             } else {
00537                 run_state = ALL_NONZERO;
00538                 toprun_count = icount;
00539                 botrun_count = icount;
00540             }
00541         } else
00542 #endif /* RAWVOLUME */
00543         if (j == 0) {
00544             run_state = BOT_NONZERO;
00545             toprun_count = icount+2;
00546             botrun_count = 0;
00547         } else if (j == jcount) {
00548             run_state = TOP_NONZERO;
00549             toprun_count = 0;
00550             botrun_count = icount+2;
00551         } else {
00552             run_state = ALL_NONZERO;
00553             toprun_count = 0;
00554             botrun_count = 0;
00555         }
00556 
00557 #ifdef INDEX_VOLUME
00558         scanline_topRLElen = topRLElen;
00559         scanline_botRLElen = botRLElen;
00560         scanline_topRLEdata = topRLEdata;
00561         scanline_botRLEdata = botRLEdata;
00562         if (j == 0) {
00563             top_voxel_index = voxel_index;
00564             bot_voxel_index = voxel_index;
00565         } else {
00566             top_voxel_index = bot_voxel_index;
00567             bot_voxel_index += icount;
00568         }
00569 #endif /* INDEX_VOLUME */
00570 
00571         /***************************************************************
00572          * If the volume is not run-length encoded, use the min-max
00573          * to find run lengths for the current voxel scanline.
00574          ***************************************************************/
00575 
00576 #ifdef RAWVOLUME
00577         if (use_octree) {
00578             top_len_base = bot_len_base;
00579             if (scans_left == 0) {
00580                 if (bot_len_base == runlen_buf1)
00581                     bot_len_base = runlen_buf2;
00582                 else
00583                     bot_len_base = runlen_buf1;
00584 
00585                 GET_HIRES_TIME(vpc, t1);
00586                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00587                 COPY_HIRES_TIME(t0, t1);
00588 
00589                 scans_left = VPComputeScanRuns(vpc, level_stack, bot_len_base,
00590                                                best_view_axis, j, icount);
00591 
00592                 GET_HIRES_TIME(vpc, t1);
00593                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_OCTREE, t0, t1);
00594                 COPY_HIRES_TIME(t0, t1);
00595             }
00596 #ifdef DEBUG
00597             if (j > 0)
00598                 VPCheckRuns(vpc, top_len_base, best_view_axis, k, j-1);
00599             if (j < jcount)
00600                 VPCheckRuns(vpc, bot_len_base, best_view_axis, k, j);
00601 #endif
00602             scans_left--;
00603             topRLElen = top_len_base;
00604             botRLElen = bot_len_base;
00605         }
00606 #endif /* RAWVOLUME */
00607 
00608         /***************************************************************
00609          * Loop over runs in the voxel scanline.
00610          ***************************************************************/
00611 
00612         Debug((vpc, VPDEBUG_COMPOSITE, "StartIScan(u=%d,v=%d)\n",
00613                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00614                 sizeof(GrayIntPixel)) % vpc->intermediate_width,
00615                (((int)ipixel - (int)vpc->int_image.gray_intim) /
00616                 sizeof(GrayIntPixel)) / vpc->intermediate_width));
00617 
00618 #ifdef UNROLL_RUN_LOOP
00619         while (i > 0) {
00620 #else
00621         while (i >= 0) {
00622 #endif
00623             /***********************************************************
00624              * Skip over any empty runs at beginning of scanline.
00625              ***********************************************************/
00626 
00627             if (last_run_state == ALL_ZERO) {
00628 #ifndef UNROLL_RUN_LOOP
00629                 if (i == 0) {
00630                     Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00631                     ipixel += 1;
00632                     final_run_state = ALL_ZERO;
00633                     i = -1;
00634                     break;      /* scanline is done */
00635                 }
00636 #endif
00637 
00638                 /* check if this is the start of a new run */
00639                 while (toprun_count == 0) {
00640                     toprun_count = *topRLElen++;
00641                     run_state ^= 1;
00642                 }
00643                 while (botrun_count == 0) {
00644                     botrun_count = *botRLElen++;
00645                     run_state ^= 2;
00646                 }
00647                 if (run_state == ALL_ZERO) {
00648                     COUNT_SPECIAL_ZERO_SKIP;
00649 
00650                     /* find the union of the two runs of voxels */
00651                     count = MIN(toprun_count, botrun_count);
00652                     toprun_count -= count;
00653                     botrun_count -= count;
00654                     ipixel += count;
00655                     ;
00656                     ;
00657                     i -= count;
00658                     ASSERT(i >= 0);
00659                     Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(%d)\n", count));
00660                     continue;
00661                 }
00662             }
00663 
00664 #ifndef SKIP_ERT
00665             /***********************************************************
00666              * Skip over opaque pixels (early-ray termination).
00667              ***********************************************************/
00668 
00669             if ((ert_skip_count = ipixel->lnk) != 0) {
00670 
00671                 GET_HIRES_TIME(vpc, t1);
00672                 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00673                 COPY_HIRES_TIME(t0, t1);
00674 
00675                 COUNT_ERT_SKIP;
00676 
00677 #ifndef UNROLL_RUN_LOOP
00678                 if (i == 0) {
00679                     ipixel += 1;
00680                     final_run_state = last_run_state;
00681                     i = -1;
00682                     Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00683                     break;      /* scanline is done */
00684                 }
00685 #endif
00686 
00687                 /* find out how many pixels to skip */
00688                 if (ert_skip_count < i &&
00689                                 (count = ipixel[ert_skip_count].lnk) != 0) {
00690                     /* follow pointer chain */
00691                     do {
00692                         COUNT_ERT_SKIP_AGAIN;
00693                         ert_skip_count += count;
00694                     } while (ert_skip_count < i &&
00695                                  (count = ipixel[ert_skip_count].lnk) != 0);
00696 
00697                     /* update some of the lnk pointers in the run of opaque
00698                        pixels; the more links we update the longer it will
00699                        take to perform the update, but we will potentially
00700                        save time in future slices by not having to follow
00701                        long pointer chains */
00702                     ipixel2 = ipixel;
00703                     update_interval = 1;
00704                     count = ert_skip_count - 1;
00705                     while (count > 0) {
00706                         COUNT_ERT_UPDATE;
00707                         ipixel2 += update_interval;
00708                         if (count > 255)
00709                             ipixel2->lnk = 255;
00710                         else
00711                             ipixel2->lnk = count;
00712                         update_interval *= 2;
00713                         count -= update_interval;
00714                     }
00715 
00716                     /* update the current link */
00717                     COUNT_ERT_UPDATE;
00718                     if (ert_skip_count > 255)
00719                         ert_skip_count = 255;
00720                     ipixel->lnk = ert_skip_count;
00721                 }
00722 
00723                 /* skip over the opaque pixels */
00724                 if (ert_skip_count > i)
00725                     ert_skip_count = i;
00726                 Debug((vpc, VPDEBUG_COMPOSITE,"ERTSkip(%d)\n",ert_skip_count));
00727                 ipixel += ert_skip_count;
00728                 CLEAR_VOXELS_LOADED;
00729 
00730 #ifdef INDEX_VOLUME
00731                 /* compute i coordinate of voxel to skip to */
00732                 next_i = icount - i + ert_skip_count;
00733                 if (next_i == icount) {
00734                     next_i--;
00735                     next_scan = 1;
00736                 } else {
00737                     next_scan = 0;
00738                 }
00739 
00740                 /* skip over voxels in top scanline */
00741                 vindex = &top_voxel_index[next_i];
00742                 toprun_count = vindex->run_count;
00743                 topRLElen = scanline_topRLElen + vindex->len_offset;
00744                 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00745                     run_state &= ~1;
00746                     topRLEdata = scanline_topRLEdata +
00747                         (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00748                 } else {
00749                     run_state |= 1;
00750                     topRLEdata = scanline_topRLEdata + vindex->data_offset;
00751                 }
00752 
00753                 /* skip over voxels in bottom scanline */
00754                 vindex = &bot_voxel_index[next_i];
00755                 botrun_count = vindex->run_count;
00756                 botRLElen = scanline_botRLElen + vindex->len_offset;
00757                 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00758                     run_state &= ~2;
00759                     botRLEdata = scanline_botRLEdata +
00760                         (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00761                 } else {
00762                     run_state |= 2;
00763                     botRLEdata = scanline_botRLEdata + vindex->data_offset;
00764                 }
00765 
00766                 /* special case to skip over last voxel in scanline */
00767                 if (next_scan) {
00768                     /* advance to beginning of next top scanline */
00769                     while (toprun_count == 0) {
00770                         toprun_count = *topRLElen++;
00771                         run_state ^= 1;
00772                     }
00773                     toprun_count--;
00774                     if (run_state & 1) {
00775                         topRLEdata += 1 * voxel_istride;
00776                     } else {
00777                         ;
00778                     }
00779 
00780                     /* advance to beginning of next bottom scanline */
00781                     while (botrun_count == 0) {
00782                         botrun_count = *botRLElen++;
00783                         run_state ^= 2;
00784                     }
00785                     botrun_count--;
00786                     if (run_state & 2) {
00787                         botRLEdata += 1 * voxel_istride;
00788                     } else {
00789                         ;
00790                     }
00791                 }
00792 
00793 #else /* !INDEX_VOLUME */
00794                 /* skip over voxels in top scanline */
00795                 count = ert_skip_count;
00796                 for (;;) {
00797                     if (toprun_count >= count) {
00798                         toprun_count -= count;
00799                         if (run_state & 1) {
00800                             topRLEdata += count * voxel_istride;
00801                         } else {
00802                             ;
00803                         }
00804                         break;
00805                     } else {
00806                         count -= toprun_count;
00807                         if (run_state & 1) {
00808                             topRLEdata += toprun_count * voxel_istride;
00809                         } else {
00810                             ;
00811                         }
00812                         toprun_count = *topRLElen++;
00813                         if (toprun_count == 0)
00814                             toprun_count = *topRLElen++;
00815                         else
00816                             run_state ^= 1;
00817                     }
00818                 }
00819 
00820                 /* skip over voxels in bottom scanline */
00821                 count = ert_skip_count;
00822                 for (;;) {
00823                     if (botrun_count >= count) {
00824                         botrun_count -= count;
00825                         if (run_state & 2) {
00826                             botRLEdata += count * voxel_istride;
00827                         } else {
00828                             ;
00829                         }
00830                         break;
00831                     } else {
00832                         count -= botrun_count;
00833                         if (run_state & 2) {
00834                             botRLEdata += botrun_count * voxel_istride;
00835                         } else {
00836                             ;
00837                         }
00838                         botrun_count = *botRLElen++;
00839                         if (botrun_count == 0)
00840                             botrun_count = *botRLElen++;
00841                         else
00842                             run_state ^= 2;
00843                     }
00844                 }
00845 #endif /* INDEX_VOLUME */
00846                 i -= ert_skip_count;
00847                 last_run_state = run_state;
00848                 if (i == 0) {
00849 #ifdef UNROLL_RUN_LOOP
00850                     break;
00851 #else
00852                     if (last_run_state == ALL_ZERO) {
00853                         ipixel += 1;
00854                         final_run_state = ALL_ZERO;
00855                         i = -1;
00856                         Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00857                         break;  /* scanline is done */
00858                     }
00859                     if (ipixel->lnk != 0) {
00860                         ipixel += 1;
00861                         final_run_state = last_run_state;
00862                         i = -1;
00863                         Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00864                         break;  /* scanline is done */
00865                     }
00866 #endif /* UNROLL_RUN_LOOP */
00867                 }
00868 
00869                 GET_HIRES_TIME(vpc, t1);
00870                 STORE_HIRES_TIME(vpc, VPTIMER_ERT, t0, t1);
00871                 COPY_HIRES_TIME(t0, t1);
00872             }
00873             ASSERT(ipixel->opcflt < max_opacity);
00874 #endif /* SKIP_ERT */
00875 
00876             /***********************************************************
00877              * Compute the length of the current run.
00878              ***********************************************************/
00879 
00880 #ifndef UNROLL_RUN_LOOP
00881             if (i == 0) {
00882                 final_run_state = last_run_state;
00883                 run_state = ALL_ZERO;
00884                 i = -1;
00885                 count = 1;
00886                 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
00887             } else {
00888 #endif
00889                 /* check if this is the start of a new run */
00890                 while (toprun_count == 0) {
00891                     toprun_count = *topRLElen++;
00892                     run_state ^= 1;
00893                 }
00894                 while (botrun_count == 0) {
00895                     botrun_count = *botRLElen++;
00896                     run_state ^= 2;
00897                 }
00898 
00899                 /* find the union of the two runs of voxels */
00900                 count = MIN(toprun_count, botrun_count);
00901                 toprun_count -= count;
00902                 botrun_count -= count;
00903                 i -= count;
00904                 Debug((vpc, VPDEBUG_COMPOSITE, "Run(%d)\n", count));
00905                 ASSERT(i >= 0);
00906 #ifndef UNROLL_RUN_LOOP
00907             }
00908 #endif
00909             COUNT_RUN_FRAGMENT;
00910 
00911             /***********************************************************
00912              * composite the voxels in the current run.
00913              ***********************************************************/
00914 
00915             GET_HIRES_TIME(vpc, t1);
00916             STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00917             COPY_HIRES_TIME(t0, t1);
00918 
00919 #ifdef SKIP_COMPOSITE
00920             switch (run_state) {
00921             case ALL_ZERO:
00922                 ipixel += count;
00923                 ;
00924                 ;
00925                 count = 0;
00926                 break;
00927             case TOP_NONZERO:
00928                 ipixel += count;
00929                 topRLEdata += count * voxel_istride;
00930                 ;
00931                 count = 0;
00932                 break;
00933             case BOT_NONZERO:
00934                 ipixel += count;
00935                 ;
00936                 botRLEdata += count * voxel_istride;
00937                 count = 0;
00938                 break;
00939             case ALL_NONZERO:
00940                 ipixel += count;
00941                 topRLEdata += count * voxel_istride;
00942                 botRLEdata += count * voxel_istride;
00943                 count = 0;
00944                 break;
00945             }
00946 #else /* !SKIP_COMPOSITE */
00947 #ifdef UNROLL_RUN_LOOP
00948             /* this run contains pixels, so process them */
00949             switch ((last_run_state << 2) | run_state) {
00950             case ALL_ZERO__ALL_ZERO:
00951                 /* no voxels contribute to the pixels in this run */
00952                 ipixel += count;
00953                 ;
00954                 ;
00955                 count = 0;
00956                 break;
00957             case TOP_NONZERO__ALL_ZERO:
00958                 /* only the top-left voxel contributes to the first
00959                    pixel of the run, and the rest are zero */
00960                 if (!voxels_loaded) {
00961                     
00962     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
00963     
00964     
00965     ;
00966     ;
00967     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
00968     shade_factor = top_opc * slice_depth_cueing;
00969     
00970         top_clr *= shade_factor;
00971     ;
00972                 }
00973                 
00974 #ifdef DEBUG
00975     if (ipixel == trace_pixel_ptr) {
00976         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
00977         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
00978         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
00979         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
00980         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
00981     }
00982 #endif
00983 ;
00984                 
00985        acc_opc = top_opc * wgtTL;
00986        acc_clr = top_clr * wgtTL;
00987        
00988 #ifdef DEBUG
00989     if (ipixel == trace_pixel_ptr) {
00990         trace_opcTL = top_opc;
00991         trace_rclrTL = top_clr;
00992         
00993     }
00994 #endif
00995 ;
00996                 
00997         COUNT_RESAMPLE;
00998         if (acc_opc > min_opacity) {
00999             COUNT_COMPOSITE;
01000             iopc = ipixel->opcflt;
01001 #           ifndef SKIP_ERT
01002                 ASSERT(iopc < max_opacity);
01003 #           endif
01004             iopc_inv = (float)1. - iopc;
01005             ipixel->clrflt += acc_clr * iopc_inv;
01006             iopc += acc_opc * iopc_inv;
01007             ipixel->opcflt = iopc;
01008             
01009 #ifdef DEBUG
01010     if (ipixel == trace_pixel_ptr) {
01011 #ifdef COMPUTE_SHADOW_BUFFER
01012         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01013 #else
01014         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01015 #endif
01016         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01017         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01018         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01019         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01020         printf("  %3.0f %3.0f\n", iopc*255., 
01021                ipixel->clrflt);
01022         
01023         
01024     }
01025 #endif /* DEBUG */
01026 ;
01027 #           ifndef SKIP_ERT
01028                 if (iopc >= max_opacity) {
01029                     ASSERT(ipixel->lnk == 0);
01030                     ipixel->lnk = 1;
01031                 }
01032 #           endif
01033         };
01034                 ipixel += count;
01035                 ;
01036                 ;
01037                 count = 0;
01038                 break;
01039             case BOT_NONZERO__ALL_ZERO:
01040                 /* only the bottom left voxel contributes to the first
01041                    pixel of the run, and the rest are zero */
01042                 if (!voxels_loaded) {
01043                     
01044     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01045     
01046     
01047     ;
01048     ;
01049     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
01050     shade_factor = bot_opc * slice_depth_cueing;
01051     
01052         bot_clr *= shade_factor;
01053     ;
01054                 }
01055                 
01056 #ifdef DEBUG
01057     if (ipixel == trace_pixel_ptr) {
01058         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01059         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01060         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01061         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01062         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01063     }
01064 #endif
01065 ;
01066                 
01067        acc_opc = bot_opc * wgtBL;
01068        acc_clr = bot_clr * wgtBL;
01069        
01070 #ifdef DEBUG
01071     if (ipixel == trace_pixel_ptr) {
01072         trace_opcBL = bot_opc;
01073         trace_rclrBL = bot_clr;
01074         
01075     }
01076 #endif
01077 ;
01078                 
01079         COUNT_RESAMPLE;
01080         if (acc_opc > min_opacity) {
01081             COUNT_COMPOSITE;
01082             iopc = ipixel->opcflt;
01083 #           ifndef SKIP_ERT
01084                 ASSERT(iopc < max_opacity);
01085 #           endif
01086             iopc_inv = (float)1. - iopc;
01087             ipixel->clrflt += acc_clr * iopc_inv;
01088             iopc += acc_opc * iopc_inv;
01089             ipixel->opcflt = iopc;
01090             
01091 #ifdef DEBUG
01092     if (ipixel == trace_pixel_ptr) {
01093 #ifdef COMPUTE_SHADOW_BUFFER
01094         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01095 #else
01096         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01097 #endif
01098         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01099         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01100         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01101         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01102         printf("  %3.0f %3.0f\n", iopc*255., 
01103                ipixel->clrflt);
01104         
01105         
01106     }
01107 #endif /* DEBUG */
01108 ;
01109 #           ifndef SKIP_ERT
01110                 if (iopc >= max_opacity) {
01111                     ASSERT(ipixel->lnk == 0);
01112                     ipixel->lnk = 1;
01113                 }
01114 #           endif
01115         };
01116                 ipixel += count;
01117                 ;
01118                 ;
01119                 count = 0;
01120                 break;
01121             case ALL_NONZERO__ALL_ZERO:
01122                 /* the top and bottom left voxels contribute to the
01123                    first pixel of the run, and the rest are zero */
01124                 if (!voxels_loaded) {
01125                     
01126     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01127     
01128     
01129     ;
01130     ;
01131     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
01132     shade_factor = top_opc * slice_depth_cueing;
01133     
01134         top_clr *= shade_factor;
01135     ;
01136                     
01137     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01138     
01139     
01140     ;
01141     ;
01142     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
01143     shade_factor = bot_opc * slice_depth_cueing;
01144     
01145         bot_clr *= shade_factor;
01146     ;
01147                 }
01148                 
01149 #ifdef DEBUG
01150     if (ipixel == trace_pixel_ptr) {
01151         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01152         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01153         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01154         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01155         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01156     }
01157 #endif
01158 ;
01159                 
01160        acc_opc = top_opc * wgtTL;
01161        acc_clr = top_clr * wgtTL;
01162        
01163 #ifdef DEBUG
01164     if (ipixel == trace_pixel_ptr) {
01165         trace_opcTL = top_opc;
01166         trace_rclrTL = top_clr;
01167         
01168     }
01169 #endif
01170 ;
01171                 
01172        acc_opc += bot_opc * wgtBL;
01173        acc_clr += bot_clr * wgtBL;
01174        
01175 #ifdef DEBUG
01176     if (ipixel == trace_pixel_ptr) {
01177         trace_opcBL = bot_opc;
01178         trace_rclrBL = bot_clr;
01179         
01180     }
01181 #endif
01182 ;
01183                 
01184         COUNT_RESAMPLE;
01185         if (acc_opc > min_opacity) {
01186             COUNT_COMPOSITE;
01187             iopc = ipixel->opcflt;
01188 #           ifndef SKIP_ERT
01189                 ASSERT(iopc < max_opacity);
01190 #           endif
01191             iopc_inv = (float)1. - iopc;
01192             ipixel->clrflt += acc_clr * iopc_inv;
01193             iopc += acc_opc * iopc_inv;
01194             ipixel->opcflt = iopc;
01195             
01196 #ifdef DEBUG
01197     if (ipixel == trace_pixel_ptr) {
01198 #ifdef COMPUTE_SHADOW_BUFFER
01199         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01200 #else
01201         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01202 #endif
01203         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01204         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01205         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01206         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01207         printf("  %3.0f %3.0f\n", iopc*255., 
01208                ipixel->clrflt);
01209         
01210         
01211     }
01212 #endif /* DEBUG */
01213 ;
01214 #           ifndef SKIP_ERT
01215                 if (iopc >= max_opacity) {
01216                     ASSERT(ipixel->lnk == 0);
01217                     ipixel->lnk = 1;
01218                 }
01219 #           endif
01220         };
01221                 ipixel += count;
01222                 ;
01223                 ;
01224                 count = 0;
01225                 break;
01226             case ALL_ZERO__TOP_NONZERO:
01227                 /* first pixel: only the top-right voxel contributes */
01228                 
01229     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01230     
01231     
01232     ;
01233     ;
01234     shade_func(topRLEdata, &(top_clr), client_data);
01235     shade_factor = top_opc * slice_depth_cueing;
01236     
01237         top_clr *= shade_factor;
01238     ;
01239                 
01240 #ifdef DEBUG
01241     if (ipixel == trace_pixel_ptr) {
01242         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01243         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01244         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01245         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01246         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01247     }
01248 #endif
01249 ;
01250                 
01251        acc_opc = top_opc * wgtTR;
01252        acc_clr = top_clr * wgtTR;
01253        
01254 #ifdef DEBUG
01255     if (ipixel == trace_pixel_ptr) {
01256         trace_opcTR = top_opc;
01257         trace_rclrTR = top_clr;
01258         
01259     }
01260 #endif
01261 ;
01262                 
01263         COUNT_RESAMPLE;
01264         if (acc_opc > min_opacity) {
01265             COUNT_COMPOSITE;
01266             iopc = ipixel->opcflt;
01267 #           ifndef SKIP_ERT
01268                 ASSERT(iopc < max_opacity);
01269 #           endif
01270             iopc_inv = (float)1. - iopc;
01271             ipixel->clrflt += acc_clr * iopc_inv;
01272             iopc += acc_opc * iopc_inv;
01273             ipixel->opcflt = iopc;
01274             
01275 #ifdef DEBUG
01276     if (ipixel == trace_pixel_ptr) {
01277 #ifdef COMPUTE_SHADOW_BUFFER
01278         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01279 #else
01280         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01281 #endif
01282         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01283         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01284         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01285         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01286         printf("  %3.0f %3.0f\n", iopc*255., 
01287                ipixel->clrflt);
01288         
01289         
01290     }
01291 #endif /* DEBUG */
01292 ;
01293 #           ifndef SKIP_ERT
01294                 if (iopc >= max_opacity) {
01295                     ASSERT(ipixel->lnk == 0);
01296                     ipixel->lnk = 1;
01297                 }
01298 #           endif
01299         };
01300                 ipixel += 1;
01301                 topRLEdata += 1 * voxel_istride;
01302                 ;
01303                 count--;
01304                 SET_VOXELS_LOADED;
01305 
01306                 /* do the rest of the pixels in this run;
01307                    the top-left and top-right voxels contribute */
01308                 while (count > 0) {
01309                     if (PIXEL_IS_OPAQUE(ipixel))
01310                         break;
01311                     if (!voxels_loaded) {
01312                         
01313     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01314     
01315     
01316     ;
01317     ;
01318     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
01319     shade_factor = top_opc * slice_depth_cueing;
01320     
01321         top_clr *= shade_factor;
01322     ;
01323                     }
01324                     
01325 #ifdef DEBUG
01326     if (ipixel == trace_pixel_ptr) {
01327         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01328         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01329         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01330         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01331         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01332     }
01333 #endif
01334 ;
01335                     
01336        acc_opc = top_opc * wgtTL;
01337        acc_clr = top_clr * wgtTL;
01338        
01339 #ifdef DEBUG
01340     if (ipixel == trace_pixel_ptr) {
01341         trace_opcTL = top_opc;
01342         trace_rclrTL = top_clr;
01343         
01344     }
01345 #endif
01346 ;
01347                     
01348     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01349     
01350     
01351     ;
01352     ;
01353     shade_func(topRLEdata, &(top_clr), client_data);
01354     shade_factor = top_opc * slice_depth_cueing;
01355     
01356         top_clr *= shade_factor;
01357     ;
01358                     
01359        acc_opc += top_opc * wgtTR;
01360        acc_clr += top_clr * wgtTR;
01361        
01362 #ifdef DEBUG
01363     if (ipixel == trace_pixel_ptr) {
01364         trace_opcTR = top_opc;
01365         trace_rclrTR = top_clr;
01366         
01367     }
01368 #endif
01369 ;
01370                     
01371         COUNT_RESAMPLE;
01372         if (acc_opc > min_opacity) {
01373             COUNT_COMPOSITE;
01374             iopc = ipixel->opcflt;
01375 #           ifndef SKIP_ERT
01376                 ASSERT(iopc < max_opacity);
01377 #           endif
01378             iopc_inv = (float)1. - iopc;
01379             ipixel->clrflt += acc_clr * iopc_inv;
01380             iopc += acc_opc * iopc_inv;
01381             ipixel->opcflt = iopc;
01382             
01383 #ifdef DEBUG
01384     if (ipixel == trace_pixel_ptr) {
01385 #ifdef COMPUTE_SHADOW_BUFFER
01386         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01387 #else
01388         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01389 #endif
01390         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01391         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01392         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01393         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01394         printf("  %3.0f %3.0f\n", iopc*255., 
01395                ipixel->clrflt);
01396         
01397         
01398     }
01399 #endif /* DEBUG */
01400 ;
01401 #           ifndef SKIP_ERT
01402                 if (iopc >= max_opacity) {
01403                     ASSERT(ipixel->lnk == 0);
01404                     ipixel->lnk = 1;
01405                 }
01406 #           endif
01407         };
01408                     ipixel += 1;
01409                     topRLEdata += 1 * voxel_istride;
01410                     ;
01411                     count--;
01412                     SET_VOXELS_LOADED;
01413                 }
01414                 break;
01415             case TOP_NONZERO__TOP_NONZERO:
01416                 /* do the pixels in this run; the top-left and
01417                    top-right voxels contribute */
01418                 while (count > 0) {
01419                     if (PIXEL_IS_OPAQUE(ipixel))
01420                         break;
01421                     if (!voxels_loaded) {
01422                         
01423     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01424     
01425     
01426     ;
01427     ;
01428     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
01429     shade_factor = top_opc * slice_depth_cueing;
01430     
01431         top_clr *= shade_factor;
01432     ;
01433                     }
01434                     
01435 #ifdef DEBUG
01436     if (ipixel == trace_pixel_ptr) {
01437         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01438         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01439         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01440         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01441         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01442     }
01443 #endif
01444 ;
01445                     
01446        acc_opc = top_opc * wgtTL;
01447        acc_clr = top_clr * wgtTL;
01448        
01449 #ifdef DEBUG
01450     if (ipixel == trace_pixel_ptr) {
01451         trace_opcTL = top_opc;
01452         trace_rclrTL = top_clr;
01453         
01454     }
01455 #endif
01456 ;
01457                     
01458     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01459     
01460     
01461     ;
01462     ;
01463     shade_func(topRLEdata, &(top_clr), client_data);
01464     shade_factor = top_opc * slice_depth_cueing;
01465     
01466         top_clr *= shade_factor;
01467     ;
01468                     
01469        acc_opc += top_opc * wgtTR;
01470        acc_clr += top_clr * wgtTR;
01471        
01472 #ifdef DEBUG
01473     if (ipixel == trace_pixel_ptr) {
01474         trace_opcTR = top_opc;
01475         trace_rclrTR = top_clr;
01476         
01477     }
01478 #endif
01479 ;
01480                     
01481         COUNT_RESAMPLE;
01482         if (acc_opc > min_opacity) {
01483             COUNT_COMPOSITE;
01484             iopc = ipixel->opcflt;
01485 #           ifndef SKIP_ERT
01486                 ASSERT(iopc < max_opacity);
01487 #           endif
01488             iopc_inv = (float)1. - iopc;
01489             ipixel->clrflt += acc_clr * iopc_inv;
01490             iopc += acc_opc * iopc_inv;
01491             ipixel->opcflt = iopc;
01492             
01493 #ifdef DEBUG
01494     if (ipixel == trace_pixel_ptr) {
01495 #ifdef COMPUTE_SHADOW_BUFFER
01496         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01497 #else
01498         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01499 #endif
01500         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01501         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01502         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01503         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01504         printf("  %3.0f %3.0f\n", iopc*255., 
01505                ipixel->clrflt);
01506         
01507         
01508     }
01509 #endif /* DEBUG */
01510 ;
01511 #           ifndef SKIP_ERT
01512                 if (iopc >= max_opacity) {
01513                     ASSERT(ipixel->lnk == 0);
01514                     ipixel->lnk = 1;
01515                 }
01516 #           endif
01517         };
01518                     ipixel += 1;
01519                     topRLEdata += 1 * voxel_istride;
01520                     ;
01521                     count--;
01522                     SET_VOXELS_LOADED;
01523                 }
01524                 break;
01525             case BOT_NONZERO__TOP_NONZERO:
01526                 /* first pixel: bottom-left and top-right voxels
01527                    contribute */
01528                 if (!voxels_loaded) {
01529                     
01530     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01531     
01532     
01533     ;
01534     ;
01535     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
01536     shade_factor = bot_opc * slice_depth_cueing;
01537     
01538         bot_clr *= shade_factor;
01539     ;
01540                 }
01541                 
01542 #ifdef DEBUG
01543     if (ipixel == trace_pixel_ptr) {
01544         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01545         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01546         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01547         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01548         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01549     }
01550 #endif
01551 ;
01552                 
01553        acc_opc = bot_opc * wgtBL;
01554        acc_clr = bot_clr * wgtBL;
01555        
01556 #ifdef DEBUG
01557     if (ipixel == trace_pixel_ptr) {
01558         trace_opcBL = bot_opc;
01559         trace_rclrBL = bot_clr;
01560         
01561     }
01562 #endif
01563 ;
01564                 
01565     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01566     
01567     
01568     ;
01569     ;
01570     shade_func(topRLEdata, &(top_clr), client_data);
01571     shade_factor = top_opc * slice_depth_cueing;
01572     
01573         top_clr *= shade_factor;
01574     ;
01575                 
01576        acc_opc += top_opc * wgtTR;
01577        acc_clr += top_clr * wgtTR;
01578        
01579 #ifdef DEBUG
01580     if (ipixel == trace_pixel_ptr) {
01581         trace_opcTR = top_opc;
01582         trace_rclrTR = top_clr;
01583         
01584     }
01585 #endif
01586 ;
01587                 
01588         COUNT_RESAMPLE;
01589         if (acc_opc > min_opacity) {
01590             COUNT_COMPOSITE;
01591             iopc = ipixel->opcflt;
01592 #           ifndef SKIP_ERT
01593                 ASSERT(iopc < max_opacity);
01594 #           endif
01595             iopc_inv = (float)1. - iopc;
01596             ipixel->clrflt += acc_clr * iopc_inv;
01597             iopc += acc_opc * iopc_inv;
01598             ipixel->opcflt = iopc;
01599             
01600 #ifdef DEBUG
01601     if (ipixel == trace_pixel_ptr) {
01602 #ifdef COMPUTE_SHADOW_BUFFER
01603         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01604 #else
01605         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01606 #endif
01607         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01608         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01609         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01610         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01611         printf("  %3.0f %3.0f\n", iopc*255., 
01612                ipixel->clrflt);
01613         
01614         
01615     }
01616 #endif /* DEBUG */
01617 ;
01618 #           ifndef SKIP_ERT
01619                 if (iopc >= max_opacity) {
01620                     ASSERT(ipixel->lnk == 0);
01621                     ipixel->lnk = 1;
01622                 }
01623 #           endif
01624         };
01625                 ipixel += 1;
01626                 topRLEdata += 1 * voxel_istride;
01627                 ;
01628                 count--;
01629                 SET_VOXELS_LOADED;
01630 
01631                 /* do the rest of the pixels in this run;
01632                    the top-left and top-right voxels contribute */
01633                 while (count > 0) {
01634                     if (PIXEL_IS_OPAQUE(ipixel))
01635                         break;
01636                     if (!voxels_loaded) {
01637                         
01638     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01639     
01640     
01641     ;
01642     ;
01643     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
01644     shade_factor = top_opc * slice_depth_cueing;
01645     
01646         top_clr *= shade_factor;
01647     ;
01648                     }
01649                     
01650 #ifdef DEBUG
01651     if (ipixel == trace_pixel_ptr) {
01652         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01653         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01654         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01655         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01656         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01657     }
01658 #endif
01659 ;
01660                     
01661        acc_opc = top_opc * wgtTL;
01662        acc_clr = top_clr * wgtTL;
01663        
01664 #ifdef DEBUG
01665     if (ipixel == trace_pixel_ptr) {
01666         trace_opcTL = top_opc;
01667         trace_rclrTL = top_clr;
01668         
01669     }
01670 #endif
01671 ;
01672                     
01673     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01674     
01675     
01676     ;
01677     ;
01678     shade_func(topRLEdata, &(top_clr), client_data);
01679     shade_factor = top_opc * slice_depth_cueing;
01680     
01681         top_clr *= shade_factor;
01682     ;
01683                     
01684        acc_opc += top_opc * wgtTR;
01685        acc_clr += top_clr * wgtTR;
01686        
01687 #ifdef DEBUG
01688     if (ipixel == trace_pixel_ptr) {
01689         trace_opcTR = top_opc;
01690         trace_rclrTR = top_clr;
01691         
01692     }
01693 #endif
01694 ;
01695                     
01696         COUNT_RESAMPLE;
01697         if (acc_opc > min_opacity) {
01698             COUNT_COMPOSITE;
01699             iopc = ipixel->opcflt;
01700 #           ifndef SKIP_ERT
01701                 ASSERT(iopc < max_opacity);
01702 #           endif
01703             iopc_inv = (float)1. - iopc;
01704             ipixel->clrflt += acc_clr * iopc_inv;
01705             iopc += acc_opc * iopc_inv;
01706             ipixel->opcflt = iopc;
01707             
01708 #ifdef DEBUG
01709     if (ipixel == trace_pixel_ptr) {
01710 #ifdef COMPUTE_SHADOW_BUFFER
01711         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01712 #else
01713         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01714 #endif
01715         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01716         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01717         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01718         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01719         printf("  %3.0f %3.0f\n", iopc*255., 
01720                ipixel->clrflt);
01721         
01722         
01723     }
01724 #endif /* DEBUG */
01725 ;
01726 #           ifndef SKIP_ERT
01727                 if (iopc >= max_opacity) {
01728                     ASSERT(ipixel->lnk == 0);
01729                     ipixel->lnk = 1;
01730                 }
01731 #           endif
01732         };
01733                     ipixel += 1;
01734                     topRLEdata += 1 * voxel_istride;
01735                     ;
01736                     count--;
01737                     SET_VOXELS_LOADED;
01738                 }
01739                 break;
01740             case ALL_NONZERO__TOP_NONZERO:
01741                 /* first pixel: top-left, bottom-left and top-right voxels
01742                    contribute */
01743                 if (!voxels_loaded) {
01744                     
01745     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01746     
01747     
01748     ;
01749     ;
01750     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
01751     shade_factor = top_opc * slice_depth_cueing;
01752     
01753         top_clr *= shade_factor;
01754     ;
01755                     
01756     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01757     
01758     
01759     ;
01760     ;
01761     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
01762     shade_factor = bot_opc * slice_depth_cueing;
01763     
01764         bot_clr *= shade_factor;
01765     ;
01766                 }
01767                 
01768 #ifdef DEBUG
01769     if (ipixel == trace_pixel_ptr) {
01770         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01771         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01772         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01773         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01774         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01775     }
01776 #endif
01777 ;
01778                 
01779        acc_opc = top_opc * wgtTL;
01780        acc_clr = top_clr * wgtTL;
01781        
01782 #ifdef DEBUG
01783     if (ipixel == trace_pixel_ptr) {
01784         trace_opcTL = top_opc;
01785         trace_rclrTL = top_clr;
01786         
01787     }
01788 #endif
01789 ;
01790                 
01791        acc_opc += bot_opc * wgtBL;
01792        acc_clr += bot_clr * wgtBL;
01793        
01794 #ifdef DEBUG
01795     if (ipixel == trace_pixel_ptr) {
01796         trace_opcBL = bot_opc;
01797         trace_rclrBL = bot_clr;
01798         
01799     }
01800 #endif
01801 ;
01802                 
01803     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01804     
01805     
01806     ;
01807     ;
01808     shade_func(topRLEdata, &(top_clr), client_data);
01809     shade_factor = top_opc * slice_depth_cueing;
01810     
01811         top_clr *= shade_factor;
01812     ;
01813                 
01814        acc_opc += top_opc * wgtTR;
01815        acc_clr += top_clr * wgtTR;
01816        
01817 #ifdef DEBUG
01818     if (ipixel == trace_pixel_ptr) {
01819         trace_opcTR = top_opc;
01820         trace_rclrTR = top_clr;
01821         
01822     }
01823 #endif
01824 ;
01825                 
01826         COUNT_RESAMPLE;
01827         if (acc_opc > min_opacity) {
01828             COUNT_COMPOSITE;
01829             iopc = ipixel->opcflt;
01830 #           ifndef SKIP_ERT
01831                 ASSERT(iopc < max_opacity);
01832 #           endif
01833             iopc_inv = (float)1. - iopc;
01834             ipixel->clrflt += acc_clr * iopc_inv;
01835             iopc += acc_opc * iopc_inv;
01836             ipixel->opcflt = iopc;
01837             
01838 #ifdef DEBUG
01839     if (ipixel == trace_pixel_ptr) {
01840 #ifdef COMPUTE_SHADOW_BUFFER
01841         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01842 #else
01843         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01844 #endif
01845         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01846         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01847         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01848         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01849         printf("  %3.0f %3.0f\n", iopc*255., 
01850                ipixel->clrflt);
01851         
01852         
01853     }
01854 #endif /* DEBUG */
01855 ;
01856 #           ifndef SKIP_ERT
01857                 if (iopc >= max_opacity) {
01858                     ASSERT(ipixel->lnk == 0);
01859                     ipixel->lnk = 1;
01860                 }
01861 #           endif
01862         };
01863                 ipixel += 1;
01864                 topRLEdata += 1 * voxel_istride;
01865                 ;
01866                 count--;
01867                 SET_VOXELS_LOADED;
01868 
01869                 /* do the rest of the pixels in this run;
01870                    the top-left and top-right voxels contribute */
01871                 while (count > 0) {
01872                     if (PIXEL_IS_OPAQUE(ipixel))
01873                         break;
01874                     if (!voxels_loaded) {
01875                         
01876     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01877     
01878     
01879     ;
01880     ;
01881     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
01882     shade_factor = top_opc * slice_depth_cueing;
01883     
01884         top_clr *= shade_factor;
01885     ;
01886                     }
01887                     
01888 #ifdef DEBUG
01889     if (ipixel == trace_pixel_ptr) {
01890         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01891         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01892         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01893         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01894         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01895     }
01896 #endif
01897 ;
01898                     
01899        acc_opc = top_opc * wgtTL;
01900        acc_clr = top_clr * wgtTL;
01901        
01902 #ifdef DEBUG
01903     if (ipixel == trace_pixel_ptr) {
01904         trace_opcTL = top_opc;
01905         trace_rclrTL = top_clr;
01906         
01907     }
01908 #endif
01909 ;
01910                     
01911     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01912     
01913     
01914     ;
01915     ;
01916     shade_func(topRLEdata, &(top_clr), client_data);
01917     shade_factor = top_opc * slice_depth_cueing;
01918     
01919         top_clr *= shade_factor;
01920     ;
01921                     
01922        acc_opc += top_opc * wgtTR;
01923        acc_clr += top_clr * wgtTR;
01924        
01925 #ifdef DEBUG
01926     if (ipixel == trace_pixel_ptr) {
01927         trace_opcTR = top_opc;
01928         trace_rclrTR = top_clr;
01929         
01930     }
01931 #endif
01932 ;
01933                     
01934         COUNT_RESAMPLE;
01935         if (acc_opc > min_opacity) {
01936             COUNT_COMPOSITE;
01937             iopc = ipixel->opcflt;
01938 #           ifndef SKIP_ERT
01939                 ASSERT(iopc < max_opacity);
01940 #           endif
01941             iopc_inv = (float)1. - iopc;
01942             ipixel->clrflt += acc_clr * iopc_inv;
01943             iopc += acc_opc * iopc_inv;
01944             ipixel->opcflt = iopc;
01945             
01946 #ifdef DEBUG
01947     if (ipixel == trace_pixel_ptr) {
01948 #ifdef COMPUTE_SHADOW_BUFFER
01949         printf("{%3d}  %3d %3d", k, icount-i-count, j);
01950 #else
01951         printf("[%3d]  %3d %3d", k, icount-i-count, j);
01952 #endif
01953         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01954         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01955         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01956         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01957         printf("  %3.0f %3.0f\n", iopc*255., 
01958                ipixel->clrflt);
01959         
01960         
01961     }
01962 #endif /* DEBUG */
01963 ;
01964 #           ifndef SKIP_ERT
01965                 if (iopc >= max_opacity) {
01966                     ASSERT(ipixel->lnk == 0);
01967                     ipixel->lnk = 1;
01968                 }
01969 #           endif
01970         };
01971                     ipixel += 1;
01972                     topRLEdata += 1 * voxel_istride;
01973                     ;
01974                     count--;
01975                     SET_VOXELS_LOADED;
01976                 }
01977                 break;
01978             case ALL_ZERO__BOT_NONZERO:
01979                 /* first pixel: only the bottom-right voxel contributes */
01980                 
01981     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
01982     
01983     
01984     ;
01985     ;
01986     shade_func(botRLEdata, &(bot_clr), client_data);
01987     shade_factor = bot_opc * slice_depth_cueing;
01988     
01989         bot_clr *= shade_factor;
01990     ;
01991                 
01992 #ifdef DEBUG
01993     if (ipixel == trace_pixel_ptr) {
01994         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01995         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01996         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01997         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01998         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01999     }
02000 #endif
02001 ;
02002                 
02003        acc_opc = bot_opc * wgtBR;
02004        acc_clr = bot_clr * wgtBR;
02005        
02006 #ifdef DEBUG
02007     if (ipixel == trace_pixel_ptr) {
02008         trace_opcBR = bot_opc;
02009         trace_rclrBR = bot_clr;
02010         
02011     }
02012 #endif
02013 ;
02014                 
02015         COUNT_RESAMPLE;
02016         if (acc_opc > min_opacity) {
02017             COUNT_COMPOSITE;
02018             iopc = ipixel->opcflt;
02019 #           ifndef SKIP_ERT
02020                 ASSERT(iopc < max_opacity);
02021 #           endif
02022             iopc_inv = (float)1. - iopc;
02023             ipixel->clrflt += acc_clr * iopc_inv;
02024             iopc += acc_opc * iopc_inv;
02025             ipixel->opcflt = iopc;
02026             
02027 #ifdef DEBUG
02028     if (ipixel == trace_pixel_ptr) {
02029 #ifdef COMPUTE_SHADOW_BUFFER
02030         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02031 #else
02032         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02033 #endif
02034         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02035         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02036         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02037         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02038         printf("  %3.0f %3.0f\n", iopc*255., 
02039                ipixel->clrflt);
02040         
02041         
02042     }
02043 #endif /* DEBUG */
02044 ;
02045 #           ifndef SKIP_ERT
02046                 if (iopc >= max_opacity) {
02047                     ASSERT(ipixel->lnk == 0);
02048                     ipixel->lnk = 1;
02049                 }
02050 #           endif
02051         };      
02052                 ipixel += 1;
02053                 ;
02054                 botRLEdata += 1 * voxel_istride;
02055                 count--;
02056                 SET_VOXELS_LOADED;
02057 
02058                 /* do the rest of the pixels in this run;
02059                    bottom-left and bottom-right voxels contribute */
02060                 while (count > 0) {
02061                     if (PIXEL_IS_OPAQUE(ipixel))
02062                         break;
02063                     if (!voxels_loaded) {
02064                         
02065     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02066     
02067     
02068     ;
02069     ;
02070     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
02071     shade_factor = bot_opc * slice_depth_cueing;
02072     
02073         bot_clr *= shade_factor;
02074     ;
02075                     }
02076                     
02077 #ifdef DEBUG
02078     if (ipixel == trace_pixel_ptr) {
02079         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02080         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02081         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02082         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02083         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02084     }
02085 #endif
02086 ;
02087                     
02088        acc_opc = bot_opc * wgtBL;
02089        acc_clr = bot_clr * wgtBL;
02090        
02091 #ifdef DEBUG
02092     if (ipixel == trace_pixel_ptr) {
02093         trace_opcBL = bot_opc;
02094         trace_rclrBL = bot_clr;
02095         
02096     }
02097 #endif
02098 ;
02099                     
02100     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02101     
02102     
02103     ;
02104     ;
02105     shade_func(botRLEdata, &(bot_clr), client_data);
02106     shade_factor = bot_opc * slice_depth_cueing;
02107     
02108         bot_clr *= shade_factor;
02109     ;
02110                     
02111        acc_opc += bot_opc * wgtBR;
02112        acc_clr += bot_clr * wgtBR;
02113        
02114 #ifdef DEBUG
02115     if (ipixel == trace_pixel_ptr) {
02116         trace_opcBR = bot_opc;
02117         trace_rclrBR = bot_clr;
02118         
02119     }
02120 #endif
02121 ;
02122                     
02123         COUNT_RESAMPLE;
02124         if (acc_opc > min_opacity) {
02125             COUNT_COMPOSITE;
02126             iopc = ipixel->opcflt;
02127 #           ifndef SKIP_ERT
02128                 ASSERT(iopc < max_opacity);
02129 #           endif
02130             iopc_inv = (float)1. - iopc;
02131             ipixel->clrflt += acc_clr * iopc_inv;
02132             iopc += acc_opc * iopc_inv;
02133             ipixel->opcflt = iopc;
02134             
02135 #ifdef DEBUG
02136     if (ipixel == trace_pixel_ptr) {
02137 #ifdef COMPUTE_SHADOW_BUFFER
02138         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02139 #else
02140         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02141 #endif
02142         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02143         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02144         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02145         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02146         printf("  %3.0f %3.0f\n", iopc*255., 
02147                ipixel->clrflt);
02148         
02149         
02150     }
02151 #endif /* DEBUG */
02152 ;
02153 #           ifndef SKIP_ERT
02154                 if (iopc >= max_opacity) {
02155                     ASSERT(ipixel->lnk == 0);
02156                     ipixel->lnk = 1;
02157                 }
02158 #           endif
02159         };
02160                     ipixel += 1;
02161                     ;
02162                     botRLEdata += 1 * voxel_istride;
02163                     count--;
02164                     SET_VOXELS_LOADED;
02165                 }
02166                 break;
02167             case TOP_NONZERO__BOT_NONZERO:
02168                 /* first pixel: top-left and bottom-right voxels contribute */
02169                 if (!voxels_loaded) {
02170                     
02171     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02172     
02173     
02174     ;
02175     ;
02176     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
02177     shade_factor = top_opc * slice_depth_cueing;
02178     
02179         top_clr *= shade_factor;
02180     ;
02181                 }
02182                 
02183 #ifdef DEBUG
02184     if (ipixel == trace_pixel_ptr) {
02185         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02186         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02187         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02188         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02189         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02190     }
02191 #endif
02192 ;
02193                 
02194        acc_opc = top_opc * wgtTL;
02195        acc_clr = top_clr * wgtTL;
02196        
02197 #ifdef DEBUG
02198     if (ipixel == trace_pixel_ptr) {
02199         trace_opcTL = top_opc;
02200         trace_rclrTL = top_clr;
02201         
02202     }
02203 #endif
02204 ;
02205                 
02206     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02207     
02208     
02209     ;
02210     ;
02211     shade_func(botRLEdata, &(bot_clr), client_data);
02212     shade_factor = bot_opc * slice_depth_cueing;
02213     
02214         bot_clr *= shade_factor;
02215     ;
02216                 
02217        acc_opc += bot_opc * wgtBR;
02218        acc_clr += bot_clr * wgtBR;
02219        
02220 #ifdef DEBUG
02221     if (ipixel == trace_pixel_ptr) {
02222         trace_opcBR = bot_opc;
02223         trace_rclrBR = bot_clr;
02224         
02225     }
02226 #endif
02227 ;
02228                 
02229         COUNT_RESAMPLE;
02230         if (acc_opc > min_opacity) {
02231             COUNT_COMPOSITE;
02232             iopc = ipixel->opcflt;
02233 #           ifndef SKIP_ERT
02234                 ASSERT(iopc < max_opacity);
02235 #           endif
02236             iopc_inv = (float)1. - iopc;
02237             ipixel->clrflt += acc_clr * iopc_inv;
02238             iopc += acc_opc * iopc_inv;
02239             ipixel->opcflt = iopc;
02240             
02241 #ifdef DEBUG
02242     if (ipixel == trace_pixel_ptr) {
02243 #ifdef COMPUTE_SHADOW_BUFFER
02244         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02245 #else
02246         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02247 #endif
02248         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02249         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02250         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02251         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02252         printf("  %3.0f %3.0f\n", iopc*255., 
02253                ipixel->clrflt);
02254         
02255         
02256     }
02257 #endif /* DEBUG */
02258 ;
02259 #           ifndef SKIP_ERT
02260                 if (iopc >= max_opacity) {
02261                     ASSERT(ipixel->lnk == 0);
02262                     ipixel->lnk = 1;
02263                 }
02264 #           endif
02265         };
02266                 ipixel += 1;
02267                 ;
02268                 botRLEdata += 1 * voxel_istride;
02269                 count--;
02270                 SET_VOXELS_LOADED;
02271 
02272                 /* do the rest of the pixels in this run;
02273                    bottom-left and bottom-right voxels contribute */
02274                 while (count > 0) {
02275                     if (PIXEL_IS_OPAQUE(ipixel))
02276                         break;
02277                     if (!voxels_loaded) {
02278                         
02279     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02280     
02281     
02282     ;
02283     ;
02284     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
02285     shade_factor = bot_opc * slice_depth_cueing;
02286     
02287         bot_clr *= shade_factor;
02288     ;
02289                     }
02290                     
02291 #ifdef DEBUG
02292     if (ipixel == trace_pixel_ptr) {
02293         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02294         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02295         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02296         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02297         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02298     }
02299 #endif
02300 ;
02301                     
02302        acc_opc = bot_opc * wgtBL;
02303        acc_clr = bot_clr * wgtBL;
02304        
02305 #ifdef DEBUG
02306     if (ipixel == trace_pixel_ptr) {
02307         trace_opcBL = bot_opc;
02308         trace_rclrBL = bot_clr;
02309         
02310     }
02311 #endif
02312 ;
02313                     
02314     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02315     
02316     
02317     ;
02318     ;
02319     shade_func(botRLEdata, &(bot_clr), client_data);
02320     shade_factor = bot_opc * slice_depth_cueing;
02321     
02322         bot_clr *= shade_factor;
02323     ;
02324                     
02325        acc_opc += bot_opc * wgtBR;
02326        acc_clr += bot_clr * wgtBR;
02327        
02328 #ifdef DEBUG
02329     if (ipixel == trace_pixel_ptr) {
02330         trace_opcBR = bot_opc;
02331         trace_rclrBR = bot_clr;
02332         
02333     }
02334 #endif
02335 ;
02336                     
02337         COUNT_RESAMPLE;
02338         if (acc_opc > min_opacity) {
02339             COUNT_COMPOSITE;
02340             iopc = ipixel->opcflt;
02341 #           ifndef SKIP_ERT
02342                 ASSERT(iopc < max_opacity);
02343 #           endif
02344             iopc_inv = (float)1. - iopc;
02345             ipixel->clrflt += acc_clr * iopc_inv;
02346             iopc += acc_opc * iopc_inv;
02347             ipixel->opcflt = iopc;
02348             
02349 #ifdef DEBUG
02350     if (ipixel == trace_pixel_ptr) {
02351 #ifdef COMPUTE_SHADOW_BUFFER
02352         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02353 #else
02354         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02355 #endif
02356         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02357         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02358         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02359         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02360         printf("  %3.0f %3.0f\n", iopc*255., 
02361                ipixel->clrflt);
02362         
02363         
02364     }
02365 #endif /* DEBUG */
02366 ;
02367 #           ifndef SKIP_ERT
02368                 if (iopc >= max_opacity) {
02369                     ASSERT(ipixel->lnk == 0);
02370                     ipixel->lnk = 1;
02371                 }
02372 #           endif
02373         };
02374                     ipixel += 1;
02375                     ;
02376                     botRLEdata += 1 * voxel_istride;
02377                     count--;
02378                     SET_VOXELS_LOADED;
02379                 }
02380                 break;
02381             case BOT_NONZERO__BOT_NONZERO:
02382                 /* do the pixels in this run; bottom-left and
02383                    bottom-right voxels contribute */
02384                 while (count > 0) {
02385                     if (PIXEL_IS_OPAQUE(ipixel))
02386                         break;
02387                     if (!voxels_loaded) {
02388                         
02389     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02390     
02391     
02392     ;
02393     ;
02394     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
02395     shade_factor = bot_opc * slice_depth_cueing;
02396     
02397         bot_clr *= shade_factor;
02398     ;
02399                     }
02400                     
02401 #ifdef DEBUG
02402     if (ipixel == trace_pixel_ptr) {
02403         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02404         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02405         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02406         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02407         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02408     }
02409 #endif
02410 ;
02411                     
02412        acc_opc = bot_opc * wgtBL;
02413        acc_clr = bot_clr * wgtBL;
02414        
02415 #ifdef DEBUG
02416     if (ipixel == trace_pixel_ptr) {
02417         trace_opcBL = bot_opc;
02418         trace_rclrBL = bot_clr;
02419         
02420     }
02421 #endif
02422 ;
02423                     
02424     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02425     
02426     
02427     ;
02428     ;
02429     shade_func(botRLEdata, &(bot_clr), client_data);
02430     shade_factor = bot_opc * slice_depth_cueing;
02431     
02432         bot_clr *= shade_factor;
02433     ;
02434                     
02435        acc_opc += bot_opc * wgtBR;
02436        acc_clr += bot_clr * wgtBR;
02437        
02438 #ifdef DEBUG
02439     if (ipixel == trace_pixel_ptr) {
02440         trace_opcBR = bot_opc;
02441         trace_rclrBR = bot_clr;
02442         
02443     }
02444 #endif
02445 ;
02446                     
02447         COUNT_RESAMPLE;
02448         if (acc_opc > min_opacity) {
02449             COUNT_COMPOSITE;
02450             iopc = ipixel->opcflt;
02451 #           ifndef SKIP_ERT
02452                 ASSERT(iopc < max_opacity);
02453 #           endif
02454             iopc_inv = (float)1. - iopc;
02455             ipixel->clrflt += acc_clr * iopc_inv;
02456             iopc += acc_opc * iopc_inv;
02457             ipixel->opcflt = iopc;
02458             
02459 #ifdef DEBUG
02460     if (ipixel == trace_pixel_ptr) {
02461 #ifdef COMPUTE_SHADOW_BUFFER
02462         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02463 #else
02464         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02465 #endif
02466         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02467         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02468         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02469         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02470         printf("  %3.0f %3.0f\n", iopc*255., 
02471                ipixel->clrflt);
02472         
02473         
02474     }
02475 #endif /* DEBUG */
02476 ;
02477 #           ifndef SKIP_ERT
02478                 if (iopc >= max_opacity) {
02479                     ASSERT(ipixel->lnk == 0);
02480                     ipixel->lnk = 1;
02481                 }
02482 #           endif
02483         };
02484                     ipixel += 1;
02485                     ;
02486                     botRLEdata += 1 * voxel_istride;
02487                     count--;
02488                     SET_VOXELS_LOADED;
02489                 }
02490                 break;
02491             case ALL_NONZERO__BOT_NONZERO:
02492                 /* first pixel: top-left, bottom-left and bottom-right
02493                    voxels contribute */
02494                 if (!voxels_loaded) {
02495                     
02496     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02497     
02498     
02499     ;
02500     ;
02501     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
02502     shade_factor = top_opc * slice_depth_cueing;
02503     
02504         top_clr *= shade_factor;
02505     ;
02506                     
02507     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02508     
02509     
02510     ;
02511     ;
02512     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
02513     shade_factor = bot_opc * slice_depth_cueing;
02514     
02515         bot_clr *= shade_factor;
02516     ;
02517                 }
02518                 
02519 #ifdef DEBUG
02520     if (ipixel == trace_pixel_ptr) {
02521         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02522         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02523         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02524         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02525         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02526     }
02527 #endif
02528 ;
02529                 
02530        acc_opc = top_opc * wgtTL;
02531        acc_clr = top_clr * wgtTL;
02532        
02533 #ifdef DEBUG
02534     if (ipixel == trace_pixel_ptr) {
02535         trace_opcTL = top_opc;
02536         trace_rclrTL = top_clr;
02537         
02538     }
02539 #endif
02540 ;
02541                 
02542        acc_opc += bot_opc * wgtBL;
02543        acc_clr += bot_clr * wgtBL;
02544        
02545 #ifdef DEBUG
02546     if (ipixel == trace_pixel_ptr) {
02547         trace_opcBL = bot_opc;
02548         trace_rclrBL = bot_clr;
02549         
02550     }
02551 #endif
02552 ;
02553                 
02554     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02555     
02556     
02557     ;
02558     ;
02559     shade_func(botRLEdata, &(bot_clr), client_data);
02560     shade_factor = bot_opc * slice_depth_cueing;
02561     
02562         bot_clr *= shade_factor;
02563     ;
02564                 
02565        acc_opc += bot_opc * wgtBR;
02566        acc_clr += bot_clr * wgtBR;
02567        
02568 #ifdef DEBUG
02569     if (ipixel == trace_pixel_ptr) {
02570         trace_opcBR = bot_opc;
02571         trace_rclrBR = bot_clr;
02572         
02573     }
02574 #endif
02575 ;
02576                 
02577         COUNT_RESAMPLE;
02578         if (acc_opc > min_opacity) {
02579             COUNT_COMPOSITE;
02580             iopc = ipixel->opcflt;
02581 #           ifndef SKIP_ERT
02582                 ASSERT(iopc < max_opacity);
02583 #           endif
02584             iopc_inv = (float)1. - iopc;
02585             ipixel->clrflt += acc_clr * iopc_inv;
02586             iopc += acc_opc * iopc_inv;
02587             ipixel->opcflt = iopc;
02588             
02589 #ifdef DEBUG
02590     if (ipixel == trace_pixel_ptr) {
02591 #ifdef COMPUTE_SHADOW_BUFFER
02592         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02593 #else
02594         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02595 #endif
02596         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02597         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02598         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02599         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02600         printf("  %3.0f %3.0f\n", iopc*255., 
02601                ipixel->clrflt);
02602         
02603         
02604     }
02605 #endif /* DEBUG */
02606 ;
02607 #           ifndef SKIP_ERT
02608                 if (iopc >= max_opacity) {
02609                     ASSERT(ipixel->lnk == 0);
02610                     ipixel->lnk = 1;
02611                 }
02612 #           endif
02613         };
02614                 ipixel += 1;
02615                 ;
02616                 botRLEdata += 1 * voxel_istride;
02617                 count--;
02618                 SET_VOXELS_LOADED;
02619 
02620                 /* do the rest of the pixels in this run;
02621                    bottom-left and bottom-right voxels contribute */
02622                 while (count > 0) {
02623                     if (PIXEL_IS_OPAQUE(ipixel))
02624                         break;
02625                     if (!voxels_loaded) {
02626                         
02627     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02628     
02629     
02630     ;
02631     ;
02632     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
02633     shade_factor = bot_opc * slice_depth_cueing;
02634     
02635         bot_clr *= shade_factor;
02636     ;
02637                     }
02638                     
02639 #ifdef DEBUG
02640     if (ipixel == trace_pixel_ptr) {
02641         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02642         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02643         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02644         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02645         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02646     }
02647 #endif
02648 ;
02649                     
02650        acc_opc = bot_opc * wgtBL;
02651        acc_clr = bot_clr * wgtBL;
02652        
02653 #ifdef DEBUG
02654     if (ipixel == trace_pixel_ptr) {
02655         trace_opcBL = bot_opc;
02656         trace_rclrBL = bot_clr;
02657         
02658     }
02659 #endif
02660 ;
02661                     
02662     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02663     
02664     
02665     ;
02666     ;
02667     shade_func(botRLEdata, &(bot_clr), client_data);
02668     shade_factor = bot_opc * slice_depth_cueing;
02669     
02670         bot_clr *= shade_factor;
02671     ;
02672                     
02673        acc_opc += bot_opc * wgtBR;
02674        acc_clr += bot_clr * wgtBR;
02675        
02676 #ifdef DEBUG
02677     if (ipixel == trace_pixel_ptr) {
02678         trace_opcBR = bot_opc;
02679         trace_rclrBR = bot_clr;
02680         
02681     }
02682 #endif
02683 ;
02684                     
02685         COUNT_RESAMPLE;
02686         if (acc_opc > min_opacity) {
02687             COUNT_COMPOSITE;
02688             iopc = ipixel->opcflt;
02689 #           ifndef SKIP_ERT
02690                 ASSERT(iopc < max_opacity);
02691 #           endif
02692             iopc_inv = (float)1. - iopc;
02693             ipixel->clrflt += acc_clr * iopc_inv;
02694             iopc += acc_opc * iopc_inv;
02695             ipixel->opcflt = iopc;
02696             
02697 #ifdef DEBUG
02698     if (ipixel == trace_pixel_ptr) {
02699 #ifdef COMPUTE_SHADOW_BUFFER
02700         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02701 #else
02702         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02703 #endif
02704         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02705         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02706         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02707         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02708         printf("  %3.0f %3.0f\n", iopc*255., 
02709                ipixel->clrflt);
02710         
02711         
02712     }
02713 #endif /* DEBUG */
02714 ;
02715 #           ifndef SKIP_ERT
02716                 if (iopc >= max_opacity) {
02717                     ASSERT(ipixel->lnk == 0);
02718                     ipixel->lnk = 1;
02719                 }
02720 #           endif
02721         };
02722                     ipixel += 1;
02723                     ;
02724                     botRLEdata += 1 * voxel_istride;
02725                     count--;
02726                     SET_VOXELS_LOADED;
02727                 }
02728                 break;
02729             case ALL_ZERO__ALL_NONZERO:
02730                 /* first pixel: top-right and bottom-right voxels contribute */
02731                 
02732     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02733     
02734     
02735     ;
02736     ;
02737     shade_func(topRLEdata, &(top_clr), client_data);
02738     shade_factor = top_opc * slice_depth_cueing;
02739     
02740         top_clr *= shade_factor;
02741     ;
02742                 
02743     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02744     
02745     
02746     ;
02747     ;
02748     shade_func(botRLEdata, &(bot_clr), client_data);
02749     shade_factor = bot_opc * slice_depth_cueing;
02750     
02751         bot_clr *= shade_factor;
02752     ;
02753                 
02754 #ifdef DEBUG
02755     if (ipixel == trace_pixel_ptr) {
02756         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02757         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02758         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02759         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02760         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02761     }
02762 #endif
02763 ;
02764                 
02765        acc_opc = top_opc * wgtTR;
02766        acc_clr = top_clr * wgtTR;
02767        
02768 #ifdef DEBUG
02769     if (ipixel == trace_pixel_ptr) {
02770         trace_opcTR = top_opc;
02771         trace_rclrTR = top_clr;
02772         
02773     }
02774 #endif
02775 ;
02776                 
02777        acc_opc += bot_opc * wgtBR;
02778        acc_clr += bot_clr * wgtBR;
02779        
02780 #ifdef DEBUG
02781     if (ipixel == trace_pixel_ptr) {
02782         trace_opcBR = bot_opc;
02783         trace_rclrBR = bot_clr;
02784         
02785     }
02786 #endif
02787 ;
02788                 
02789         COUNT_RESAMPLE;
02790         if (acc_opc > min_opacity) {
02791             COUNT_COMPOSITE;
02792             iopc = ipixel->opcflt;
02793 #           ifndef SKIP_ERT
02794                 ASSERT(iopc < max_opacity);
02795 #           endif
02796             iopc_inv = (float)1. - iopc;
02797             ipixel->clrflt += acc_clr * iopc_inv;
02798             iopc += acc_opc * iopc_inv;
02799             ipixel->opcflt = iopc;
02800             
02801 #ifdef DEBUG
02802     if (ipixel == trace_pixel_ptr) {
02803 #ifdef COMPUTE_SHADOW_BUFFER
02804         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02805 #else
02806         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02807 #endif
02808         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02809         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02810         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02811         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02812         printf("  %3.0f %3.0f\n", iopc*255., 
02813                ipixel->clrflt);
02814         
02815         
02816     }
02817 #endif /* DEBUG */
02818 ;
02819 #           ifndef SKIP_ERT
02820                 if (iopc >= max_opacity) {
02821                     ASSERT(ipixel->lnk == 0);
02822                     ipixel->lnk = 1;
02823                 }
02824 #           endif
02825         };
02826                 ipixel += 1;
02827                 topRLEdata += 1 * voxel_istride;
02828                 botRLEdata += 1 * voxel_istride;
02829                 count--;
02830                 SET_VOXELS_LOADED;
02831 
02832                 /* do the rest of the pixels in this run;
02833                    all four voxels contribute */
02834                 while (count > 0) {
02835                     if (PIXEL_IS_OPAQUE(ipixel))
02836                         break;
02837                     if (!voxels_loaded) {
02838                         
02839     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02840     
02841     
02842     ;
02843     ;
02844     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
02845     shade_factor = top_opc * slice_depth_cueing;
02846     
02847         top_clr *= shade_factor;
02848     ;
02849                         
02850     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02851     
02852     
02853     ;
02854     ;
02855     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
02856     shade_factor = bot_opc * slice_depth_cueing;
02857     
02858         bot_clr *= shade_factor;
02859     ;
02860                     }
02861                     
02862 #ifdef DEBUG
02863     if (ipixel == trace_pixel_ptr) {
02864         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02865         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02866         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02867         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02868         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02869     }
02870 #endif
02871 ;
02872                     
02873        acc_opc = top_opc * wgtTL;
02874        acc_clr = top_clr * wgtTL;
02875        
02876 #ifdef DEBUG
02877     if (ipixel == trace_pixel_ptr) {
02878         trace_opcTL = top_opc;
02879         trace_rclrTL = top_clr;
02880         
02881     }
02882 #endif
02883 ;
02884                     
02885        acc_opc += bot_opc * wgtBL;
02886        acc_clr += bot_clr * wgtBL;
02887        
02888 #ifdef DEBUG
02889     if (ipixel == trace_pixel_ptr) {
02890         trace_opcBL = bot_opc;
02891         trace_rclrBL = bot_clr;
02892         
02893     }
02894 #endif
02895 ;
02896                     
02897     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02898     
02899     
02900     ;
02901     ;
02902     shade_func(topRLEdata, &(top_clr), client_data);
02903     shade_factor = top_opc * slice_depth_cueing;
02904     
02905         top_clr *= shade_factor;
02906     ;
02907                     
02908     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02909     
02910     
02911     ;
02912     ;
02913     shade_func(botRLEdata, &(bot_clr), client_data);
02914     shade_factor = bot_opc * slice_depth_cueing;
02915     
02916         bot_clr *= shade_factor;
02917     ;
02918                     
02919        acc_opc += top_opc * wgtTR;
02920        acc_clr += top_clr * wgtTR;
02921        
02922 #ifdef DEBUG
02923     if (ipixel == trace_pixel_ptr) {
02924         trace_opcTR = top_opc;
02925         trace_rclrTR = top_clr;
02926         
02927     }
02928 #endif
02929 ;
02930                     
02931        acc_opc += bot_opc * wgtBR;
02932        acc_clr += bot_clr * wgtBR;
02933        
02934 #ifdef DEBUG
02935     if (ipixel == trace_pixel_ptr) {
02936         trace_opcBR = bot_opc;
02937         trace_rclrBR = bot_clr;
02938         
02939     }
02940 #endif
02941 ;
02942                     
02943         COUNT_RESAMPLE;
02944         if (acc_opc > min_opacity) {
02945             COUNT_COMPOSITE;
02946             iopc = ipixel->opcflt;
02947 #           ifndef SKIP_ERT
02948                 ASSERT(iopc < max_opacity);
02949 #           endif
02950             iopc_inv = (float)1. - iopc;
02951             ipixel->clrflt += acc_clr * iopc_inv;
02952             iopc += acc_opc * iopc_inv;
02953             ipixel->opcflt = iopc;
02954             
02955 #ifdef DEBUG
02956     if (ipixel == trace_pixel_ptr) {
02957 #ifdef COMPUTE_SHADOW_BUFFER
02958         printf("{%3d}  %3d %3d", k, icount-i-count, j);
02959 #else
02960         printf("[%3d]  %3d %3d", k, icount-i-count, j);
02961 #endif
02962         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02963         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02964         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02965         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02966         printf("  %3.0f %3.0f\n", iopc*255., 
02967                ipixel->clrflt);
02968         
02969         
02970     }
02971 #endif /* DEBUG */
02972 ;
02973 #           ifndef SKIP_ERT
02974                 if (iopc >= max_opacity) {
02975                     ASSERT(ipixel->lnk == 0);
02976                     ipixel->lnk = 1;
02977                 }
02978 #           endif
02979         };
02980                     ipixel += 1;
02981                     topRLEdata += 1 * voxel_istride;
02982                     botRLEdata += 1 * voxel_istride;
02983                     count--;
02984                     SET_VOXELS_LOADED;
02985                 }
02986                 break;
02987             case TOP_NONZERO__ALL_NONZERO:
02988                 /* first pixel: top-left, top-right and bottom-right
02989                    voxels contribute */
02990                 if (!voxels_loaded) {
02991                     
02992     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02993     
02994     
02995     ;
02996     ;
02997     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
02998     shade_factor = top_opc * slice_depth_cueing;
02999     
03000         top_clr *= shade_factor;
03001     ;
03002                 }
03003                 
03004 #ifdef DEBUG
03005     if (ipixel == trace_pixel_ptr) {
03006         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03007         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03008         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03009         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03010         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03011     }
03012 #endif
03013 ;
03014                 
03015        acc_opc = top_opc * wgtTL;
03016        acc_clr = top_clr * wgtTL;
03017        
03018 #ifdef DEBUG
03019     if (ipixel == trace_pixel_ptr) {
03020         trace_opcTL = top_opc;
03021         trace_rclrTL = top_clr;
03022         
03023     }
03024 #endif
03025 ;
03026                 
03027     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03028     
03029     
03030     ;
03031     ;
03032     shade_func(topRLEdata, &(top_clr), client_data);
03033     shade_factor = top_opc * slice_depth_cueing;
03034     
03035         top_clr *= shade_factor;
03036     ;
03037                 
03038     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03039     
03040     
03041     ;
03042     ;
03043     shade_func(botRLEdata, &(bot_clr), client_data);
03044     shade_factor = bot_opc * slice_depth_cueing;
03045     
03046         bot_clr *= shade_factor;
03047     ;
03048                 
03049        acc_opc += top_opc * wgtTR;
03050        acc_clr += top_clr * wgtTR;
03051        
03052 #ifdef DEBUG
03053     if (ipixel == trace_pixel_ptr) {
03054         trace_opcTR = top_opc;
03055         trace_rclrTR = top_clr;
03056         
03057     }
03058 #endif
03059 ;
03060                 
03061        acc_opc += bot_opc * wgtBR;
03062        acc_clr += bot_clr * wgtBR;
03063        
03064 #ifdef DEBUG
03065     if (ipixel == trace_pixel_ptr) {
03066         trace_opcBR = bot_opc;
03067         trace_rclrBR = bot_clr;
03068         
03069     }
03070 #endif
03071 ;
03072                 
03073         COUNT_RESAMPLE;
03074         if (acc_opc > min_opacity) {
03075             COUNT_COMPOSITE;
03076             iopc = ipixel->opcflt;
03077 #           ifndef SKIP_ERT
03078                 ASSERT(iopc < max_opacity);
03079 #           endif
03080             iopc_inv = (float)1. - iopc;
03081             ipixel->clrflt += acc_clr * iopc_inv;
03082             iopc += acc_opc * iopc_inv;
03083             ipixel->opcflt = iopc;
03084             
03085 #ifdef DEBUG
03086     if (ipixel == trace_pixel_ptr) {
03087 #ifdef COMPUTE_SHADOW_BUFFER
03088         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03089 #else
03090         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03091 #endif
03092         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03093         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03094         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03095         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03096         printf("  %3.0f %3.0f\n", iopc*255., 
03097                ipixel->clrflt);
03098         
03099         
03100     }
03101 #endif /* DEBUG */
03102 ;
03103 #           ifndef SKIP_ERT
03104                 if (iopc >= max_opacity) {
03105                     ASSERT(ipixel->lnk == 0);
03106                     ipixel->lnk = 1;
03107                 }
03108 #           endif
03109         };
03110                 ipixel += 1;
03111                 topRLEdata += 1 * voxel_istride;
03112                 botRLEdata += 1 * voxel_istride;
03113                 count--;
03114                 SET_VOXELS_LOADED;
03115                     
03116                 /* do the rest of the pixels in this run;
03117                    all four voxels contribute */
03118                 while (count > 0) {
03119                     if (PIXEL_IS_OPAQUE(ipixel))
03120                         break;
03121                     if (!voxels_loaded) {
03122                         
03123     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03124     
03125     
03126     ;
03127     ;
03128     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
03129     shade_factor = top_opc * slice_depth_cueing;
03130     
03131         top_clr *= shade_factor;
03132     ;
03133                         
03134     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03135     
03136     
03137     ;
03138     ;
03139     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
03140     shade_factor = bot_opc * slice_depth_cueing;
03141     
03142         bot_clr *= shade_factor;
03143     ;
03144                     }
03145                     
03146 #ifdef DEBUG
03147     if (ipixel == trace_pixel_ptr) {
03148         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03149         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03150         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03151         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03152         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03153     }
03154 #endif
03155 ;
03156                     
03157        acc_opc = top_opc * wgtTL;
03158        acc_clr = top_clr * wgtTL;
03159        
03160 #ifdef DEBUG
03161     if (ipixel == trace_pixel_ptr) {
03162         trace_opcTL = top_opc;
03163         trace_rclrTL = top_clr;
03164         
03165     }
03166 #endif
03167 ;
03168                     
03169        acc_opc += bot_opc * wgtBL;
03170        acc_clr += bot_clr * wgtBL;
03171        
03172 #ifdef DEBUG
03173     if (ipixel == trace_pixel_ptr) {
03174         trace_opcBL = bot_opc;
03175         trace_rclrBL = bot_clr;
03176         
03177     }
03178 #endif
03179 ;
03180                     
03181     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03182     
03183     
03184     ;
03185     ;
03186     shade_func(topRLEdata, &(top_clr), client_data);
03187     shade_factor = top_opc * slice_depth_cueing;
03188     
03189         top_clr *= shade_factor;
03190     ;
03191                     
03192     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03193     
03194     
03195     ;
03196     ;
03197     shade_func(botRLEdata, &(bot_clr), client_data);
03198     shade_factor = bot_opc * slice_depth_cueing;
03199     
03200         bot_clr *= shade_factor;
03201     ;
03202                     
03203        acc_opc += top_opc * wgtTR;
03204        acc_clr += top_clr * wgtTR;
03205        
03206 #ifdef DEBUG
03207     if (ipixel == trace_pixel_ptr) {
03208         trace_opcTR = top_opc;
03209         trace_rclrTR = top_clr;
03210         
03211     }
03212 #endif
03213 ;
03214                     
03215        acc_opc += bot_opc * wgtBR;
03216        acc_clr += bot_clr * wgtBR;
03217        
03218 #ifdef DEBUG
03219     if (ipixel == trace_pixel_ptr) {
03220         trace_opcBR = bot_opc;
03221         trace_rclrBR = bot_clr;
03222         
03223     }
03224 #endif
03225 ;
03226                     
03227         COUNT_RESAMPLE;
03228         if (acc_opc > min_opacity) {
03229             COUNT_COMPOSITE;
03230             iopc = ipixel->opcflt;
03231 #           ifndef SKIP_ERT
03232                 ASSERT(iopc < max_opacity);
03233 #           endif
03234             iopc_inv = (float)1. - iopc;
03235             ipixel->clrflt += acc_clr * iopc_inv;
03236             iopc += acc_opc * iopc_inv;
03237             ipixel->opcflt = iopc;
03238             
03239 #ifdef DEBUG
03240     if (ipixel == trace_pixel_ptr) {
03241 #ifdef COMPUTE_SHADOW_BUFFER
03242         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03243 #else
03244         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03245 #endif
03246         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03247         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03248         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03249         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03250         printf("  %3.0f %3.0f\n", iopc*255., 
03251                ipixel->clrflt);
03252         
03253         
03254     }
03255 #endif /* DEBUG */
03256 ;
03257 #           ifndef SKIP_ERT
03258                 if (iopc >= max_opacity) {
03259                     ASSERT(ipixel->lnk == 0);
03260                     ipixel->lnk = 1;
03261                 }
03262 #           endif
03263         };
03264                     ipixel += 1;
03265                     topRLEdata += 1 * voxel_istride;
03266                     botRLEdata += 1 * voxel_istride;
03267                     count--;
03268                     SET_VOXELS_LOADED;
03269                 }
03270                 break;
03271             case BOT_NONZERO__ALL_NONZERO:
03272                 /* first pixel: bottom-left, top-right and bottom-right
03273                    voxels contribute */
03274                 if (!voxels_loaded) {
03275                     
03276     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03277     
03278     
03279     ;
03280     ;
03281     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
03282     shade_factor = bot_opc * slice_depth_cueing;
03283     
03284         bot_clr *= shade_factor;
03285     ;
03286                 }
03287                 
03288 #ifdef DEBUG
03289     if (ipixel == trace_pixel_ptr) {
03290         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03291         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03292         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03293         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03294         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03295     }
03296 #endif
03297 ;
03298                 
03299        acc_opc = bot_opc * wgtBL;
03300        acc_clr = bot_clr * wgtBL;
03301        
03302 #ifdef DEBUG
03303     if (ipixel == trace_pixel_ptr) {
03304         trace_opcBL = bot_opc;
03305         trace_rclrBL = bot_clr;
03306         
03307     }
03308 #endif
03309 ;
03310                 
03311     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03312     
03313     
03314     ;
03315     ;
03316     shade_func(topRLEdata, &(top_clr), client_data);
03317     shade_factor = top_opc * slice_depth_cueing;
03318     
03319         top_clr *= shade_factor;
03320     ;
03321                 
03322     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03323     
03324     
03325     ;
03326     ;
03327     shade_func(botRLEdata, &(bot_clr), client_data);
03328     shade_factor = bot_opc * slice_depth_cueing;
03329     
03330         bot_clr *= shade_factor;
03331     ;
03332                 
03333        acc_opc += top_opc * wgtTR;
03334        acc_clr += top_clr * wgtTR;
03335        
03336 #ifdef DEBUG
03337     if (ipixel == trace_pixel_ptr) {
03338         trace_opcTR = top_opc;
03339         trace_rclrTR = top_clr;
03340         
03341     }
03342 #endif
03343 ;
03344                 
03345        acc_opc += bot_opc * wgtBR;
03346        acc_clr += bot_clr * wgtBR;
03347        
03348 #ifdef DEBUG
03349     if (ipixel == trace_pixel_ptr) {
03350         trace_opcBR = bot_opc;
03351         trace_rclrBR = bot_clr;
03352         
03353     }
03354 #endif
03355 ;
03356                 
03357         COUNT_RESAMPLE;
03358         if (acc_opc > min_opacity) {
03359             COUNT_COMPOSITE;
03360             iopc = ipixel->opcflt;
03361 #           ifndef SKIP_ERT
03362                 ASSERT(iopc < max_opacity);
03363 #           endif
03364             iopc_inv = (float)1. - iopc;
03365             ipixel->clrflt += acc_clr * iopc_inv;
03366             iopc += acc_opc * iopc_inv;
03367             ipixel->opcflt = iopc;
03368             
03369 #ifdef DEBUG
03370     if (ipixel == trace_pixel_ptr) {
03371 #ifdef COMPUTE_SHADOW_BUFFER
03372         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03373 #else
03374         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03375 #endif
03376         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03377         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03378         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03379         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03380         printf("  %3.0f %3.0f\n", iopc*255., 
03381                ipixel->clrflt);
03382         
03383         
03384     }
03385 #endif /* DEBUG */
03386 ;
03387 #           ifndef SKIP_ERT
03388                 if (iopc >= max_opacity) {
03389                     ASSERT(ipixel->lnk == 0);
03390                     ipixel->lnk = 1;
03391                 }
03392 #           endif
03393         };
03394                 ipixel += 1;
03395                 topRLEdata += 1 * voxel_istride;
03396                 botRLEdata += 1 * voxel_istride;
03397                 count--;
03398                 SET_VOXELS_LOADED;
03399                     
03400                 /* do the rest of the pixels in this run;
03401                    all four voxels contribute */
03402                 while (count > 0) {
03403                     if (PIXEL_IS_OPAQUE(ipixel))
03404                         break;
03405                     if (!voxels_loaded) {
03406                         
03407     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03408     
03409     
03410     ;
03411     ;
03412     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
03413     shade_factor = top_opc * slice_depth_cueing;
03414     
03415         top_clr *= shade_factor;
03416     ;
03417                         
03418     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03419     
03420     
03421     ;
03422     ;
03423     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
03424     shade_factor = bot_opc * slice_depth_cueing;
03425     
03426         bot_clr *= shade_factor;
03427     ;
03428                     }
03429                     
03430 #ifdef DEBUG
03431     if (ipixel == trace_pixel_ptr) {
03432         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03433         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03434         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03435         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03436         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03437     }
03438 #endif
03439 ;
03440                     
03441        acc_opc = top_opc * wgtTL;
03442        acc_clr = top_clr * wgtTL;
03443        
03444 #ifdef DEBUG
03445     if (ipixel == trace_pixel_ptr) {
03446         trace_opcTL = top_opc;
03447         trace_rclrTL = top_clr;
03448         
03449     }
03450 #endif
03451 ;
03452                     
03453        acc_opc += bot_opc * wgtBL;
03454        acc_clr += bot_clr * wgtBL;
03455        
03456 #ifdef DEBUG
03457     if (ipixel == trace_pixel_ptr) {
03458         trace_opcBL = bot_opc;
03459         trace_rclrBL = bot_clr;
03460         
03461     }
03462 #endif
03463 ;
03464                     
03465     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03466     
03467     
03468     ;
03469     ;
03470     shade_func(topRLEdata, &(top_clr), client_data);
03471     shade_factor = top_opc * slice_depth_cueing;
03472     
03473         top_clr *= shade_factor;
03474     ;
03475                     
03476     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03477     
03478     
03479     ;
03480     ;
03481     shade_func(botRLEdata, &(bot_clr), client_data);
03482     shade_factor = bot_opc * slice_depth_cueing;
03483     
03484         bot_clr *= shade_factor;
03485     ;
03486                     
03487        acc_opc += top_opc * wgtTR;
03488        acc_clr += top_clr * wgtTR;
03489        
03490 #ifdef DEBUG
03491     if (ipixel == trace_pixel_ptr) {
03492         trace_opcTR = top_opc;
03493         trace_rclrTR = top_clr;
03494         
03495     }
03496 #endif
03497 ;
03498                     
03499        acc_opc += bot_opc * wgtBR;
03500        acc_clr += bot_clr * wgtBR;
03501        
03502 #ifdef DEBUG
03503     if (ipixel == trace_pixel_ptr) {
03504         trace_opcBR = bot_opc;
03505         trace_rclrBR = bot_clr;
03506         
03507     }
03508 #endif
03509 ;
03510                     
03511         COUNT_RESAMPLE;
03512         if (acc_opc > min_opacity) {
03513             COUNT_COMPOSITE;
03514             iopc = ipixel->opcflt;
03515 #           ifndef SKIP_ERT
03516                 ASSERT(iopc < max_opacity);
03517 #           endif
03518             iopc_inv = (float)1. - iopc;
03519             ipixel->clrflt += acc_clr * iopc_inv;
03520             iopc += acc_opc * iopc_inv;
03521             ipixel->opcflt = iopc;
03522             
03523 #ifdef DEBUG
03524     if (ipixel == trace_pixel_ptr) {
03525 #ifdef COMPUTE_SHADOW_BUFFER
03526         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03527 #else
03528         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03529 #endif
03530         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03531         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03532         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03533         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03534         printf("  %3.0f %3.0f\n", iopc*255., 
03535                ipixel->clrflt);
03536         
03537         
03538     }
03539 #endif /* DEBUG */
03540 ;
03541 #           ifndef SKIP_ERT
03542                 if (iopc >= max_opacity) {
03543                     ASSERT(ipixel->lnk == 0);
03544                     ipixel->lnk = 1;
03545                 }
03546 #           endif
03547         };
03548                     ipixel += 1;
03549                     topRLEdata += 1 * voxel_istride;
03550                     botRLEdata += 1 * voxel_istride;
03551                     count--;
03552                     SET_VOXELS_LOADED;
03553                 }
03554                 break;
03555             case ALL_NONZERO__ALL_NONZERO:
03556                 /* do the pixels in this run; all four voxels contribute */
03557                 while (count > 0) {
03558                     if (PIXEL_IS_OPAQUE(ipixel))
03559                         break;
03560                     if (!voxels_loaded) {
03561                         
03562     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03563     
03564     
03565     ;
03566     ;
03567     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
03568     shade_factor = top_opc * slice_depth_cueing;
03569     
03570         top_clr *= shade_factor;
03571     ;
03572                         
03573     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03574     
03575     
03576     ;
03577     ;
03578     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
03579     shade_factor = bot_opc * slice_depth_cueing;
03580     
03581         bot_clr *= shade_factor;
03582     ;
03583                     }
03584                     
03585 #ifdef DEBUG
03586     if (ipixel == trace_pixel_ptr) {
03587         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03588         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03589         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03590         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03591         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03592     }
03593 #endif
03594 ;
03595                     
03596        acc_opc = top_opc * wgtTL;
03597        acc_clr = top_clr * wgtTL;
03598        
03599 #ifdef DEBUG
03600     if (ipixel == trace_pixel_ptr) {
03601         trace_opcTL = top_opc;
03602         trace_rclrTL = top_clr;
03603         
03604     }
03605 #endif
03606 ;
03607                     
03608        acc_opc += bot_opc * wgtBL;
03609        acc_clr += bot_clr * wgtBL;
03610        
03611 #ifdef DEBUG
03612     if (ipixel == trace_pixel_ptr) {
03613         trace_opcBL = bot_opc;
03614         trace_rclrBL = bot_clr;
03615         
03616     }
03617 #endif
03618 ;
03619                     
03620     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03621     
03622     
03623     ;
03624     ;
03625     shade_func(topRLEdata, &(top_clr), client_data);
03626     shade_factor = top_opc * slice_depth_cueing;
03627     
03628         top_clr *= shade_factor;
03629     ;
03630                     
03631     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03632     
03633     
03634     ;
03635     ;
03636     shade_func(botRLEdata, &(bot_clr), client_data);
03637     shade_factor = bot_opc * slice_depth_cueing;
03638     
03639         bot_clr *= shade_factor;
03640     ;
03641                     
03642        acc_opc += top_opc * wgtTR;
03643        acc_clr += top_clr * wgtTR;
03644        
03645 #ifdef DEBUG
03646     if (ipixel == trace_pixel_ptr) {
03647         trace_opcTR = top_opc;
03648         trace_rclrTR = top_clr;
03649         
03650     }
03651 #endif
03652 ;
03653                     
03654        acc_opc += bot_opc * wgtBR;
03655        acc_clr += bot_clr * wgtBR;
03656        
03657 #ifdef DEBUG
03658     if (ipixel == trace_pixel_ptr) {
03659         trace_opcBR = bot_opc;
03660         trace_rclrBR = bot_clr;
03661         
03662     }
03663 #endif
03664 ;
03665                     
03666         COUNT_RESAMPLE;
03667         if (acc_opc > min_opacity) {
03668             COUNT_COMPOSITE;
03669             iopc = ipixel->opcflt;
03670 #           ifndef SKIP_ERT
03671                 ASSERT(iopc < max_opacity);
03672 #           endif
03673             iopc_inv = (float)1. - iopc;
03674             ipixel->clrflt += acc_clr * iopc_inv;
03675             iopc += acc_opc * iopc_inv;
03676             ipixel->opcflt = iopc;
03677             
03678 #ifdef DEBUG
03679     if (ipixel == trace_pixel_ptr) {
03680 #ifdef COMPUTE_SHADOW_BUFFER
03681         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03682 #else
03683         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03684 #endif
03685         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03686         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03687         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03688         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03689         printf("  %3.0f %3.0f\n", iopc*255., 
03690                ipixel->clrflt);
03691         
03692         
03693     }
03694 #endif /* DEBUG */
03695 ;
03696 #           ifndef SKIP_ERT
03697                 if (iopc >= max_opacity) {
03698                     ASSERT(ipixel->lnk == 0);
03699                     ipixel->lnk = 1;
03700                 }
03701 #           endif
03702         };
03703                     ipixel += 1;
03704                     topRLEdata += 1 * voxel_istride;
03705                     botRLEdata += 1 * voxel_istride;
03706                     count--;
03707                     SET_VOXELS_LOADED;
03708                 }
03709                 break;
03710             default:
03711                 VPBug("illegal value for run states in compositing loop");
03712             }
03713 #else /* UNROLL_RUN_LOOP */
03714             /* this run contains pixels, so process them */
03715             while (count > 0) {
03716                 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
03717                     ipixel += count;
03718                     if (i != -1) {
03719                         ;
03720                         ;
03721                     }
03722                     count = 0;
03723                     break;
03724                 }
03725                 if (ipixel->lnk != 0)
03726                     break;
03727                 
03728 #ifdef DEBUG
03729     if (ipixel == trace_pixel_ptr) {
03730         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03731         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03732         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03733         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03734         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03735     }
03736 #endif
03737 ;
03738                 
03739        acc_opc = 0;
03740        acc_clr = 0;
03741                 if (last_run_state & TOP_NONZERO) {
03742                     if (!voxels_loaded) {
03743                         
03744     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03745     
03746     
03747     ;
03748     ;
03749     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
03750     shade_factor = top_opc * slice_depth_cueing;
03751     
03752         top_clr *= shade_factor;
03753     ;
03754                     }
03755                     
03756        acc_opc += top_opc * wgtTL;
03757        acc_clr += top_clr * wgtTL;
03758        
03759 #ifdef DEBUG
03760     if (ipixel == trace_pixel_ptr) {
03761         trace_opcTL = top_opc;
03762         trace_rclrTL = top_clr;
03763         
03764     }
03765 #endif
03766 ;
03767                 }
03768                 if (last_run_state & BOT_NONZERO) {
03769                     if (!voxels_loaded) {
03770                         
03771     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03772     
03773     
03774     ;
03775     ;
03776     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
03777     shade_factor = bot_opc * slice_depth_cueing;
03778     
03779         bot_clr *= shade_factor;
03780     ;
03781                     }
03782                     
03783        acc_opc += bot_opc * wgtBL;
03784        acc_clr += bot_clr * wgtBL;
03785        
03786 #ifdef DEBUG
03787     if (ipixel == trace_pixel_ptr) {
03788         trace_opcBL = bot_opc;
03789         trace_rclrBL = bot_clr;
03790         
03791     }
03792 #endif
03793 ;
03794                 }
03795                 if (run_state & TOP_NONZERO) {
03796                     
03797     top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03798     
03799     
03800     ;
03801     ;
03802     shade_func(topRLEdata, &(top_clr), client_data);
03803     shade_factor = top_opc * slice_depth_cueing;
03804     
03805         top_clr *= shade_factor;
03806     ;
03807                     
03808        acc_opc += top_opc * wgtTR;
03809        acc_clr += top_clr * wgtTR;
03810        
03811 #ifdef DEBUG
03812     if (ipixel == trace_pixel_ptr) {
03813         trace_opcTR = top_opc;
03814         trace_rclrTR = top_clr;
03815         
03816     }
03817 #endif
03818 ;
03819                     topRLEdata += 1 * voxel_istride;
03820                 } else {
03821                     if (i != -1) {
03822                         ;
03823                     }
03824                 }
03825                 if (run_state & BOT_NONZERO) {
03826                     
03827     bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03828     
03829     
03830     ;
03831     ;
03832     shade_func(botRLEdata, &(bot_clr), client_data);
03833     shade_factor = bot_opc * slice_depth_cueing;
03834     
03835         bot_clr *= shade_factor;
03836     ;
03837                     
03838        acc_opc += bot_opc * wgtBR;
03839        acc_clr += bot_clr * wgtBR;
03840        
03841 #ifdef DEBUG
03842     if (ipixel == trace_pixel_ptr) {
03843         trace_opcBR = bot_opc;
03844         trace_rclrBR = bot_clr;
03845         
03846     }
03847 #endif
03848 ;
03849                     botRLEdata += 1 * voxel_istride;
03850                 } else {
03851                     if (i != -1) {
03852                         ;
03853                     }
03854                 }
03855                 
03856         COUNT_RESAMPLE;
03857         if (acc_opc > min_opacity) {
03858             COUNT_COMPOSITE;
03859             iopc = ipixel->opcflt;
03860 #           ifndef SKIP_ERT
03861                 ASSERT(iopc < max_opacity);
03862 #           endif
03863             iopc_inv = (float)1. - iopc;
03864             ipixel->clrflt += acc_clr * iopc_inv;
03865             iopc += acc_opc * iopc_inv;
03866             ipixel->opcflt = iopc;
03867             
03868 #ifdef DEBUG
03869     if (ipixel == trace_pixel_ptr) {
03870 #ifdef COMPUTE_SHADOW_BUFFER
03871         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03872 #else
03873         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03874 #endif
03875         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03876         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03877         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03878         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03879         printf("  %3.0f %3.0f\n", iopc*255., 
03880                ipixel->clrflt);
03881         
03882         
03883     }
03884 #endif /* DEBUG */
03885 ;
03886 #           ifndef SKIP_ERT
03887                 if (iopc >= max_opacity) {
03888                     ASSERT(ipixel->lnk == 0);
03889                     ipixel->lnk = 1;
03890                 }
03891 #           endif
03892         };
03893                 ipixel += 1;
03894                 count--;
03895                 SET_VOXELS_LOADED;
03896                 last_run_state = run_state;
03897             }
03898 #endif /* UNROLL_RUN_LOOP */
03899 
03900             GET_HIRES_TIME(vpc, t1);
03901             STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
03902             COPY_HIRES_TIME(t0, t1);
03903 
03904             if (count > 0) {
03905                 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
03906                 toprun_count += count;
03907                 botrun_count += count;
03908                 i += count;
03909             }
03910 #endif /* SKIP_COMPOSITE */
03911 
03912             /***********************************************************
03913              * Go on to next voxel run.
03914              ***********************************************************/
03915 
03916             last_run_state = run_state;
03917         } /* while (i > 0) */
03918 
03919         /***************************************************************
03920          * Finish processing voxel scanline and go on to next one.
03921          ***************************************************************/
03922 
03923 #ifdef UNROLL_RUN_LOOP
03924         ASSERT(i == 0);
03925 #else
03926         ASSERT(i == -1);
03927 #endif
03928 
03929 #ifndef SKIP_COMPOSITE
03930 #ifdef UNROLL_RUN_LOOP
03931         /* do the last pixel (to the right of the last voxel) */
03932         if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
03933             /* last voxels are nonzero and the pixel is not opaque yet
03934                so there is work to be done */
03935             Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
03936             switch (last_run_state) {
03937             case TOP_NONZERO:
03938                 /* only the top-left voxel contributes */
03939                 if (!voxels_loaded) {
03940                     
03941     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03942     
03943     
03944     ;
03945     ;
03946     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
03947     shade_factor = top_opc * slice_depth_cueing;
03948     
03949         top_clr *= shade_factor;
03950     ;
03951                 }
03952                 
03953 #ifdef DEBUG
03954     if (ipixel == trace_pixel_ptr) {
03955         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03956         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03957         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03958         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03959         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03960     }
03961 #endif
03962 ;
03963                 
03964        acc_opc = top_opc * wgtTL;
03965        acc_clr = top_clr * wgtTL;
03966        
03967 #ifdef DEBUG
03968     if (ipixel == trace_pixel_ptr) {
03969         trace_opcTL = top_opc;
03970         trace_rclrTL = top_clr;
03971         
03972     }
03973 #endif
03974 ;
03975                 
03976         COUNT_RESAMPLE;
03977         if (acc_opc > min_opacity) {
03978             COUNT_COMPOSITE;
03979             iopc = ipixel->opcflt;
03980 #           ifndef SKIP_ERT
03981                 ASSERT(iopc < max_opacity);
03982 #           endif
03983             iopc_inv = (float)1. - iopc;
03984             ipixel->clrflt += acc_clr * iopc_inv;
03985             iopc += acc_opc * iopc_inv;
03986             ipixel->opcflt = iopc;
03987             
03988 #ifdef DEBUG
03989     if (ipixel == trace_pixel_ptr) {
03990 #ifdef COMPUTE_SHADOW_BUFFER
03991         printf("{%3d}  %3d %3d", k, icount-i-count, j);
03992 #else
03993         printf("[%3d]  %3d %3d", k, icount-i-count, j);
03994 #endif
03995         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03996         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03997         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03998         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03999         printf("  %3.0f %3.0f\n", iopc*255., 
04000                ipixel->clrflt);
04001         
04002         
04003     }
04004 #endif /* DEBUG */
04005 ;
04006 #           ifndef SKIP_ERT
04007                 if (iopc >= max_opacity) {
04008                     ASSERT(ipixel->lnk == 0);
04009                     ipixel->lnk = 1;
04010                 }
04011 #           endif
04012         };
04013                 break;
04014             case BOT_NONZERO:
04015                 /* only the bottom left voxel contributes */
04016                 if (!voxels_loaded) {
04017                     
04018     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04019     
04020     
04021     ;
04022     ;
04023     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
04024     shade_factor = bot_opc * slice_depth_cueing;
04025     
04026         bot_clr *= shade_factor;
04027     ;
04028                 }
04029                 
04030 #ifdef DEBUG
04031     if (ipixel == trace_pixel_ptr) {
04032         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04033         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04034         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04035         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04036         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04037     }
04038 #endif
04039 ;
04040                 
04041        acc_opc = bot_opc * wgtBL;
04042        acc_clr = bot_clr * wgtBL;
04043        
04044 #ifdef DEBUG
04045     if (ipixel == trace_pixel_ptr) {
04046         trace_opcBL = bot_opc;
04047         trace_rclrBL = bot_clr;
04048         
04049     }
04050 #endif
04051 ;
04052                 
04053         COUNT_RESAMPLE;
04054         if (acc_opc > min_opacity) {
04055             COUNT_COMPOSITE;
04056             iopc = ipixel->opcflt;
04057 #           ifndef SKIP_ERT
04058                 ASSERT(iopc < max_opacity);
04059 #           endif
04060             iopc_inv = (float)1. - iopc;
04061             ipixel->clrflt += acc_clr * iopc_inv;
04062             iopc += acc_opc * iopc_inv;
04063             ipixel->opcflt = iopc;
04064             
04065 #ifdef DEBUG
04066     if (ipixel == trace_pixel_ptr) {
04067 #ifdef COMPUTE_SHADOW_BUFFER
04068         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04069 #else
04070         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04071 #endif
04072         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04073         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04074         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04075         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04076         printf("  %3.0f %3.0f\n", iopc*255., 
04077                ipixel->clrflt);
04078         
04079         
04080     }
04081 #endif /* DEBUG */
04082 ;
04083 #           ifndef SKIP_ERT
04084                 if (iopc >= max_opacity) {
04085                     ASSERT(ipixel->lnk == 0);
04086                     ipixel->lnk = 1;
04087                 }
04088 #           endif
04089         };
04090                 break;
04091             case ALL_NONZERO:
04092                 /* the top and bottom left voxels contribute */
04093                 if (!voxels_loaded) {
04094                     
04095     top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04096     
04097     
04098     ;
04099     ;
04100     shade_func(topRLEdata - voxel_istride, &(top_clr), client_data);
04101     shade_factor = top_opc * slice_depth_cueing;
04102     
04103         top_clr *= shade_factor;
04104     ;
04105                     
04106     bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04107     
04108     
04109     ;
04110     ;
04111     shade_func(botRLEdata - voxel_istride, &(bot_clr), client_data);
04112     shade_factor = bot_opc * slice_depth_cueing;
04113     
04114         bot_clr *= shade_factor;
04115     ;
04116                 }
04117                 
04118 #ifdef DEBUG
04119     if (ipixel == trace_pixel_ptr) {
04120         trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04121         trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04122         trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04123         trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04124         trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04125     }
04126 #endif
04127 ;
04128                 
04129        acc_opc = top_opc * wgtTL;
04130        acc_clr = top_clr * wgtTL;
04131        
04132 #ifdef DEBUG
04133     if (ipixel == trace_pixel_ptr) {
04134         trace_opcTL = top_opc;
04135         trace_rclrTL = top_clr;
04136         
04137     }
04138 #endif
04139 ;
04140                 
04141        acc_opc += bot_opc * wgtBL;
04142        acc_clr += bot_clr * wgtBL;
04143        
04144 #ifdef DEBUG
04145     if (ipixel == trace_pixel_ptr) {
04146         trace_opcBL = bot_opc;
04147         trace_rclrBL = bot_clr;
04148         
04149     }
04150 #endif
04151 ;
04152                 
04153         COUNT_RESAMPLE;
04154         if (acc_opc > min_opacity) {
04155             COUNT_COMPOSITE;
04156             iopc = ipixel->opcflt;
04157 #           ifndef SKIP_ERT
04158                 ASSERT(iopc < max_opacity);
04159 #           endif
04160             iopc_inv = (float)1. - iopc;
04161             ipixel->clrflt += acc_clr * iopc_inv;
04162             iopc += acc_opc * iopc_inv;
04163             ipixel->opcflt = iopc;
04164             
04165 #ifdef DEBUG
04166     if (ipixel == trace_pixel_ptr) {
04167 #ifdef COMPUTE_SHADOW_BUFFER
04168         printf("{%3d}  %3d %3d", k, icount-i-count, j);
04169 #else
04170         printf("[%3d]  %3d %3d", k, icount-i-count, j);
04171 #endif
04172         printf("  %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04173         printf("  %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04174         printf("  %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04175         printf("  %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04176         printf("  %3.0f %3.0f\n", iopc*255., 
04177                ipixel->clrflt);
04178         
04179         
04180     }
04181 #endif /* DEBUG */
04182 ;
04183 #           ifndef SKIP_ERT
04184                 if (iopc >= max_opacity) {
04185                     ASSERT(ipixel->lnk == 0);
04186                     ipixel->lnk = 1;
04187                 }
04188 #           endif
04189         };
04190                 break;
04191             default:
04192                 VPBug("illegal value for run state at end of scanline");
04193             }
04194         } else if (last_run_state == ALL_ZERO) {
04195             Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
04196         } else {
04197             Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
04198         }
04199 #endif /* UNROLL_RUN_LOOP */
04200 #endif /* SKIP_COMPOSITE */
04201 
04202 #ifndef UNROLL_RUN_LOOP
04203         run_state = final_run_state;
04204 #endif
04205         /* skip over any zero-length runs remaining in this scanline */
04206         if (j != 0 && ((run_state & 1) == 0)) {
04207             toprun_count = *topRLElen++;
04208             ASSERT(toprun_count == 0);
04209         }
04210         if (j != jcount && ((run_state & 2) == 0)) {
04211             botrun_count = *botRLElen++;
04212             ASSERT(botrun_count == 0);
04213         }
04214 
04215         /* go to next intermediate image scanline */
04216 #ifdef UNROLL_RUN_LOOP
04217         ipixel += intermediate_width - icount;
04218 #ifdef USE_SHADOW_BUFFER
04219         shadow_pixel += shadow_width - icount;
04220 #endif
04221 #else /* UNROLL_RUN_LOOP */
04222         ipixel += intermediate_width - (icount+1);
04223 #ifdef USE_SHADOW_BUFFER
04224         shadow_pixel += shadow_width - (icount+1);
04225 #endif
04226 #endif /* UNROLL_RUN_LOOP */
04227 
04228         Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
04229     } /* for j */
04230 
04231     /***************************************************************
04232      * Finish processing the voxel slice.
04233      ***************************************************************/
04234 
04235     GET_HIRES_TIME(vpc, t1);
04236     STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
04237 
04238     Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
04239 }
 

Powered by Plone

This site conforms to the following standards: